From: Niels Möller Date: Tue, 15 Mar 2016 19:37:35 +0000 (+0100) Subject: blowfish: Use READ_UINT32 macro. X-Git-Tag: nettle_3.3_release_20161001~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f1403b9758d5b718f74db45f4eeb5471ec7b5a6;p=thirdparty%2Fnettle.git blowfish: Use READ_UINT32 macro. --- diff --git a/ChangeLog b/ChangeLog index 950a1964..2208874c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2016-03-15 Niels Möller + * blowfish.c (blowfish_encrypt, blowfish_decrypt): Use READ_UINT32 + macro. Fixes an undefined shift, reported by Nikos + Mavrogiannopoulos. + From Nikos Mavrogiannopoulos. * configure.ac (HOGWEED_EXTRA_SYMBOLS): Add "mp_*", when building with mini-gmp. diff --git a/blowfish.c b/blowfish.c index ba921e71..52040f13 100644 --- a/blowfish.c +++ b/blowfish.c @@ -337,8 +337,8 @@ blowfish_encrypt (const struct blowfish_ctx *ctx, { uint32_t d1, d2; - d1 = src[0] << 24 | src[1] << 16 | src[2] << 8 | src[3]; - d2 = src[4] << 24 | src[5] << 16 | src[6] << 8 | src[7]; + d1 = READ_UINT32(src); + d2 = READ_UINT32(src+4); encrypt (ctx, &d1, &d2); dst[0] = (d1 >> 24) & 0xff; dst[1] = (d1 >> 16) & 0xff; @@ -359,8 +359,8 @@ blowfish_decrypt (const struct blowfish_ctx *ctx, { uint32_t d1, d2; - d1 = src[0] << 24 | src[1] << 16 | src[2] << 8 | src[3]; - d2 = src[4] << 24 | src[5] << 16 | src[6] << 8 | src[7]; + d1 = READ_UINT32(src); + d2 = READ_UINT32(src+4); decrypt (ctx, &d1, &d2); dst[0] = (d1 >> 24) & 0xff; dst[1] = (d1 >> 16) & 0xff;