diff --git a/lib/crypto/crypto_scrypt_smix.c b/lib/crypto/crypto_scrypt_smix.c index c69b5116..f145e506 100644 --- a/lib/crypto/crypto_scrypt_smix.c +++ b/lib/crypto/crypto_scrypt_smix.c @@ -34,7 +34,7 @@ #include "crypto_scrypt_smix.h" static void blkcpy(uint32_t *, const uint32_t *, size_t); -static void blkxor(uint32_t *, const uint32_t *, size_t); +static void blkxor(unsigned char *, const unsigned char *, size_t); static void salsa20_8(uint32_t[16]); static void blockmix_salsa8(const uint32_t *, uint32_t *, uint32_t *, size_t); static uint64_t integerify(const uint32_t *, size_t); @@ -47,11 +47,11 @@ blkcpy(uint32_t * dest, const uint32_t * src, size_t len) } static void -blkxor(uint32_t * dest, const uint32_t * src, size_t len) +blkxor(unsigned char * dest, const unsigned char * src, size_t len) { size_t i; - for (i = 0; i < len / 4; i++) + for (i = 0; i < len; i++) dest[i] ^= src[i]; } @@ -116,7 +116,8 @@ blockmix_salsa8(const uint32_t * Bin, uint32_t * Bout, uint32_t * X, size_t r) /* 2: for i = 0 to 2r - 1 do */ for (i = 0; i < 2 * r; i += 2) { /* 3: X <-- H(X \xor B_i) */ - blkxor(X, &Bin[i * 16], 64); + blkxor((unsigned char *)X, + (const unsigned char *)&Bin[i * 16], 64); salsa20_8(X); /* 4: Y_i <-- X */ @@ -124,7 +125,8 @@ blockmix_salsa8(const uint32_t * Bin, uint32_t * Bout, uint32_t * X, size_t r) blkcpy(&Bout[i * 8], X, 64); /* 3: X <-- H(X \xor B_i) */ - blkxor(X, &Bin[i * 16 + 16], 64); + blkxor((unsigned char *)X, + (const unsigned char *)&Bin[i * 16 + 16], 64); salsa20_8(X); /* 4: Y_i <-- X */ @@ -189,14 +191,16 @@ crypto_scrypt_smix(uint8_t * B, size_t r, uint64_t N, void * _v, void * XY) j = integerify(X, r) & (N - 1); /* 8: X <-- H(X \xor V_j) */ - blkxor(X, &V[j * (32 * r)], 128 * r); + blkxor((unsigned char *)X, + (const unsigned char *)&V[j * (32 * r)], 128 * r); blockmix_salsa8(X, Y, Z, r); /* 7: j <-- Integerify(X) mod N */ j = integerify(Y, r) & (N - 1); /* 8: X <-- H(X \xor V_j) */ - blkxor(Y, &V[j * (32 * r)], 128 * r); + blkxor((unsigned char *)Y, + (const unsigned char *)&V[j * (32 * r)], 128 * r); blockmix_salsa8(Y, X, Z, r); }