summaryrefslogtreecommitdiff
path: root/cipher/scrypt.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-09-07 11:52:05 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2013-09-07 11:52:05 +0300
commit38a038a135d82231eff9d84f1ae3c4a25c6a5e75 (patch)
tree29ef40b903106b9d49fdbe1950a1b90f1240d1f7 /cipher/scrypt.c
parentf7135e299e659d78906aac3dfdf30f380b5cf9c6 (diff)
downloadlibgcrypt-38a038a135d82231eff9d84f1ae3c4a25c6a5e75.tar.gz
scrypt: fix for big-endian systems
* cipher/scrypt.c (_salsa20_core): Fix endianess issues. -- On big-endian systems 'tests/t-kdf' was failing scrypt tests. Patch fixes the issue. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/scrypt.c')
-rw-r--r--cipher/scrypt.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/cipher/scrypt.c b/cipher/scrypt.c
index 06196d62..9e29288a 100644
--- a/cipher/scrypt.c
+++ b/cipher/scrypt.c
@@ -107,7 +107,9 @@ _salsa20_core(u32 *dst, const u32 *src, unsigned rounds)
assert ( (rounds & 1) == 0);
- memcpy (x, src, sizeof(x));
+ for (i = 0; i < SALSA20_INPUT_LENGTH; i++)
+ x[i] = LE_SWAP32(src[i]);
+
for (i = 0; i < rounds;i += 2)
{
QROUND(x[0], x[4], x[8], x[12]);
@@ -123,8 +125,8 @@ _salsa20_core(u32 *dst, const u32 *src, unsigned rounds)
for (i = 0; i < SALSA20_INPUT_LENGTH; i++)
{
- u32 t = x[i] + src[i];
- dst[i] = LE_SWAP32 (t);
+ u32 t = x[i] + LE_SWAP32(src[i]);
+ dst[i] = LE_SWAP32(t);
}
}