summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2013-04-16 07:59:40 +0200
committerNiels Möller <nisse@lysator.liu.se>2013-04-16 07:59:40 +0200
commit1d4c756ce97c24cdfdea8369c1a3726ec3e18b66 (patch)
tree46e5c92986123d6903849d78dc1aaa6b2579a9f0
parente4f490c940afc239268de2d0c9a8e8f6d786442c (diff)
downloadnettle-1d4c756ce97c24cdfdea8369c1a3726ec3e18b66.tar.gz
Fixed umac nonce increment.
-rw-r--r--ChangeLog6
-rw-r--r--umac128.c7
-rw-r--r--umac32.c6
-rw-r--r--umac64.c6
-rw-r--r--umac96.c7
5 files changed, 12 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index d069e75a..59f37bf3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
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.
2013-04-15 Niels Möller <nisse@lysator.liu.se>
diff --git a/umac128.c b/umac128.c
index 74936021..6d33b4f9 100644
--- a/umac128.c
+++ b/umac128.c
@@ -108,12 +108,7 @@ umac128_digest (struct umac128_ctx *ctx,
aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE,
(uint8_t *) tag, ctx->nonce);
- /* Increment nonce */
- i = ctx->nonce_length - 1;
- if (++ctx->nonce[i] == 0)
- while (i > 0)
- if (++ctx->nonce[--i] == 0)
- break;
+ INCREMENT (ctx->nonce_length, ctx->nonce);
_umac_l2_final (ctx->l2_key, ctx->l2_state, 4, ctx->count, ctx->l1_out);
for (i = 0; i < 4; i++)
diff --git a/umac32.c b/umac32.c
index c3714fa3..98f987e9 100644
--- a/umac32.c
+++ b/umac32.c
@@ -115,10 +115,8 @@ umac32_digest (struct umac32_ctx *ctx,
ctx->nonce_low = 0;
ctx->nonce[i] += 4;
- if (ctx->nonce[i] == 0)
- while (i > 0)
- if (++ctx->nonce[--i] == 0)
- break;
+ if (ctx->nonce[i] == 0 && i > 0)
+ INCREMENT (i, ctx->nonce);
}
_umac_l2_final (ctx->l2_key, ctx->l2_state, 1, ctx->count, ctx->l1_out);
diff --git a/umac64.c b/umac64.c
index 6f8132de..b2a69709 100644
--- a/umac64.c
+++ b/umac64.c
@@ -118,10 +118,8 @@ umac64_digest (struct umac64_ctx *ctx,
ctx->nonce_low = 0;
ctx->nonce[i] += 2;
- if (ctx->nonce[i] == 0)
- while (i > 0)
- if (++ctx->nonce[--i] == 0)
- break;
+ if (ctx->nonce[i] == 0 && i > 0)
+ INCREMENT (i, ctx->nonce);
}
_umac_l2_final (ctx->l2_key, ctx->l2_state, 2, ctx->count, ctx->l1_out);
diff --git a/umac96.c b/umac96.c
index b4b43ed7..2831ad14 100644
--- a/umac96.c
+++ b/umac96.c
@@ -106,12 +106,7 @@ umac96_digest (struct umac96_ctx *ctx,
aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE,
(uint8_t *) tag, ctx->nonce);
- /* Increment nonce */
- i = ctx->nonce_length - 1;
- if (++ctx->nonce[i] == 0)
- while (i > 0)
- if (++ctx->nonce[--i] == 0)
- break;
+ INCREMENT (ctx->nonce_length, ctx->nonce);
_umac_l2_final (ctx->l2_key, ctx->l2_state, 3, ctx->count, ctx->l1_out);
for (i = 0; i < 3; i++)