Commit 614a672e authored by Niels Möller's avatar Niels Möller

Rearranged struct aes_ctx.

parent ff29d0a9
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.
......
......@@ -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);
}
......@@ -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);
}
......@@ -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]);
}
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment