]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - crypto/tcrypt.c
x86: let intel 64-bit use intel.c
[linux-2.6-omap-h63xx.git] / crypto / tcrypt.c
index e99cb4bc546314a0061cd4431d49063a7c69a8cc..66368022e0bf32466fa4a4e0569e9e03303b6b12 100644 (file)
@@ -15,6 +15,7 @@
  *
  */
 
+#include <crypto/hash.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/module.h>
@@ -23,7 +24,6 @@
 #include <linux/scatterlist.h>
 #include <linux/string.h>
 #include <linux/crypto.h>
-#include <linux/highmem.h>
 #include <linux/moduleparam.h>
 #include <linux/jiffies.h>
 #include <linux/timex.h>
@@ -31,7 +31,7 @@
 #include "tcrypt.h"
 
 /*
- * Need to kmalloc() memory for testing kmap().
+ * Need to kmalloc() memory for testing.
  */
 #define TVMEMSIZE      16384
 #define XBUFSIZE       32768
@@ -376,13 +376,12 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
                                goto next_one;
                        }
 
-                       q = kmap(sg_page(&sg[0])) + sg[0].offset;
+                       q = input;
                        hexdump(q, template[i].rlen);
 
                        printk(KERN_INFO "enc/dec: %s\n",
                               memcmp(q, template[i].result,
                                      template[i].rlen) ? "fail" : "pass");
-                       kunmap(sg_page(&sg[0]));
 next_one:
                        if (!template[i].key)
                                kfree(key);
@@ -482,25 +481,34 @@ next_one:
 
                        for (k = 0, temp = 0; k < template[i].np; k++) {
                                printk(KERN_INFO "page %u\n", k);
-                               q = kmap(sg_page(&sg[k])) + sg[k].offset;
-                               hexdump(q, template[i].tap[k]);
+                               q = &xbuf[IDX[k]];
+
+                               n = template[i].tap[k];
+                               if (k == template[i].np - 1)
+                                       n += enc ? authsize : -authsize;
+                               hexdump(q, n);
                                printk(KERN_INFO "%s\n",
-                                      memcmp(q, template[i].result + temp,
-                                             template[i].tap[k] -
-                                             (k < template[i].np - 1 || enc ?
-                                              0 : authsize)) ?
+                                      memcmp(q, template[i].result + temp, n) ?
                                       "fail" : "pass");
 
-                               for (n = 0; q[template[i].tap[k] + n]; n++)
-                                       ;
+                               q += n;
+                               if (k == template[i].np - 1 && !enc) {
+                                       if (memcmp(q, template[i].input +
+                                                     temp + n, authsize))
+                                               n = authsize;
+                                       else
+                                               n = 0;
+                               } else {
+                                       for (n = 0; q[n]; n++)
+                                               ;
+                               }
                                if (n) {
                                        printk("Result buffer corruption %u "
                                               "bytes:\n", n);
-                                       hexdump(&q[template[i].tap[k]], n);
+                                       hexdump(q, n);
                                }
 
                                temp += template[i].tap[k];
-                               kunmap(sg_page(&sg[k]));
                        }
                }
        }
@@ -609,13 +617,12 @@ static void test_cipher(char *algo, int enc,
                                goto out;
                        }
 
-                       q = kmap(sg_page(&sg[0])) + sg[0].offset;
+                       q = data;
                        hexdump(q, template[i].rlen);
 
                        printk("%s\n",
                               memcmp(q, template[i].result,
                                      template[i].rlen) ? "fail" : "pass");
-                       kunmap(sg_page(&sg[0]));
                }
                kfree(data);
        }
@@ -689,7 +696,7 @@ static void test_cipher(char *algo, int enc,
                        temp = 0;
                        for (k = 0; k < template[i].np; k++) {
                                printk("page %u\n", k);
-                               q = kmap(sg_page(&sg[k])) + sg[k].offset;
+                               q = &xbuf[IDX[k]];
                                hexdump(q, template[i].tap[k]);
                                printk("%s\n",
                                        memcmp(q, template[i].result + temp,
@@ -704,7 +711,6 @@ static void test_cipher(char *algo, int enc,
                                        hexdump(&q[template[i].tap[k]], n);
                                }
                                temp += template[i].tap[k];
-                               kunmap(sg_page(&sg[k]));
                        }
                }
        }
@@ -1220,6 +1226,14 @@ static void do_test(void)
                test_cipher("ecb(des3_ede)", DECRYPT, des3_ede_dec_tv_template,
                            DES3_EDE_DEC_TEST_VECTORS);
 
+               test_cipher("cbc(des3_ede)", ENCRYPT,
+                           des3_ede_cbc_enc_tv_template,
+                           DES3_EDE_CBC_ENC_TEST_VECTORS);
+
+               test_cipher("cbc(des3_ede)", DECRYPT,
+                           des3_ede_cbc_dec_tv_template,
+                           DES3_EDE_CBC_DEC_TEST_VECTORS);
+
                test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
 
                test_hash("sha224", sha224_tv_template, SHA224_TEST_VECTORS);
@@ -1430,6 +1444,14 @@ static void do_test(void)
                            DES3_EDE_ENC_TEST_VECTORS);
                test_cipher("ecb(des3_ede)", DECRYPT, des3_ede_dec_tv_template,
                            DES3_EDE_DEC_TEST_VECTORS);
+
+               test_cipher("cbc(des3_ede)", ENCRYPT,
+                           des3_ede_cbc_enc_tv_template,
+                           DES3_EDE_CBC_ENC_TEST_VECTORS);
+
+               test_cipher("cbc(des3_ede)", DECRYPT,
+                           des3_ede_cbc_dec_tv_template,
+                           DES3_EDE_CBC_DEC_TEST_VECTORS);
                break;
 
        case 5: