diff options
author | Niels Möller <nisse@lysator.liu.se> | 2013-04-16 08:12:23 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2013-04-16 08:16:36 +0200 |
commit | 0f10b7b44b4dd1f68078ae52d231ac23eb7dcbf6 (patch) | |
tree | 7e4da6b62628ea0281364686fa45e3ad63046e52 | |
parent | aa9ccf8f4159b9ab4d1dcfb9512945e3c37f8748 (diff) | |
download | nettle-0f10b7b44b4dd1f68078ae52d231ac23eb7dcbf6.tar.gz |
Fixed nonce caching for umac32 and umac64.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | umac32.c | 7 | ||||
-rw-r--r-- | umac64.c | 8 |
3 files changed, 13 insertions, 5 deletions
@@ -1,5 +1,8 @@ 2013-04-16 Niels Möller <nisse@lysator.liu.se> + * umac32.c (umac32_digest): Fix nonce caching. + * umac64.c (umac64_digest): Likewise. + * testsuite/umac-test.c (test_incr): New function. (test_main): Test nonce increment. @@ -101,8 +101,11 @@ umac32_digest (struct umac32_ctx *ctx, } assert (ctx->count > 0); if ( !(ctx->nonce_low & _UMAC_NONCE_CACHED)) - aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE, - (uint8_t *) ctx->pad_cache, ctx->nonce); + { + aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE, + (uint8_t *) ctx->pad_cache, ctx->nonce); + ctx->nonce_low |= _UMAC_NONCE_CACHED; + } pad = ctx->pad_cache[ctx->nonce_low & 3]; @@ -104,9 +104,11 @@ umac64_digest (struct umac64_ctx *ctx, } assert (ctx->count > 0); if ( !(ctx->nonce_low & _UMAC_NONCE_CACHED)) - aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE, - (uint8_t *) ctx->pad_cache, ctx->nonce); - + { + aes_encrypt (&ctx->pdf_key, AES_BLOCK_SIZE, + (uint8_t *) ctx->pad_cache, ctx->nonce); + ctx->nonce_low |= _UMAC_NONCE_CACHED; + } pad = ctx->pad_cache + 2*(ctx->nonce_low & 1); /* Increment nonce */ |