diff options
author | Werner Koch <wk@gnupg.org> | 2011-02-15 18:37:43 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2011-02-15 18:37:43 +0100 |
commit | b825c5db17292988d261fefdc83cbc43d97d4b02 (patch) | |
tree | 6be065ad0599e797cde0f72afce78c44884d4832 /tests/benchmark.c | |
parent | 83f80d39c3feddc7e055525d47dcf3f069801e89 (diff) | |
download | libgcrypt-b825c5db17292988d261fefdc83cbc43d97d4b02.tar.gz |
Add asm code to use aeskeygenassist.
However, this code is disabled right now.
Diffstat (limited to 'tests/benchmark.c')
-rw-r--r-- | tests/benchmark.c | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/tests/benchmark.c b/tests/benchmark.c index 465f1b51..536b76a6 100644 --- a/tests/benchmark.c +++ b/tests/benchmark.c @@ -54,6 +54,9 @@ static int hash_repetitions; /* Alignment of the buffers. */ static int buffer_alignment; +/* Whether to include the keysetup in the cipher timings. */ +static int cipher_with_keysetup; + /* Whether fips mode was active at startup. */ static int in_fips_mode; @@ -619,13 +622,16 @@ cipher_bench ( const char *algoname ) exit (1); } - err = gcry_cipher_setkey (hd, key, keylen); - if (err) - { - fprintf (stderr, "gcry_cipher_setkey failed: %s\n", - gpg_strerror (err)); - gcry_cipher_close (hd); - exit (1); + if (!cipher_with_keysetup) + { + err = gcry_cipher_setkey (hd, key, keylen); + if (err) + { + fprintf (stderr, "gcry_cipher_setkey failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hd); + exit (1); + } } buflen = allocated_buflen; @@ -634,7 +640,20 @@ cipher_bench ( const char *algoname ) start_timer (); for (i=err=0; !err && i < repetitions; i++) - err = gcry_cipher_encrypt ( hd, outbuf, buflen, buf, buflen); + { + if (cipher_with_keysetup) + { + err = gcry_cipher_setkey (hd, key, keylen); + if (err) + { + fprintf (stderr, "gcry_cipher_setkey failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hd); + exit (1); + } + } + err = gcry_cipher_encrypt ( hd, outbuf, buflen, buf, buflen); + } stop_timer (); printf (" %s", elapsed_time ()); @@ -654,18 +673,34 @@ cipher_bench ( const char *algoname ) exit (1); } - err = gcry_cipher_setkey (hd, key, keylen); - if (err) + if (!cipher_with_keysetup) { - fprintf (stderr, "gcry_cipher_setkey failed: %s\n", - gpg_strerror (err)); - gcry_cipher_close (hd); - exit (1); + err = gcry_cipher_setkey (hd, key, keylen); + if (err) + { + fprintf (stderr, "gcry_cipher_setkey failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hd); + exit (1); + } } start_timer (); for (i=err=0; !err && i < repetitions; i++) - err = gcry_cipher_decrypt ( hd, outbuf, buflen, buf, buflen); + { + if (cipher_with_keysetup) + { + err = gcry_cipher_setkey (hd, key, keylen); + if (err) + { + fprintf (stderr, "gcry_cipher_setkey failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hd); + exit (1); + } + } + err = gcry_cipher_decrypt ( hd, outbuf, buflen, buf, buflen); + } stop_timer (); printf (" %s", elapsed_time ()); fflush (stdout); @@ -1119,6 +1154,11 @@ main( int argc, char **argv ) argc--; argv++; } } + else if (!strcmp (*argv, "--cipher-with-keysetup")) + { + cipher_with_keysetup = 1; + argc--; argv++; + } else if (!strcmp (*argv, "--hash-repetitions")) { argc--; argv++; |