diff --git a/ChangeLog b/ChangeLog index 80af73fb1af9116ee079150f72e443e4b238b386..ac2f4997bb4a66e26f4643694af23ff47c8fec00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2013-04-11 Niels Möller <nisse@lysator.liu.se> + * examples/nettle-benchmark.c (time_umac): New function. + (main): Call it. + * umac-set-key.c (_umac_set_key): Drop byteswapping of l3_key2, it can be xored directly to the pad in native byteorder. * umac-l3.c (_umac_l3): Drop key_2 argument, let caller do that diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c index 852baef85e8b47d68b45eab5aeee54816635b2ed..5be3d49b9d5b94b19ef6fb583f2aea2676a36f8e 100644 --- a/examples/nettle-benchmark.c +++ b/examples/nettle-benchmark.c @@ -55,6 +55,7 @@ #include "sha2.h" #include "sha3.h" #include "twofish.h" +#include "umac.h" #include "nettle-meta.h" #include "nettle-internal.h" @@ -352,6 +353,51 @@ time_hash(const struct nettle_hash *hash) free(info.ctx); } +static void +time_umac(void) +{ + static uint8_t data[BENCH_BLOCK]; + struct bench_hash_info info; + struct umac32_ctx ctx32; + struct umac64_ctx ctx64; + struct umac96_ctx ctx96; + struct umac128_ctx ctx128; + + uint8_t key[16]; + + umac32_set_key (&ctx32, key); + info.ctx = &ctx32; + info.update = (nettle_hash_update_func *) umac32_update; + info.data = data; + + display("umac32", "update", UMAC_BLOCK_SIZE, + time_function(bench_hash, &info)); + + umac64_set_key (&ctx64, key); + info.ctx = &ctx64; + info.update = (nettle_hash_update_func *) umac64_update; + info.data = data; + + display("umac64", "update", UMAC_BLOCK_SIZE, + time_function(bench_hash, &info)); + + umac96_set_key (&ctx96, key); + info.ctx = &ctx96; + info.update = (nettle_hash_update_func *) umac96_update; + info.data = data; + + display("umac96", "update", UMAC_BLOCK_SIZE, + time_function(bench_hash, &info)); + + umac128_set_key (&ctx128, key); + info.ctx = &ctx128; + info.update = (nettle_hash_update_func *) umac128_update; + info.data = data; + + display("umac128", "update", UMAC_BLOCK_SIZE, + time_function(bench_hash, &info)); +} + static void time_gcm(void) { @@ -669,6 +715,9 @@ main(int argc, char **argv) if (!alg || strstr(hashes[i]->name, alg)) time_hash(hashes[i]); + if (!alg || strstr ("umac", alg)) + time_umac(); + for (i = 0; ciphers[i]; i++) if (!alg || strstr(ciphers[i]->name, alg)) time_cipher(ciphers[i]);