Skip to content

Commit

Permalink
crypto: tcrypt - fix AEAD decryption speed test
Browse files Browse the repository at this point in the history
The AEAD speed test pretended to support decryption, however that support
was broken as decryption requires a valid auth field which the test did
not provide.

Fix this by running the encryption path once with inout/output sgls
switched to calculate the auth field prior to performing decryption
speed tests.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Gilad Ben-Yossef authored and Herbert Xu committed Dec 28, 2017
1 parent 7c3f132 commit 4431bd4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion crypto/tcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,30 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
*b_size + (enc ? authsize : 0), assoc,
aad_size);

aead_request_set_ad(req, aad_size);

if (!enc) {

/*
* For decryption we need a proper auth so
* we do the encryption path once with buffers
* reversed (input <-> output) to calculate it
*/
aead_request_set_crypt(req, sgout, sg,
*b_size, iv);
ret = do_one_aead_op(req,
crypto_aead_encrypt(req));

if (ret) {
pr_err("calculating auth failed failed (%d)\n",
ret);
break;
}
}

aead_request_set_crypt(req, sg, sgout,
*b_size + (enc ? 0 : authsize),
iv);
aead_request_set_ad(req, aad_size);

if (secs)
ret = test_aead_jiffies(req, enc, *b_size,
Expand Down Expand Up @@ -1566,16 +1586,24 @@ static int do_test(const char *alg, u32 type, u32 mask, int m)
NULL, 0, 16, 16, aead_speed_template_20);
test_aead_speed("gcm(aes)", ENCRYPT, sec,
NULL, 0, 16, 8, speed_template_16_24_32);
test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec,
NULL, 0, 16, 16, aead_speed_template_20);
test_aead_speed("gcm(aes)", DECRYPT, sec,
NULL, 0, 16, 8, speed_template_16_24_32);
break;

case 212:
test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec,
NULL, 0, 16, 16, aead_speed_template_19);
test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec,
NULL, 0, 16, 16, aead_speed_template_19);
break;

case 213:
test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
NULL, 0, 16, 8, aead_speed_template_36);
test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec,
NULL, 0, 16, 8, aead_speed_template_36);
break;

case 214:
Expand Down

0 comments on commit 4431bd4

Please sign in to comment.