Commit 93cc74e0 authored by Joy Latten's avatar Joy Latten Committed by Herbert Xu

[CRYPTO] tcrypt: Add CCM vectors

This patch adds 7 test vectors to tcrypt for CCM.
The test vectors are from rfc 3610.
There are about 10 more test vectors in RFC 3610
and 4 or 5 more in NIST. I can add these as time permits.

I also needed to set authsize. CCM has a prerequisite of
authsize. 
Signed-off-by: default avatarJoy Latten <latten@austin.ibm.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 4a49b499
...@@ -266,8 +266,6 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template, ...@@ -266,8 +266,6 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
return; return;
} }
authsize = crypto_aead_authsize(tfm);
req = aead_request_alloc(tfm, GFP_KERNEL); req = aead_request_alloc(tfm, GFP_KERNEL);
if (!req) { if (!req) {
printk(KERN_INFO "failed to allocate request for %s\n", algo); 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,6 +296,15 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
goto out; goto out;
} }
authsize = abs(aead_tv[i].rlen - aead_tv[i].ilen);
ret = crypto_aead_setauthsize(tfm, authsize);
if (ret) {
printk(KERN_INFO
"failed to set authsize = %u\n",
authsize);
goto out;
}
sg_init_one(&sg[0], aead_tv[i].input, sg_init_one(&sg[0], aead_tv[i].input,
aead_tv[i].ilen + (enc ? authsize : 0)); aead_tv[i].ilen + (enc ? authsize : 0));
...@@ -374,6 +381,15 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template, ...@@ -374,6 +381,15 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
aead_tv[i].tap[k]); aead_tv[i].tap[k]);
} }
authsize = abs(aead_tv[i].rlen - aead_tv[i].ilen);
ret = crypto_aead_setauthsize(tfm, authsize);
if (ret) {
printk(KERN_INFO
"failed to set authsize = %u\n",
authsize);
goto out;
}
if (enc) if (enc)
sg[k - 1].length += authsize; sg[k - 1].length += authsize;
...@@ -1201,6 +1217,10 @@ static void do_test(void) ...@@ -1201,6 +1217,10 @@ static void do_test(void)
AES_GCM_ENC_TEST_VECTORS); AES_GCM_ENC_TEST_VECTORS);
test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template, test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template,
AES_GCM_DEC_TEST_VECTORS); AES_GCM_DEC_TEST_VECTORS);
test_aead("ccm(aes)", ENCRYPT, aes_ccm_enc_tv_template,
AES_CCM_ENC_TEST_VECTORS);
test_aead("ccm(aes)", DECRYPT, aes_ccm_dec_tv_template,
AES_CCM_DEC_TEST_VECTORS);
//CAST5 //CAST5
test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template, test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template,
...@@ -1557,6 +1577,13 @@ static void do_test(void) ...@@ -1557,6 +1577,13 @@ static void do_test(void)
LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS); LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS);
break; break;
case 37:
test_aead("ccm(aes)", ENCRYPT, aes_ccm_enc_tv_template,
AES_CCM_ENC_TEST_VECTORS);
test_aead("ccm(aes)", DECRYPT, aes_ccm_dec_tv_template,
AES_CCM_DEC_TEST_VECTORS);
break;
case 100: case 100:
test_hash("hmac(md5)", hmac_md5_tv_template, test_hash("hmac(md5)", hmac_md5_tv_template,
HMAC_MD5_TEST_VECTORS); HMAC_MD5_TEST_VECTORS);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment