Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Quick & dirty crypto testing module. |
| 3 | * |
| 4 | * This will only exist until we have a better testing mechanism |
| 5 | * (e.g. a char device). |
| 6 | * |
| 7 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> |
| 8 | * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the Free |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 12 | * Software Foundation; either version 2 of the License, or (at your option) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * any later version. |
| 14 | * |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 15 | * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 16 | * 2004-08-09 Added cipher speed tests (Reyk Floeter <reyk@vantronix.net>) |
| 17 | * 2003-09-14 Rewritten by Kartikey Mahendra Bhatt |
| 18 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | */ |
| 20 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 21 | #include <linux/err.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/init.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/mm.h> |
| 25 | #include <linux/slab.h> |
David Hardeman | 378f058 | 2005-09-17 17:55:31 +1000 | [diff] [blame] | 26 | #include <linux/scatterlist.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/string.h> |
| 28 | #include <linux/crypto.h> |
| 29 | #include <linux/highmem.h> |
| 30 | #include <linux/moduleparam.h> |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 31 | #include <linux/jiffies.h> |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 32 | #include <linux/timex.h> |
| 33 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include "tcrypt.h" |
| 35 | |
| 36 | /* |
| 37 | * Need to kmalloc() memory for testing kmap(). |
| 38 | */ |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 39 | #define TVMEMSIZE 16384 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #define XBUFSIZE 32768 |
| 41 | |
| 42 | /* |
| 43 | * Indexes into the xbuf to simulate cross-page access. |
| 44 | */ |
| 45 | #define IDX1 37 |
| 46 | #define IDX2 32400 |
| 47 | #define IDX3 1 |
| 48 | #define IDX4 8193 |
| 49 | #define IDX5 22222 |
| 50 | #define IDX6 17101 |
| 51 | #define IDX7 27333 |
| 52 | #define IDX8 3000 |
| 53 | |
| 54 | /* |
| 55 | * Used by test_cipher() |
| 56 | */ |
| 57 | #define ENCRYPT 1 |
| 58 | #define DECRYPT 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 60 | struct tcrypt_result { |
| 61 | struct completion completion; |
| 62 | int err; |
| 63 | }; |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 }; |
| 66 | |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 67 | /* |
| 68 | * Used by test_cipher_speed() |
| 69 | */ |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 70 | static unsigned int sec; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 71 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | static int mode; |
| 73 | static char *xbuf; |
| 74 | static char *tvmem; |
| 75 | |
| 76 | static char *check[] = { |
| 77 | "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish", |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 78 | "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", |
| 79 | "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 80 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", |
Hye-Shik Chang | e2ee95b | 2007-08-21 20:01:03 +0800 | [diff] [blame] | 81 | "camellia", "seed", NULL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 84 | static void hexdump(unsigned char *buf, unsigned int len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | { |
| 86 | while (len--) |
| 87 | printk("%02x", *buf++); |
| 88 | |
| 89 | printk("\n"); |
| 90 | } |
| 91 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 92 | static void tcrypt_complete(struct crypto_async_request *req, int err) |
| 93 | { |
| 94 | struct tcrypt_result *res = req->data; |
| 95 | |
| 96 | if (err == -EINPROGRESS) |
| 97 | return; |
| 98 | |
| 99 | res->err = err; |
| 100 | complete(&res->completion); |
| 101 | } |
| 102 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 103 | static void test_hash(char *algo, struct hash_testvec *template, |
| 104 | unsigned int tcount) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | { |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 106 | unsigned int i, j, k, temp; |
| 107 | struct scatterlist sg[8]; |
| 108 | char result[64]; |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 109 | struct crypto_hash *tfm; |
| 110 | struct hash_desc desc; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 111 | struct hash_testvec *hash_tv; |
| 112 | unsigned int tsize; |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 113 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 115 | printk("\ntesting %s\n", algo); |
| 116 | |
| 117 | tsize = sizeof(struct hash_testvec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | tsize *= tcount; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | if (tsize > TVMEMSIZE) { |
| 121 | printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | memcpy(tvmem, template, tsize); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 126 | hash_tv = (void *)tvmem; |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 127 | |
| 128 | tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC); |
| 129 | if (IS_ERR(tfm)) { |
| 130 | printk("failed to load transform for %s: %ld\n", algo, |
| 131 | PTR_ERR(tfm)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | return; |
| 133 | } |
| 134 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 135 | desc.tfm = tfm; |
| 136 | desc.flags = 0; |
| 137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | for (i = 0; i < tcount; i++) { |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 139 | printk("test %u:\n", i + 1); |
| 140 | memset(result, 0, 64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 142 | sg_init_one(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 144 | if (hash_tv[i].ksize) { |
| 145 | ret = crypto_hash_setkey(tfm, hash_tv[i].key, |
| 146 | hash_tv[i].ksize); |
| 147 | if (ret) { |
| 148 | printk("setkey() failed ret=%d\n", ret); |
| 149 | goto out; |
| 150 | } |
| 151 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 153 | ret = crypto_hash_digest(&desc, sg, hash_tv[i].psize, result); |
| 154 | if (ret) { |
| 155 | printk("digest () failed ret=%d\n", ret); |
| 156 | goto out; |
| 157 | } |
| 158 | |
| 159 | hexdump(result, crypto_hash_digestsize(tfm)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | printk("%s\n", |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 161 | memcmp(result, hash_tv[i].digest, |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 162 | crypto_hash_digestsize(tfm)) ? |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 163 | "fail" : "pass"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 166 | printk("testing %s across pages\n", algo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
| 168 | /* setup the dummy buffer first */ |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 169 | memset(xbuf, 0, XBUFSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
| 171 | j = 0; |
| 172 | for (i = 0; i < tcount; i++) { |
| 173 | if (hash_tv[i].np) { |
| 174 | j++; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 175 | printk("test %u:\n", j); |
| 176 | memset(result, 0, 64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | |
| 178 | temp = 0; |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 179 | sg_init_table(sg, hash_tv[i].np); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | for (k = 0; k < hash_tv[i].np; k++) { |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 181 | memcpy(&xbuf[IDX[k]], |
| 182 | hash_tv[i].plaintext + temp, |
| 183 | hash_tv[i].tap[k]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | temp += hash_tv[i].tap[k]; |
David Hardeman | 378f058 | 2005-09-17 17:55:31 +1000 | [diff] [blame] | 185 | sg_set_buf(&sg[k], &xbuf[IDX[k]], |
| 186 | hash_tv[i].tap[k]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 189 | if (hash_tv[i].ksize) { |
| 190 | ret = crypto_hash_setkey(tfm, hash_tv[i].key, |
| 191 | hash_tv[i].ksize); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 192 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 193 | if (ret) { |
| 194 | printk("setkey() failed ret=%d\n", ret); |
| 195 | goto out; |
| 196 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 199 | ret = crypto_hash_digest(&desc, sg, hash_tv[i].psize, |
| 200 | result); |
| 201 | if (ret) { |
| 202 | printk("digest () failed ret=%d\n", ret); |
| 203 | goto out; |
| 204 | } |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 205 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 206 | hexdump(result, crypto_hash_digestsize(tfm)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | printk("%s\n", |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 208 | memcmp(result, hash_tv[i].digest, |
| 209 | crypto_hash_digestsize(tfm)) ? |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 210 | "fail" : "pass"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 214 | out: |
| 215 | crypto_free_hash(tfm); |
| 216 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 218 | static void test_cipher(char *algo, int enc, |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 219 | struct cipher_testvec *template, unsigned int tcount) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | { |
| 221 | unsigned int ret, i, j, k, temp; |
| 222 | unsigned int tsize; |
David Hardeman | 378f058 | 2005-09-17 17:55:31 +1000 | [diff] [blame] | 223 | char *q; |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 224 | struct crypto_ablkcipher *tfm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | char *key; |
| 226 | struct cipher_testvec *cipher_tv; |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 227 | struct ablkcipher_request *req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | struct scatterlist sg[8]; |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 229 | const char *e; |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 230 | struct tcrypt_result result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
| 232 | if (enc == ENCRYPT) |
Herbert Xu | 3cc3816 | 2005-06-22 13:26:36 -0700 | [diff] [blame] | 233 | e = "encryption"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | else |
Herbert Xu | 3cc3816 | 2005-06-22 13:26:36 -0700 | [diff] [blame] | 235 | e = "decryption"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 237 | printk("\ntesting %s %s\n", algo, e); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 239 | tsize = sizeof (struct cipher_testvec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | tsize *= tcount; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | if (tsize > TVMEMSIZE) { |
| 243 | printk("template (%u) too big for tvmem (%u)\n", tsize, |
| 244 | TVMEMSIZE); |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | memcpy(tvmem, template, tsize); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 249 | cipher_tv = (void *)tvmem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 251 | init_completion(&result.completion); |
| 252 | |
| 253 | tfm = crypto_alloc_ablkcipher(algo, 0, 0); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 254 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 255 | if (IS_ERR(tfm)) { |
| 256 | printk("failed to load transform for %s: %ld\n", algo, |
| 257 | PTR_ERR(tfm)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | return; |
| 259 | } |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 260 | |
| 261 | req = ablkcipher_request_alloc(tfm, GFP_KERNEL); |
| 262 | if (!req) { |
| 263 | printk("failed to allocate request for %s\n", algo); |
| 264 | goto out; |
| 265 | } |
| 266 | |
| 267 | ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 268 | tcrypt_complete, &result); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 269 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | j = 0; |
| 271 | for (i = 0; i < tcount; i++) { |
| 272 | if (!(cipher_tv[i].np)) { |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 273 | j++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | printk("test %u (%d bit key):\n", |
| 275 | j, cipher_tv[i].klen * 8); |
| 276 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 277 | crypto_ablkcipher_clear_flags(tfm, ~0); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 278 | if (cipher_tv[i].wk) |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 279 | crypto_ablkcipher_set_flags( |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 280 | tfm, CRYPTO_TFM_REQ_WEAK_KEY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | key = cipher_tv[i].key; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 282 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 283 | ret = crypto_ablkcipher_setkey(tfm, key, |
| 284 | cipher_tv[i].klen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | if (ret) { |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 286 | printk("setkey() failed flags=%x\n", |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 287 | crypto_ablkcipher_get_flags(tfm)); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 288 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | if (!cipher_tv[i].fail) |
| 290 | goto out; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 291 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 293 | sg_init_one(&sg[0], cipher_tv[i].input, |
| 294 | cipher_tv[i].ilen); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 295 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 296 | ablkcipher_request_set_crypt(req, sg, sg, |
| 297 | cipher_tv[i].ilen, |
| 298 | cipher_tv[i].iv); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 299 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 300 | ret = enc ? |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 301 | crypto_ablkcipher_encrypt(req) : |
| 302 | crypto_ablkcipher_decrypt(req); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 303 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 304 | switch (ret) { |
| 305 | case 0: |
| 306 | break; |
| 307 | case -EINPROGRESS: |
| 308 | case -EBUSY: |
| 309 | ret = wait_for_completion_interruptible( |
| 310 | &result.completion); |
| 311 | if (!ret && !((ret = result.err))) { |
| 312 | INIT_COMPLETION(result.completion); |
| 313 | break; |
| 314 | } |
| 315 | /* fall through */ |
| 316 | default: |
| 317 | printk("%s () failed err=%d\n", e, -ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | goto out; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 319 | } |
| 320 | |
Jens Axboe | 78c2f0b | 2007-10-22 19:40:16 +0200 | [diff] [blame] | 321 | q = kmap(sg_page(&sg[0])) + sg[0].offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | hexdump(q, cipher_tv[i].rlen); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 323 | |
| 324 | printk("%s\n", |
| 325 | memcmp(q, cipher_tv[i].result, |
| 326 | cipher_tv[i].rlen) ? "fail" : "pass"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | } |
| 328 | } |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 329 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 330 | printk("\ntesting %s %s across pages (chunking)\n", algo, e); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | memset(xbuf, 0, XBUFSIZE); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | j = 0; |
| 334 | for (i = 0; i < tcount; i++) { |
| 335 | if (cipher_tv[i].np) { |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 336 | j++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | printk("test %u (%d bit key):\n", |
| 338 | j, cipher_tv[i].klen * 8); |
| 339 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 340 | crypto_ablkcipher_clear_flags(tfm, ~0); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 341 | if (cipher_tv[i].wk) |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 342 | crypto_ablkcipher_set_flags( |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 343 | tfm, CRYPTO_TFM_REQ_WEAK_KEY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | key = cipher_tv[i].key; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 345 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 346 | ret = crypto_ablkcipher_setkey(tfm, key, |
| 347 | cipher_tv[i].klen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | if (ret) { |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 349 | printk("setkey() failed flags=%x\n", |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 350 | crypto_ablkcipher_get_flags(tfm)); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 351 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | if (!cipher_tv[i].fail) |
| 353 | goto out; |
| 354 | } |
| 355 | |
| 356 | temp = 0; |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 357 | sg_init_table(sg, cipher_tv[i].np); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | for (k = 0; k < cipher_tv[i].np; k++) { |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 359 | memcpy(&xbuf[IDX[k]], |
| 360 | cipher_tv[i].input + temp, |
| 361 | cipher_tv[i].tap[k]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | temp += cipher_tv[i].tap[k]; |
David Hardeman | 378f058 | 2005-09-17 17:55:31 +1000 | [diff] [blame] | 363 | sg_set_buf(&sg[k], &xbuf[IDX[k]], |
| 364 | cipher_tv[i].tap[k]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 366 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 367 | ablkcipher_request_set_crypt(req, sg, sg, |
| 368 | cipher_tv[i].ilen, |
| 369 | cipher_tv[i].iv); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 370 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 371 | ret = enc ? |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 372 | crypto_ablkcipher_encrypt(req) : |
| 373 | crypto_ablkcipher_decrypt(req); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 374 | |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 375 | switch (ret) { |
| 376 | case 0: |
| 377 | break; |
| 378 | case -EINPROGRESS: |
| 379 | case -EBUSY: |
| 380 | ret = wait_for_completion_interruptible( |
| 381 | &result.completion); |
| 382 | if (!ret && !((ret = result.err))) { |
| 383 | INIT_COMPLETION(result.completion); |
| 384 | break; |
| 385 | } |
| 386 | /* fall through */ |
| 387 | default: |
| 388 | printk("%s () failed err=%d\n", e, -ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | goto out; |
| 390 | } |
| 391 | |
| 392 | temp = 0; |
| 393 | for (k = 0; k < cipher_tv[i].np; k++) { |
| 394 | printk("page %u\n", k); |
Jens Axboe | 78c2f0b | 2007-10-22 19:40:16 +0200 | [diff] [blame] | 395 | q = kmap(sg_page(&sg[k])) + sg[k].offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | hexdump(q, cipher_tv[i].tap[k]); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 397 | printk("%s\n", |
| 398 | memcmp(q, cipher_tv[i].result + temp, |
| 399 | cipher_tv[i].tap[k]) ? "fail" : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | "pass"); |
| 401 | temp += cipher_tv[i].tap[k]; |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | out: |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 407 | crypto_free_ablkcipher(tfm); |
| 408 | ablkcipher_request_free(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | } |
| 410 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 411 | static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, char *p, |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 412 | int blen, int sec) |
| 413 | { |
Herbert Xu | 6df5b9f | 2005-09-19 22:30:11 +1000 | [diff] [blame] | 414 | struct scatterlist sg[1]; |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 415 | unsigned long start, end; |
| 416 | int bcount; |
| 417 | int ret; |
| 418 | |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 419 | sg_init_one(sg, p, blen); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 420 | |
| 421 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
| 422 | time_before(jiffies, end); bcount++) { |
| 423 | if (enc) |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 424 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 425 | else |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 426 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 427 | |
| 428 | if (ret) |
| 429 | return ret; |
| 430 | } |
| 431 | |
| 432 | printk("%d operations in %d seconds (%ld bytes)\n", |
| 433 | bcount, sec, (long)bcount * blen); |
| 434 | return 0; |
| 435 | } |
| 436 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 437 | static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, char *p, |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 438 | int blen) |
| 439 | { |
Herbert Xu | 6df5b9f | 2005-09-19 22:30:11 +1000 | [diff] [blame] | 440 | struct scatterlist sg[1]; |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 441 | unsigned long cycles = 0; |
| 442 | int ret = 0; |
| 443 | int i; |
| 444 | |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 445 | sg_init_one(sg, p, blen); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 446 | |
| 447 | local_bh_disable(); |
| 448 | local_irq_disable(); |
| 449 | |
| 450 | /* Warm-up run. */ |
| 451 | for (i = 0; i < 4; i++) { |
| 452 | if (enc) |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 453 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 454 | else |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 455 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 456 | |
| 457 | if (ret) |
| 458 | goto out; |
| 459 | } |
| 460 | |
| 461 | /* The real thing. */ |
| 462 | for (i = 0; i < 8; i++) { |
| 463 | cycles_t start, end; |
| 464 | |
| 465 | start = get_cycles(); |
| 466 | if (enc) |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 467 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 468 | else |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 469 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 470 | end = get_cycles(); |
| 471 | |
| 472 | if (ret) |
| 473 | goto out; |
| 474 | |
| 475 | cycles += end - start; |
| 476 | } |
| 477 | |
| 478 | out: |
| 479 | local_irq_enable(); |
| 480 | local_bh_enable(); |
| 481 | |
| 482 | if (ret == 0) |
| 483 | printk("1 operation in %lu cycles (%d bytes)\n", |
| 484 | (cycles + 4) / 8, blen); |
| 485 | |
| 486 | return ret; |
| 487 | } |
| 488 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 489 | static void test_cipher_speed(char *algo, int enc, unsigned int sec, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 490 | struct cipher_testvec *template, |
| 491 | unsigned int tcount, struct cipher_speed *speed) |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 492 | { |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 493 | unsigned int ret, i, j, iv_len; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 494 | unsigned char *key, *p, iv[128]; |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 495 | struct crypto_blkcipher *tfm; |
| 496 | struct blkcipher_desc desc; |
| 497 | const char *e; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 498 | |
| 499 | if (enc == ENCRYPT) |
| 500 | e = "encryption"; |
| 501 | else |
| 502 | e = "decryption"; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 503 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 504 | printk("\ntesting speed of %s %s\n", algo, e); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 505 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 506 | tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 507 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 508 | if (IS_ERR(tfm)) { |
| 509 | printk("failed to load transform for %s: %ld\n", algo, |
| 510 | PTR_ERR(tfm)); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 511 | return; |
| 512 | } |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 513 | desc.tfm = tfm; |
| 514 | desc.flags = 0; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 515 | |
| 516 | for (i = 0; speed[i].klen != 0; i++) { |
| 517 | if ((speed[i].blen + speed[i].klen) > TVMEMSIZE) { |
| 518 | printk("template (%u) too big for tvmem (%u)\n", |
| 519 | speed[i].blen + speed[i].klen, TVMEMSIZE); |
| 520 | goto out; |
| 521 | } |
| 522 | |
| 523 | printk("test %u (%d bit key, %d byte blocks): ", i, |
| 524 | speed[i].klen * 8, speed[i].blen); |
| 525 | |
| 526 | memset(tvmem, 0xff, speed[i].klen + speed[i].blen); |
| 527 | |
| 528 | /* set key, plain text and IV */ |
| 529 | key = (unsigned char *)tvmem; |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 530 | for (j = 0; j < tcount; j++) { |
| 531 | if (template[j].klen == speed[i].klen) { |
| 532 | key = template[j].key; |
| 533 | break; |
| 534 | } |
| 535 | } |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 536 | p = (unsigned char *)tvmem + speed[i].klen; |
| 537 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 538 | ret = crypto_blkcipher_setkey(tfm, key, speed[i].klen); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 539 | if (ret) { |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 540 | printk("setkey() failed flags=%x\n", |
| 541 | crypto_blkcipher_get_flags(tfm)); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 542 | goto out; |
| 543 | } |
| 544 | |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 545 | iv_len = crypto_blkcipher_ivsize(tfm); |
| 546 | if (iv_len) { |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 547 | memset(&iv, 0xff, iv_len); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 548 | crypto_blkcipher_set_iv(tfm, iv, iv_len); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 549 | } |
| 550 | |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 551 | if (sec) |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 552 | ret = test_cipher_jiffies(&desc, enc, p, speed[i].blen, |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 553 | sec); |
| 554 | else |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 555 | ret = test_cipher_cycles(&desc, enc, p, speed[i].blen); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 556 | |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 557 | if (ret) { |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 558 | printk("%s() failed flags=%x\n", e, desc.flags); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 559 | break; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 560 | } |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | out: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 564 | crypto_free_blkcipher(tfm); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 567 | static int test_hash_jiffies_digest(struct hash_desc *desc, char *p, int blen, |
| 568 | char *out, int sec) |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 569 | { |
| 570 | struct scatterlist sg[1]; |
| 571 | unsigned long start, end; |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 572 | int bcount; |
| 573 | int ret; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 574 | |
| 575 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
| 576 | time_before(jiffies, end); bcount++) { |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 577 | sg_init_one(sg, p, blen); |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 578 | ret = crypto_hash_digest(desc, sg, blen, out); |
| 579 | if (ret) |
| 580 | return ret; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | printk("%6u opers/sec, %9lu bytes/sec\n", |
| 584 | bcount / sec, ((long)bcount * blen) / sec); |
| 585 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 586 | return 0; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 587 | } |
| 588 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 589 | static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen, |
| 590 | int plen, char *out, int sec) |
| 591 | { |
| 592 | struct scatterlist sg[1]; |
| 593 | unsigned long start, end; |
| 594 | int bcount, pcount; |
| 595 | int ret; |
| 596 | |
| 597 | if (plen == blen) |
| 598 | return test_hash_jiffies_digest(desc, p, blen, out, sec); |
| 599 | |
| 600 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
| 601 | time_before(jiffies, end); bcount++) { |
| 602 | ret = crypto_hash_init(desc); |
| 603 | if (ret) |
| 604 | return ret; |
| 605 | for (pcount = 0; pcount < blen; pcount += plen) { |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 606 | sg_init_one(sg, p + pcount, plen); |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 607 | ret = crypto_hash_update(desc, sg, plen); |
| 608 | if (ret) |
| 609 | return ret; |
| 610 | } |
| 611 | /* we assume there is enough space in 'out' for the result */ |
| 612 | ret = crypto_hash_final(desc, out); |
| 613 | if (ret) |
| 614 | return ret; |
| 615 | } |
| 616 | |
| 617 | printk("%6u opers/sec, %9lu bytes/sec\n", |
| 618 | bcount / sec, ((long)bcount * blen) / sec); |
| 619 | |
| 620 | return 0; |
| 621 | } |
| 622 | |
| 623 | static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen, |
| 624 | char *out) |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 625 | { |
| 626 | struct scatterlist sg[1]; |
| 627 | unsigned long cycles = 0; |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 628 | int i; |
| 629 | int ret; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 630 | |
| 631 | local_bh_disable(); |
| 632 | local_irq_disable(); |
| 633 | |
| 634 | /* Warm-up run. */ |
| 635 | for (i = 0; i < 4; i++) { |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 636 | sg_init_one(sg, p, blen); |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 637 | ret = crypto_hash_digest(desc, sg, blen, out); |
| 638 | if (ret) |
| 639 | goto out; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | /* The real thing. */ |
| 643 | for (i = 0; i < 8; i++) { |
| 644 | cycles_t start, end; |
| 645 | |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 646 | start = get_cycles(); |
| 647 | |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 648 | sg_init_one(sg, p, blen); |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 649 | ret = crypto_hash_digest(desc, sg, blen, out); |
| 650 | if (ret) |
| 651 | goto out; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 652 | |
| 653 | end = get_cycles(); |
| 654 | |
| 655 | cycles += end - start; |
| 656 | } |
| 657 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 658 | out: |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 659 | local_irq_enable(); |
| 660 | local_bh_enable(); |
| 661 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 662 | if (ret) |
| 663 | return ret; |
| 664 | |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 665 | printk("%6lu cycles/operation, %4lu cycles/byte\n", |
| 666 | cycles / 8, cycles / (8 * blen)); |
| 667 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 668 | return 0; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 669 | } |
| 670 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 671 | static int test_hash_cycles(struct hash_desc *desc, char *p, int blen, |
| 672 | int plen, char *out) |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 673 | { |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 674 | struct scatterlist sg[1]; |
| 675 | unsigned long cycles = 0; |
| 676 | int i, pcount; |
| 677 | int ret; |
| 678 | |
| 679 | if (plen == blen) |
| 680 | return test_hash_cycles_digest(desc, p, blen, out); |
| 681 | |
| 682 | local_bh_disable(); |
| 683 | local_irq_disable(); |
| 684 | |
| 685 | /* Warm-up run. */ |
| 686 | for (i = 0; i < 4; i++) { |
| 687 | ret = crypto_hash_init(desc); |
| 688 | if (ret) |
| 689 | goto out; |
| 690 | for (pcount = 0; pcount < blen; pcount += plen) { |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 691 | sg_init_one(sg, p + pcount, plen); |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 692 | ret = crypto_hash_update(desc, sg, plen); |
| 693 | if (ret) |
| 694 | goto out; |
| 695 | } |
Herbert Xu | 29059d1 | 2007-05-18 16:25:19 +1000 | [diff] [blame] | 696 | ret = crypto_hash_final(desc, out); |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 697 | if (ret) |
| 698 | goto out; |
| 699 | } |
| 700 | |
| 701 | /* The real thing. */ |
| 702 | for (i = 0; i < 8; i++) { |
| 703 | cycles_t start, end; |
| 704 | |
| 705 | start = get_cycles(); |
| 706 | |
| 707 | ret = crypto_hash_init(desc); |
| 708 | if (ret) |
| 709 | goto out; |
| 710 | for (pcount = 0; pcount < blen; pcount += plen) { |
David S. Miller | b733588 | 2007-10-26 00:38:10 -0700 | [diff] [blame^] | 711 | sg_init_one(sg, p + pcount, plen); |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 712 | ret = crypto_hash_update(desc, sg, plen); |
| 713 | if (ret) |
| 714 | goto out; |
| 715 | } |
| 716 | ret = crypto_hash_final(desc, out); |
| 717 | if (ret) |
| 718 | goto out; |
| 719 | |
| 720 | end = get_cycles(); |
| 721 | |
| 722 | cycles += end - start; |
| 723 | } |
| 724 | |
| 725 | out: |
| 726 | local_irq_enable(); |
| 727 | local_bh_enable(); |
| 728 | |
| 729 | if (ret) |
| 730 | return ret; |
| 731 | |
| 732 | printk("%6lu cycles/operation, %4lu cycles/byte\n", |
| 733 | cycles / 8, cycles / (8 * blen)); |
| 734 | |
| 735 | return 0; |
| 736 | } |
| 737 | |
| 738 | static void test_hash_speed(char *algo, unsigned int sec, |
| 739 | struct hash_speed *speed) |
| 740 | { |
| 741 | struct crypto_hash *tfm; |
| 742 | struct hash_desc desc; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 743 | char output[1024]; |
| 744 | int i; |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 745 | int ret; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 746 | |
| 747 | printk("\ntesting speed of %s\n", algo); |
| 748 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 749 | tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 750 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 751 | if (IS_ERR(tfm)) { |
| 752 | printk("failed to load transform for %s: %ld\n", algo, |
| 753 | PTR_ERR(tfm)); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 754 | return; |
| 755 | } |
| 756 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 757 | desc.tfm = tfm; |
| 758 | desc.flags = 0; |
| 759 | |
| 760 | if (crypto_hash_digestsize(tfm) > sizeof(output)) { |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 761 | printk("digestsize(%u) > outputbuffer(%zu)\n", |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 762 | crypto_hash_digestsize(tfm), sizeof(output)); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 763 | goto out; |
| 764 | } |
| 765 | |
| 766 | for (i = 0; speed[i].blen != 0; i++) { |
| 767 | if (speed[i].blen > TVMEMSIZE) { |
| 768 | printk("template (%u) too big for tvmem (%u)\n", |
| 769 | speed[i].blen, TVMEMSIZE); |
| 770 | goto out; |
| 771 | } |
| 772 | |
| 773 | printk("test%3u (%5u byte blocks,%5u bytes per update,%4u updates): ", |
| 774 | i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); |
| 775 | |
| 776 | memset(tvmem, 0xff, speed[i].blen); |
| 777 | |
| 778 | if (sec) |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 779 | ret = test_hash_jiffies(&desc, tvmem, speed[i].blen, |
| 780 | speed[i].plen, output, sec); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 781 | else |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 782 | ret = test_hash_cycles(&desc, tvmem, speed[i].blen, |
| 783 | speed[i].plen, output); |
| 784 | |
| 785 | if (ret) { |
| 786 | printk("hashing failed ret=%d\n", ret); |
| 787 | break; |
| 788 | } |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | out: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 792 | crypto_free_hash(tfm); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 793 | } |
| 794 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 795 | static void test_deflate(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | { |
| 797 | unsigned int i; |
| 798 | char result[COMP_BUF_SIZE]; |
Herbert Xu | e4d5b79 | 2006-08-26 18:12:40 +1000 | [diff] [blame] | 799 | struct crypto_comp *tfm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | struct comp_testvec *tv; |
| 801 | unsigned int tsize; |
| 802 | |
| 803 | printk("\ntesting deflate compression\n"); |
| 804 | |
| 805 | tsize = sizeof (deflate_comp_tv_template); |
| 806 | if (tsize > TVMEMSIZE) { |
| 807 | printk("template (%u) too big for tvmem (%u)\n", tsize, |
| 808 | TVMEMSIZE); |
| 809 | return; |
| 810 | } |
| 811 | |
| 812 | memcpy(tvmem, deflate_comp_tv_template, tsize); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 813 | tv = (void *)tvmem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | |
Herbert Xu | ba8da2a | 2006-12-17 08:57:38 +1100 | [diff] [blame] | 815 | tfm = crypto_alloc_comp("deflate", 0, CRYPTO_ALG_ASYNC); |
Sebastian Siewior | 7bc301e | 2007-03-21 08:58:43 +1100 | [diff] [blame] | 816 | if (IS_ERR(tfm)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | printk("failed to load transform for deflate\n"); |
| 818 | return; |
| 819 | } |
| 820 | |
| 821 | for (i = 0; i < DEFLATE_COMP_TEST_VECTORS; i++) { |
| 822 | int ilen, ret, dlen = COMP_BUF_SIZE; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 823 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | printk("test %u:\n", i + 1); |
| 825 | memset(result, 0, sizeof (result)); |
| 826 | |
| 827 | ilen = tv[i].inlen; |
| 828 | ret = crypto_comp_compress(tfm, tv[i].input, |
| 829 | ilen, result, &dlen); |
| 830 | if (ret) { |
| 831 | printk("fail: ret=%d\n", ret); |
| 832 | continue; |
| 833 | } |
| 834 | hexdump(result, dlen); |
| 835 | printk("%s (ratio %d:%d)\n", |
| 836 | memcmp(result, tv[i].output, dlen) ? "fail" : "pass", |
| 837 | ilen, dlen); |
| 838 | } |
| 839 | |
| 840 | printk("\ntesting deflate decompression\n"); |
| 841 | |
| 842 | tsize = sizeof (deflate_decomp_tv_template); |
| 843 | if (tsize > TVMEMSIZE) { |
| 844 | printk("template (%u) too big for tvmem (%u)\n", tsize, |
| 845 | TVMEMSIZE); |
| 846 | goto out; |
| 847 | } |
| 848 | |
| 849 | memcpy(tvmem, deflate_decomp_tv_template, tsize); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 850 | tv = (void *)tvmem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | |
| 852 | for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) { |
| 853 | int ilen, ret, dlen = COMP_BUF_SIZE; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 854 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | printk("test %u:\n", i + 1); |
| 856 | memset(result, 0, sizeof (result)); |
| 857 | |
| 858 | ilen = tv[i].inlen; |
| 859 | ret = crypto_comp_decompress(tfm, tv[i].input, |
| 860 | ilen, result, &dlen); |
| 861 | if (ret) { |
| 862 | printk("fail: ret=%d\n", ret); |
| 863 | continue; |
| 864 | } |
| 865 | hexdump(result, dlen); |
| 866 | printk("%s (ratio %d:%d)\n", |
| 867 | memcmp(result, tv[i].output, dlen) ? "fail" : "pass", |
| 868 | ilen, dlen); |
| 869 | } |
| 870 | out: |
Herbert Xu | e4d5b79 | 2006-08-26 18:12:40 +1000 | [diff] [blame] | 871 | crypto_free_comp(tfm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | } |
| 873 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 874 | static void test_available(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | { |
| 876 | char **name = check; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 877 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | while (*name) { |
| 879 | printk("alg %s ", *name); |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 880 | printk(crypto_has_alg(*name, 0, 0) ? |
Herbert Xu | e4d5b79 | 2006-08-26 18:12:40 +1000 | [diff] [blame] | 881 | "found\n" : "not found\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | name++; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 883 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | } |
| 885 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 886 | static void do_test(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | { |
| 888 | switch (mode) { |
| 889 | |
| 890 | case 0: |
| 891 | test_hash("md5", md5_tv_template, MD5_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 892 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 894 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | //DES |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 896 | test_cipher("ecb(des)", ENCRYPT, des_enc_tv_template, |
| 897 | DES_ENC_TEST_VECTORS); |
| 898 | test_cipher("ecb(des)", DECRYPT, des_dec_tv_template, |
| 899 | DES_DEC_TEST_VECTORS); |
| 900 | test_cipher("cbc(des)", ENCRYPT, des_cbc_enc_tv_template, |
| 901 | DES_CBC_ENC_TEST_VECTORS); |
| 902 | test_cipher("cbc(des)", DECRYPT, des_cbc_dec_tv_template, |
| 903 | DES_CBC_DEC_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 904 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | //DES3_EDE |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 906 | test_cipher("ecb(des3_ede)", ENCRYPT, des3_ede_enc_tv_template, |
| 907 | DES3_EDE_ENC_TEST_VECTORS); |
| 908 | test_cipher("ecb(des3_ede)", DECRYPT, des3_ede_dec_tv_template, |
| 909 | DES3_EDE_DEC_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 910 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 912 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 914 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | //BLOWFISH |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 916 | test_cipher("ecb(blowfish)", ENCRYPT, bf_enc_tv_template, |
| 917 | BF_ENC_TEST_VECTORS); |
| 918 | test_cipher("ecb(blowfish)", DECRYPT, bf_dec_tv_template, |
| 919 | BF_DEC_TEST_VECTORS); |
| 920 | test_cipher("cbc(blowfish)", ENCRYPT, bf_cbc_enc_tv_template, |
| 921 | BF_CBC_ENC_TEST_VECTORS); |
| 922 | test_cipher("cbc(blowfish)", DECRYPT, bf_cbc_dec_tv_template, |
| 923 | BF_CBC_DEC_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 924 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | //TWOFISH |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 926 | test_cipher("ecb(twofish)", ENCRYPT, tf_enc_tv_template, |
| 927 | TF_ENC_TEST_VECTORS); |
| 928 | test_cipher("ecb(twofish)", DECRYPT, tf_dec_tv_template, |
| 929 | TF_DEC_TEST_VECTORS); |
| 930 | test_cipher("cbc(twofish)", ENCRYPT, tf_cbc_enc_tv_template, |
| 931 | TF_CBC_ENC_TEST_VECTORS); |
| 932 | test_cipher("cbc(twofish)", DECRYPT, tf_cbc_dec_tv_template, |
| 933 | TF_CBC_DEC_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 934 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | //SERPENT |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 936 | test_cipher("ecb(serpent)", ENCRYPT, serpent_enc_tv_template, |
| 937 | SERPENT_ENC_TEST_VECTORS); |
| 938 | test_cipher("ecb(serpent)", DECRYPT, serpent_dec_tv_template, |
| 939 | SERPENT_DEC_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 940 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | //TNEPRES |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 942 | test_cipher("ecb(tnepres)", ENCRYPT, tnepres_enc_tv_template, |
| 943 | TNEPRES_ENC_TEST_VECTORS); |
| 944 | test_cipher("ecb(tnepres)", DECRYPT, tnepres_dec_tv_template, |
| 945 | TNEPRES_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | |
| 947 | //AES |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 948 | test_cipher("ecb(aes)", ENCRYPT, aes_enc_tv_template, |
| 949 | AES_ENC_TEST_VECTORS); |
| 950 | test_cipher("ecb(aes)", DECRYPT, aes_dec_tv_template, |
| 951 | AES_DEC_TEST_VECTORS); |
| 952 | test_cipher("cbc(aes)", ENCRYPT, aes_cbc_enc_tv_template, |
| 953 | AES_CBC_ENC_TEST_VECTORS); |
| 954 | test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template, |
| 955 | AES_CBC_DEC_TEST_VECTORS); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 956 | test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template, |
| 957 | AES_LRW_ENC_TEST_VECTORS); |
| 958 | test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template, |
| 959 | AES_LRW_DEC_TEST_VECTORS); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 960 | test_cipher("xts(aes)", ENCRYPT, aes_xts_enc_tv_template, |
| 961 | AES_XTS_ENC_TEST_VECTORS); |
| 962 | test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template, |
| 963 | AES_XTS_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | |
| 965 | //CAST5 |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 966 | test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template, |
| 967 | CAST5_ENC_TEST_VECTORS); |
| 968 | test_cipher("ecb(cast5)", DECRYPT, cast5_dec_tv_template, |
| 969 | CAST5_DEC_TEST_VECTORS); |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 970 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | //CAST6 |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 972 | test_cipher("ecb(cast6)", ENCRYPT, cast6_enc_tv_template, |
| 973 | CAST6_ENC_TEST_VECTORS); |
| 974 | test_cipher("ecb(cast6)", DECRYPT, cast6_dec_tv_template, |
| 975 | CAST6_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | |
| 977 | //ARC4 |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 978 | test_cipher("ecb(arc4)", ENCRYPT, arc4_enc_tv_template, |
| 979 | ARC4_ENC_TEST_VECTORS); |
| 980 | test_cipher("ecb(arc4)", DECRYPT, arc4_dec_tv_template, |
| 981 | ARC4_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | |
| 983 | //TEA |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 984 | test_cipher("ecb(tea)", ENCRYPT, tea_enc_tv_template, |
| 985 | TEA_ENC_TEST_VECTORS); |
| 986 | test_cipher("ecb(tea)", DECRYPT, tea_dec_tv_template, |
| 987 | TEA_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | |
| 989 | |
| 990 | //XTEA |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 991 | test_cipher("ecb(xtea)", ENCRYPT, xtea_enc_tv_template, |
| 992 | XTEA_ENC_TEST_VECTORS); |
| 993 | test_cipher("ecb(xtea)", DECRYPT, xtea_dec_tv_template, |
| 994 | XTEA_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | |
| 996 | //KHAZAD |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 997 | test_cipher("ecb(khazad)", ENCRYPT, khazad_enc_tv_template, |
| 998 | KHAZAD_ENC_TEST_VECTORS); |
| 999 | test_cipher("ecb(khazad)", DECRYPT, khazad_dec_tv_template, |
| 1000 | KHAZAD_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | |
| 1002 | //ANUBIS |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1003 | test_cipher("ecb(anubis)", ENCRYPT, anubis_enc_tv_template, |
| 1004 | ANUBIS_ENC_TEST_VECTORS); |
| 1005 | test_cipher("ecb(anubis)", DECRYPT, anubis_dec_tv_template, |
| 1006 | ANUBIS_DEC_TEST_VECTORS); |
| 1007 | test_cipher("cbc(anubis)", ENCRYPT, anubis_cbc_enc_tv_template, |
| 1008 | ANUBIS_CBC_ENC_TEST_VECTORS); |
| 1009 | test_cipher("cbc(anubis)", DECRYPT, anubis_cbc_dec_tv_template, |
| 1010 | ANUBIS_CBC_ENC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1012 | //XETA |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1013 | test_cipher("ecb(xeta)", ENCRYPT, xeta_enc_tv_template, |
| 1014 | XETA_ENC_TEST_VECTORS); |
| 1015 | test_cipher("ecb(xeta)", DECRYPT, xeta_dec_tv_template, |
| 1016 | XETA_DEC_TEST_VECTORS); |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1017 | |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 1018 | //FCrypt |
| 1019 | test_cipher("pcbc(fcrypt)", ENCRYPT, fcrypt_pcbc_enc_tv_template, |
| 1020 | FCRYPT_ENC_TEST_VECTORS); |
| 1021 | test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template, |
| 1022 | FCRYPT_DEC_TEST_VECTORS); |
| 1023 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1024 | //CAMELLIA |
| 1025 | test_cipher("ecb(camellia)", ENCRYPT, |
| 1026 | camellia_enc_tv_template, |
| 1027 | CAMELLIA_ENC_TEST_VECTORS); |
| 1028 | test_cipher("ecb(camellia)", DECRYPT, |
| 1029 | camellia_dec_tv_template, |
| 1030 | CAMELLIA_DEC_TEST_VECTORS); |
| 1031 | test_cipher("cbc(camellia)", ENCRYPT, |
| 1032 | camellia_cbc_enc_tv_template, |
| 1033 | CAMELLIA_CBC_ENC_TEST_VECTORS); |
| 1034 | test_cipher("cbc(camellia)", DECRYPT, |
| 1035 | camellia_cbc_dec_tv_template, |
| 1036 | CAMELLIA_CBC_DEC_TEST_VECTORS); |
| 1037 | |
Hye-Shik Chang | e2ee95b | 2007-08-21 20:01:03 +0800 | [diff] [blame] | 1038 | //SEED |
| 1039 | test_cipher("ecb(seed)", ENCRYPT, seed_enc_tv_template, |
| 1040 | SEED_ENC_TEST_VECTORS); |
| 1041 | test_cipher("ecb(seed)", DECRYPT, seed_dec_tv_template, |
| 1042 | SEED_DEC_TEST_VECTORS); |
| 1043 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); |
| 1045 | test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); |
| 1046 | test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS); |
| 1047 | test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS); |
| 1048 | test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS); |
| 1049 | test_hash("tgr192", tgr192_tv_template, TGR192_TEST_VECTORS); |
| 1050 | test_hash("tgr160", tgr160_tv_template, TGR160_TEST_VECTORS); |
| 1051 | test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS); |
| 1052 | test_deflate(); |
Herbert Xu | c907ee7 | 2006-08-21 22:04:03 +1000 | [diff] [blame] | 1053 | test_hash("crc32c", crc32c_tv_template, CRC32C_TEST_VECTORS); |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1054 | test_hash("hmac(md5)", hmac_md5_tv_template, |
| 1055 | HMAC_MD5_TEST_VECTORS); |
| 1056 | test_hash("hmac(sha1)", hmac_sha1_tv_template, |
| 1057 | HMAC_SHA1_TEST_VECTORS); |
| 1058 | test_hash("hmac(sha256)", hmac_sha256_tv_template, |
| 1059 | HMAC_SHA256_TEST_VECTORS); |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1060 | test_hash("hmac(sha384)", hmac_sha384_tv_template, |
| 1061 | HMAC_SHA384_TEST_VECTORS); |
| 1062 | test_hash("hmac(sha512)", hmac_sha512_tv_template, |
| 1063 | HMAC_SHA512_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | |
Kazunori MIYAZAWA | 5b2becf | 2006-10-28 13:18:53 +1000 | [diff] [blame] | 1065 | test_hash("xcbc(aes)", aes_xcbc128_tv_template, |
| 1066 | XCBC_AES_TEST_VECTORS); |
| 1067 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS); |
| 1069 | break; |
| 1070 | |
| 1071 | case 1: |
| 1072 | test_hash("md5", md5_tv_template, MD5_TEST_VECTORS); |
| 1073 | break; |
| 1074 | |
| 1075 | case 2: |
| 1076 | test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS); |
| 1077 | break; |
| 1078 | |
| 1079 | case 3: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1080 | test_cipher("ecb(des)", ENCRYPT, des_enc_tv_template, |
| 1081 | DES_ENC_TEST_VECTORS); |
| 1082 | test_cipher("ecb(des)", DECRYPT, des_dec_tv_template, |
| 1083 | DES_DEC_TEST_VECTORS); |
| 1084 | test_cipher("cbc(des)", ENCRYPT, des_cbc_enc_tv_template, |
| 1085 | DES_CBC_ENC_TEST_VECTORS); |
| 1086 | test_cipher("cbc(des)", DECRYPT, des_cbc_dec_tv_template, |
| 1087 | DES_CBC_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | break; |
| 1089 | |
| 1090 | case 4: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1091 | test_cipher("ecb(des3_ede)", ENCRYPT, des3_ede_enc_tv_template, |
| 1092 | DES3_EDE_ENC_TEST_VECTORS); |
| 1093 | test_cipher("ecb(des3_ede)", DECRYPT, des3_ede_dec_tv_template, |
| 1094 | DES3_EDE_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | break; |
| 1096 | |
| 1097 | case 5: |
| 1098 | test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); |
| 1099 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | case 6: |
| 1102 | test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); |
| 1103 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | case 7: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1106 | test_cipher("ecb(blowfish)", ENCRYPT, bf_enc_tv_template, |
| 1107 | BF_ENC_TEST_VECTORS); |
| 1108 | test_cipher("ecb(blowfish)", DECRYPT, bf_dec_tv_template, |
| 1109 | BF_DEC_TEST_VECTORS); |
| 1110 | test_cipher("cbc(blowfish)", ENCRYPT, bf_cbc_enc_tv_template, |
| 1111 | BF_CBC_ENC_TEST_VECTORS); |
| 1112 | test_cipher("cbc(blowfish)", DECRYPT, bf_cbc_dec_tv_template, |
| 1113 | BF_CBC_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | break; |
| 1115 | |
| 1116 | case 8: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1117 | test_cipher("ecb(twofish)", ENCRYPT, tf_enc_tv_template, |
| 1118 | TF_ENC_TEST_VECTORS); |
| 1119 | test_cipher("ecb(twofish)", DECRYPT, tf_dec_tv_template, |
| 1120 | TF_DEC_TEST_VECTORS); |
| 1121 | test_cipher("cbc(twofish)", ENCRYPT, tf_cbc_enc_tv_template, |
| 1122 | TF_CBC_ENC_TEST_VECTORS); |
| 1123 | test_cipher("cbc(twofish)", DECRYPT, tf_cbc_dec_tv_template, |
| 1124 | TF_CBC_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | case 9: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1128 | test_cipher("ecb(serpent)", ENCRYPT, serpent_enc_tv_template, |
| 1129 | SERPENT_ENC_TEST_VECTORS); |
| 1130 | test_cipher("ecb(serpent)", DECRYPT, serpent_dec_tv_template, |
| 1131 | SERPENT_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | break; |
| 1133 | |
| 1134 | case 10: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1135 | test_cipher("ecb(aes)", ENCRYPT, aes_enc_tv_template, |
| 1136 | AES_ENC_TEST_VECTORS); |
| 1137 | test_cipher("ecb(aes)", DECRYPT, aes_dec_tv_template, |
| 1138 | AES_DEC_TEST_VECTORS); |
| 1139 | test_cipher("cbc(aes)", ENCRYPT, aes_cbc_enc_tv_template, |
| 1140 | AES_CBC_ENC_TEST_VECTORS); |
| 1141 | test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template, |
| 1142 | AES_CBC_DEC_TEST_VECTORS); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 1143 | test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template, |
| 1144 | AES_LRW_ENC_TEST_VECTORS); |
| 1145 | test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template, |
| 1146 | AES_LRW_DEC_TEST_VECTORS); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 1147 | test_cipher("xts(aes)", ENCRYPT, aes_xts_enc_tv_template, |
| 1148 | AES_XTS_ENC_TEST_VECTORS); |
| 1149 | test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template, |
| 1150 | AES_XTS_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | break; |
| 1152 | |
| 1153 | case 11: |
| 1154 | test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); |
| 1155 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | case 12: |
| 1158 | test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); |
| 1159 | break; |
| 1160 | |
| 1161 | case 13: |
| 1162 | test_deflate(); |
| 1163 | break; |
| 1164 | |
| 1165 | case 14: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1166 | test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template, |
| 1167 | CAST5_ENC_TEST_VECTORS); |
| 1168 | test_cipher("ecb(cast5)", DECRYPT, cast5_dec_tv_template, |
| 1169 | CAST5_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | break; |
| 1171 | |
| 1172 | case 15: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1173 | test_cipher("ecb(cast6)", ENCRYPT, cast6_enc_tv_template, |
| 1174 | CAST6_ENC_TEST_VECTORS); |
| 1175 | test_cipher("ecb(cast6)", DECRYPT, cast6_dec_tv_template, |
| 1176 | CAST6_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | break; |
| 1178 | |
| 1179 | case 16: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1180 | test_cipher("ecb(arc4)", ENCRYPT, arc4_enc_tv_template, |
| 1181 | ARC4_ENC_TEST_VECTORS); |
| 1182 | test_cipher("ecb(arc4)", DECRYPT, arc4_dec_tv_template, |
| 1183 | ARC4_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1184 | break; |
| 1185 | |
| 1186 | case 17: |
| 1187 | test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS); |
| 1188 | break; |
| 1189 | |
| 1190 | case 18: |
Herbert Xu | c907ee7 | 2006-08-21 22:04:03 +1000 | [diff] [blame] | 1191 | test_hash("crc32c", crc32c_tv_template, CRC32C_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | break; |
| 1193 | |
| 1194 | case 19: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1195 | test_cipher("ecb(tea)", ENCRYPT, tea_enc_tv_template, |
| 1196 | TEA_ENC_TEST_VECTORS); |
| 1197 | test_cipher("ecb(tea)", DECRYPT, tea_dec_tv_template, |
| 1198 | TEA_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | break; |
| 1200 | |
| 1201 | case 20: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1202 | test_cipher("ecb(xtea)", ENCRYPT, xtea_enc_tv_template, |
| 1203 | XTEA_ENC_TEST_VECTORS); |
| 1204 | test_cipher("ecb(xtea)", DECRYPT, xtea_dec_tv_template, |
| 1205 | XTEA_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | break; |
| 1207 | |
| 1208 | case 21: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1209 | test_cipher("ecb(khazad)", ENCRYPT, khazad_enc_tv_template, |
| 1210 | KHAZAD_ENC_TEST_VECTORS); |
| 1211 | test_cipher("ecb(khazad)", DECRYPT, khazad_dec_tv_template, |
| 1212 | KHAZAD_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1213 | break; |
| 1214 | |
| 1215 | case 22: |
| 1216 | test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS); |
| 1217 | break; |
| 1218 | |
| 1219 | case 23: |
| 1220 | test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS); |
| 1221 | break; |
| 1222 | |
| 1223 | case 24: |
| 1224 | test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS); |
| 1225 | break; |
| 1226 | |
| 1227 | case 25: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1228 | test_cipher("ecb(tnepres)", ENCRYPT, tnepres_enc_tv_template, |
| 1229 | TNEPRES_ENC_TEST_VECTORS); |
| 1230 | test_cipher("ecb(tnepres)", DECRYPT, tnepres_dec_tv_template, |
| 1231 | TNEPRES_DEC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | break; |
| 1233 | |
| 1234 | case 26: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1235 | test_cipher("ecb(anubis)", ENCRYPT, anubis_enc_tv_template, |
| 1236 | ANUBIS_ENC_TEST_VECTORS); |
| 1237 | test_cipher("ecb(anubis)", DECRYPT, anubis_dec_tv_template, |
| 1238 | ANUBIS_DEC_TEST_VECTORS); |
| 1239 | test_cipher("cbc(anubis)", ENCRYPT, anubis_cbc_enc_tv_template, |
| 1240 | ANUBIS_CBC_ENC_TEST_VECTORS); |
| 1241 | test_cipher("cbc(anubis)", DECRYPT, anubis_cbc_dec_tv_template, |
| 1242 | ANUBIS_CBC_ENC_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1243 | break; |
| 1244 | |
| 1245 | case 27: |
| 1246 | test_hash("tgr192", tgr192_tv_template, TGR192_TEST_VECTORS); |
| 1247 | break; |
| 1248 | |
| 1249 | case 28: |
| 1250 | |
| 1251 | test_hash("tgr160", tgr160_tv_template, TGR160_TEST_VECTORS); |
| 1252 | break; |
| 1253 | |
| 1254 | case 29: |
| 1255 | test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS); |
| 1256 | break; |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1257 | |
| 1258 | case 30: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1259 | test_cipher("ecb(xeta)", ENCRYPT, xeta_enc_tv_template, |
| 1260 | XETA_ENC_TEST_VECTORS); |
| 1261 | test_cipher("ecb(xeta)", DECRYPT, xeta_dec_tv_template, |
| 1262 | XETA_DEC_TEST_VECTORS); |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1263 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 1265 | case 31: |
| 1266 | test_cipher("pcbc(fcrypt)", ENCRYPT, fcrypt_pcbc_enc_tv_template, |
| 1267 | FCRYPT_ENC_TEST_VECTORS); |
| 1268 | test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template, |
| 1269 | FCRYPT_DEC_TEST_VECTORS); |
| 1270 | break; |
| 1271 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1272 | case 32: |
| 1273 | test_cipher("ecb(camellia)", ENCRYPT, |
| 1274 | camellia_enc_tv_template, |
| 1275 | CAMELLIA_ENC_TEST_VECTORS); |
| 1276 | test_cipher("ecb(camellia)", DECRYPT, |
| 1277 | camellia_dec_tv_template, |
| 1278 | CAMELLIA_DEC_TEST_VECTORS); |
| 1279 | test_cipher("cbc(camellia)", ENCRYPT, |
| 1280 | camellia_cbc_enc_tv_template, |
| 1281 | CAMELLIA_CBC_ENC_TEST_VECTORS); |
| 1282 | test_cipher("cbc(camellia)", DECRYPT, |
| 1283 | camellia_cbc_dec_tv_template, |
| 1284 | CAMELLIA_CBC_DEC_TEST_VECTORS); |
| 1285 | break; |
| 1286 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | case 100: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1288 | test_hash("hmac(md5)", hmac_md5_tv_template, |
| 1289 | HMAC_MD5_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1290 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1291 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | case 101: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1293 | test_hash("hmac(sha1)", hmac_sha1_tv_template, |
| 1294 | HMAC_SHA1_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | case 102: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1298 | test_hash("hmac(sha256)", hmac_sha256_tv_template, |
| 1299 | HMAC_SHA256_TEST_VECTORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1300 | break; |
| 1301 | |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1302 | case 103: |
| 1303 | test_hash("hmac(sha384)", hmac_sha384_tv_template, |
| 1304 | HMAC_SHA384_TEST_VECTORS); |
| 1305 | break; |
| 1306 | |
| 1307 | case 104: |
| 1308 | test_hash("hmac(sha512)", hmac_sha512_tv_template, |
| 1309 | HMAC_SHA512_TEST_VECTORS); |
| 1310 | break; |
| 1311 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1313 | case 200: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1314 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1315 | aes_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1316 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1317 | aes_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1318 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1319 | aes_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1320 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1321 | aes_speed_template); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 1322 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
| 1323 | aes_lrw_speed_template); |
| 1324 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
| 1325 | aes_lrw_speed_template); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 1326 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
| 1327 | aes_xts_speed_template); |
| 1328 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
| 1329 | aes_xts_speed_template); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1330 | break; |
| 1331 | |
| 1332 | case 201: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1333 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1334 | des3_ede_enc_tv_template, |
| 1335 | DES3_EDE_ENC_TEST_VECTORS, |
| 1336 | des3_ede_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1337 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1338 | des3_ede_dec_tv_template, |
| 1339 | DES3_EDE_DEC_TEST_VECTORS, |
| 1340 | des3_ede_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1341 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1342 | des3_ede_enc_tv_template, |
| 1343 | DES3_EDE_ENC_TEST_VECTORS, |
| 1344 | des3_ede_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1345 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1346 | des3_ede_dec_tv_template, |
| 1347 | DES3_EDE_DEC_TEST_VECTORS, |
| 1348 | des3_ede_speed_template); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1349 | break; |
| 1350 | |
| 1351 | case 202: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1352 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1353 | twofish_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1354 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1355 | twofish_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1356 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1357 | twofish_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1358 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1359 | twofish_speed_template); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1360 | break; |
| 1361 | |
| 1362 | case 203: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1363 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1364 | blowfish_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1365 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1366 | blowfish_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1367 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1368 | blowfish_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1369 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1370 | blowfish_speed_template); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1371 | break; |
| 1372 | |
| 1373 | case 204: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1374 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1375 | des_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1376 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1377 | des_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1378 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1379 | des_speed_template); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1380 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
Herbert Xu | dce907c | 2005-06-22 13:27:51 -0700 | [diff] [blame] | 1381 | des_speed_template); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1382 | break; |
| 1383 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1384 | case 205: |
| 1385 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
| 1386 | camellia_speed_template); |
| 1387 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
| 1388 | camellia_speed_template); |
| 1389 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
| 1390 | camellia_speed_template); |
| 1391 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
| 1392 | camellia_speed_template); |
| 1393 | break; |
| 1394 | |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1395 | case 300: |
| 1396 | /* fall through */ |
| 1397 | |
| 1398 | case 301: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1399 | test_hash_speed("md4", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1400 | if (mode > 300 && mode < 400) break; |
| 1401 | |
| 1402 | case 302: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1403 | test_hash_speed("md5", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1404 | if (mode > 300 && mode < 400) break; |
| 1405 | |
| 1406 | case 303: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1407 | test_hash_speed("sha1", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1408 | if (mode > 300 && mode < 400) break; |
| 1409 | |
| 1410 | case 304: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1411 | test_hash_speed("sha256", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1412 | if (mode > 300 && mode < 400) break; |
| 1413 | |
| 1414 | case 305: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1415 | test_hash_speed("sha384", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1416 | if (mode > 300 && mode < 400) break; |
| 1417 | |
| 1418 | case 306: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1419 | test_hash_speed("sha512", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1420 | if (mode > 300 && mode < 400) break; |
| 1421 | |
| 1422 | case 307: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1423 | test_hash_speed("wp256", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1424 | if (mode > 300 && mode < 400) break; |
| 1425 | |
| 1426 | case 308: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1427 | test_hash_speed("wp384", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1428 | if (mode > 300 && mode < 400) break; |
| 1429 | |
| 1430 | case 309: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1431 | test_hash_speed("wp512", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1432 | if (mode > 300 && mode < 400) break; |
| 1433 | |
| 1434 | case 310: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1435 | test_hash_speed("tgr128", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1436 | if (mode > 300 && mode < 400) break; |
| 1437 | |
| 1438 | case 311: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1439 | test_hash_speed("tgr160", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1440 | if (mode > 300 && mode < 400) break; |
| 1441 | |
| 1442 | case 312: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1443 | test_hash_speed("tgr192", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1444 | if (mode > 300 && mode < 400) break; |
| 1445 | |
| 1446 | case 399: |
| 1447 | break; |
| 1448 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1449 | case 1000: |
| 1450 | test_available(); |
| 1451 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | default: |
| 1454 | /* useful for debugging */ |
| 1455 | printk("not testing anything\n"); |
| 1456 | break; |
| 1457 | } |
| 1458 | } |
| 1459 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1460 | static int __init init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1461 | { |
| 1462 | tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL); |
| 1463 | if (tvmem == NULL) |
| 1464 | return -ENOMEM; |
| 1465 | |
| 1466 | xbuf = kmalloc(XBUFSIZE, GFP_KERNEL); |
| 1467 | if (xbuf == NULL) { |
| 1468 | kfree(tvmem); |
| 1469 | return -ENOMEM; |
| 1470 | } |
| 1471 | |
| 1472 | do_test(); |
| 1473 | |
| 1474 | kfree(xbuf); |
| 1475 | kfree(tvmem); |
Michal Ludvig | 14fdf47 | 2006-05-30 14:49:38 +1000 | [diff] [blame] | 1476 | |
| 1477 | /* We intentionaly return -EAGAIN to prevent keeping |
| 1478 | * the module. It does all its work from init() |
| 1479 | * and doesn't offer any runtime functionality |
| 1480 | * => we don't need it in the memory, do we? |
| 1481 | * -- mludvig |
| 1482 | */ |
| 1483 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | } |
| 1485 | |
| 1486 | /* |
| 1487 | * If an init function is provided, an exit function must also be provided |
| 1488 | * to allow module unload. |
| 1489 | */ |
| 1490 | static void __exit fini(void) { } |
| 1491 | |
| 1492 | module_init(init); |
| 1493 | module_exit(fini); |
| 1494 | |
| 1495 | module_param(mode, int, 0); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1496 | module_param(sec, uint, 0); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 1497 | MODULE_PARM_DESC(sec, "Length in seconds of speed tests " |
| 1498 | "(defaults to zero which uses CPU cycles instead)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | |
| 1500 | MODULE_LICENSE("GPL"); |
| 1501 | MODULE_DESCRIPTION("Quick & dirty crypto testing module"); |
| 1502 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); |