summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2015-08-11 07:22:16 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2015-08-12 17:41:42 +0300
commit24ebf53f1e8a8afa27dcd768339bda70a740bb03 (patch)
tree2086fe6cd7e7d5c0cb24181fdaf332946aa3f69c /tests
parente11895da1f4af9782d89e92ba2e6b1a63235b54b (diff)
downloadlibgcrypt-24ebf53f1e8a8afa27dcd768339bda70a740bb03.tar.gz
Simplify OCB offset calculation for parallel implementations
* cipher/camellia-glue.c (_gcry_camellia_ocb_crypt) (_gcry_camellia_ocb_auth): Precalculate Ls array always, instead of just if 'blkn % <parallel blocks> == 0'. * cipher/serpent.c (_gcry_serpent_ocb_crypt) (_gcry_serpent_ocb_auth): Ditto. * cipher/rijndael-aesni.c (get_l): Remove low-bit checks. (aes_ocb_enc, aes_ocb_dec, _gcry_aes_aesni_ocb_auth): Handle leading blocks until block counter is multiple of 4, so that parallel block processing loop can use 'c->u_mode.ocb.L' array directly. * tests/basic.c (check_ocb_cipher_largebuf): Rename to... (check_ocb_cipher_largebuf_split): ...this and add option to process large buffer as two split buffers. (check_ocb_cipher_largebuf): New. -- Patch simplifies source and reduce object size. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/tests/basic.c b/tests/basic.c
index c1aa76a7..4ea91a93 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -3153,7 +3153,8 @@ do_check_ocb_cipher (int inplace)
static void
-check_ocb_cipher_largebuf (int algo, int keylen, const char *tagexpect)
+check_ocb_cipher_largebuf_split (int algo, int keylen, const char *tagexpect,
+ unsigned int splitpos)
{
static const unsigned char key[32] =
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
@@ -3219,7 +3220,14 @@ check_ocb_cipher_largebuf (int algo, int keylen, const char *tagexpect)
goto out_free;
}
- err = gcry_cipher_authenticate (hde, inbuf, buflen);
+ if (splitpos)
+ {
+ err = gcry_cipher_authenticate (hde, inbuf, splitpos);
+ }
+ if (!err)
+ {
+ err = gcry_cipher_authenticate (hde, inbuf + splitpos, buflen - splitpos);
+ }
if (err)
{
fail ("cipher-ocb, gcry_cipher_authenticate failed (large, algo %d): %s\n",
@@ -3229,10 +3237,18 @@ check_ocb_cipher_largebuf (int algo, int keylen, const char *tagexpect)
goto out_free;
}
- err = gcry_cipher_final (hde);
+ if (splitpos)
+ {
+ err = gcry_cipher_encrypt (hde, outbuf, splitpos, inbuf, splitpos);
+ }
if (!err)
{
- err = gcry_cipher_encrypt (hde, outbuf, buflen, inbuf, buflen);
+ err = gcry_cipher_final (hde);
+ if (!err)
+ {
+ err = gcry_cipher_encrypt (hde, outbuf + splitpos, buflen - splitpos,
+ inbuf + splitpos, buflen - splitpos);
+ }
}
if (err)
{
@@ -3267,10 +3283,18 @@ check_ocb_cipher_largebuf (int algo, int keylen, const char *tagexpect)
}
/* Now for the decryption. */
- err = gcry_cipher_final (hdd);
+ if (splitpos)
+ {
+ err = gcry_cipher_decrypt (hdd, outbuf, splitpos, NULL, 0);
+ }
if (!err)
{
- err = gcry_cipher_decrypt (hdd, outbuf, buflen, NULL, 0);
+ err = gcry_cipher_final (hdd);
+ if (!err)
+ {
+ err = gcry_cipher_decrypt (hdd, outbuf + splitpos, buflen - splitpos,
+ NULL, 0);
+ }
}
if (err)
{
@@ -3319,6 +3343,18 @@ out_free:
static void
+check_ocb_cipher_largebuf (int algo, int keylen, const char *tagexpect)
+{
+ unsigned int split;
+
+ for (split = 0; split < 32 * 16; split = split * 2 + 16)
+ {
+ check_ocb_cipher_largebuf_split(algo, keylen, tagexpect, split);
+ }
+}
+
+
+static void
check_ocb_cipher (void)
{
/* Check OCB cipher with separate destination and source buffers for