]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Use ROTL32 in the aes code.
authorNiels Möller <nisse@lysator.liu.se>
Sat, 31 Mar 2012 19:26:07 +0000 (21:26 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 31 Mar 2012 19:26:07 +0000 (21:26 +0200)
ChangeLog
aes-internal.h
aes-set-encrypt-key.c

index 483f337f2d4b43c96b0fdd5ea2fbbe8383bd123e..e6fc6bddd1bc9c77d4ac5bef9573e291855f3d8e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
 
        * macros.h (ROTL32): New macro, to replace (almost) all other
        rotation macros.
+       * aes-set-encrypt-key.c: Include macros.h.
+       (aes_set_encrypt_key): Use ROTL32.
+       * aes-internal.h (ROTBYTE, ROTRBYTE): Deleted macros.
 
 2012-03-30  Niels Möller  <nisse@lysator.liu.se>
 
index ae988e40250ac64ec68c815302bb89a96340eb00..3bedff7815ad548171c8e005bd8fd7e4e62d1545 100644 (file)
@@ -63,8 +63,6 @@ _aes_decrypt(const struct aes_ctx *ctx,
             const uint8_t *src);
 
 /* Macros */
-#define ROTBYTE(x) (((x) >> 8) | (((x) & 0xff) << 24))
-#define ROTRBYTE(x) (((x) << 8) | (((x) >> 24) & 0xff))
 #define SUBBYTE(x, box) (((box)[((x) & 0xff)]) | \
                         ((box)[(((x) >> 8) & 0xff)] << 8) | \
                         ((box)[(((x) >> 16) & 0xff)] << 16) | \
index 71f9f9f85b80912bf6c8bf077af122dd248dfe14..dfd102f722f664f01ddbc321b5ae7de54053c045 100644 (file)
@@ -32,6 +32,7 @@
 #include <assert.h>
 
 #include "aes-internal.h"
+#include "macros.h"
 
 static unsigned
 xtime(unsigned x)
@@ -83,7 +84,7 @@ aes_set_encrypt_key(struct aes_ctx *ctx,
       temp = ctx->keys[i-1];
       if (i % nk == 0)
        {
-         temp = SUBBYTE(ROTBYTE(temp), aes_sbox) ^ rcon;
+         temp = SUBBYTE(ROTL32(24, temp), aes_sbox) ^ rcon;
          rcon = (uint32_t)xtime((uint8_t)rcon&0xff);
        }
       else if (nk > 6 && (i%nk) == 4)