Commit 2e090fb9 authored by Niels Möller's avatar Niels Möller

(time_gcm): Renamed. Updated for gcm_aes_auth to gcm_aes_update

renaming. Benchmark both encryption and hashing.
(time_gmac): ...old name.

Rev: nettle/examples/nettle-benchmark.c:1.20
parent 1c7bddc1
...@@ -390,23 +390,37 @@ time_hash(const struct nettle_hash *hash) ...@@ -390,23 +390,37 @@ time_hash(const struct nettle_hash *hash)
} }
static void static void
time_gmac(void) time_gcm(void)
{ {
static uint8_t data[BENCH_BLOCK]; static uint8_t data[BENCH_BLOCK];
struct bench_hash_info info; struct bench_hash_info hinfo;
struct bench_cipher_info cinfo;
struct gcm_aes_ctx ctx; struct gcm_aes_ctx ctx;
uint8_t key[16]; uint8_t key[16];
uint8_t iv[GCM_IV_SIZE]; uint8_t iv[GCM_IV_SIZE];
gcm_aes_set_key(&ctx, sizeof(key), key); gcm_aes_set_key(&ctx, sizeof(key), key);
gcm_aes_set_iv(&ctx, sizeof(iv), iv); gcm_aes_set_iv(&ctx, sizeof(iv), iv);
info.ctx = &ctx; hinfo.ctx = &ctx;
info.update = (nettle_hash_update_func *) gcm_aes_auth; hinfo.update = (nettle_hash_update_func *) gcm_aes_update;
info.data = data; hinfo.data = data;
display("gcm-aes", "update", GCM_BLOCK_SIZE,
time_function(bench_hash, &hinfo));
cinfo.ctx = &ctx;
cinfo.crypt = (nettle_crypt_func *) gcm_aes_encrypt;
cinfo.data = data;
display("gmac", "auth", GCM_BLOCK_SIZE, display("gcm-aes", "encrypt", GCM_BLOCK_SIZE,
time_function(bench_hash, &info)); time_function(bench_cipher, &cinfo));
cinfo.crypt = (nettle_crypt_func *) gcm_aes_decrypt;
display("gcm-aes", "decrypt", GCM_BLOCK_SIZE,
time_function(bench_cipher, &cinfo));
} }
static void static void
...@@ -636,20 +650,18 @@ main(int argc, char **argv) ...@@ -636,20 +650,18 @@ main(int argc, char **argv)
} }
for (i = 0; hashes[i]; i++) for (i = 0; hashes[i]; i++)
{ if (!alg || strstr(hashes[i]->name, alg))
if (!alg || strstr(hashes[i]->name, alg)) time_hash(hashes[i]);
time_hash(hashes[i]);
}
if (!alg || strstr ("gmac", alg))
{
time_gmac();
printf("\n");
}
for (i = 0; ciphers[i]; i++) for (i = 0; ciphers[i]; i++)
if (!alg || strstr(ciphers[i]->name, alg)) if (!alg || strstr(ciphers[i]->name, alg))
time_cipher(ciphers[i]); time_cipher(ciphers[i]);
if (!alg || strstr ("gcm", alg))
{
printf("\n");
time_gcm();
}
return 0; return 0;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment