Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[pandora-kernel.git] / crypto / tcrypt.c
index 943a514..1ab8c01 100644 (file)
@@ -172,7 +172,6 @@ static void test_hash(char *algo, struct hash_testvec *template,
 
        /* setup the dummy buffer first */
        memset(xbuf, 0, XBUFSIZE);
-       memset(axbuf, 0, XBUFSIZE);
 
        j = 0;
        for (i = 0; i < tcount; i++) {
@@ -266,8 +265,6 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
                return;
        }
 
-       authsize = crypto_aead_authsize(tfm);
-
        req = aead_request_alloc(tfm, GFP_KERNEL);
        if (!req) {
                printk(KERN_INFO "failed to allocate request for %s\n", algo);
@@ -298,6 +295,15 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
                                        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,
                                    aead_tv[i].ilen + (enc ? authsize : 0));
 
@@ -343,6 +349,7 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
 
        printk(KERN_INFO "\ntesting %s %s across pages (chunking)\n", algo, e);
        memset(xbuf, 0, XBUFSIZE);
+       memset(axbuf, 0, XBUFSIZE);
 
        for (i = 0, j = 0; i < tcount; i++) {
                if (aead_tv[i].np) {
@@ -374,6 +381,15 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
                                           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)
                                sg[k - 1].length += authsize;
 
@@ -1193,14 +1209,18 @@ static void do_test(void)
                            AES_XTS_ENC_TEST_VECTORS);
                test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
                            AES_XTS_DEC_TEST_VECTORS);
-               test_cipher("ctr(aes,4,8,4)", ENCRYPT, aes_ctr_enc_tv_template,
+               test_cipher("rfc3686(ctr(aes))", ENCRYPT, aes_ctr_enc_tv_template,
                            AES_CTR_ENC_TEST_VECTORS);
-               test_cipher("ctr(aes,4,8,4)", DECRYPT, aes_ctr_dec_tv_template,
+               test_cipher("rfc3686(ctr(aes))", DECRYPT, aes_ctr_dec_tv_template,
                            AES_CTR_DEC_TEST_VECTORS);
                test_aead("gcm(aes)", ENCRYPT, aes_gcm_enc_tv_template,
                          AES_GCM_ENC_TEST_VECTORS);
                test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template,
                          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
                test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template,
@@ -1394,9 +1414,9 @@ static void do_test(void)
                            AES_XTS_ENC_TEST_VECTORS);
                test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
                            AES_XTS_DEC_TEST_VECTORS);
-               test_cipher("ctr(aes,4,8,4)", ENCRYPT, aes_ctr_enc_tv_template,
+               test_cipher("rfc3686(ctr(aes))", ENCRYPT, aes_ctr_enc_tv_template,
                            AES_CTR_ENC_TEST_VECTORS);
-               test_cipher("ctr(aes,4,8,4)", DECRYPT, aes_ctr_dec_tv_template,
+               test_cipher("rfc3686(ctr(aes))", DECRYPT, aes_ctr_dec_tv_template,
                            AES_CTR_DEC_TEST_VECTORS);
                break;
 
@@ -1557,6 +1577,13 @@ static void do_test(void)
                          LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS);
                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:
                test_hash("hmac(md5)", hmac_md5_tv_template,
                          HMAC_MD5_TEST_VECTORS);
@@ -1581,11 +1608,17 @@ static void do_test(void)
                test_hash("hmac(sha512)", hmac_sha512_tv_template,
                          HMAC_SHA512_TEST_VECTORS);
                break;
+
        case 105:
                test_hash("hmac(sha224)", hmac_sha224_tv_template,
                          HMAC_SHA224_TEST_VECTORS);
                break;
 
+       case 106:
+               test_hash("xcbc(aes)", aes_xcbc128_tv_template,
+                         XCBC_AES_TEST_VECTORS);
+               break;
+
        case 200:
                test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
                                  aes_speed_template);
@@ -1668,6 +1701,11 @@ static void do_test(void)
                                camellia_speed_template);
                break;
 
+       case 206:
+               test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
+                                 salsa20_speed_template);
+               break;
+
        case 300:
                /* fall through */