summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2013-05-17 17:35:36 +0200
committerNiels Möller <nisse@lysator.liu.se>2013-05-17 17:35:36 +0200
commit614a672e7efd87b82c514b471ccc66c081c380d4 (patch)
tree6d330873fe585b300613ca841e713f6228b72260
parentff29d0a9c9b7d17e0bc15bbba88993244903222b (diff)
downloadnettle-614a672e7efd87b82c514b471ccc66c081c380d4.tar.gz
Rearranged struct aes_ctx.
-rw-r--r--ChangeLog5
-rw-r--r--aes-decrypt.c2
-rw-r--r--aes-encrypt.c2
-rw-r--r--aes-set-decrypt-key.c14
-rw-r--r--aes-set-encrypt-key.c2
-rw-r--r--aes.h2
6 files changed, 16 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 5086e171..cd7ca286 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2013-05-17 Niels Möller <nisse@lysator.liu.se>
+ * aes.h (struct aes_ctx): Renamed nrounds to rounds, and moved
+ first in the structure.
+ * aes-set-encrypt-key.c (aes_set_encrypt_key): Updated for renaming.
+ * aes-set-decrypt-key.c (aes_invert_key): Likewise.
+
* aes-encrypt-internal.c (_nettle_aes_encrypt): Take rounds and
subkeys as separate arguments, not a struct aes_ctx *. Updated
callers.
diff --git a/aes-decrypt.c b/aes-decrypt.c
index d83a6952..d08eac34 100644
--- a/aes-decrypt.c
+++ b/aes-decrypt.c
@@ -342,6 +342,6 @@ aes_decrypt(const struct aes_ctx *ctx,
const uint8_t *src)
{
assert(!(length % AES_BLOCK_SIZE) );
- _aes_decrypt(ctx->nrounds, ctx->keys, &_aes_decrypt_table,
+ _aes_decrypt(ctx->rounds, ctx->keys, &_aes_decrypt_table,
length, dst, src);
}
diff --git a/aes-encrypt.c b/aes-encrypt.c
index 5ee1a49b..0077693a 100644
--- a/aes-encrypt.c
+++ b/aes-encrypt.c
@@ -40,6 +40,6 @@ aes_encrypt(const struct aes_ctx *ctx,
const uint8_t *src)
{
assert(!(length % AES_BLOCK_SIZE) );
- _aes_encrypt(ctx->nrounds, ctx->keys, &_aes_encrypt_table,
+ _aes_encrypt(ctx->rounds, ctx->keys, &_aes_encrypt_table,
length, dst, src);
}
diff --git a/aes-set-decrypt-key.c b/aes-set-decrypt-key.c
index 04e4c992..f8e8ef71 100644
--- a/aes-set-decrypt-key.c
+++ b/aes-set-decrypt-key.c
@@ -126,10 +126,10 @@ void
aes_invert_key(struct aes_ctx *dst,
const struct aes_ctx *src)
{
- unsigned nrounds;
+ unsigned rounds;
unsigned i;
- nrounds = src->nrounds;
+ rounds = src->rounds;
/* Reverse the order of subkeys, in groups of 4. */
/* FIXME: Instead of reordering the subkeys, change the access order
@@ -138,7 +138,7 @@ aes_invert_key(struct aes_ctx *dst,
{
unsigned j, k;
- for (i = 0, j = nrounds * 4;
+ for (i = 0, j = rounds * 4;
i < j;
i += 4, j -= 4)
for (k = 0; k<4; k++)
@@ -148,14 +148,14 @@ aes_invert_key(struct aes_ctx *dst,
{
unsigned k;
- dst->nrounds = nrounds;
- for (i = 0; i <= nrounds * 4; i += 4)
+ dst->rounds = rounds;
+ for (i = 0; i <= rounds * 4; i += 4)
for (k = 0; k < 4; k++)
- dst->keys[i+k] = src->keys[nrounds * 4 - i + k];
+ dst->keys[i+k] = src->keys[rounds * 4 - i + k];
}
/* Transform all subkeys but the first and last. */
- for (i = 4; i < 4 * nrounds; i++)
+ for (i = 4; i < 4 * rounds; i++)
MIX_COLUMN (mtable, dst->keys[i]);
}
diff --git a/aes-set-encrypt-key.c b/aes-set-encrypt-key.c
index 04f53270..d96a8ebc 100644
--- a/aes-set-encrypt-key.c
+++ b/aes-set-encrypt-key.c
@@ -61,7 +61,7 @@ aes_set_encrypt_key(struct aes_ctx *ctx,
}
lastkey = (AES_BLOCK_SIZE/4) * (nr + 1);
- ctx->nrounds = nr;
+ ctx->rounds = nr;
for (i=0, rp = rcon; i<nk; i++)
ctx->keys[i] = LE_READ_UINT32(key + i*4);
diff --git a/aes.h b/aes.h
index b3bb9659..d26c0013 100644
--- a/aes.h
+++ b/aes.h
@@ -53,8 +53,8 @@ extern "C" {
sizes? */
struct aes_ctx
{
+ unsigned rounds; /* number of rounds to use for our key size */
uint32_t keys[60]; /* maximum size of key schedule */
- unsigned nrounds; /* number of rounds to use for our key size */
};
void