Skip to content
Snippets Groups Projects
Commit 1d4c756c authored by Niels Möller's avatar Niels Möller
Browse files

Fixed umac nonce increment.

parent e4f490c9
No related branches found
No related tags found
No related merge requests found
2013-04-16 Niels Möller <nisse@lysator.liu.se> 2013-04-16 Niels Möller <nisse@lysator.liu.se>
* umac32.c (umac32_digest): Fix nonce increment, use INCREMENT
macro.
* umac64.c (umac64_digest): Likewise.
* umac96.c (umac96_digest): Likewise.
* umac128.c (umac128_digest): Likewise.
* macros.h (INCREMENT): Allow size == 1. * macros.h (INCREMENT): Allow size == 1.
2013-04-15 Niels Möller <nisse@lysator.liu.se> 2013-04-15 Niels Möller <nisse@lysator.liu.se>
......
...@@ -108,12 +108,7 @@ umac128_digest (struct umac128_ctx *ctx, ...@@ -108,12 +108,7 @@ umac128_digest (struct umac128_ctx *ctx,
aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE, aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE,
(uint8_t *) tag, ctx->nonce); (uint8_t *) tag, ctx->nonce);
/* Increment nonce */ INCREMENT (ctx->nonce_length, ctx->nonce);
i = ctx->nonce_length - 1;
if (++ctx->nonce[i] == 0)
while (i > 0)
if (++ctx->nonce[--i] == 0)
break;
_umac_l2_final (ctx->l2_key, ctx->l2_state, 4, ctx->count, ctx->l1_out); _umac_l2_final (ctx->l2_key, ctx->l2_state, 4, ctx->count, ctx->l1_out);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
......
...@@ -115,10 +115,8 @@ umac32_digest (struct umac32_ctx *ctx, ...@@ -115,10 +115,8 @@ umac32_digest (struct umac32_ctx *ctx,
ctx->nonce_low = 0; ctx->nonce_low = 0;
ctx->nonce[i] += 4; ctx->nonce[i] += 4;
if (ctx->nonce[i] == 0) if (ctx->nonce[i] == 0 && i > 0)
while (i > 0) INCREMENT (i, ctx->nonce);
if (++ctx->nonce[--i] == 0)
break;
} }
_umac_l2_final (ctx->l2_key, ctx->l2_state, 1, ctx->count, ctx->l1_out); _umac_l2_final (ctx->l2_key, ctx->l2_state, 1, ctx->count, ctx->l1_out);
......
...@@ -118,10 +118,8 @@ umac64_digest (struct umac64_ctx *ctx, ...@@ -118,10 +118,8 @@ umac64_digest (struct umac64_ctx *ctx,
ctx->nonce_low = 0; ctx->nonce_low = 0;
ctx->nonce[i] += 2; ctx->nonce[i] += 2;
if (ctx->nonce[i] == 0) if (ctx->nonce[i] == 0 && i > 0)
while (i > 0) INCREMENT (i, ctx->nonce);
if (++ctx->nonce[--i] == 0)
break;
} }
_umac_l2_final (ctx->l2_key, ctx->l2_state, 2, ctx->count, ctx->l1_out); _umac_l2_final (ctx->l2_key, ctx->l2_state, 2, ctx->count, ctx->l1_out);
......
...@@ -106,12 +106,7 @@ umac96_digest (struct umac96_ctx *ctx, ...@@ -106,12 +106,7 @@ umac96_digest (struct umac96_ctx *ctx,
aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE, aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE,
(uint8_t *) tag, ctx->nonce); (uint8_t *) tag, ctx->nonce);
/* Increment nonce */ INCREMENT (ctx->nonce_length, ctx->nonce);
i = ctx->nonce_length - 1;
if (++ctx->nonce[i] == 0)
while (i > 0)
if (++ctx->nonce[--i] == 0)
break;
_umac_l2_final (ctx->l2_key, ctx->l2_state, 3, ctx->count, ctx->l1_out); _umac_l2_final (ctx->l2_key, ctx->l2_state, 3, ctx->count, ctx->l1_out);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment