From: Niels Möller Date: Fri, 13 Apr 2012 14:56:14 +0000 (+0200) Subject: Minor cleanup of SUBBYTE mmacro. X-Git-Tag: nettle_2.5_release_20120707~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ff8ded579f9166b8a20f954bcc28225b661755b;p=thirdparty%2Fnettle.git Minor cleanup of SUBBYTE mmacro. --- diff --git a/ChangeLog b/ChangeLog index c64bafb1..ff613329 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-04-13 Niels Möller + + * aes-internal.h (SUBBYTE): Cast to uint32_t. Use B0, ..., B3 + macros. + 2012-04-09 Niels Möller Timing resistant RSA decryption, based on RSA blinding code diff --git a/aes-internal.h b/aes-internal.h index 3bedff78..a3475d92 100644 --- a/aes-internal.h +++ b/aes-internal.h @@ -63,17 +63,17 @@ _aes_decrypt(const struct aes_ctx *ctx, const uint8_t *src); /* Macros */ -#define SUBBYTE(x, box) (((box)[((x) & 0xff)]) | \ - ((box)[(((x) >> 8) & 0xff)] << 8) | \ - ((box)[(((x) >> 16) & 0xff)] << 16) | \ - ((box)[(((x) >> 24) & 0xff)] << 24)) - /* Get the byte with index 0, 1, 2 and 3 */ #define B0(x) ((x) & 0xff) #define B1(x) (((x) >> 8) & 0xff) #define B2(x) (((x) >> 16) & 0xff) #define B3(x) (((x) >> 24) & 0xff) +#define SUBBYTE(x, box) ((uint32_t)(box)[B0(x)] \ + | ((uint32_t)(box)[B1(x)] << 8) \ + | ((uint32_t)(box)[B2(x)] << 16) \ + | ((uint32_t)(box)[B3(x)] << 24)) + #define AES_ROUND(T, w0, w1, w2, w3, k) \ (( T->table[0][ B0(w0) ] \ ^ T->table[1][ B1(w1) ] \