Skip to content

Commit

Permalink
Fix bug #3: EAX produces wrong tag for empty AAD
Browse files Browse the repository at this point in the history
This was caused by the CMAC update function with len=0 and isfinal=1
doing nothing (because the work it needed to do already happened
with the last message).

Now:
- CMAC defends against and documents this case.
- EAX makes the correct CMAC calls.
  • Loading branch information
ctz committed Apr 16, 2016
1 parent b03c1ab commit 82d77cd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/eax.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ static void cmac_compute_n(cf_cmac_stream *ctx,
firstblock[blocksz - 1] = t;

cf_cmac_stream_reset(ctx);
cf_cmac_stream_update(ctx, firstblock, blocksz, 0);
cf_cmac_stream_update(ctx, input, ninput, 1);
if (ninput)
{
cf_cmac_stream_update(ctx, firstblock, blocksz, 0);
cf_cmac_stream_update(ctx, input, ninput, 1);
} else {
cf_cmac_stream_update(ctx, firstblock, blocksz, 1);
}

cf_cmac_stream_final(ctx, out);
}

Expand Down

0 comments on commit 82d77cd

Please sign in to comment.