diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-01-10 09:29:17 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2018-02-19 21:31:51 +0100 |
commit | a254a7761fd1165f2a1ffd3bb2f4c38ee5723715 (patch) | |
tree | dc27d093f71333780b69f91d4c07a50989ba1f38 /examples | |
parent | 36168d2942b82c351daf00cd3e2744ebb10add13 (diff) | |
download | nettle-a254a7761fd1165f2a1ffd3bb2f4c38ee5723715.tar.gz |
Added support for CMAC
That adds support for CMAC as a generic framework for
128-bit block and key ciphers, as well as API for AES-128-CMAC,
and AES-256-CMAC.
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/nettle-benchmark.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c index 655ce09e..b6863cb5 100644 --- a/examples/nettle-benchmark.c +++ b/examples/nettle-benchmark.c @@ -64,6 +64,7 @@ #include "sha3.h" #include "twofish.h" #include "umac.h" +#include "cmac.h" #include "poly1305.h" #include "nettle-meta.h" @@ -403,7 +404,7 @@ time_umac(void) struct umac64_ctx ctx64; struct umac96_ctx ctx96; struct umac128_ctx ctx128; - + uint8_t key[16]; umac32_set_key (&ctx32, key); @@ -440,6 +441,24 @@ time_umac(void) } static void +time_cmac(void) +{ + static uint8_t data[BENCH_BLOCK]; + struct bench_hash_info info; + struct cmac_aes128_ctx ctx; + + uint8_t key[16]; + + cmac_aes128_set_key (&ctx, key); + info.ctx = &ctx; + info.update = (nettle_hash_update_func *) cmac_aes128_update; + info.data = data; + + display("cmac-aes128", "update", AES_BLOCK_SIZE, + time_function(bench_hash, &info)); +} + +static void time_poly1305_aes(void) { static uint8_t data[BENCH_BLOCK]; @@ -849,6 +868,9 @@ main(int argc, char **argv) if (!alg || strstr ("umac", alg)) time_umac(); + if (!alg || strstr ("cmac", alg)) + time_cmac(); + if (!alg || strstr ("poly1305-aes", alg)) time_poly1305_aes(); |