Instead, change be32toh to le32toh if nonce_bigendian is false.