diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2013-09-16 06:55:13 +0400 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-09-19 16:40:35 +0200 |
commit | d399faf5db71d429bfd6fa4a9cfc82e2a55055f0 (patch) | |
tree | 50b41b0c16b64054d7b1418f7b1fcd0cccd4239f /cipher/stribog.c | |
parent | 85722afb379f7a392a8117b895de273fd88c4ebc (diff) | |
download | libgcrypt-d399faf5db71d429bfd6fa4a9cfc82e2a55055f0.tar.gz |
Fix Stribog digest on bigendian platforms
* cipher/stribog.c (stribog_final): swap bytes in the result of digest
calculations.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'cipher/stribog.c')
-rw-r--r-- | cipher/stribog.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cipher/stribog.c b/cipher/stribog.c index 979045e7..ec7ffe94 100644 --- a/cipher/stribog.c +++ b/cipher/stribog.c @@ -1394,6 +1394,21 @@ stribog_final (void *context) g (hd->h, hd->N, Z); g (hd->h, hd->Sigma, Z); + +#ifdef WORDS_BIGENDIAN + for (i = 0; i < 8; i++) + { + u64 T = hd->h[i]; + T = ((T & U64_C(0x00ff00ff00ff00ff)) << 8) | + ((T & U64_C(0xff00ff00ff00ff00)) >> 8); + T = ((T & U64_C(0x0000ffff0000ffff)) << 16) | + ((T & U64_C(0xffff0000ffff0000)) >> 16); + T = ((T & U64_C(0x00000000ffffffff)) << 32) | + ((T & U64_C(0xffffffff00000000)) >> 32); + hd->h[i] = T; + } +#endif + _gcry_burn_stack (768); } |