Index: src/scrypt.m ================================================================== --- src/scrypt.m +++ src/scrypt.m @@ -30,11 +30,11 @@ of_salsa20_8_core(uint32_t buffer[16]) { uint32_t tmp[16]; for (uint_fast8_t i = 0; i < 16; i++) - tmp[i] = buffer[i]; + tmp[i] = OF_BSWAP32_IF_BE(buffer[i]); for (uint_fast8_t i = 0; i < 8; i+= 2) { tmp[ 4] ^= OF_ROL(tmp[ 0] + tmp[12], 7); tmp[ 8] ^= OF_ROL(tmp[ 4] + tmp[ 0], 9); tmp[12] ^= OF_ROL(tmp[ 8] + tmp[ 4], 13); @@ -68,11 +68,12 @@ tmp[14] ^= OF_ROL(tmp[13] + tmp[12], 13); tmp[15] ^= OF_ROL(tmp[14] + tmp[13], 18); } for (uint_fast8_t i = 0; i < 16; i++) - buffer[i] += tmp[i]; + buffer[i] = OF_BSWAP32_IF_BE(OF_BSWAP32_IF_BE(buffer[i]) + + tmp[i]); of_explicit_memset(tmp, 0, sizeof(tmp)); } void @@ -121,11 +122,12 @@ memcpy(tmp2 + i * 32 * blockSize, tmp, 128 * blockSize); of_scrypt_block_mix(tmp, tmp2 + i * 32 * blockSize, blockSize); } for (size_t i = 0; i < costFactor; i++) { - uint32_t j = tmp[(2 * blockSize - 1) * 16] & (costFactor - 1); + uint32_t j = OF_BSWAP32_IF_BE(tmp[(2 * blockSize - 1) * 16]) & + (costFactor - 1); for (size_t k = 0; k < 32 * blockSize; k++) tmp[k] ^= tmp2[j * 32 * blockSize + k]; of_scrypt_block_mix(buffer, tmp, blockSize);