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>
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++)
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);
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);
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++)