Commit 54216bbd76aa394c93a9e92c0a2e3b314391b134
Committed by
Herbert Xu
1 parent
d8a32ac256
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
crypto: tcrypt - add missing tests for camellia and ghash
Add missing tests for ctr(camellia), lrw(camellia), xts(camellia) and ghash, as these have test vectors available. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 1 changed file with 7 additions and 0 deletions Inline Diff
crypto/tcrypt.c
1 | /* | 1 | /* |
2 | * Quick & dirty crypto testing module. | 2 | * Quick & dirty crypto testing module. |
3 | * | 3 | * |
4 | * This will only exist until we have a better testing mechanism | 4 | * This will only exist until we have a better testing mechanism |
5 | * (e.g. a char device). | 5 | * (e.g. a char device). |
6 | * | 6 | * |
7 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> | 7 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> |
8 | * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org> | 8 | * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org> |
9 | * Copyright (c) 2007 Nokia Siemens Networks | 9 | * Copyright (c) 2007 Nokia Siemens Networks |
10 | * | 10 | * |
11 | * Updated RFC4106 AES-GCM testing. | 11 | * Updated RFC4106 AES-GCM testing. |
12 | * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com) | 12 | * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com) |
13 | * Adrian Hoban <adrian.hoban@intel.com> | 13 | * Adrian Hoban <adrian.hoban@intel.com> |
14 | * Gabriele Paoloni <gabriele.paoloni@intel.com> | 14 | * Gabriele Paoloni <gabriele.paoloni@intel.com> |
15 | * Tadeusz Struk (tadeusz.struk@intel.com) | 15 | * Tadeusz Struk (tadeusz.struk@intel.com) |
16 | * Copyright (c) 2010, Intel Corporation. | 16 | * Copyright (c) 2010, Intel Corporation. |
17 | * | 17 | * |
18 | * This program is free software; you can redistribute it and/or modify it | 18 | * This program is free software; you can redistribute it and/or modify it |
19 | * under the terms of the GNU General Public License as published by the Free | 19 | * under the terms of the GNU General Public License as published by the Free |
20 | * Software Foundation; either version 2 of the License, or (at your option) | 20 | * Software Foundation; either version 2 of the License, or (at your option) |
21 | * any later version. | 21 | * any later version. |
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <crypto/hash.h> | 25 | #include <crypto/hash.h> |
26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/gfp.h> | 28 | #include <linux/gfp.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/scatterlist.h> | 30 | #include <linux/scatterlist.h> |
31 | #include <linux/string.h> | 31 | #include <linux/string.h> |
32 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
33 | #include <linux/jiffies.h> | 33 | #include <linux/jiffies.h> |
34 | #include <linux/timex.h> | 34 | #include <linux/timex.h> |
35 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
36 | #include "tcrypt.h" | 36 | #include "tcrypt.h" |
37 | #include "internal.h" | 37 | #include "internal.h" |
38 | 38 | ||
39 | /* | 39 | /* |
40 | * Need slab memory for testing (size in number of pages). | 40 | * Need slab memory for testing (size in number of pages). |
41 | */ | 41 | */ |
42 | #define TVMEMSIZE 4 | 42 | #define TVMEMSIZE 4 |
43 | 43 | ||
44 | /* | 44 | /* |
45 | * Used by test_cipher_speed() | 45 | * Used by test_cipher_speed() |
46 | */ | 46 | */ |
47 | #define ENCRYPT 1 | 47 | #define ENCRYPT 1 |
48 | #define DECRYPT 0 | 48 | #define DECRYPT 0 |
49 | 49 | ||
50 | /* | 50 | /* |
51 | * Used by test_cipher_speed() | 51 | * Used by test_cipher_speed() |
52 | */ | 52 | */ |
53 | static unsigned int sec; | 53 | static unsigned int sec; |
54 | 54 | ||
55 | static char *alg = NULL; | 55 | static char *alg = NULL; |
56 | static u32 type; | 56 | static u32 type; |
57 | static u32 mask; | 57 | static u32 mask; |
58 | static int mode; | 58 | static int mode; |
59 | static char *tvmem[TVMEMSIZE]; | 59 | static char *tvmem[TVMEMSIZE]; |
60 | 60 | ||
61 | static char *check[] = { | 61 | static char *check[] = { |
62 | "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", | 62 | "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", |
63 | "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", | 63 | "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", |
64 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", | 64 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", |
65 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", | 65 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", |
66 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", | 66 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", |
67 | "lzo", "cts", "zlib", NULL | 67 | "lzo", "cts", "zlib", NULL |
68 | }; | 68 | }; |
69 | 69 | ||
70 | static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, | 70 | static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, |
71 | struct scatterlist *sg, int blen, int sec) | 71 | struct scatterlist *sg, int blen, int sec) |
72 | { | 72 | { |
73 | unsigned long start, end; | 73 | unsigned long start, end; |
74 | int bcount; | 74 | int bcount; |
75 | int ret; | 75 | int ret; |
76 | 76 | ||
77 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 77 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
78 | time_before(jiffies, end); bcount++) { | 78 | time_before(jiffies, end); bcount++) { |
79 | if (enc) | 79 | if (enc) |
80 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); | 80 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); |
81 | else | 81 | else |
82 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); | 82 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); |
83 | 83 | ||
84 | if (ret) | 84 | if (ret) |
85 | return ret; | 85 | return ret; |
86 | } | 86 | } |
87 | 87 | ||
88 | printk("%d operations in %d seconds (%ld bytes)\n", | 88 | printk("%d operations in %d seconds (%ld bytes)\n", |
89 | bcount, sec, (long)bcount * blen); | 89 | bcount, sec, (long)bcount * blen); |
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, | 93 | static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, |
94 | struct scatterlist *sg, int blen) | 94 | struct scatterlist *sg, int blen) |
95 | { | 95 | { |
96 | unsigned long cycles = 0; | 96 | unsigned long cycles = 0; |
97 | int ret = 0; | 97 | int ret = 0; |
98 | int i; | 98 | int i; |
99 | 99 | ||
100 | local_irq_disable(); | 100 | local_irq_disable(); |
101 | 101 | ||
102 | /* Warm-up run. */ | 102 | /* Warm-up run. */ |
103 | for (i = 0; i < 4; i++) { | 103 | for (i = 0; i < 4; i++) { |
104 | if (enc) | 104 | if (enc) |
105 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); | 105 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); |
106 | else | 106 | else |
107 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); | 107 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); |
108 | 108 | ||
109 | if (ret) | 109 | if (ret) |
110 | goto out; | 110 | goto out; |
111 | } | 111 | } |
112 | 112 | ||
113 | /* The real thing. */ | 113 | /* The real thing. */ |
114 | for (i = 0; i < 8; i++) { | 114 | for (i = 0; i < 8; i++) { |
115 | cycles_t start, end; | 115 | cycles_t start, end; |
116 | 116 | ||
117 | start = get_cycles(); | 117 | start = get_cycles(); |
118 | if (enc) | 118 | if (enc) |
119 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); | 119 | ret = crypto_blkcipher_encrypt(desc, sg, sg, blen); |
120 | else | 120 | else |
121 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); | 121 | ret = crypto_blkcipher_decrypt(desc, sg, sg, blen); |
122 | end = get_cycles(); | 122 | end = get_cycles(); |
123 | 123 | ||
124 | if (ret) | 124 | if (ret) |
125 | goto out; | 125 | goto out; |
126 | 126 | ||
127 | cycles += end - start; | 127 | cycles += end - start; |
128 | } | 128 | } |
129 | 129 | ||
130 | out: | 130 | out: |
131 | local_irq_enable(); | 131 | local_irq_enable(); |
132 | 132 | ||
133 | if (ret == 0) | 133 | if (ret == 0) |
134 | printk("1 operation in %lu cycles (%d bytes)\n", | 134 | printk("1 operation in %lu cycles (%d bytes)\n", |
135 | (cycles + 4) / 8, blen); | 135 | (cycles + 4) / 8, blen); |
136 | 136 | ||
137 | return ret; | 137 | return ret; |
138 | } | 138 | } |
139 | 139 | ||
140 | static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 }; | 140 | static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 }; |
141 | 141 | ||
142 | static void test_cipher_speed(const char *algo, int enc, unsigned int sec, | 142 | static void test_cipher_speed(const char *algo, int enc, unsigned int sec, |
143 | struct cipher_speed_template *template, | 143 | struct cipher_speed_template *template, |
144 | unsigned int tcount, u8 *keysize) | 144 | unsigned int tcount, u8 *keysize) |
145 | { | 145 | { |
146 | unsigned int ret, i, j, iv_len; | 146 | unsigned int ret, i, j, iv_len; |
147 | const char *key; | 147 | const char *key; |
148 | char iv[128]; | 148 | char iv[128]; |
149 | struct crypto_blkcipher *tfm; | 149 | struct crypto_blkcipher *tfm; |
150 | struct blkcipher_desc desc; | 150 | struct blkcipher_desc desc; |
151 | const char *e; | 151 | const char *e; |
152 | u32 *b_size; | 152 | u32 *b_size; |
153 | 153 | ||
154 | if (enc == ENCRYPT) | 154 | if (enc == ENCRYPT) |
155 | e = "encryption"; | 155 | e = "encryption"; |
156 | else | 156 | else |
157 | e = "decryption"; | 157 | e = "decryption"; |
158 | 158 | ||
159 | printk("\ntesting speed of %s %s\n", algo, e); | 159 | printk("\ntesting speed of %s %s\n", algo, e); |
160 | 160 | ||
161 | tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC); | 161 | tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC); |
162 | 162 | ||
163 | if (IS_ERR(tfm)) { | 163 | if (IS_ERR(tfm)) { |
164 | printk("failed to load transform for %s: %ld\n", algo, | 164 | printk("failed to load transform for %s: %ld\n", algo, |
165 | PTR_ERR(tfm)); | 165 | PTR_ERR(tfm)); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | desc.tfm = tfm; | 168 | desc.tfm = tfm; |
169 | desc.flags = 0; | 169 | desc.flags = 0; |
170 | 170 | ||
171 | i = 0; | 171 | i = 0; |
172 | do { | 172 | do { |
173 | 173 | ||
174 | b_size = block_sizes; | 174 | b_size = block_sizes; |
175 | do { | 175 | do { |
176 | struct scatterlist sg[TVMEMSIZE]; | 176 | struct scatterlist sg[TVMEMSIZE]; |
177 | 177 | ||
178 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { | 178 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { |
179 | printk("template (%u) too big for " | 179 | printk("template (%u) too big for " |
180 | "tvmem (%lu)\n", *keysize + *b_size, | 180 | "tvmem (%lu)\n", *keysize + *b_size, |
181 | TVMEMSIZE * PAGE_SIZE); | 181 | TVMEMSIZE * PAGE_SIZE); |
182 | goto out; | 182 | goto out; |
183 | } | 183 | } |
184 | 184 | ||
185 | printk("test %u (%d bit key, %d byte blocks): ", i, | 185 | printk("test %u (%d bit key, %d byte blocks): ", i, |
186 | *keysize * 8, *b_size); | 186 | *keysize * 8, *b_size); |
187 | 187 | ||
188 | memset(tvmem[0], 0xff, PAGE_SIZE); | 188 | memset(tvmem[0], 0xff, PAGE_SIZE); |
189 | 189 | ||
190 | /* set key, plain text and IV */ | 190 | /* set key, plain text and IV */ |
191 | key = tvmem[0]; | 191 | key = tvmem[0]; |
192 | for (j = 0; j < tcount; j++) { | 192 | for (j = 0; j < tcount; j++) { |
193 | if (template[j].klen == *keysize) { | 193 | if (template[j].klen == *keysize) { |
194 | key = template[j].key; | 194 | key = template[j].key; |
195 | break; | 195 | break; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | ret = crypto_blkcipher_setkey(tfm, key, *keysize); | 199 | ret = crypto_blkcipher_setkey(tfm, key, *keysize); |
200 | if (ret) { | 200 | if (ret) { |
201 | printk("setkey() failed flags=%x\n", | 201 | printk("setkey() failed flags=%x\n", |
202 | crypto_blkcipher_get_flags(tfm)); | 202 | crypto_blkcipher_get_flags(tfm)); |
203 | goto out; | 203 | goto out; |
204 | } | 204 | } |
205 | 205 | ||
206 | sg_init_table(sg, TVMEMSIZE); | 206 | sg_init_table(sg, TVMEMSIZE); |
207 | sg_set_buf(sg, tvmem[0] + *keysize, | 207 | sg_set_buf(sg, tvmem[0] + *keysize, |
208 | PAGE_SIZE - *keysize); | 208 | PAGE_SIZE - *keysize); |
209 | for (j = 1; j < TVMEMSIZE; j++) { | 209 | for (j = 1; j < TVMEMSIZE; j++) { |
210 | sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); | 210 | sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); |
211 | memset (tvmem[j], 0xff, PAGE_SIZE); | 211 | memset (tvmem[j], 0xff, PAGE_SIZE); |
212 | } | 212 | } |
213 | 213 | ||
214 | iv_len = crypto_blkcipher_ivsize(tfm); | 214 | iv_len = crypto_blkcipher_ivsize(tfm); |
215 | if (iv_len) { | 215 | if (iv_len) { |
216 | memset(&iv, 0xff, iv_len); | 216 | memset(&iv, 0xff, iv_len); |
217 | crypto_blkcipher_set_iv(tfm, iv, iv_len); | 217 | crypto_blkcipher_set_iv(tfm, iv, iv_len); |
218 | } | 218 | } |
219 | 219 | ||
220 | if (sec) | 220 | if (sec) |
221 | ret = test_cipher_jiffies(&desc, enc, sg, | 221 | ret = test_cipher_jiffies(&desc, enc, sg, |
222 | *b_size, sec); | 222 | *b_size, sec); |
223 | else | 223 | else |
224 | ret = test_cipher_cycles(&desc, enc, sg, | 224 | ret = test_cipher_cycles(&desc, enc, sg, |
225 | *b_size); | 225 | *b_size); |
226 | 226 | ||
227 | if (ret) { | 227 | if (ret) { |
228 | printk("%s() failed flags=%x\n", e, desc.flags); | 228 | printk("%s() failed flags=%x\n", e, desc.flags); |
229 | break; | 229 | break; |
230 | } | 230 | } |
231 | b_size++; | 231 | b_size++; |
232 | i++; | 232 | i++; |
233 | } while (*b_size); | 233 | } while (*b_size); |
234 | keysize++; | 234 | keysize++; |
235 | } while (*keysize); | 235 | } while (*keysize); |
236 | 236 | ||
237 | out: | 237 | out: |
238 | crypto_free_blkcipher(tfm); | 238 | crypto_free_blkcipher(tfm); |
239 | } | 239 | } |
240 | 240 | ||
241 | static int test_hash_jiffies_digest(struct hash_desc *desc, | 241 | static int test_hash_jiffies_digest(struct hash_desc *desc, |
242 | struct scatterlist *sg, int blen, | 242 | struct scatterlist *sg, int blen, |
243 | char *out, int sec) | 243 | char *out, int sec) |
244 | { | 244 | { |
245 | unsigned long start, end; | 245 | unsigned long start, end; |
246 | int bcount; | 246 | int bcount; |
247 | int ret; | 247 | int ret; |
248 | 248 | ||
249 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 249 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
250 | time_before(jiffies, end); bcount++) { | 250 | time_before(jiffies, end); bcount++) { |
251 | ret = crypto_hash_digest(desc, sg, blen, out); | 251 | ret = crypto_hash_digest(desc, sg, blen, out); |
252 | if (ret) | 252 | if (ret) |
253 | return ret; | 253 | return ret; |
254 | } | 254 | } |
255 | 255 | ||
256 | printk("%6u opers/sec, %9lu bytes/sec\n", | 256 | printk("%6u opers/sec, %9lu bytes/sec\n", |
257 | bcount / sec, ((long)bcount * blen) / sec); | 257 | bcount / sec, ((long)bcount * blen) / sec); |
258 | 258 | ||
259 | return 0; | 259 | return 0; |
260 | } | 260 | } |
261 | 261 | ||
262 | static int test_hash_jiffies(struct hash_desc *desc, struct scatterlist *sg, | 262 | static int test_hash_jiffies(struct hash_desc *desc, struct scatterlist *sg, |
263 | int blen, int plen, char *out, int sec) | 263 | int blen, int plen, char *out, int sec) |
264 | { | 264 | { |
265 | unsigned long start, end; | 265 | unsigned long start, end; |
266 | int bcount, pcount; | 266 | int bcount, pcount; |
267 | int ret; | 267 | int ret; |
268 | 268 | ||
269 | if (plen == blen) | 269 | if (plen == blen) |
270 | return test_hash_jiffies_digest(desc, sg, blen, out, sec); | 270 | return test_hash_jiffies_digest(desc, sg, blen, out, sec); |
271 | 271 | ||
272 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 272 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
273 | time_before(jiffies, end); bcount++) { | 273 | time_before(jiffies, end); bcount++) { |
274 | ret = crypto_hash_init(desc); | 274 | ret = crypto_hash_init(desc); |
275 | if (ret) | 275 | if (ret) |
276 | return ret; | 276 | return ret; |
277 | for (pcount = 0; pcount < blen; pcount += plen) { | 277 | for (pcount = 0; pcount < blen; pcount += plen) { |
278 | ret = crypto_hash_update(desc, sg, plen); | 278 | ret = crypto_hash_update(desc, sg, plen); |
279 | if (ret) | 279 | if (ret) |
280 | return ret; | 280 | return ret; |
281 | } | 281 | } |
282 | /* we assume there is enough space in 'out' for the result */ | 282 | /* we assume there is enough space in 'out' for the result */ |
283 | ret = crypto_hash_final(desc, out); | 283 | ret = crypto_hash_final(desc, out); |
284 | if (ret) | 284 | if (ret) |
285 | return ret; | 285 | return ret; |
286 | } | 286 | } |
287 | 287 | ||
288 | printk("%6u opers/sec, %9lu bytes/sec\n", | 288 | printk("%6u opers/sec, %9lu bytes/sec\n", |
289 | bcount / sec, ((long)bcount * blen) / sec); | 289 | bcount / sec, ((long)bcount * blen) / sec); |
290 | 290 | ||
291 | return 0; | 291 | return 0; |
292 | } | 292 | } |
293 | 293 | ||
294 | static int test_hash_cycles_digest(struct hash_desc *desc, | 294 | static int test_hash_cycles_digest(struct hash_desc *desc, |
295 | struct scatterlist *sg, int blen, char *out) | 295 | struct scatterlist *sg, int blen, char *out) |
296 | { | 296 | { |
297 | unsigned long cycles = 0; | 297 | unsigned long cycles = 0; |
298 | int i; | 298 | int i; |
299 | int ret; | 299 | int ret; |
300 | 300 | ||
301 | local_irq_disable(); | 301 | local_irq_disable(); |
302 | 302 | ||
303 | /* Warm-up run. */ | 303 | /* Warm-up run. */ |
304 | for (i = 0; i < 4; i++) { | 304 | for (i = 0; i < 4; i++) { |
305 | ret = crypto_hash_digest(desc, sg, blen, out); | 305 | ret = crypto_hash_digest(desc, sg, blen, out); |
306 | if (ret) | 306 | if (ret) |
307 | goto out; | 307 | goto out; |
308 | } | 308 | } |
309 | 309 | ||
310 | /* The real thing. */ | 310 | /* The real thing. */ |
311 | for (i = 0; i < 8; i++) { | 311 | for (i = 0; i < 8; i++) { |
312 | cycles_t start, end; | 312 | cycles_t start, end; |
313 | 313 | ||
314 | start = get_cycles(); | 314 | start = get_cycles(); |
315 | 315 | ||
316 | ret = crypto_hash_digest(desc, sg, blen, out); | 316 | ret = crypto_hash_digest(desc, sg, blen, out); |
317 | if (ret) | 317 | if (ret) |
318 | goto out; | 318 | goto out; |
319 | 319 | ||
320 | end = get_cycles(); | 320 | end = get_cycles(); |
321 | 321 | ||
322 | cycles += end - start; | 322 | cycles += end - start; |
323 | } | 323 | } |
324 | 324 | ||
325 | out: | 325 | out: |
326 | local_irq_enable(); | 326 | local_irq_enable(); |
327 | 327 | ||
328 | if (ret) | 328 | if (ret) |
329 | return ret; | 329 | return ret; |
330 | 330 | ||
331 | printk("%6lu cycles/operation, %4lu cycles/byte\n", | 331 | printk("%6lu cycles/operation, %4lu cycles/byte\n", |
332 | cycles / 8, cycles / (8 * blen)); | 332 | cycles / 8, cycles / (8 * blen)); |
333 | 333 | ||
334 | return 0; | 334 | return 0; |
335 | } | 335 | } |
336 | 336 | ||
337 | static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg, | 337 | static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg, |
338 | int blen, int plen, char *out) | 338 | int blen, int plen, char *out) |
339 | { | 339 | { |
340 | unsigned long cycles = 0; | 340 | unsigned long cycles = 0; |
341 | int i, pcount; | 341 | int i, pcount; |
342 | int ret; | 342 | int ret; |
343 | 343 | ||
344 | if (plen == blen) | 344 | if (plen == blen) |
345 | return test_hash_cycles_digest(desc, sg, blen, out); | 345 | return test_hash_cycles_digest(desc, sg, blen, out); |
346 | 346 | ||
347 | local_irq_disable(); | 347 | local_irq_disable(); |
348 | 348 | ||
349 | /* Warm-up run. */ | 349 | /* Warm-up run. */ |
350 | for (i = 0; i < 4; i++) { | 350 | for (i = 0; i < 4; i++) { |
351 | ret = crypto_hash_init(desc); | 351 | ret = crypto_hash_init(desc); |
352 | if (ret) | 352 | if (ret) |
353 | goto out; | 353 | goto out; |
354 | for (pcount = 0; pcount < blen; pcount += plen) { | 354 | for (pcount = 0; pcount < blen; pcount += plen) { |
355 | ret = crypto_hash_update(desc, sg, plen); | 355 | ret = crypto_hash_update(desc, sg, plen); |
356 | if (ret) | 356 | if (ret) |
357 | goto out; | 357 | goto out; |
358 | } | 358 | } |
359 | ret = crypto_hash_final(desc, out); | 359 | ret = crypto_hash_final(desc, out); |
360 | if (ret) | 360 | if (ret) |
361 | goto out; | 361 | goto out; |
362 | } | 362 | } |
363 | 363 | ||
364 | /* The real thing. */ | 364 | /* The real thing. */ |
365 | for (i = 0; i < 8; i++) { | 365 | for (i = 0; i < 8; i++) { |
366 | cycles_t start, end; | 366 | cycles_t start, end; |
367 | 367 | ||
368 | start = get_cycles(); | 368 | start = get_cycles(); |
369 | 369 | ||
370 | ret = crypto_hash_init(desc); | 370 | ret = crypto_hash_init(desc); |
371 | if (ret) | 371 | if (ret) |
372 | goto out; | 372 | goto out; |
373 | for (pcount = 0; pcount < blen; pcount += plen) { | 373 | for (pcount = 0; pcount < blen; pcount += plen) { |
374 | ret = crypto_hash_update(desc, sg, plen); | 374 | ret = crypto_hash_update(desc, sg, plen); |
375 | if (ret) | 375 | if (ret) |
376 | goto out; | 376 | goto out; |
377 | } | 377 | } |
378 | ret = crypto_hash_final(desc, out); | 378 | ret = crypto_hash_final(desc, out); |
379 | if (ret) | 379 | if (ret) |
380 | goto out; | 380 | goto out; |
381 | 381 | ||
382 | end = get_cycles(); | 382 | end = get_cycles(); |
383 | 383 | ||
384 | cycles += end - start; | 384 | cycles += end - start; |
385 | } | 385 | } |
386 | 386 | ||
387 | out: | 387 | out: |
388 | local_irq_enable(); | 388 | local_irq_enable(); |
389 | 389 | ||
390 | if (ret) | 390 | if (ret) |
391 | return ret; | 391 | return ret; |
392 | 392 | ||
393 | printk("%6lu cycles/operation, %4lu cycles/byte\n", | 393 | printk("%6lu cycles/operation, %4lu cycles/byte\n", |
394 | cycles / 8, cycles / (8 * blen)); | 394 | cycles / 8, cycles / (8 * blen)); |
395 | 395 | ||
396 | return 0; | 396 | return 0; |
397 | } | 397 | } |
398 | 398 | ||
399 | static void test_hash_sg_init(struct scatterlist *sg) | 399 | static void test_hash_sg_init(struct scatterlist *sg) |
400 | { | 400 | { |
401 | int i; | 401 | int i; |
402 | 402 | ||
403 | sg_init_table(sg, TVMEMSIZE); | 403 | sg_init_table(sg, TVMEMSIZE); |
404 | for (i = 0; i < TVMEMSIZE; i++) { | 404 | for (i = 0; i < TVMEMSIZE; i++) { |
405 | sg_set_buf(sg + i, tvmem[i], PAGE_SIZE); | 405 | sg_set_buf(sg + i, tvmem[i], PAGE_SIZE); |
406 | memset(tvmem[i], 0xff, PAGE_SIZE); | 406 | memset(tvmem[i], 0xff, PAGE_SIZE); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | static void test_hash_speed(const char *algo, unsigned int sec, | 410 | static void test_hash_speed(const char *algo, unsigned int sec, |
411 | struct hash_speed *speed) | 411 | struct hash_speed *speed) |
412 | { | 412 | { |
413 | struct scatterlist sg[TVMEMSIZE]; | 413 | struct scatterlist sg[TVMEMSIZE]; |
414 | struct crypto_hash *tfm; | 414 | struct crypto_hash *tfm; |
415 | struct hash_desc desc; | 415 | struct hash_desc desc; |
416 | static char output[1024]; | 416 | static char output[1024]; |
417 | int i; | 417 | int i; |
418 | int ret; | 418 | int ret; |
419 | 419 | ||
420 | printk(KERN_INFO "\ntesting speed of %s\n", algo); | 420 | printk(KERN_INFO "\ntesting speed of %s\n", algo); |
421 | 421 | ||
422 | tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC); | 422 | tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC); |
423 | 423 | ||
424 | if (IS_ERR(tfm)) { | 424 | if (IS_ERR(tfm)) { |
425 | printk(KERN_ERR "failed to load transform for %s: %ld\n", algo, | 425 | printk(KERN_ERR "failed to load transform for %s: %ld\n", algo, |
426 | PTR_ERR(tfm)); | 426 | PTR_ERR(tfm)); |
427 | return; | 427 | return; |
428 | } | 428 | } |
429 | 429 | ||
430 | desc.tfm = tfm; | 430 | desc.tfm = tfm; |
431 | desc.flags = 0; | 431 | desc.flags = 0; |
432 | 432 | ||
433 | if (crypto_hash_digestsize(tfm) > sizeof(output)) { | 433 | if (crypto_hash_digestsize(tfm) > sizeof(output)) { |
434 | printk(KERN_ERR "digestsize(%u) > outputbuffer(%zu)\n", | 434 | printk(KERN_ERR "digestsize(%u) > outputbuffer(%zu)\n", |
435 | crypto_hash_digestsize(tfm), sizeof(output)); | 435 | crypto_hash_digestsize(tfm), sizeof(output)); |
436 | goto out; | 436 | goto out; |
437 | } | 437 | } |
438 | 438 | ||
439 | test_hash_sg_init(sg); | 439 | test_hash_sg_init(sg); |
440 | for (i = 0; speed[i].blen != 0; i++) { | 440 | for (i = 0; speed[i].blen != 0; i++) { |
441 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { | 441 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { |
442 | printk(KERN_ERR | 442 | printk(KERN_ERR |
443 | "template (%u) too big for tvmem (%lu)\n", | 443 | "template (%u) too big for tvmem (%lu)\n", |
444 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); | 444 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); |
445 | goto out; | 445 | goto out; |
446 | } | 446 | } |
447 | 447 | ||
448 | if (speed[i].klen) | 448 | if (speed[i].klen) |
449 | crypto_hash_setkey(tfm, tvmem[0], speed[i].klen); | 449 | crypto_hash_setkey(tfm, tvmem[0], speed[i].klen); |
450 | 450 | ||
451 | printk(KERN_INFO "test%3u " | 451 | printk(KERN_INFO "test%3u " |
452 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", | 452 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", |
453 | i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); | 453 | i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); |
454 | 454 | ||
455 | if (sec) | 455 | if (sec) |
456 | ret = test_hash_jiffies(&desc, sg, speed[i].blen, | 456 | ret = test_hash_jiffies(&desc, sg, speed[i].blen, |
457 | speed[i].plen, output, sec); | 457 | speed[i].plen, output, sec); |
458 | else | 458 | else |
459 | ret = test_hash_cycles(&desc, sg, speed[i].blen, | 459 | ret = test_hash_cycles(&desc, sg, speed[i].blen, |
460 | speed[i].plen, output); | 460 | speed[i].plen, output); |
461 | 461 | ||
462 | if (ret) { | 462 | if (ret) { |
463 | printk(KERN_ERR "hashing failed ret=%d\n", ret); | 463 | printk(KERN_ERR "hashing failed ret=%d\n", ret); |
464 | break; | 464 | break; |
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | out: | 468 | out: |
469 | crypto_free_hash(tfm); | 469 | crypto_free_hash(tfm); |
470 | } | 470 | } |
471 | 471 | ||
472 | struct tcrypt_result { | 472 | struct tcrypt_result { |
473 | struct completion completion; | 473 | struct completion completion; |
474 | int err; | 474 | int err; |
475 | }; | 475 | }; |
476 | 476 | ||
477 | static void tcrypt_complete(struct crypto_async_request *req, int err) | 477 | static void tcrypt_complete(struct crypto_async_request *req, int err) |
478 | { | 478 | { |
479 | struct tcrypt_result *res = req->data; | 479 | struct tcrypt_result *res = req->data; |
480 | 480 | ||
481 | if (err == -EINPROGRESS) | 481 | if (err == -EINPROGRESS) |
482 | return; | 482 | return; |
483 | 483 | ||
484 | res->err = err; | 484 | res->err = err; |
485 | complete(&res->completion); | 485 | complete(&res->completion); |
486 | } | 486 | } |
487 | 487 | ||
488 | static inline int do_one_ahash_op(struct ahash_request *req, int ret) | 488 | static inline int do_one_ahash_op(struct ahash_request *req, int ret) |
489 | { | 489 | { |
490 | if (ret == -EINPROGRESS || ret == -EBUSY) { | 490 | if (ret == -EINPROGRESS || ret == -EBUSY) { |
491 | struct tcrypt_result *tr = req->base.data; | 491 | struct tcrypt_result *tr = req->base.data; |
492 | 492 | ||
493 | ret = wait_for_completion_interruptible(&tr->completion); | 493 | ret = wait_for_completion_interruptible(&tr->completion); |
494 | if (!ret) | 494 | if (!ret) |
495 | ret = tr->err; | 495 | ret = tr->err; |
496 | INIT_COMPLETION(tr->completion); | 496 | INIT_COMPLETION(tr->completion); |
497 | } | 497 | } |
498 | return ret; | 498 | return ret; |
499 | } | 499 | } |
500 | 500 | ||
501 | static int test_ahash_jiffies_digest(struct ahash_request *req, int blen, | 501 | static int test_ahash_jiffies_digest(struct ahash_request *req, int blen, |
502 | char *out, int sec) | 502 | char *out, int sec) |
503 | { | 503 | { |
504 | unsigned long start, end; | 504 | unsigned long start, end; |
505 | int bcount; | 505 | int bcount; |
506 | int ret; | 506 | int ret; |
507 | 507 | ||
508 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 508 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
509 | time_before(jiffies, end); bcount++) { | 509 | time_before(jiffies, end); bcount++) { |
510 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); | 510 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
511 | if (ret) | 511 | if (ret) |
512 | return ret; | 512 | return ret; |
513 | } | 513 | } |
514 | 514 | ||
515 | printk("%6u opers/sec, %9lu bytes/sec\n", | 515 | printk("%6u opers/sec, %9lu bytes/sec\n", |
516 | bcount / sec, ((long)bcount * blen) / sec); | 516 | bcount / sec, ((long)bcount * blen) / sec); |
517 | 517 | ||
518 | return 0; | 518 | return 0; |
519 | } | 519 | } |
520 | 520 | ||
521 | static int test_ahash_jiffies(struct ahash_request *req, int blen, | 521 | static int test_ahash_jiffies(struct ahash_request *req, int blen, |
522 | int plen, char *out, int sec) | 522 | int plen, char *out, int sec) |
523 | { | 523 | { |
524 | unsigned long start, end; | 524 | unsigned long start, end; |
525 | int bcount, pcount; | 525 | int bcount, pcount; |
526 | int ret; | 526 | int ret; |
527 | 527 | ||
528 | if (plen == blen) | 528 | if (plen == blen) |
529 | return test_ahash_jiffies_digest(req, blen, out, sec); | 529 | return test_ahash_jiffies_digest(req, blen, out, sec); |
530 | 530 | ||
531 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 531 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
532 | time_before(jiffies, end); bcount++) { | 532 | time_before(jiffies, end); bcount++) { |
533 | ret = crypto_ahash_init(req); | 533 | ret = crypto_ahash_init(req); |
534 | if (ret) | 534 | if (ret) |
535 | return ret; | 535 | return ret; |
536 | for (pcount = 0; pcount < blen; pcount += plen) { | 536 | for (pcount = 0; pcount < blen; pcount += plen) { |
537 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); | 537 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
538 | if (ret) | 538 | if (ret) |
539 | return ret; | 539 | return ret; |
540 | } | 540 | } |
541 | /* we assume there is enough space in 'out' for the result */ | 541 | /* we assume there is enough space in 'out' for the result */ |
542 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); | 542 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
543 | if (ret) | 543 | if (ret) |
544 | return ret; | 544 | return ret; |
545 | } | 545 | } |
546 | 546 | ||
547 | pr_cont("%6u opers/sec, %9lu bytes/sec\n", | 547 | pr_cont("%6u opers/sec, %9lu bytes/sec\n", |
548 | bcount / sec, ((long)bcount * blen) / sec); | 548 | bcount / sec, ((long)bcount * blen) / sec); |
549 | 549 | ||
550 | return 0; | 550 | return 0; |
551 | } | 551 | } |
552 | 552 | ||
553 | static int test_ahash_cycles_digest(struct ahash_request *req, int blen, | 553 | static int test_ahash_cycles_digest(struct ahash_request *req, int blen, |
554 | char *out) | 554 | char *out) |
555 | { | 555 | { |
556 | unsigned long cycles = 0; | 556 | unsigned long cycles = 0; |
557 | int ret, i; | 557 | int ret, i; |
558 | 558 | ||
559 | /* Warm-up run. */ | 559 | /* Warm-up run. */ |
560 | for (i = 0; i < 4; i++) { | 560 | for (i = 0; i < 4; i++) { |
561 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); | 561 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
562 | if (ret) | 562 | if (ret) |
563 | goto out; | 563 | goto out; |
564 | } | 564 | } |
565 | 565 | ||
566 | /* The real thing. */ | 566 | /* The real thing. */ |
567 | for (i = 0; i < 8; i++) { | 567 | for (i = 0; i < 8; i++) { |
568 | cycles_t start, end; | 568 | cycles_t start, end; |
569 | 569 | ||
570 | start = get_cycles(); | 570 | start = get_cycles(); |
571 | 571 | ||
572 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); | 572 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
573 | if (ret) | 573 | if (ret) |
574 | goto out; | 574 | goto out; |
575 | 575 | ||
576 | end = get_cycles(); | 576 | end = get_cycles(); |
577 | 577 | ||
578 | cycles += end - start; | 578 | cycles += end - start; |
579 | } | 579 | } |
580 | 580 | ||
581 | out: | 581 | out: |
582 | if (ret) | 582 | if (ret) |
583 | return ret; | 583 | return ret; |
584 | 584 | ||
585 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", | 585 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", |
586 | cycles / 8, cycles / (8 * blen)); | 586 | cycles / 8, cycles / (8 * blen)); |
587 | 587 | ||
588 | return 0; | 588 | return 0; |
589 | } | 589 | } |
590 | 590 | ||
591 | static int test_ahash_cycles(struct ahash_request *req, int blen, | 591 | static int test_ahash_cycles(struct ahash_request *req, int blen, |
592 | int plen, char *out) | 592 | int plen, char *out) |
593 | { | 593 | { |
594 | unsigned long cycles = 0; | 594 | unsigned long cycles = 0; |
595 | int i, pcount, ret; | 595 | int i, pcount, ret; |
596 | 596 | ||
597 | if (plen == blen) | 597 | if (plen == blen) |
598 | return test_ahash_cycles_digest(req, blen, out); | 598 | return test_ahash_cycles_digest(req, blen, out); |
599 | 599 | ||
600 | /* Warm-up run. */ | 600 | /* Warm-up run. */ |
601 | for (i = 0; i < 4; i++) { | 601 | for (i = 0; i < 4; i++) { |
602 | ret = crypto_ahash_init(req); | 602 | ret = crypto_ahash_init(req); |
603 | if (ret) | 603 | if (ret) |
604 | goto out; | 604 | goto out; |
605 | for (pcount = 0; pcount < blen; pcount += plen) { | 605 | for (pcount = 0; pcount < blen; pcount += plen) { |
606 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); | 606 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
607 | if (ret) | 607 | if (ret) |
608 | goto out; | 608 | goto out; |
609 | } | 609 | } |
610 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); | 610 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
611 | if (ret) | 611 | if (ret) |
612 | goto out; | 612 | goto out; |
613 | } | 613 | } |
614 | 614 | ||
615 | /* The real thing. */ | 615 | /* The real thing. */ |
616 | for (i = 0; i < 8; i++) { | 616 | for (i = 0; i < 8; i++) { |
617 | cycles_t start, end; | 617 | cycles_t start, end; |
618 | 618 | ||
619 | start = get_cycles(); | 619 | start = get_cycles(); |
620 | 620 | ||
621 | ret = crypto_ahash_init(req); | 621 | ret = crypto_ahash_init(req); |
622 | if (ret) | 622 | if (ret) |
623 | goto out; | 623 | goto out; |
624 | for (pcount = 0; pcount < blen; pcount += plen) { | 624 | for (pcount = 0; pcount < blen; pcount += plen) { |
625 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); | 625 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
626 | if (ret) | 626 | if (ret) |
627 | goto out; | 627 | goto out; |
628 | } | 628 | } |
629 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); | 629 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
630 | if (ret) | 630 | if (ret) |
631 | goto out; | 631 | goto out; |
632 | 632 | ||
633 | end = get_cycles(); | 633 | end = get_cycles(); |
634 | 634 | ||
635 | cycles += end - start; | 635 | cycles += end - start; |
636 | } | 636 | } |
637 | 637 | ||
638 | out: | 638 | out: |
639 | if (ret) | 639 | if (ret) |
640 | return ret; | 640 | return ret; |
641 | 641 | ||
642 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", | 642 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", |
643 | cycles / 8, cycles / (8 * blen)); | 643 | cycles / 8, cycles / (8 * blen)); |
644 | 644 | ||
645 | return 0; | 645 | return 0; |
646 | } | 646 | } |
647 | 647 | ||
648 | static void test_ahash_speed(const char *algo, unsigned int sec, | 648 | static void test_ahash_speed(const char *algo, unsigned int sec, |
649 | struct hash_speed *speed) | 649 | struct hash_speed *speed) |
650 | { | 650 | { |
651 | struct scatterlist sg[TVMEMSIZE]; | 651 | struct scatterlist sg[TVMEMSIZE]; |
652 | struct tcrypt_result tresult; | 652 | struct tcrypt_result tresult; |
653 | struct ahash_request *req; | 653 | struct ahash_request *req; |
654 | struct crypto_ahash *tfm; | 654 | struct crypto_ahash *tfm; |
655 | static char output[1024]; | 655 | static char output[1024]; |
656 | int i, ret; | 656 | int i, ret; |
657 | 657 | ||
658 | printk(KERN_INFO "\ntesting speed of async %s\n", algo); | 658 | printk(KERN_INFO "\ntesting speed of async %s\n", algo); |
659 | 659 | ||
660 | tfm = crypto_alloc_ahash(algo, 0, 0); | 660 | tfm = crypto_alloc_ahash(algo, 0, 0); |
661 | if (IS_ERR(tfm)) { | 661 | if (IS_ERR(tfm)) { |
662 | pr_err("failed to load transform for %s: %ld\n", | 662 | pr_err("failed to load transform for %s: %ld\n", |
663 | algo, PTR_ERR(tfm)); | 663 | algo, PTR_ERR(tfm)); |
664 | return; | 664 | return; |
665 | } | 665 | } |
666 | 666 | ||
667 | if (crypto_ahash_digestsize(tfm) > sizeof(output)) { | 667 | if (crypto_ahash_digestsize(tfm) > sizeof(output)) { |
668 | pr_err("digestsize(%u) > outputbuffer(%zu)\n", | 668 | pr_err("digestsize(%u) > outputbuffer(%zu)\n", |
669 | crypto_ahash_digestsize(tfm), sizeof(output)); | 669 | crypto_ahash_digestsize(tfm), sizeof(output)); |
670 | goto out; | 670 | goto out; |
671 | } | 671 | } |
672 | 672 | ||
673 | test_hash_sg_init(sg); | 673 | test_hash_sg_init(sg); |
674 | req = ahash_request_alloc(tfm, GFP_KERNEL); | 674 | req = ahash_request_alloc(tfm, GFP_KERNEL); |
675 | if (!req) { | 675 | if (!req) { |
676 | pr_err("ahash request allocation failure\n"); | 676 | pr_err("ahash request allocation failure\n"); |
677 | goto out; | 677 | goto out; |
678 | } | 678 | } |
679 | 679 | ||
680 | init_completion(&tresult.completion); | 680 | init_completion(&tresult.completion); |
681 | ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, | 681 | ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
682 | tcrypt_complete, &tresult); | 682 | tcrypt_complete, &tresult); |
683 | 683 | ||
684 | for (i = 0; speed[i].blen != 0; i++) { | 684 | for (i = 0; speed[i].blen != 0; i++) { |
685 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { | 685 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { |
686 | pr_err("template (%u) too big for tvmem (%lu)\n", | 686 | pr_err("template (%u) too big for tvmem (%lu)\n", |
687 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); | 687 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); |
688 | break; | 688 | break; |
689 | } | 689 | } |
690 | 690 | ||
691 | pr_info("test%3u " | 691 | pr_info("test%3u " |
692 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", | 692 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", |
693 | i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); | 693 | i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); |
694 | 694 | ||
695 | ahash_request_set_crypt(req, sg, output, speed[i].plen); | 695 | ahash_request_set_crypt(req, sg, output, speed[i].plen); |
696 | 696 | ||
697 | if (sec) | 697 | if (sec) |
698 | ret = test_ahash_jiffies(req, speed[i].blen, | 698 | ret = test_ahash_jiffies(req, speed[i].blen, |
699 | speed[i].plen, output, sec); | 699 | speed[i].plen, output, sec); |
700 | else | 700 | else |
701 | ret = test_ahash_cycles(req, speed[i].blen, | 701 | ret = test_ahash_cycles(req, speed[i].blen, |
702 | speed[i].plen, output); | 702 | speed[i].plen, output); |
703 | 703 | ||
704 | if (ret) { | 704 | if (ret) { |
705 | pr_err("hashing failed ret=%d\n", ret); | 705 | pr_err("hashing failed ret=%d\n", ret); |
706 | break; | 706 | break; |
707 | } | 707 | } |
708 | } | 708 | } |
709 | 709 | ||
710 | ahash_request_free(req); | 710 | ahash_request_free(req); |
711 | 711 | ||
712 | out: | 712 | out: |
713 | crypto_free_ahash(tfm); | 713 | crypto_free_ahash(tfm); |
714 | } | 714 | } |
715 | 715 | ||
716 | static inline int do_one_acipher_op(struct ablkcipher_request *req, int ret) | 716 | static inline int do_one_acipher_op(struct ablkcipher_request *req, int ret) |
717 | { | 717 | { |
718 | if (ret == -EINPROGRESS || ret == -EBUSY) { | 718 | if (ret == -EINPROGRESS || ret == -EBUSY) { |
719 | struct tcrypt_result *tr = req->base.data; | 719 | struct tcrypt_result *tr = req->base.data; |
720 | 720 | ||
721 | ret = wait_for_completion_interruptible(&tr->completion); | 721 | ret = wait_for_completion_interruptible(&tr->completion); |
722 | if (!ret) | 722 | if (!ret) |
723 | ret = tr->err; | 723 | ret = tr->err; |
724 | INIT_COMPLETION(tr->completion); | 724 | INIT_COMPLETION(tr->completion); |
725 | } | 725 | } |
726 | 726 | ||
727 | return ret; | 727 | return ret; |
728 | } | 728 | } |
729 | 729 | ||
730 | static int test_acipher_jiffies(struct ablkcipher_request *req, int enc, | 730 | static int test_acipher_jiffies(struct ablkcipher_request *req, int enc, |
731 | int blen, int sec) | 731 | int blen, int sec) |
732 | { | 732 | { |
733 | unsigned long start, end; | 733 | unsigned long start, end; |
734 | int bcount; | 734 | int bcount; |
735 | int ret; | 735 | int ret; |
736 | 736 | ||
737 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 737 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
738 | time_before(jiffies, end); bcount++) { | 738 | time_before(jiffies, end); bcount++) { |
739 | if (enc) | 739 | if (enc) |
740 | ret = do_one_acipher_op(req, | 740 | ret = do_one_acipher_op(req, |
741 | crypto_ablkcipher_encrypt(req)); | 741 | crypto_ablkcipher_encrypt(req)); |
742 | else | 742 | else |
743 | ret = do_one_acipher_op(req, | 743 | ret = do_one_acipher_op(req, |
744 | crypto_ablkcipher_decrypt(req)); | 744 | crypto_ablkcipher_decrypt(req)); |
745 | 745 | ||
746 | if (ret) | 746 | if (ret) |
747 | return ret; | 747 | return ret; |
748 | } | 748 | } |
749 | 749 | ||
750 | pr_cont("%d operations in %d seconds (%ld bytes)\n", | 750 | pr_cont("%d operations in %d seconds (%ld bytes)\n", |
751 | bcount, sec, (long)bcount * blen); | 751 | bcount, sec, (long)bcount * blen); |
752 | return 0; | 752 | return 0; |
753 | } | 753 | } |
754 | 754 | ||
755 | static int test_acipher_cycles(struct ablkcipher_request *req, int enc, | 755 | static int test_acipher_cycles(struct ablkcipher_request *req, int enc, |
756 | int blen) | 756 | int blen) |
757 | { | 757 | { |
758 | unsigned long cycles = 0; | 758 | unsigned long cycles = 0; |
759 | int ret = 0; | 759 | int ret = 0; |
760 | int i; | 760 | int i; |
761 | 761 | ||
762 | /* Warm-up run. */ | 762 | /* Warm-up run. */ |
763 | for (i = 0; i < 4; i++) { | 763 | for (i = 0; i < 4; i++) { |
764 | if (enc) | 764 | if (enc) |
765 | ret = do_one_acipher_op(req, | 765 | ret = do_one_acipher_op(req, |
766 | crypto_ablkcipher_encrypt(req)); | 766 | crypto_ablkcipher_encrypt(req)); |
767 | else | 767 | else |
768 | ret = do_one_acipher_op(req, | 768 | ret = do_one_acipher_op(req, |
769 | crypto_ablkcipher_decrypt(req)); | 769 | crypto_ablkcipher_decrypt(req)); |
770 | 770 | ||
771 | if (ret) | 771 | if (ret) |
772 | goto out; | 772 | goto out; |
773 | } | 773 | } |
774 | 774 | ||
775 | /* The real thing. */ | 775 | /* The real thing. */ |
776 | for (i = 0; i < 8; i++) { | 776 | for (i = 0; i < 8; i++) { |
777 | cycles_t start, end; | 777 | cycles_t start, end; |
778 | 778 | ||
779 | start = get_cycles(); | 779 | start = get_cycles(); |
780 | if (enc) | 780 | if (enc) |
781 | ret = do_one_acipher_op(req, | 781 | ret = do_one_acipher_op(req, |
782 | crypto_ablkcipher_encrypt(req)); | 782 | crypto_ablkcipher_encrypt(req)); |
783 | else | 783 | else |
784 | ret = do_one_acipher_op(req, | 784 | ret = do_one_acipher_op(req, |
785 | crypto_ablkcipher_decrypt(req)); | 785 | crypto_ablkcipher_decrypt(req)); |
786 | end = get_cycles(); | 786 | end = get_cycles(); |
787 | 787 | ||
788 | if (ret) | 788 | if (ret) |
789 | goto out; | 789 | goto out; |
790 | 790 | ||
791 | cycles += end - start; | 791 | cycles += end - start; |
792 | } | 792 | } |
793 | 793 | ||
794 | out: | 794 | out: |
795 | if (ret == 0) | 795 | if (ret == 0) |
796 | pr_cont("1 operation in %lu cycles (%d bytes)\n", | 796 | pr_cont("1 operation in %lu cycles (%d bytes)\n", |
797 | (cycles + 4) / 8, blen); | 797 | (cycles + 4) / 8, blen); |
798 | 798 | ||
799 | return ret; | 799 | return ret; |
800 | } | 800 | } |
801 | 801 | ||
802 | static void test_acipher_speed(const char *algo, int enc, unsigned int sec, | 802 | static void test_acipher_speed(const char *algo, int enc, unsigned int sec, |
803 | struct cipher_speed_template *template, | 803 | struct cipher_speed_template *template, |
804 | unsigned int tcount, u8 *keysize) | 804 | unsigned int tcount, u8 *keysize) |
805 | { | 805 | { |
806 | unsigned int ret, i, j, k, iv_len; | 806 | unsigned int ret, i, j, k, iv_len; |
807 | struct tcrypt_result tresult; | 807 | struct tcrypt_result tresult; |
808 | const char *key; | 808 | const char *key; |
809 | char iv[128]; | 809 | char iv[128]; |
810 | struct ablkcipher_request *req; | 810 | struct ablkcipher_request *req; |
811 | struct crypto_ablkcipher *tfm; | 811 | struct crypto_ablkcipher *tfm; |
812 | const char *e; | 812 | const char *e; |
813 | u32 *b_size; | 813 | u32 *b_size; |
814 | 814 | ||
815 | if (enc == ENCRYPT) | 815 | if (enc == ENCRYPT) |
816 | e = "encryption"; | 816 | e = "encryption"; |
817 | else | 817 | else |
818 | e = "decryption"; | 818 | e = "decryption"; |
819 | 819 | ||
820 | pr_info("\ntesting speed of async %s %s\n", algo, e); | 820 | pr_info("\ntesting speed of async %s %s\n", algo, e); |
821 | 821 | ||
822 | init_completion(&tresult.completion); | 822 | init_completion(&tresult.completion); |
823 | 823 | ||
824 | tfm = crypto_alloc_ablkcipher(algo, 0, 0); | 824 | tfm = crypto_alloc_ablkcipher(algo, 0, 0); |
825 | 825 | ||
826 | if (IS_ERR(tfm)) { | 826 | if (IS_ERR(tfm)) { |
827 | pr_err("failed to load transform for %s: %ld\n", algo, | 827 | pr_err("failed to load transform for %s: %ld\n", algo, |
828 | PTR_ERR(tfm)); | 828 | PTR_ERR(tfm)); |
829 | return; | 829 | return; |
830 | } | 830 | } |
831 | 831 | ||
832 | req = ablkcipher_request_alloc(tfm, GFP_KERNEL); | 832 | req = ablkcipher_request_alloc(tfm, GFP_KERNEL); |
833 | if (!req) { | 833 | if (!req) { |
834 | pr_err("tcrypt: skcipher: Failed to allocate request for %s\n", | 834 | pr_err("tcrypt: skcipher: Failed to allocate request for %s\n", |
835 | algo); | 835 | algo); |
836 | goto out; | 836 | goto out; |
837 | } | 837 | } |
838 | 838 | ||
839 | ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, | 839 | ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
840 | tcrypt_complete, &tresult); | 840 | tcrypt_complete, &tresult); |
841 | 841 | ||
842 | i = 0; | 842 | i = 0; |
843 | do { | 843 | do { |
844 | b_size = block_sizes; | 844 | b_size = block_sizes; |
845 | 845 | ||
846 | do { | 846 | do { |
847 | struct scatterlist sg[TVMEMSIZE]; | 847 | struct scatterlist sg[TVMEMSIZE]; |
848 | 848 | ||
849 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { | 849 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { |
850 | pr_err("template (%u) too big for " | 850 | pr_err("template (%u) too big for " |
851 | "tvmem (%lu)\n", *keysize + *b_size, | 851 | "tvmem (%lu)\n", *keysize + *b_size, |
852 | TVMEMSIZE * PAGE_SIZE); | 852 | TVMEMSIZE * PAGE_SIZE); |
853 | goto out_free_req; | 853 | goto out_free_req; |
854 | } | 854 | } |
855 | 855 | ||
856 | pr_info("test %u (%d bit key, %d byte blocks): ", i, | 856 | pr_info("test %u (%d bit key, %d byte blocks): ", i, |
857 | *keysize * 8, *b_size); | 857 | *keysize * 8, *b_size); |
858 | 858 | ||
859 | memset(tvmem[0], 0xff, PAGE_SIZE); | 859 | memset(tvmem[0], 0xff, PAGE_SIZE); |
860 | 860 | ||
861 | /* set key, plain text and IV */ | 861 | /* set key, plain text and IV */ |
862 | key = tvmem[0]; | 862 | key = tvmem[0]; |
863 | for (j = 0; j < tcount; j++) { | 863 | for (j = 0; j < tcount; j++) { |
864 | if (template[j].klen == *keysize) { | 864 | if (template[j].klen == *keysize) { |
865 | key = template[j].key; | 865 | key = template[j].key; |
866 | break; | 866 | break; |
867 | } | 867 | } |
868 | } | 868 | } |
869 | 869 | ||
870 | crypto_ablkcipher_clear_flags(tfm, ~0); | 870 | crypto_ablkcipher_clear_flags(tfm, ~0); |
871 | 871 | ||
872 | ret = crypto_ablkcipher_setkey(tfm, key, *keysize); | 872 | ret = crypto_ablkcipher_setkey(tfm, key, *keysize); |
873 | if (ret) { | 873 | if (ret) { |
874 | pr_err("setkey() failed flags=%x\n", | 874 | pr_err("setkey() failed flags=%x\n", |
875 | crypto_ablkcipher_get_flags(tfm)); | 875 | crypto_ablkcipher_get_flags(tfm)); |
876 | goto out_free_req; | 876 | goto out_free_req; |
877 | } | 877 | } |
878 | 878 | ||
879 | sg_init_table(sg, TVMEMSIZE); | 879 | sg_init_table(sg, TVMEMSIZE); |
880 | 880 | ||
881 | k = *keysize + *b_size; | 881 | k = *keysize + *b_size; |
882 | if (k > PAGE_SIZE) { | 882 | if (k > PAGE_SIZE) { |
883 | sg_set_buf(sg, tvmem[0] + *keysize, | 883 | sg_set_buf(sg, tvmem[0] + *keysize, |
884 | PAGE_SIZE - *keysize); | 884 | PAGE_SIZE - *keysize); |
885 | k -= PAGE_SIZE; | 885 | k -= PAGE_SIZE; |
886 | j = 1; | 886 | j = 1; |
887 | while (k > PAGE_SIZE) { | 887 | while (k > PAGE_SIZE) { |
888 | sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); | 888 | sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); |
889 | memset(tvmem[j], 0xff, PAGE_SIZE); | 889 | memset(tvmem[j], 0xff, PAGE_SIZE); |
890 | j++; | 890 | j++; |
891 | k -= PAGE_SIZE; | 891 | k -= PAGE_SIZE; |
892 | } | 892 | } |
893 | sg_set_buf(sg + j, tvmem[j], k); | 893 | sg_set_buf(sg + j, tvmem[j], k); |
894 | memset(tvmem[j], 0xff, k); | 894 | memset(tvmem[j], 0xff, k); |
895 | } else { | 895 | } else { |
896 | sg_set_buf(sg, tvmem[0] + *keysize, *b_size); | 896 | sg_set_buf(sg, tvmem[0] + *keysize, *b_size); |
897 | } | 897 | } |
898 | 898 | ||
899 | iv_len = crypto_ablkcipher_ivsize(tfm); | 899 | iv_len = crypto_ablkcipher_ivsize(tfm); |
900 | if (iv_len) | 900 | if (iv_len) |
901 | memset(&iv, 0xff, iv_len); | 901 | memset(&iv, 0xff, iv_len); |
902 | 902 | ||
903 | ablkcipher_request_set_crypt(req, sg, sg, *b_size, iv); | 903 | ablkcipher_request_set_crypt(req, sg, sg, *b_size, iv); |
904 | 904 | ||
905 | if (sec) | 905 | if (sec) |
906 | ret = test_acipher_jiffies(req, enc, | 906 | ret = test_acipher_jiffies(req, enc, |
907 | *b_size, sec); | 907 | *b_size, sec); |
908 | else | 908 | else |
909 | ret = test_acipher_cycles(req, enc, | 909 | ret = test_acipher_cycles(req, enc, |
910 | *b_size); | 910 | *b_size); |
911 | 911 | ||
912 | if (ret) { | 912 | if (ret) { |
913 | pr_err("%s() failed flags=%x\n", e, | 913 | pr_err("%s() failed flags=%x\n", e, |
914 | crypto_ablkcipher_get_flags(tfm)); | 914 | crypto_ablkcipher_get_flags(tfm)); |
915 | break; | 915 | break; |
916 | } | 916 | } |
917 | b_size++; | 917 | b_size++; |
918 | i++; | 918 | i++; |
919 | } while (*b_size); | 919 | } while (*b_size); |
920 | keysize++; | 920 | keysize++; |
921 | } while (*keysize); | 921 | } while (*keysize); |
922 | 922 | ||
923 | out_free_req: | 923 | out_free_req: |
924 | ablkcipher_request_free(req); | 924 | ablkcipher_request_free(req); |
925 | out: | 925 | out: |
926 | crypto_free_ablkcipher(tfm); | 926 | crypto_free_ablkcipher(tfm); |
927 | } | 927 | } |
928 | 928 | ||
929 | static void test_available(void) | 929 | static void test_available(void) |
930 | { | 930 | { |
931 | char **name = check; | 931 | char **name = check; |
932 | 932 | ||
933 | while (*name) { | 933 | while (*name) { |
934 | printk("alg %s ", *name); | 934 | printk("alg %s ", *name); |
935 | printk(crypto_has_alg(*name, 0, 0) ? | 935 | printk(crypto_has_alg(*name, 0, 0) ? |
936 | "found\n" : "not found\n"); | 936 | "found\n" : "not found\n"); |
937 | name++; | 937 | name++; |
938 | } | 938 | } |
939 | } | 939 | } |
940 | 940 | ||
941 | static inline int tcrypt_test(const char *alg) | 941 | static inline int tcrypt_test(const char *alg) |
942 | { | 942 | { |
943 | int ret; | 943 | int ret; |
944 | 944 | ||
945 | ret = alg_test(alg, alg, 0, 0); | 945 | ret = alg_test(alg, alg, 0, 0); |
946 | /* non-fips algs return -EINVAL in fips mode */ | 946 | /* non-fips algs return -EINVAL in fips mode */ |
947 | if (fips_enabled && ret == -EINVAL) | 947 | if (fips_enabled && ret == -EINVAL) |
948 | ret = 0; | 948 | ret = 0; |
949 | return ret; | 949 | return ret; |
950 | } | 950 | } |
951 | 951 | ||
952 | static int do_test(int m) | 952 | static int do_test(int m) |
953 | { | 953 | { |
954 | int i; | 954 | int i; |
955 | int ret = 0; | 955 | int ret = 0; |
956 | 956 | ||
957 | switch (m) { | 957 | switch (m) { |
958 | case 0: | 958 | case 0: |
959 | for (i = 1; i < 200; i++) | 959 | for (i = 1; i < 200; i++) |
960 | ret += do_test(i); | 960 | ret += do_test(i); |
961 | break; | 961 | break; |
962 | 962 | ||
963 | case 1: | 963 | case 1: |
964 | ret += tcrypt_test("md5"); | 964 | ret += tcrypt_test("md5"); |
965 | break; | 965 | break; |
966 | 966 | ||
967 | case 2: | 967 | case 2: |
968 | ret += tcrypt_test("sha1"); | 968 | ret += tcrypt_test("sha1"); |
969 | break; | 969 | break; |
970 | 970 | ||
971 | case 3: | 971 | case 3: |
972 | ret += tcrypt_test("ecb(des)"); | 972 | ret += tcrypt_test("ecb(des)"); |
973 | ret += tcrypt_test("cbc(des)"); | 973 | ret += tcrypt_test("cbc(des)"); |
974 | break; | 974 | break; |
975 | 975 | ||
976 | case 4: | 976 | case 4: |
977 | ret += tcrypt_test("ecb(des3_ede)"); | 977 | ret += tcrypt_test("ecb(des3_ede)"); |
978 | ret += tcrypt_test("cbc(des3_ede)"); | 978 | ret += tcrypt_test("cbc(des3_ede)"); |
979 | break; | 979 | break; |
980 | 980 | ||
981 | case 5: | 981 | case 5: |
982 | ret += tcrypt_test("md4"); | 982 | ret += tcrypt_test("md4"); |
983 | break; | 983 | break; |
984 | 984 | ||
985 | case 6: | 985 | case 6: |
986 | ret += tcrypt_test("sha256"); | 986 | ret += tcrypt_test("sha256"); |
987 | break; | 987 | break; |
988 | 988 | ||
989 | case 7: | 989 | case 7: |
990 | ret += tcrypt_test("ecb(blowfish)"); | 990 | ret += tcrypt_test("ecb(blowfish)"); |
991 | ret += tcrypt_test("cbc(blowfish)"); | 991 | ret += tcrypt_test("cbc(blowfish)"); |
992 | ret += tcrypt_test("ctr(blowfish)"); | 992 | ret += tcrypt_test("ctr(blowfish)"); |
993 | break; | 993 | break; |
994 | 994 | ||
995 | case 8: | 995 | case 8: |
996 | ret += tcrypt_test("ecb(twofish)"); | 996 | ret += tcrypt_test("ecb(twofish)"); |
997 | ret += tcrypt_test("cbc(twofish)"); | 997 | ret += tcrypt_test("cbc(twofish)"); |
998 | ret += tcrypt_test("ctr(twofish)"); | 998 | ret += tcrypt_test("ctr(twofish)"); |
999 | ret += tcrypt_test("lrw(twofish)"); | 999 | ret += tcrypt_test("lrw(twofish)"); |
1000 | ret += tcrypt_test("xts(twofish)"); | 1000 | ret += tcrypt_test("xts(twofish)"); |
1001 | break; | 1001 | break; |
1002 | 1002 | ||
1003 | case 9: | 1003 | case 9: |
1004 | ret += tcrypt_test("ecb(serpent)"); | 1004 | ret += tcrypt_test("ecb(serpent)"); |
1005 | ret += tcrypt_test("cbc(serpent)"); | 1005 | ret += tcrypt_test("cbc(serpent)"); |
1006 | ret += tcrypt_test("ctr(serpent)"); | 1006 | ret += tcrypt_test("ctr(serpent)"); |
1007 | ret += tcrypt_test("lrw(serpent)"); | 1007 | ret += tcrypt_test("lrw(serpent)"); |
1008 | ret += tcrypt_test("xts(serpent)"); | 1008 | ret += tcrypt_test("xts(serpent)"); |
1009 | break; | 1009 | break; |
1010 | 1010 | ||
1011 | case 10: | 1011 | case 10: |
1012 | ret += tcrypt_test("ecb(aes)"); | 1012 | ret += tcrypt_test("ecb(aes)"); |
1013 | ret += tcrypt_test("cbc(aes)"); | 1013 | ret += tcrypt_test("cbc(aes)"); |
1014 | ret += tcrypt_test("lrw(aes)"); | 1014 | ret += tcrypt_test("lrw(aes)"); |
1015 | ret += tcrypt_test("xts(aes)"); | 1015 | ret += tcrypt_test("xts(aes)"); |
1016 | ret += tcrypt_test("ctr(aes)"); | 1016 | ret += tcrypt_test("ctr(aes)"); |
1017 | ret += tcrypt_test("rfc3686(ctr(aes))"); | 1017 | ret += tcrypt_test("rfc3686(ctr(aes))"); |
1018 | break; | 1018 | break; |
1019 | 1019 | ||
1020 | case 11: | 1020 | case 11: |
1021 | ret += tcrypt_test("sha384"); | 1021 | ret += tcrypt_test("sha384"); |
1022 | break; | 1022 | break; |
1023 | 1023 | ||
1024 | case 12: | 1024 | case 12: |
1025 | ret += tcrypt_test("sha512"); | 1025 | ret += tcrypt_test("sha512"); |
1026 | break; | 1026 | break; |
1027 | 1027 | ||
1028 | case 13: | 1028 | case 13: |
1029 | ret += tcrypt_test("deflate"); | 1029 | ret += tcrypt_test("deflate"); |
1030 | break; | 1030 | break; |
1031 | 1031 | ||
1032 | case 14: | 1032 | case 14: |
1033 | ret += tcrypt_test("ecb(cast5)"); | 1033 | ret += tcrypt_test("ecb(cast5)"); |
1034 | ret += tcrypt_test("cbc(cast5)"); | 1034 | ret += tcrypt_test("cbc(cast5)"); |
1035 | ret += tcrypt_test("ctr(cast5)"); | 1035 | ret += tcrypt_test("ctr(cast5)"); |
1036 | break; | 1036 | break; |
1037 | 1037 | ||
1038 | case 15: | 1038 | case 15: |
1039 | ret += tcrypt_test("ecb(cast6)"); | 1039 | ret += tcrypt_test("ecb(cast6)"); |
1040 | ret += tcrypt_test("cbc(cast6)"); | 1040 | ret += tcrypt_test("cbc(cast6)"); |
1041 | ret += tcrypt_test("ctr(cast6)"); | 1041 | ret += tcrypt_test("ctr(cast6)"); |
1042 | ret += tcrypt_test("lrw(cast6)"); | 1042 | ret += tcrypt_test("lrw(cast6)"); |
1043 | ret += tcrypt_test("xts(cast6)"); | 1043 | ret += tcrypt_test("xts(cast6)"); |
1044 | break; | 1044 | break; |
1045 | 1045 | ||
1046 | case 16: | 1046 | case 16: |
1047 | ret += tcrypt_test("ecb(arc4)"); | 1047 | ret += tcrypt_test("ecb(arc4)"); |
1048 | break; | 1048 | break; |
1049 | 1049 | ||
1050 | case 17: | 1050 | case 17: |
1051 | ret += tcrypt_test("michael_mic"); | 1051 | ret += tcrypt_test("michael_mic"); |
1052 | break; | 1052 | break; |
1053 | 1053 | ||
1054 | case 18: | 1054 | case 18: |
1055 | ret += tcrypt_test("crc32c"); | 1055 | ret += tcrypt_test("crc32c"); |
1056 | break; | 1056 | break; |
1057 | 1057 | ||
1058 | case 19: | 1058 | case 19: |
1059 | ret += tcrypt_test("ecb(tea)"); | 1059 | ret += tcrypt_test("ecb(tea)"); |
1060 | break; | 1060 | break; |
1061 | 1061 | ||
1062 | case 20: | 1062 | case 20: |
1063 | ret += tcrypt_test("ecb(xtea)"); | 1063 | ret += tcrypt_test("ecb(xtea)"); |
1064 | break; | 1064 | break; |
1065 | 1065 | ||
1066 | case 21: | 1066 | case 21: |
1067 | ret += tcrypt_test("ecb(khazad)"); | 1067 | ret += tcrypt_test("ecb(khazad)"); |
1068 | break; | 1068 | break; |
1069 | 1069 | ||
1070 | case 22: | 1070 | case 22: |
1071 | ret += tcrypt_test("wp512"); | 1071 | ret += tcrypt_test("wp512"); |
1072 | break; | 1072 | break; |
1073 | 1073 | ||
1074 | case 23: | 1074 | case 23: |
1075 | ret += tcrypt_test("wp384"); | 1075 | ret += tcrypt_test("wp384"); |
1076 | break; | 1076 | break; |
1077 | 1077 | ||
1078 | case 24: | 1078 | case 24: |
1079 | ret += tcrypt_test("wp256"); | 1079 | ret += tcrypt_test("wp256"); |
1080 | break; | 1080 | break; |
1081 | 1081 | ||
1082 | case 25: | 1082 | case 25: |
1083 | ret += tcrypt_test("ecb(tnepres)"); | 1083 | ret += tcrypt_test("ecb(tnepres)"); |
1084 | break; | 1084 | break; |
1085 | 1085 | ||
1086 | case 26: | 1086 | case 26: |
1087 | ret += tcrypt_test("ecb(anubis)"); | 1087 | ret += tcrypt_test("ecb(anubis)"); |
1088 | ret += tcrypt_test("cbc(anubis)"); | 1088 | ret += tcrypt_test("cbc(anubis)"); |
1089 | break; | 1089 | break; |
1090 | 1090 | ||
1091 | case 27: | 1091 | case 27: |
1092 | ret += tcrypt_test("tgr192"); | 1092 | ret += tcrypt_test("tgr192"); |
1093 | break; | 1093 | break; |
1094 | 1094 | ||
1095 | case 28: | 1095 | case 28: |
1096 | 1096 | ||
1097 | ret += tcrypt_test("tgr160"); | 1097 | ret += tcrypt_test("tgr160"); |
1098 | break; | 1098 | break; |
1099 | 1099 | ||
1100 | case 29: | 1100 | case 29: |
1101 | ret += tcrypt_test("tgr128"); | 1101 | ret += tcrypt_test("tgr128"); |
1102 | break; | 1102 | break; |
1103 | 1103 | ||
1104 | case 30: | 1104 | case 30: |
1105 | ret += tcrypt_test("ecb(xeta)"); | 1105 | ret += tcrypt_test("ecb(xeta)"); |
1106 | break; | 1106 | break; |
1107 | 1107 | ||
1108 | case 31: | 1108 | case 31: |
1109 | ret += tcrypt_test("pcbc(fcrypt)"); | 1109 | ret += tcrypt_test("pcbc(fcrypt)"); |
1110 | break; | 1110 | break; |
1111 | 1111 | ||
1112 | case 32: | 1112 | case 32: |
1113 | ret += tcrypt_test("ecb(camellia)"); | 1113 | ret += tcrypt_test("ecb(camellia)"); |
1114 | ret += tcrypt_test("cbc(camellia)"); | 1114 | ret += tcrypt_test("cbc(camellia)"); |
1115 | ret += tcrypt_test("ctr(camellia)"); | ||
1116 | ret += tcrypt_test("lrw(camellia)"); | ||
1117 | ret += tcrypt_test("xts(camellia)"); | ||
1115 | break; | 1118 | break; |
1116 | case 33: | 1119 | case 33: |
1117 | ret += tcrypt_test("sha224"); | 1120 | ret += tcrypt_test("sha224"); |
1118 | break; | 1121 | break; |
1119 | 1122 | ||
1120 | case 34: | 1123 | case 34: |
1121 | ret += tcrypt_test("salsa20"); | 1124 | ret += tcrypt_test("salsa20"); |
1122 | break; | 1125 | break; |
1123 | 1126 | ||
1124 | case 35: | 1127 | case 35: |
1125 | ret += tcrypt_test("gcm(aes)"); | 1128 | ret += tcrypt_test("gcm(aes)"); |
1126 | break; | 1129 | break; |
1127 | 1130 | ||
1128 | case 36: | 1131 | case 36: |
1129 | ret += tcrypt_test("lzo"); | 1132 | ret += tcrypt_test("lzo"); |
1130 | break; | 1133 | break; |
1131 | 1134 | ||
1132 | case 37: | 1135 | case 37: |
1133 | ret += tcrypt_test("ccm(aes)"); | 1136 | ret += tcrypt_test("ccm(aes)"); |
1134 | break; | 1137 | break; |
1135 | 1138 | ||
1136 | case 38: | 1139 | case 38: |
1137 | ret += tcrypt_test("cts(cbc(aes))"); | 1140 | ret += tcrypt_test("cts(cbc(aes))"); |
1138 | break; | 1141 | break; |
1139 | 1142 | ||
1140 | case 39: | 1143 | case 39: |
1141 | ret += tcrypt_test("rmd128"); | 1144 | ret += tcrypt_test("rmd128"); |
1142 | break; | 1145 | break; |
1143 | 1146 | ||
1144 | case 40: | 1147 | case 40: |
1145 | ret += tcrypt_test("rmd160"); | 1148 | ret += tcrypt_test("rmd160"); |
1146 | break; | 1149 | break; |
1147 | 1150 | ||
1148 | case 41: | 1151 | case 41: |
1149 | ret += tcrypt_test("rmd256"); | 1152 | ret += tcrypt_test("rmd256"); |
1150 | break; | 1153 | break; |
1151 | 1154 | ||
1152 | case 42: | 1155 | case 42: |
1153 | ret += tcrypt_test("rmd320"); | 1156 | ret += tcrypt_test("rmd320"); |
1154 | break; | 1157 | break; |
1155 | 1158 | ||
1156 | case 43: | 1159 | case 43: |
1157 | ret += tcrypt_test("ecb(seed)"); | 1160 | ret += tcrypt_test("ecb(seed)"); |
1158 | break; | 1161 | break; |
1159 | 1162 | ||
1160 | case 44: | 1163 | case 44: |
1161 | ret += tcrypt_test("zlib"); | 1164 | ret += tcrypt_test("zlib"); |
1162 | break; | 1165 | break; |
1163 | 1166 | ||
1164 | case 45: | 1167 | case 45: |
1165 | ret += tcrypt_test("rfc4309(ccm(aes))"); | 1168 | ret += tcrypt_test("rfc4309(ccm(aes))"); |
1169 | break; | ||
1170 | |||
1171 | case 46: | ||
1172 | ret += tcrypt_test("ghash"); | ||
1166 | break; | 1173 | break; |
1167 | 1174 | ||
1168 | case 100: | 1175 | case 100: |
1169 | ret += tcrypt_test("hmac(md5)"); | 1176 | ret += tcrypt_test("hmac(md5)"); |
1170 | break; | 1177 | break; |
1171 | 1178 | ||
1172 | case 101: | 1179 | case 101: |
1173 | ret += tcrypt_test("hmac(sha1)"); | 1180 | ret += tcrypt_test("hmac(sha1)"); |
1174 | break; | 1181 | break; |
1175 | 1182 | ||
1176 | case 102: | 1183 | case 102: |
1177 | ret += tcrypt_test("hmac(sha256)"); | 1184 | ret += tcrypt_test("hmac(sha256)"); |
1178 | break; | 1185 | break; |
1179 | 1186 | ||
1180 | case 103: | 1187 | case 103: |
1181 | ret += tcrypt_test("hmac(sha384)"); | 1188 | ret += tcrypt_test("hmac(sha384)"); |
1182 | break; | 1189 | break; |
1183 | 1190 | ||
1184 | case 104: | 1191 | case 104: |
1185 | ret += tcrypt_test("hmac(sha512)"); | 1192 | ret += tcrypt_test("hmac(sha512)"); |
1186 | break; | 1193 | break; |
1187 | 1194 | ||
1188 | case 105: | 1195 | case 105: |
1189 | ret += tcrypt_test("hmac(sha224)"); | 1196 | ret += tcrypt_test("hmac(sha224)"); |
1190 | break; | 1197 | break; |
1191 | 1198 | ||
1192 | case 106: | 1199 | case 106: |
1193 | ret += tcrypt_test("xcbc(aes)"); | 1200 | ret += tcrypt_test("xcbc(aes)"); |
1194 | break; | 1201 | break; |
1195 | 1202 | ||
1196 | case 107: | 1203 | case 107: |
1197 | ret += tcrypt_test("hmac(rmd128)"); | 1204 | ret += tcrypt_test("hmac(rmd128)"); |
1198 | break; | 1205 | break; |
1199 | 1206 | ||
1200 | case 108: | 1207 | case 108: |
1201 | ret += tcrypt_test("hmac(rmd160)"); | 1208 | ret += tcrypt_test("hmac(rmd160)"); |
1202 | break; | 1209 | break; |
1203 | 1210 | ||
1204 | case 109: | 1211 | case 109: |
1205 | ret += tcrypt_test("vmac(aes)"); | 1212 | ret += tcrypt_test("vmac(aes)"); |
1206 | break; | 1213 | break; |
1207 | case 110: | 1214 | case 110: |
1208 | ret += tcrypt_test("hmac(crc32)"); | 1215 | ret += tcrypt_test("hmac(crc32)"); |
1209 | break; | 1216 | break; |
1210 | 1217 | ||
1211 | case 150: | 1218 | case 150: |
1212 | ret += tcrypt_test("ansi_cprng"); | 1219 | ret += tcrypt_test("ansi_cprng"); |
1213 | break; | 1220 | break; |
1214 | 1221 | ||
1215 | case 151: | 1222 | case 151: |
1216 | ret += tcrypt_test("rfc4106(gcm(aes))"); | 1223 | ret += tcrypt_test("rfc4106(gcm(aes))"); |
1217 | break; | 1224 | break; |
1218 | 1225 | ||
1219 | case 200: | 1226 | case 200: |
1220 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, | 1227 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
1221 | speed_template_16_24_32); | 1228 | speed_template_16_24_32); |
1222 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, | 1229 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
1223 | speed_template_16_24_32); | 1230 | speed_template_16_24_32); |
1224 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, | 1231 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
1225 | speed_template_16_24_32); | 1232 | speed_template_16_24_32); |
1226 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, | 1233 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
1227 | speed_template_16_24_32); | 1234 | speed_template_16_24_32); |
1228 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, | 1235 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
1229 | speed_template_32_40_48); | 1236 | speed_template_32_40_48); |
1230 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, | 1237 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
1231 | speed_template_32_40_48); | 1238 | speed_template_32_40_48); |
1232 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, | 1239 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
1233 | speed_template_32_48_64); | 1240 | speed_template_32_48_64); |
1234 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, | 1241 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
1235 | speed_template_32_48_64); | 1242 | speed_template_32_48_64); |
1236 | test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, | 1243 | test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
1237 | speed_template_16_24_32); | 1244 | speed_template_16_24_32); |
1238 | test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, | 1245 | test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
1239 | speed_template_16_24_32); | 1246 | speed_template_16_24_32); |
1240 | break; | 1247 | break; |
1241 | 1248 | ||
1242 | case 201: | 1249 | case 201: |
1243 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, | 1250 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
1244 | des3_speed_template, DES3_SPEED_VECTORS, | 1251 | des3_speed_template, DES3_SPEED_VECTORS, |
1245 | speed_template_24); | 1252 | speed_template_24); |
1246 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, | 1253 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, |
1247 | des3_speed_template, DES3_SPEED_VECTORS, | 1254 | des3_speed_template, DES3_SPEED_VECTORS, |
1248 | speed_template_24); | 1255 | speed_template_24); |
1249 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, | 1256 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
1250 | des3_speed_template, DES3_SPEED_VECTORS, | 1257 | des3_speed_template, DES3_SPEED_VECTORS, |
1251 | speed_template_24); | 1258 | speed_template_24); |
1252 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, | 1259 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, |
1253 | des3_speed_template, DES3_SPEED_VECTORS, | 1260 | des3_speed_template, DES3_SPEED_VECTORS, |
1254 | speed_template_24); | 1261 | speed_template_24); |
1255 | break; | 1262 | break; |
1256 | 1263 | ||
1257 | case 202: | 1264 | case 202: |
1258 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, | 1265 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
1259 | speed_template_16_24_32); | 1266 | speed_template_16_24_32); |
1260 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, | 1267 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
1261 | speed_template_16_24_32); | 1268 | speed_template_16_24_32); |
1262 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, | 1269 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
1263 | speed_template_16_24_32); | 1270 | speed_template_16_24_32); |
1264 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, | 1271 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
1265 | speed_template_16_24_32); | 1272 | speed_template_16_24_32); |
1266 | test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, | 1273 | test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
1267 | speed_template_16_24_32); | 1274 | speed_template_16_24_32); |
1268 | test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, | 1275 | test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
1269 | speed_template_16_24_32); | 1276 | speed_template_16_24_32); |
1270 | test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, | 1277 | test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
1271 | speed_template_32_40_48); | 1278 | speed_template_32_40_48); |
1272 | test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, | 1279 | test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
1273 | speed_template_32_40_48); | 1280 | speed_template_32_40_48); |
1274 | test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, | 1281 | test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
1275 | speed_template_32_48_64); | 1282 | speed_template_32_48_64); |
1276 | test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, | 1283 | test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
1277 | speed_template_32_48_64); | 1284 | speed_template_32_48_64); |
1278 | break; | 1285 | break; |
1279 | 1286 | ||
1280 | case 203: | 1287 | case 203: |
1281 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, | 1288 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
1282 | speed_template_8_32); | 1289 | speed_template_8_32); |
1283 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, | 1290 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
1284 | speed_template_8_32); | 1291 | speed_template_8_32); |
1285 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, | 1292 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
1286 | speed_template_8_32); | 1293 | speed_template_8_32); |
1287 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, | 1294 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
1288 | speed_template_8_32); | 1295 | speed_template_8_32); |
1289 | test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, | 1296 | test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
1290 | speed_template_8_32); | 1297 | speed_template_8_32); |
1291 | test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, | 1298 | test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, |
1292 | speed_template_8_32); | 1299 | speed_template_8_32); |
1293 | break; | 1300 | break; |
1294 | 1301 | ||
1295 | case 204: | 1302 | case 204: |
1296 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, | 1303 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
1297 | speed_template_8); | 1304 | speed_template_8); |
1298 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, | 1305 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
1299 | speed_template_8); | 1306 | speed_template_8); |
1300 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, | 1307 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
1301 | speed_template_8); | 1308 | speed_template_8); |
1302 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, | 1309 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
1303 | speed_template_8); | 1310 | speed_template_8); |
1304 | break; | 1311 | break; |
1305 | 1312 | ||
1306 | case 205: | 1313 | case 205: |
1307 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, | 1314 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
1308 | speed_template_16_24_32); | 1315 | speed_template_16_24_32); |
1309 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, | 1316 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
1310 | speed_template_16_24_32); | 1317 | speed_template_16_24_32); |
1311 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, | 1318 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
1312 | speed_template_16_24_32); | 1319 | speed_template_16_24_32); |
1313 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, | 1320 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
1314 | speed_template_16_24_32); | 1321 | speed_template_16_24_32); |
1315 | test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, | 1322 | test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
1316 | speed_template_16_24_32); | 1323 | speed_template_16_24_32); |
1317 | test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, | 1324 | test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, |
1318 | speed_template_16_24_32); | 1325 | speed_template_16_24_32); |
1319 | test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, | 1326 | test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, |
1320 | speed_template_32_40_48); | 1327 | speed_template_32_40_48); |
1321 | test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, | 1328 | test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, |
1322 | speed_template_32_40_48); | 1329 | speed_template_32_40_48); |
1323 | test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, | 1330 | test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, |
1324 | speed_template_32_48_64); | 1331 | speed_template_32_48_64); |
1325 | test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, | 1332 | test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, |
1326 | speed_template_32_48_64); | 1333 | speed_template_32_48_64); |
1327 | break; | 1334 | break; |
1328 | 1335 | ||
1329 | case 206: | 1336 | case 206: |
1330 | test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, | 1337 | test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, |
1331 | speed_template_16_32); | 1338 | speed_template_16_32); |
1332 | break; | 1339 | break; |
1333 | 1340 | ||
1334 | case 207: | 1341 | case 207: |
1335 | test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, | 1342 | test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
1336 | speed_template_16_32); | 1343 | speed_template_16_32); |
1337 | test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, | 1344 | test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
1338 | speed_template_16_32); | 1345 | speed_template_16_32); |
1339 | test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, | 1346 | test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
1340 | speed_template_16_32); | 1347 | speed_template_16_32); |
1341 | test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, | 1348 | test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
1342 | speed_template_16_32); | 1349 | speed_template_16_32); |
1343 | test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, | 1350 | test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
1344 | speed_template_16_32); | 1351 | speed_template_16_32); |
1345 | test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, | 1352 | test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
1346 | speed_template_16_32); | 1353 | speed_template_16_32); |
1347 | test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, | 1354 | test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
1348 | speed_template_32_48); | 1355 | speed_template_32_48); |
1349 | test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, | 1356 | test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
1350 | speed_template_32_48); | 1357 | speed_template_32_48); |
1351 | test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, | 1358 | test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
1352 | speed_template_32_64); | 1359 | speed_template_32_64); |
1353 | test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, | 1360 | test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
1354 | speed_template_32_64); | 1361 | speed_template_32_64); |
1355 | break; | 1362 | break; |
1356 | 1363 | ||
1357 | case 208: | 1364 | case 208: |
1358 | test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, | 1365 | test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
1359 | speed_template_8); | 1366 | speed_template_8); |
1360 | break; | 1367 | break; |
1361 | 1368 | ||
1362 | case 209: | 1369 | case 209: |
1363 | test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, | 1370 | test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
1364 | speed_template_8_16); | 1371 | speed_template_8_16); |
1365 | test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, | 1372 | test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
1366 | speed_template_8_16); | 1373 | speed_template_8_16); |
1367 | test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, | 1374 | test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
1368 | speed_template_8_16); | 1375 | speed_template_8_16); |
1369 | test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, | 1376 | test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
1370 | speed_template_8_16); | 1377 | speed_template_8_16); |
1371 | test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, | 1378 | test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
1372 | speed_template_8_16); | 1379 | speed_template_8_16); |
1373 | test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, | 1380 | test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
1374 | speed_template_8_16); | 1381 | speed_template_8_16); |
1375 | break; | 1382 | break; |
1376 | 1383 | ||
1377 | case 210: | 1384 | case 210: |
1378 | test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, | 1385 | test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
1379 | speed_template_16_32); | 1386 | speed_template_16_32); |
1380 | test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, | 1387 | test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
1381 | speed_template_16_32); | 1388 | speed_template_16_32); |
1382 | test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, | 1389 | test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
1383 | speed_template_16_32); | 1390 | speed_template_16_32); |
1384 | test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, | 1391 | test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
1385 | speed_template_16_32); | 1392 | speed_template_16_32); |
1386 | test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, | 1393 | test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
1387 | speed_template_16_32); | 1394 | speed_template_16_32); |
1388 | test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, | 1395 | test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
1389 | speed_template_16_32); | 1396 | speed_template_16_32); |
1390 | test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, | 1397 | test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
1391 | speed_template_32_48); | 1398 | speed_template_32_48); |
1392 | test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, | 1399 | test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
1393 | speed_template_32_48); | 1400 | speed_template_32_48); |
1394 | test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, | 1401 | test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
1395 | speed_template_32_64); | 1402 | speed_template_32_64); |
1396 | test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, | 1403 | test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
1397 | speed_template_32_64); | 1404 | speed_template_32_64); |
1398 | break; | 1405 | break; |
1399 | 1406 | ||
1400 | case 300: | 1407 | case 300: |
1401 | /* fall through */ | 1408 | /* fall through */ |
1402 | 1409 | ||
1403 | case 301: | 1410 | case 301: |
1404 | test_hash_speed("md4", sec, generic_hash_speed_template); | 1411 | test_hash_speed("md4", sec, generic_hash_speed_template); |
1405 | if (mode > 300 && mode < 400) break; | 1412 | if (mode > 300 && mode < 400) break; |
1406 | 1413 | ||
1407 | case 302: | 1414 | case 302: |
1408 | test_hash_speed("md5", sec, generic_hash_speed_template); | 1415 | test_hash_speed("md5", sec, generic_hash_speed_template); |
1409 | if (mode > 300 && mode < 400) break; | 1416 | if (mode > 300 && mode < 400) break; |
1410 | 1417 | ||
1411 | case 303: | 1418 | case 303: |
1412 | test_hash_speed("sha1", sec, generic_hash_speed_template); | 1419 | test_hash_speed("sha1", sec, generic_hash_speed_template); |
1413 | if (mode > 300 && mode < 400) break; | 1420 | if (mode > 300 && mode < 400) break; |
1414 | 1421 | ||
1415 | case 304: | 1422 | case 304: |
1416 | test_hash_speed("sha256", sec, generic_hash_speed_template); | 1423 | test_hash_speed("sha256", sec, generic_hash_speed_template); |
1417 | if (mode > 300 && mode < 400) break; | 1424 | if (mode > 300 && mode < 400) break; |
1418 | 1425 | ||
1419 | case 305: | 1426 | case 305: |
1420 | test_hash_speed("sha384", sec, generic_hash_speed_template); | 1427 | test_hash_speed("sha384", sec, generic_hash_speed_template); |
1421 | if (mode > 300 && mode < 400) break; | 1428 | if (mode > 300 && mode < 400) break; |
1422 | 1429 | ||
1423 | case 306: | 1430 | case 306: |
1424 | test_hash_speed("sha512", sec, generic_hash_speed_template); | 1431 | test_hash_speed("sha512", sec, generic_hash_speed_template); |
1425 | if (mode > 300 && mode < 400) break; | 1432 | if (mode > 300 && mode < 400) break; |
1426 | 1433 | ||
1427 | case 307: | 1434 | case 307: |
1428 | test_hash_speed("wp256", sec, generic_hash_speed_template); | 1435 | test_hash_speed("wp256", sec, generic_hash_speed_template); |
1429 | if (mode > 300 && mode < 400) break; | 1436 | if (mode > 300 && mode < 400) break; |
1430 | 1437 | ||
1431 | case 308: | 1438 | case 308: |
1432 | test_hash_speed("wp384", sec, generic_hash_speed_template); | 1439 | test_hash_speed("wp384", sec, generic_hash_speed_template); |
1433 | if (mode > 300 && mode < 400) break; | 1440 | if (mode > 300 && mode < 400) break; |
1434 | 1441 | ||
1435 | case 309: | 1442 | case 309: |
1436 | test_hash_speed("wp512", sec, generic_hash_speed_template); | 1443 | test_hash_speed("wp512", sec, generic_hash_speed_template); |
1437 | if (mode > 300 && mode < 400) break; | 1444 | if (mode > 300 && mode < 400) break; |
1438 | 1445 | ||
1439 | case 310: | 1446 | case 310: |
1440 | test_hash_speed("tgr128", sec, generic_hash_speed_template); | 1447 | test_hash_speed("tgr128", sec, generic_hash_speed_template); |
1441 | if (mode > 300 && mode < 400) break; | 1448 | if (mode > 300 && mode < 400) break; |
1442 | 1449 | ||
1443 | case 311: | 1450 | case 311: |
1444 | test_hash_speed("tgr160", sec, generic_hash_speed_template); | 1451 | test_hash_speed("tgr160", sec, generic_hash_speed_template); |
1445 | if (mode > 300 && mode < 400) break; | 1452 | if (mode > 300 && mode < 400) break; |
1446 | 1453 | ||
1447 | case 312: | 1454 | case 312: |
1448 | test_hash_speed("tgr192", sec, generic_hash_speed_template); | 1455 | test_hash_speed("tgr192", sec, generic_hash_speed_template); |
1449 | if (mode > 300 && mode < 400) break; | 1456 | if (mode > 300 && mode < 400) break; |
1450 | 1457 | ||
1451 | case 313: | 1458 | case 313: |
1452 | test_hash_speed("sha224", sec, generic_hash_speed_template); | 1459 | test_hash_speed("sha224", sec, generic_hash_speed_template); |
1453 | if (mode > 300 && mode < 400) break; | 1460 | if (mode > 300 && mode < 400) break; |
1454 | 1461 | ||
1455 | case 314: | 1462 | case 314: |
1456 | test_hash_speed("rmd128", sec, generic_hash_speed_template); | 1463 | test_hash_speed("rmd128", sec, generic_hash_speed_template); |
1457 | if (mode > 300 && mode < 400) break; | 1464 | if (mode > 300 && mode < 400) break; |
1458 | 1465 | ||
1459 | case 315: | 1466 | case 315: |
1460 | test_hash_speed("rmd160", sec, generic_hash_speed_template); | 1467 | test_hash_speed("rmd160", sec, generic_hash_speed_template); |
1461 | if (mode > 300 && mode < 400) break; | 1468 | if (mode > 300 && mode < 400) break; |
1462 | 1469 | ||
1463 | case 316: | 1470 | case 316: |
1464 | test_hash_speed("rmd256", sec, generic_hash_speed_template); | 1471 | test_hash_speed("rmd256", sec, generic_hash_speed_template); |
1465 | if (mode > 300 && mode < 400) break; | 1472 | if (mode > 300 && mode < 400) break; |
1466 | 1473 | ||
1467 | case 317: | 1474 | case 317: |
1468 | test_hash_speed("rmd320", sec, generic_hash_speed_template); | 1475 | test_hash_speed("rmd320", sec, generic_hash_speed_template); |
1469 | if (mode > 300 && mode < 400) break; | 1476 | if (mode > 300 && mode < 400) break; |
1470 | 1477 | ||
1471 | case 318: | 1478 | case 318: |
1472 | test_hash_speed("ghash-generic", sec, hash_speed_template_16); | 1479 | test_hash_speed("ghash-generic", sec, hash_speed_template_16); |
1473 | if (mode > 300 && mode < 400) break; | 1480 | if (mode > 300 && mode < 400) break; |
1474 | 1481 | ||
1475 | case 399: | 1482 | case 399: |
1476 | break; | 1483 | break; |
1477 | 1484 | ||
1478 | case 400: | 1485 | case 400: |
1479 | /* fall through */ | 1486 | /* fall through */ |
1480 | 1487 | ||
1481 | case 401: | 1488 | case 401: |
1482 | test_ahash_speed("md4", sec, generic_hash_speed_template); | 1489 | test_ahash_speed("md4", sec, generic_hash_speed_template); |
1483 | if (mode > 400 && mode < 500) break; | 1490 | if (mode > 400 && mode < 500) break; |
1484 | 1491 | ||
1485 | case 402: | 1492 | case 402: |
1486 | test_ahash_speed("md5", sec, generic_hash_speed_template); | 1493 | test_ahash_speed("md5", sec, generic_hash_speed_template); |
1487 | if (mode > 400 && mode < 500) break; | 1494 | if (mode > 400 && mode < 500) break; |
1488 | 1495 | ||
1489 | case 403: | 1496 | case 403: |
1490 | test_ahash_speed("sha1", sec, generic_hash_speed_template); | 1497 | test_ahash_speed("sha1", sec, generic_hash_speed_template); |
1491 | if (mode > 400 && mode < 500) break; | 1498 | if (mode > 400 && mode < 500) break; |
1492 | 1499 | ||
1493 | case 404: | 1500 | case 404: |
1494 | test_ahash_speed("sha256", sec, generic_hash_speed_template); | 1501 | test_ahash_speed("sha256", sec, generic_hash_speed_template); |
1495 | if (mode > 400 && mode < 500) break; | 1502 | if (mode > 400 && mode < 500) break; |
1496 | 1503 | ||
1497 | case 405: | 1504 | case 405: |
1498 | test_ahash_speed("sha384", sec, generic_hash_speed_template); | 1505 | test_ahash_speed("sha384", sec, generic_hash_speed_template); |
1499 | if (mode > 400 && mode < 500) break; | 1506 | if (mode > 400 && mode < 500) break; |
1500 | 1507 | ||
1501 | case 406: | 1508 | case 406: |
1502 | test_ahash_speed("sha512", sec, generic_hash_speed_template); | 1509 | test_ahash_speed("sha512", sec, generic_hash_speed_template); |
1503 | if (mode > 400 && mode < 500) break; | 1510 | if (mode > 400 && mode < 500) break; |
1504 | 1511 | ||
1505 | case 407: | 1512 | case 407: |
1506 | test_ahash_speed("wp256", sec, generic_hash_speed_template); | 1513 | test_ahash_speed("wp256", sec, generic_hash_speed_template); |
1507 | if (mode > 400 && mode < 500) break; | 1514 | if (mode > 400 && mode < 500) break; |
1508 | 1515 | ||
1509 | case 408: | 1516 | case 408: |
1510 | test_ahash_speed("wp384", sec, generic_hash_speed_template); | 1517 | test_ahash_speed("wp384", sec, generic_hash_speed_template); |
1511 | if (mode > 400 && mode < 500) break; | 1518 | if (mode > 400 && mode < 500) break; |
1512 | 1519 | ||
1513 | case 409: | 1520 | case 409: |
1514 | test_ahash_speed("wp512", sec, generic_hash_speed_template); | 1521 | test_ahash_speed("wp512", sec, generic_hash_speed_template); |
1515 | if (mode > 400 && mode < 500) break; | 1522 | if (mode > 400 && mode < 500) break; |
1516 | 1523 | ||
1517 | case 410: | 1524 | case 410: |
1518 | test_ahash_speed("tgr128", sec, generic_hash_speed_template); | 1525 | test_ahash_speed("tgr128", sec, generic_hash_speed_template); |
1519 | if (mode > 400 && mode < 500) break; | 1526 | if (mode > 400 && mode < 500) break; |
1520 | 1527 | ||
1521 | case 411: | 1528 | case 411: |
1522 | test_ahash_speed("tgr160", sec, generic_hash_speed_template); | 1529 | test_ahash_speed("tgr160", sec, generic_hash_speed_template); |
1523 | if (mode > 400 && mode < 500) break; | 1530 | if (mode > 400 && mode < 500) break; |
1524 | 1531 | ||
1525 | case 412: | 1532 | case 412: |
1526 | test_ahash_speed("tgr192", sec, generic_hash_speed_template); | 1533 | test_ahash_speed("tgr192", sec, generic_hash_speed_template); |
1527 | if (mode > 400 && mode < 500) break; | 1534 | if (mode > 400 && mode < 500) break; |
1528 | 1535 | ||
1529 | case 413: | 1536 | case 413: |
1530 | test_ahash_speed("sha224", sec, generic_hash_speed_template); | 1537 | test_ahash_speed("sha224", sec, generic_hash_speed_template); |
1531 | if (mode > 400 && mode < 500) break; | 1538 | if (mode > 400 && mode < 500) break; |
1532 | 1539 | ||
1533 | case 414: | 1540 | case 414: |
1534 | test_ahash_speed("rmd128", sec, generic_hash_speed_template); | 1541 | test_ahash_speed("rmd128", sec, generic_hash_speed_template); |
1535 | if (mode > 400 && mode < 500) break; | 1542 | if (mode > 400 && mode < 500) break; |
1536 | 1543 | ||
1537 | case 415: | 1544 | case 415: |
1538 | test_ahash_speed("rmd160", sec, generic_hash_speed_template); | 1545 | test_ahash_speed("rmd160", sec, generic_hash_speed_template); |
1539 | if (mode > 400 && mode < 500) break; | 1546 | if (mode > 400 && mode < 500) break; |
1540 | 1547 | ||
1541 | case 416: | 1548 | case 416: |
1542 | test_ahash_speed("rmd256", sec, generic_hash_speed_template); | 1549 | test_ahash_speed("rmd256", sec, generic_hash_speed_template); |
1543 | if (mode > 400 && mode < 500) break; | 1550 | if (mode > 400 && mode < 500) break; |
1544 | 1551 | ||
1545 | case 417: | 1552 | case 417: |
1546 | test_ahash_speed("rmd320", sec, generic_hash_speed_template); | 1553 | test_ahash_speed("rmd320", sec, generic_hash_speed_template); |
1547 | if (mode > 400 && mode < 500) break; | 1554 | if (mode > 400 && mode < 500) break; |
1548 | 1555 | ||
1549 | case 499: | 1556 | case 499: |
1550 | break; | 1557 | break; |
1551 | 1558 | ||
1552 | case 500: | 1559 | case 500: |
1553 | test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, | 1560 | test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
1554 | speed_template_16_24_32); | 1561 | speed_template_16_24_32); |
1555 | test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, | 1562 | test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
1556 | speed_template_16_24_32); | 1563 | speed_template_16_24_32); |
1557 | test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, | 1564 | test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
1558 | speed_template_16_24_32); | 1565 | speed_template_16_24_32); |
1559 | test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, | 1566 | test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
1560 | speed_template_16_24_32); | 1567 | speed_template_16_24_32); |
1561 | test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, | 1568 | test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
1562 | speed_template_32_40_48); | 1569 | speed_template_32_40_48); |
1563 | test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, | 1570 | test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
1564 | speed_template_32_40_48); | 1571 | speed_template_32_40_48); |
1565 | test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, | 1572 | test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
1566 | speed_template_32_48_64); | 1573 | speed_template_32_48_64); |
1567 | test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, | 1574 | test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
1568 | speed_template_32_48_64); | 1575 | speed_template_32_48_64); |
1569 | test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, | 1576 | test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
1570 | speed_template_16_24_32); | 1577 | speed_template_16_24_32); |
1571 | test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, | 1578 | test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
1572 | speed_template_16_24_32); | 1579 | speed_template_16_24_32); |
1573 | test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0, | 1580 | test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0, |
1574 | speed_template_16_24_32); | 1581 | speed_template_16_24_32); |
1575 | test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0, | 1582 | test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0, |
1576 | speed_template_16_24_32); | 1583 | speed_template_16_24_32); |
1577 | test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0, | 1584 | test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0, |
1578 | speed_template_16_24_32); | 1585 | speed_template_16_24_32); |
1579 | test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0, | 1586 | test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0, |
1580 | speed_template_16_24_32); | 1587 | speed_template_16_24_32); |
1581 | break; | 1588 | break; |
1582 | 1589 | ||
1583 | case 501: | 1590 | case 501: |
1584 | test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec, | 1591 | test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
1585 | des3_speed_template, DES3_SPEED_VECTORS, | 1592 | des3_speed_template, DES3_SPEED_VECTORS, |
1586 | speed_template_24); | 1593 | speed_template_24); |
1587 | test_acipher_speed("ecb(des3_ede)", DECRYPT, sec, | 1594 | test_acipher_speed("ecb(des3_ede)", DECRYPT, sec, |
1588 | des3_speed_template, DES3_SPEED_VECTORS, | 1595 | des3_speed_template, DES3_SPEED_VECTORS, |
1589 | speed_template_24); | 1596 | speed_template_24); |
1590 | test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec, | 1597 | test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
1591 | des3_speed_template, DES3_SPEED_VECTORS, | 1598 | des3_speed_template, DES3_SPEED_VECTORS, |
1592 | speed_template_24); | 1599 | speed_template_24); |
1593 | test_acipher_speed("cbc(des3_ede)", DECRYPT, sec, | 1600 | test_acipher_speed("cbc(des3_ede)", DECRYPT, sec, |
1594 | des3_speed_template, DES3_SPEED_VECTORS, | 1601 | des3_speed_template, DES3_SPEED_VECTORS, |
1595 | speed_template_24); | 1602 | speed_template_24); |
1596 | test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec, | 1603 | test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec, |
1597 | des3_speed_template, DES3_SPEED_VECTORS, | 1604 | des3_speed_template, DES3_SPEED_VECTORS, |
1598 | speed_template_24); | 1605 | speed_template_24); |
1599 | test_acipher_speed("cfb(des3_ede)", DECRYPT, sec, | 1606 | test_acipher_speed("cfb(des3_ede)", DECRYPT, sec, |
1600 | des3_speed_template, DES3_SPEED_VECTORS, | 1607 | des3_speed_template, DES3_SPEED_VECTORS, |
1601 | speed_template_24); | 1608 | speed_template_24); |
1602 | test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec, | 1609 | test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec, |
1603 | des3_speed_template, DES3_SPEED_VECTORS, | 1610 | des3_speed_template, DES3_SPEED_VECTORS, |
1604 | speed_template_24); | 1611 | speed_template_24); |
1605 | test_acipher_speed("ofb(des3_ede)", DECRYPT, sec, | 1612 | test_acipher_speed("ofb(des3_ede)", DECRYPT, sec, |
1606 | des3_speed_template, DES3_SPEED_VECTORS, | 1613 | des3_speed_template, DES3_SPEED_VECTORS, |
1607 | speed_template_24); | 1614 | speed_template_24); |
1608 | break; | 1615 | break; |
1609 | 1616 | ||
1610 | case 502: | 1617 | case 502: |
1611 | test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, | 1618 | test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
1612 | speed_template_8); | 1619 | speed_template_8); |
1613 | test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, | 1620 | test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
1614 | speed_template_8); | 1621 | speed_template_8); |
1615 | test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, | 1622 | test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
1616 | speed_template_8); | 1623 | speed_template_8); |
1617 | test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, | 1624 | test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
1618 | speed_template_8); | 1625 | speed_template_8); |
1619 | test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0, | 1626 | test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0, |
1620 | speed_template_8); | 1627 | speed_template_8); |
1621 | test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0, | 1628 | test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0, |
1622 | speed_template_8); | 1629 | speed_template_8); |
1623 | test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0, | 1630 | test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0, |
1624 | speed_template_8); | 1631 | speed_template_8); |
1625 | test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0, | 1632 | test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0, |
1626 | speed_template_8); | 1633 | speed_template_8); |
1627 | break; | 1634 | break; |
1628 | 1635 | ||
1629 | case 503: | 1636 | case 503: |
1630 | test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, | 1637 | test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
1631 | speed_template_16_32); | 1638 | speed_template_16_32); |
1632 | test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, | 1639 | test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
1633 | speed_template_16_32); | 1640 | speed_template_16_32); |
1634 | test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, | 1641 | test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
1635 | speed_template_16_32); | 1642 | speed_template_16_32); |
1636 | test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, | 1643 | test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
1637 | speed_template_16_32); | 1644 | speed_template_16_32); |
1638 | test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, | 1645 | test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
1639 | speed_template_16_32); | 1646 | speed_template_16_32); |
1640 | test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, | 1647 | test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
1641 | speed_template_16_32); | 1648 | speed_template_16_32); |
1642 | test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, | 1649 | test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
1643 | speed_template_32_48); | 1650 | speed_template_32_48); |
1644 | test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, | 1651 | test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
1645 | speed_template_32_48); | 1652 | speed_template_32_48); |
1646 | test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, | 1653 | test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
1647 | speed_template_32_64); | 1654 | speed_template_32_64); |
1648 | test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, | 1655 | test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
1649 | speed_template_32_64); | 1656 | speed_template_32_64); |
1650 | break; | 1657 | break; |
1651 | 1658 | ||
1652 | case 504: | 1659 | case 504: |
1653 | test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, | 1660 | test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
1654 | speed_template_16_24_32); | 1661 | speed_template_16_24_32); |
1655 | test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, | 1662 | test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
1656 | speed_template_16_24_32); | 1663 | speed_template_16_24_32); |
1657 | test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, | 1664 | test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
1658 | speed_template_16_24_32); | 1665 | speed_template_16_24_32); |
1659 | test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, | 1666 | test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
1660 | speed_template_16_24_32); | 1667 | speed_template_16_24_32); |
1661 | test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, | 1668 | test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
1662 | speed_template_16_24_32); | 1669 | speed_template_16_24_32); |
1663 | test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, | 1670 | test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
1664 | speed_template_16_24_32); | 1671 | speed_template_16_24_32); |
1665 | test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, | 1672 | test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
1666 | speed_template_32_40_48); | 1673 | speed_template_32_40_48); |
1667 | test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, | 1674 | test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
1668 | speed_template_32_40_48); | 1675 | speed_template_32_40_48); |
1669 | test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, | 1676 | test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
1670 | speed_template_32_48_64); | 1677 | speed_template_32_48_64); |
1671 | test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, | 1678 | test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
1672 | speed_template_32_48_64); | 1679 | speed_template_32_48_64); |
1673 | break; | 1680 | break; |
1674 | 1681 | ||
1675 | case 505: | 1682 | case 505: |
1676 | test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, | 1683 | test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
1677 | speed_template_8); | 1684 | speed_template_8); |
1678 | break; | 1685 | break; |
1679 | 1686 | ||
1680 | case 506: | 1687 | case 506: |
1681 | test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, | 1688 | test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
1682 | speed_template_8_16); | 1689 | speed_template_8_16); |
1683 | test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, | 1690 | test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
1684 | speed_template_8_16); | 1691 | speed_template_8_16); |
1685 | test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, | 1692 | test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
1686 | speed_template_8_16); | 1693 | speed_template_8_16); |
1687 | test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, | 1694 | test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
1688 | speed_template_8_16); | 1695 | speed_template_8_16); |
1689 | test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, | 1696 | test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
1690 | speed_template_8_16); | 1697 | speed_template_8_16); |
1691 | test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, | 1698 | test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
1692 | speed_template_8_16); | 1699 | speed_template_8_16); |
1693 | break; | 1700 | break; |
1694 | 1701 | ||
1695 | case 507: | 1702 | case 507: |
1696 | test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, | 1703 | test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
1697 | speed_template_16_32); | 1704 | speed_template_16_32); |
1698 | test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, | 1705 | test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
1699 | speed_template_16_32); | 1706 | speed_template_16_32); |
1700 | test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, | 1707 | test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
1701 | speed_template_16_32); | 1708 | speed_template_16_32); |
1702 | test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, | 1709 | test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
1703 | speed_template_16_32); | 1710 | speed_template_16_32); |
1704 | test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, | 1711 | test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
1705 | speed_template_16_32); | 1712 | speed_template_16_32); |
1706 | test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, | 1713 | test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
1707 | speed_template_16_32); | 1714 | speed_template_16_32); |
1708 | test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, | 1715 | test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
1709 | speed_template_32_48); | 1716 | speed_template_32_48); |
1710 | test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, | 1717 | test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
1711 | speed_template_32_48); | 1718 | speed_template_32_48); |
1712 | test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, | 1719 | test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
1713 | speed_template_32_64); | 1720 | speed_template_32_64); |
1714 | test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, | 1721 | test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
1715 | speed_template_32_64); | 1722 | speed_template_32_64); |
1716 | break; | 1723 | break; |
1717 | 1724 | ||
1718 | case 1000: | 1725 | case 1000: |
1719 | test_available(); | 1726 | test_available(); |
1720 | break; | 1727 | break; |
1721 | } | 1728 | } |
1722 | 1729 | ||
1723 | return ret; | 1730 | return ret; |
1724 | } | 1731 | } |
1725 | 1732 | ||
1726 | static int do_alg_test(const char *alg, u32 type, u32 mask) | 1733 | static int do_alg_test(const char *alg, u32 type, u32 mask) |
1727 | { | 1734 | { |
1728 | return crypto_has_alg(alg, type, mask ?: CRYPTO_ALG_TYPE_MASK) ? | 1735 | return crypto_has_alg(alg, type, mask ?: CRYPTO_ALG_TYPE_MASK) ? |
1729 | 0 : -ENOENT; | 1736 | 0 : -ENOENT; |
1730 | } | 1737 | } |
1731 | 1738 | ||
1732 | static int __init tcrypt_mod_init(void) | 1739 | static int __init tcrypt_mod_init(void) |
1733 | { | 1740 | { |
1734 | int err = -ENOMEM; | 1741 | int err = -ENOMEM; |
1735 | int i; | 1742 | int i; |
1736 | 1743 | ||
1737 | for (i = 0; i < TVMEMSIZE; i++) { | 1744 | for (i = 0; i < TVMEMSIZE; i++) { |
1738 | tvmem[i] = (void *)__get_free_page(GFP_KERNEL); | 1745 | tvmem[i] = (void *)__get_free_page(GFP_KERNEL); |
1739 | if (!tvmem[i]) | 1746 | if (!tvmem[i]) |
1740 | goto err_free_tv; | 1747 | goto err_free_tv; |
1741 | } | 1748 | } |
1742 | 1749 | ||
1743 | if (alg) | 1750 | if (alg) |
1744 | err = do_alg_test(alg, type, mask); | 1751 | err = do_alg_test(alg, type, mask); |
1745 | else | 1752 | else |
1746 | err = do_test(mode); | 1753 | err = do_test(mode); |
1747 | 1754 | ||
1748 | if (err) { | 1755 | if (err) { |
1749 | printk(KERN_ERR "tcrypt: one or more tests failed!\n"); | 1756 | printk(KERN_ERR "tcrypt: one or more tests failed!\n"); |
1750 | goto err_free_tv; | 1757 | goto err_free_tv; |
1751 | } | 1758 | } |
1752 | 1759 | ||
1753 | /* We intentionaly return -EAGAIN to prevent keeping the module, | 1760 | /* We intentionaly return -EAGAIN to prevent keeping the module, |
1754 | * unless we're running in fips mode. It does all its work from | 1761 | * unless we're running in fips mode. It does all its work from |
1755 | * init() and doesn't offer any runtime functionality, but in | 1762 | * init() and doesn't offer any runtime functionality, but in |
1756 | * the fips case, checking for a successful load is helpful. | 1763 | * the fips case, checking for a successful load is helpful. |
1757 | * => we don't need it in the memory, do we? | 1764 | * => we don't need it in the memory, do we? |
1758 | * -- mludvig | 1765 | * -- mludvig |
1759 | */ | 1766 | */ |
1760 | if (!fips_enabled) | 1767 | if (!fips_enabled) |
1761 | err = -EAGAIN; | 1768 | err = -EAGAIN; |
1762 | 1769 | ||
1763 | err_free_tv: | 1770 | err_free_tv: |
1764 | for (i = 0; i < TVMEMSIZE && tvmem[i]; i++) | 1771 | for (i = 0; i < TVMEMSIZE && tvmem[i]; i++) |
1765 | free_page((unsigned long)tvmem[i]); | 1772 | free_page((unsigned long)tvmem[i]); |
1766 | 1773 | ||
1767 | return err; | 1774 | return err; |
1768 | } | 1775 | } |
1769 | 1776 | ||
1770 | /* | 1777 | /* |
1771 | * If an init function is provided, an exit function must also be provided | 1778 | * If an init function is provided, an exit function must also be provided |
1772 | * to allow module unload. | 1779 | * to allow module unload. |
1773 | */ | 1780 | */ |
1774 | static void __exit tcrypt_mod_fini(void) { } | 1781 | static void __exit tcrypt_mod_fini(void) { } |
1775 | 1782 | ||
1776 | module_init(tcrypt_mod_init); | 1783 | module_init(tcrypt_mod_init); |
1777 | module_exit(tcrypt_mod_fini); | 1784 | module_exit(tcrypt_mod_fini); |
1778 | 1785 | ||
1779 | module_param(alg, charp, 0); | 1786 | module_param(alg, charp, 0); |
1780 | module_param(type, uint, 0); | 1787 | module_param(type, uint, 0); |
1781 | module_param(mask, uint, 0); | 1788 | module_param(mask, uint, 0); |
1782 | module_param(mode, int, 0); | 1789 | module_param(mode, int, 0); |
1783 | module_param(sec, uint, 0); | 1790 | module_param(sec, uint, 0); |
1784 | MODULE_PARM_DESC(sec, "Length in seconds of speed tests " | 1791 | MODULE_PARM_DESC(sec, "Length in seconds of speed tests " |
1785 | "(defaults to zero which uses CPU cycles instead)"); | 1792 | "(defaults to zero which uses CPU cycles instead)"); |
1786 | 1793 | ||
1787 | MODULE_LICENSE("GPL"); | 1794 | MODULE_LICENSE("GPL"); |
1788 | MODULE_DESCRIPTION("Quick & dirty crypto testing module"); | 1795 | MODULE_DESCRIPTION("Quick & dirty crypto testing module"); |
1789 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); | 1796 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); |
1790 | 1797 |