summaryrefslogtreecommitdiff
path: root/tests/benchmark.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2017-01-06 12:48:17 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2017-01-06 12:48:17 +0200
commit232a129b1f915fc54881506e4b07c89cf84932e6 (patch)
tree21830feb80af49e2ab2ff344a647d0a0ec10aac5 /tests/benchmark.c
parentaada604594fd42224d366d3cb98f67fd3b989cd6 (diff)
downloadlibgcrypt-232a129b1f915fc54881506e4b07c89cf84932e6.tar.gz
Add XTS cipher mode
* cipher/Makefile.am: Add 'cipher-xts.c'. * cipher/cipher-internal.h (gcry_cipher_handle): Add 'bulk.xts_crypt' and 'u_mode.xts' members. (_gcry_cipher_xts_crypt): New prototype. * cipher/cipher-xts.c: New. * cipher/cipher.c (_gcry_cipher_open_internal, cipher_setkey) (cipher_reset, cipher_encrypt, cipher_decrypt): Add XTS mode handling. * doc/gcrypt.texi: Add XTS mode to documentation. * src/gcrypt.h.in (GCRY_CIPHER_MODE_XTS, GCRY_XTS_BLOCK_LEN): New. * tests/basic.c (do_check_xts_cipher, check_xts_cipher): New. (check_bulk_cipher_modes): Add XTS test-vectors. (check_one_cipher_core, check_one_cipher, check_ciphers): Add XTS testing support. (check_cipher_modes): Add XTS test. * tests/bench-slope.c (bench_xts_encrypt_init) (bench_xts_encrypt_do_bench, bench_xts_decrypt_do_bench) (xts_encrypt_ops, xts_decrypt_ops): New. (cipher_modes, cipher_bench_one): Add XTS. * tests/benchmark.c (cipher_bench): Add XTS testing. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'tests/benchmark.c')
-rw-r--r--tests/benchmark.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/benchmark.c b/tests/benchmark.c
index a63cce37..44a8711d 100644
--- a/tests/benchmark.c
+++ b/tests/benchmark.c
@@ -764,12 +764,15 @@ cipher_bench ( const char *algoname )
int req_blocksize;
int authlen;
int noncelen;
+ int doublekey;
} modes[] = {
{ GCRY_CIPHER_MODE_ECB, " ECB/Stream", 1 },
{ GCRY_CIPHER_MODE_CBC, " CBC", 1 },
{ GCRY_CIPHER_MODE_CFB, " CFB", 0 },
{ GCRY_CIPHER_MODE_OFB, " OFB", 0 },
{ GCRY_CIPHER_MODE_CTR, " CTR", 0 },
+ { GCRY_CIPHER_MODE_XTS, " XTS", 0,
+ NULL, GCRY_XTS_BLOCK_LEN, 0, 0, 1 },
{ GCRY_CIPHER_MODE_CCM, " CCM", 0,
ccm_aead_init, GCRY_CCM_BLOCK_LEN, 8 },
{ GCRY_CIPHER_MODE_GCM, " GCM", 0,
@@ -841,13 +844,13 @@ cipher_bench ( const char *algoname )
algoname);
exit (1);
}
- if ( keylen > sizeof key )
+ if ( keylen * 2 > sizeof key )
{
fprintf (stderr, PGM ": algo %d, keylength problem (%d)\n",
algo, keylen );
exit (1);
}
- for (i=0; i < keylen; i++)
+ for (i=0; i < keylen * 2; i++)
key[i] = i + (clock () & 0xff);
blklen = gcry_cipher_get_algo_blklen (algo);
@@ -863,6 +866,8 @@ cipher_bench ( const char *algoname )
for (modeidx=0; modes[modeidx].mode; modeidx++)
{
+ size_t modekeylen = keylen * (!!modes[modeidx].doublekey + 1);
+
if ((blklen > 1 && modes[modeidx].mode == GCRY_CIPHER_MODE_STREAM)
|| (blklen == 1 && modes[modeidx].mode != GCRY_CIPHER_MODE_STREAM))
continue;
@@ -886,7 +891,7 @@ cipher_bench ( const char *algoname )
if (!cipher_with_keysetup)
{
- err = gcry_cipher_setkey (hd, key, keylen);
+ err = gcry_cipher_setkey (hd, key, modekeylen);
if (err)
{
fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
@@ -905,7 +910,7 @@ cipher_bench ( const char *algoname )
{
if (cipher_with_keysetup)
{
- err = gcry_cipher_setkey (hd, key, keylen);
+ err = gcry_cipher_setkey (hd, key, modekeylen);
if (err)
{
fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
@@ -969,7 +974,7 @@ cipher_bench ( const char *algoname )
if (!cipher_with_keysetup)
{
- err = gcry_cipher_setkey (hd, key, keylen);
+ err = gcry_cipher_setkey (hd, key, modekeylen);
if (err)
{
fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
@@ -984,7 +989,7 @@ cipher_bench ( const char *algoname )
{
if (cipher_with_keysetup)
{
- err = gcry_cipher_setkey (hd, key, keylen);
+ err = gcry_cipher_setkey (hd, key, modekeylen);
if (err)
{
fprintf (stderr, "gcry_cipher_setkey failed: %s\n",