diff options
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r-- | crypto/tcrypt.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 1142b4998c84..2b52df7bf833 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -266,8 +266,6 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template, | |||
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | 268 | ||
269 | authsize = crypto_aead_authsize(tfm); | ||
270 | |||
271 | req = aead_request_alloc(tfm, GFP_KERNEL); | 269 | req = aead_request_alloc(tfm, GFP_KERNEL); |
272 | if (!req) { | 270 | if (!req) { |
273 | printk(KERN_INFO "failed to allocate request for %s\n", algo); | 271 | printk(KERN_INFO "failed to allocate request for %s\n", algo); |
@@ -298,6 +296,15 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template, | |||
298 | goto out; | 296 | goto out; |
299 | } | 297 | } |
300 | 298 | ||
299 | authsize = abs(aead_tv[i].rlen - aead_tv[i].ilen); | ||
300 | ret = crypto_aead_setauthsize(tfm, authsize); | ||
301 | if (ret) { | ||
302 | printk(KERN_INFO | ||
303 | "failed to set authsize = %u\n", | ||
304 | authsize); | ||
305 | goto out; | ||
306 | } | ||
307 | |||
301 | sg_init_one(&sg[0], aead_tv[i].input, | 308 | sg_init_one(&sg[0], aead_tv[i].input, |
302 | aead_tv[i].ilen + (enc ? authsize : 0)); | 309 | aead_tv[i].ilen + (enc ? authsize : 0)); |
303 | 310 | ||
@@ -374,6 +381,15 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template, | |||
374 | aead_tv[i].tap[k]); | 381 | aead_tv[i].tap[k]); |
375 | } | 382 | } |
376 | 383 | ||
384 | authsize = abs(aead_tv[i].rlen - aead_tv[i].ilen); | ||
385 | ret = crypto_aead_setauthsize(tfm, authsize); | ||
386 | if (ret) { | ||
387 | printk(KERN_INFO | ||
388 | "failed to set authsize = %u\n", | ||
389 | authsize); | ||
390 | goto out; | ||
391 | } | ||
392 | |||
377 | if (enc) | 393 | if (enc) |
378 | sg[k - 1].length += authsize; | 394 | sg[k - 1].length += authsize; |
379 | 395 | ||
@@ -1201,6 +1217,10 @@ static void do_test(void) | |||
1201 | AES_GCM_ENC_TEST_VECTORS); | 1217 | AES_GCM_ENC_TEST_VECTORS); |
1202 | test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template, | 1218 | test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template, |
1203 | AES_GCM_DEC_TEST_VECTORS); | 1219 | AES_GCM_DEC_TEST_VECTORS); |
1220 | test_aead("ccm(aes)", ENCRYPT, aes_ccm_enc_tv_template, | ||
1221 | AES_CCM_ENC_TEST_VECTORS); | ||
1222 | test_aead("ccm(aes)", DECRYPT, aes_ccm_dec_tv_template, | ||
1223 | AES_CCM_DEC_TEST_VECTORS); | ||
1204 | 1224 | ||
1205 | //CAST5 | 1225 | //CAST5 |
1206 | test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template, | 1226 | test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template, |
@@ -1557,6 +1577,13 @@ static void do_test(void) | |||
1557 | LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS); | 1577 | LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS); |
1558 | break; | 1578 | break; |
1559 | 1579 | ||
1580 | case 37: | ||
1581 | test_aead("ccm(aes)", ENCRYPT, aes_ccm_enc_tv_template, | ||
1582 | AES_CCM_ENC_TEST_VECTORS); | ||
1583 | test_aead("ccm(aes)", DECRYPT, aes_ccm_dec_tv_template, | ||
1584 | AES_CCM_DEC_TEST_VECTORS); | ||
1585 | break; | ||
1586 | |||
1560 | case 100: | 1587 | case 100: |
1561 | test_hash("hmac(md5)", hmac_md5_tv_template, | 1588 | test_hash("hmac(md5)", hmac_md5_tv_template, |
1562 | HMAC_MD5_TEST_VECTORS); | 1589 | HMAC_MD5_TEST_VECTORS); |