diff options
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r-- | crypto/tcrypt.c | 333 |
1 files changed, 165 insertions, 168 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 92b0352c8e92..5a95b4a14c2b 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -1,4 +1,4 @@ | |||
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 |
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify it | 10 | * This program is free software; you can redistribute it and/or modify it |
11 | * under the terms of the GNU General Public License as published by the Free | 11 | * under the terms of the GNU General Public License as published by the Free |
12 | * Software Foundation; either version 2 of the License, or (at your option) | 12 | * Software Foundation; either version 2 of the License, or (at your option) |
13 | * any later version. | 13 | * any later version. |
14 | * | 14 | * |
15 | * 14 - 09 - 2003 | 15 | * 14 - 09 - 2003 |
@@ -61,13 +61,12 @@ static char *tvmem; | |||
61 | 61 | ||
62 | static char *check[] = { | 62 | static char *check[] = { |
63 | "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish", | 63 | "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish", |
64 | "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", | 64 | "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", |
65 | "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", | 65 | "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", |
66 | "khazad", "wp512", "wp384", "wp256", "tnepres", NULL | 66 | "khazad", "wp512", "wp384", "wp256", "tnepres", NULL |
67 | }; | 67 | }; |
68 | 68 | ||
69 | static void | 69 | static void hexdump(unsigned char *buf, unsigned int len) |
70 | hexdump(unsigned char *buf, unsigned int len) | ||
71 | { | 70 | { |
72 | while (len--) | 71 | while (len--) |
73 | printk("%02x", *buf++); | 72 | printk("%02x", *buf++); |
@@ -75,29 +74,29 @@ hexdump(unsigned char *buf, unsigned int len) | |||
75 | printk("\n"); | 74 | printk("\n"); |
76 | } | 75 | } |
77 | 76 | ||
78 | static void | 77 | static void test_hash(char *algo, struct hash_testvec *template, |
79 | test_hash (char * algo, struct hash_testvec * template, unsigned int tcount) | 78 | unsigned int tcount) |
80 | { | 79 | { |
81 | char *p; | 80 | char *p; |
82 | unsigned int i, j, k, temp; | 81 | unsigned int i, j, k, temp; |
83 | struct scatterlist sg[8]; | 82 | struct scatterlist sg[8]; |
84 | char result[64]; | 83 | char result[64]; |
85 | struct crypto_tfm *tfm; | 84 | struct crypto_tfm *tfm; |
86 | struct hash_testvec *hash_tv; | 85 | struct hash_testvec *hash_tv; |
87 | unsigned int tsize; | 86 | unsigned int tsize; |
88 | 87 | ||
89 | printk("\ntesting %s\n", algo); | 88 | printk("\ntesting %s\n", algo); |
90 | 89 | ||
91 | tsize = sizeof (struct hash_testvec); | 90 | tsize = sizeof(struct hash_testvec); |
92 | tsize *= tcount; | 91 | tsize *= tcount; |
93 | 92 | ||
94 | if (tsize > TVMEMSIZE) { | 93 | if (tsize > TVMEMSIZE) { |
95 | printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); | 94 | printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); |
96 | return; | 95 | return; |
97 | } | 96 | } |
98 | 97 | ||
99 | memcpy(tvmem, template, tsize); | 98 | memcpy(tvmem, template, tsize); |
100 | hash_tv = (void *) tvmem; | 99 | hash_tv = (void *)tvmem; |
101 | tfm = crypto_alloc_tfm(algo, 0); | 100 | tfm = crypto_alloc_tfm(algo, 0); |
102 | if (tfm == NULL) { | 101 | if (tfm == NULL) { |
103 | printk("failed to load transform for %s\n", algo); | 102 | printk("failed to load transform for %s\n", algo); |
@@ -105,70 +104,71 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount) | |||
105 | } | 104 | } |
106 | 105 | ||
107 | for (i = 0; i < tcount; i++) { | 106 | for (i = 0; i < tcount; i++) { |
108 | printk ("test %u:\n", i + 1); | 107 | printk("test %u:\n", i + 1); |
109 | memset (result, 0, 64); | 108 | memset(result, 0, 64); |
110 | 109 | ||
111 | p = hash_tv[i].plaintext; | 110 | p = hash_tv[i].plaintext; |
112 | sg[0].page = virt_to_page (p); | 111 | sg[0].page = virt_to_page(p); |
113 | sg[0].offset = offset_in_page (p); | 112 | sg[0].offset = offset_in_page(p); |
114 | sg[0].length = hash_tv[i].psize; | 113 | sg[0].length = hash_tv[i].psize; |
115 | 114 | ||
116 | crypto_digest_init (tfm); | 115 | crypto_digest_init(tfm); |
117 | if (tfm->crt_u.digest.dit_setkey) { | 116 | if (tfm->crt_u.digest.dit_setkey) { |
118 | crypto_digest_setkey (tfm, hash_tv[i].key, | 117 | crypto_digest_setkey(tfm, hash_tv[i].key, |
119 | hash_tv[i].ksize); | 118 | hash_tv[i].ksize); |
120 | } | 119 | } |
121 | crypto_digest_update (tfm, sg, 1); | 120 | crypto_digest_update(tfm, sg, 1); |
122 | crypto_digest_final (tfm, result); | 121 | crypto_digest_final(tfm, result); |
123 | 122 | ||
124 | hexdump (result, crypto_tfm_alg_digestsize (tfm)); | 123 | hexdump(result, crypto_tfm_alg_digestsize(tfm)); |
125 | printk("%s\n", | 124 | printk("%s\n", |
126 | memcmp(result, hash_tv[i].digest, | 125 | memcmp(result, hash_tv[i].digest, |
127 | crypto_tfm_alg_digestsize(tfm)) ? "fail" : | 126 | crypto_tfm_alg_digestsize(tfm)) ? |
128 | "pass"); | 127 | "fail" : "pass"); |
129 | } | 128 | } |
130 | 129 | ||
131 | printk ("testing %s across pages\n", algo); | 130 | printk("testing %s across pages\n", algo); |
132 | 131 | ||
133 | /* setup the dummy buffer first */ | 132 | /* setup the dummy buffer first */ |
134 | memset(xbuf, 0, XBUFSIZE); | 133 | memset(xbuf, 0, XBUFSIZE); |
135 | 134 | ||
136 | j = 0; | 135 | j = 0; |
137 | for (i = 0; i < tcount; i++) { | 136 | for (i = 0; i < tcount; i++) { |
138 | if (hash_tv[i].np) { | 137 | if (hash_tv[i].np) { |
139 | j++; | 138 | j++; |
140 | printk ("test %u:\n", j); | 139 | printk("test %u:\n", j); |
141 | memset (result, 0, 64); | 140 | memset(result, 0, 64); |
142 | 141 | ||
143 | temp = 0; | 142 | temp = 0; |
144 | for (k = 0; k < hash_tv[i].np; k++) { | 143 | for (k = 0; k < hash_tv[i].np; k++) { |
145 | memcpy (&xbuf[IDX[k]], hash_tv[i].plaintext + temp, | 144 | memcpy(&xbuf[IDX[k]], |
146 | hash_tv[i].tap[k]); | 145 | hash_tv[i].plaintext + temp, |
146 | hash_tv[i].tap[k]); | ||
147 | temp += hash_tv[i].tap[k]; | 147 | temp += hash_tv[i].tap[k]; |
148 | p = &xbuf[IDX[k]]; | 148 | p = &xbuf[IDX[k]]; |
149 | sg[k].page = virt_to_page (p); | 149 | sg[k].page = virt_to_page(p); |
150 | sg[k].offset = offset_in_page (p); | 150 | sg[k].offset = offset_in_page(p); |
151 | sg[k].length = hash_tv[i].tap[k]; | 151 | sg[k].length = hash_tv[i].tap[k]; |
152 | } | 152 | } |
153 | 153 | ||
154 | crypto_digest_digest (tfm, sg, hash_tv[i].np, result); | 154 | crypto_digest_digest(tfm, sg, hash_tv[i].np, result); |
155 | 155 | ||
156 | hexdump (result, crypto_tfm_alg_digestsize (tfm)); | 156 | hexdump(result, crypto_tfm_alg_digestsize(tfm)); |
157 | printk("%s\n", | 157 | printk("%s\n", |
158 | memcmp(result, hash_tv[i].digest, | 158 | memcmp(result, hash_tv[i].digest, |
159 | crypto_tfm_alg_digestsize(tfm)) ? "fail" : | 159 | crypto_tfm_alg_digestsize(tfm)) ? |
160 | "pass"); | 160 | "fail" : "pass"); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | crypto_free_tfm (tfm); | 164 | crypto_free_tfm(tfm); |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | #ifdef CONFIG_CRYPTO_HMAC | 168 | #ifdef CONFIG_CRYPTO_HMAC |
169 | 169 | ||
170 | static void | 170 | static void test_hmac(char *algo, struct hmac_testvec *template, |
171 | test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount) | 171 | unsigned int tcount) |
172 | { | 172 | { |
173 | char *p; | 173 | char *p; |
174 | unsigned int i, j, k, temp; | 174 | unsigned int i, j, k, temp; |
@@ -185,8 +185,8 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | printk("\ntesting hmac_%s\n", algo); | 187 | printk("\ntesting hmac_%s\n", algo); |
188 | 188 | ||
189 | tsize = sizeof (struct hmac_testvec); | 189 | tsize = sizeof(struct hmac_testvec); |
190 | tsize *= tcount; | 190 | tsize *= tcount; |
191 | if (tsize > TVMEMSIZE) { | 191 | if (tsize > TVMEMSIZE) { |
192 | printk("template (%u) too big for tvmem (%u)\n", tsize, | 192 | printk("template (%u) too big for tvmem (%u)\n", tsize, |
@@ -195,7 +195,7 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount) | |||
195 | } | 195 | } |
196 | 196 | ||
197 | memcpy(tvmem, template, tsize); | 197 | memcpy(tvmem, template, tsize); |
198 | hmac_tv = (void *) tvmem; | 198 | hmac_tv = (void *)tvmem; |
199 | 199 | ||
200 | for (i = 0; i < tcount; i++) { | 200 | for (i = 0; i < tcount; i++) { |
201 | printk("test %u:\n", i + 1); | 201 | printk("test %u:\n", i + 1); |
@@ -219,34 +219,35 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount) | |||
219 | printk("\ntesting hmac_%s across pages\n", algo); | 219 | printk("\ntesting hmac_%s across pages\n", algo); |
220 | 220 | ||
221 | memset(xbuf, 0, XBUFSIZE); | 221 | memset(xbuf, 0, XBUFSIZE); |
222 | 222 | ||
223 | j = 0; | 223 | j = 0; |
224 | for (i = 0; i < tcount; i++) { | 224 | for (i = 0; i < tcount; i++) { |
225 | if (hmac_tv[i].np) { | 225 | if (hmac_tv[i].np) { |
226 | j++; | 226 | j++; |
227 | printk ("test %u:\n",j); | 227 | printk("test %u:\n",j); |
228 | memset (result, 0, 64); | 228 | memset(result, 0, 64); |
229 | 229 | ||
230 | temp = 0; | 230 | temp = 0; |
231 | klen = hmac_tv[i].ksize; | 231 | klen = hmac_tv[i].ksize; |
232 | for (k = 0; k < hmac_tv[i].np; k++) { | 232 | for (k = 0; k < hmac_tv[i].np; k++) { |
233 | memcpy (&xbuf[IDX[k]], hmac_tv[i].plaintext + temp, | 233 | memcpy(&xbuf[IDX[k]], |
234 | hmac_tv[i].tap[k]); | 234 | hmac_tv[i].plaintext + temp, |
235 | hmac_tv[i].tap[k]); | ||
235 | temp += hmac_tv[i].tap[k]; | 236 | temp += hmac_tv[i].tap[k]; |
236 | p = &xbuf[IDX[k]]; | 237 | p = &xbuf[IDX[k]]; |
237 | sg[k].page = virt_to_page (p); | 238 | sg[k].page = virt_to_page(p); |
238 | sg[k].offset = offset_in_page (p); | 239 | sg[k].offset = offset_in_page(p); |
239 | sg[k].length = hmac_tv[i].tap[k]; | 240 | sg[k].length = hmac_tv[i].tap[k]; |
240 | } | 241 | } |
241 | 242 | ||
242 | crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, hmac_tv[i].np, | 243 | crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, |
243 | result); | 244 | hmac_tv[i].np, result); |
244 | hexdump(result, crypto_tfm_alg_digestsize(tfm)); | 245 | hexdump(result, crypto_tfm_alg_digestsize(tfm)); |
245 | 246 | ||
246 | printk("%s\n", | 247 | printk("%s\n", |
247 | memcmp(result, hmac_tv[i].digest, | 248 | memcmp(result, hmac_tv[i].digest, |
248 | crypto_tfm_alg_digestsize(tfm)) ? "fail" : | 249 | crypto_tfm_alg_digestsize(tfm)) ? |
249 | "pass"); | 250 | "fail" : "pass"); |
250 | } | 251 | } |
251 | } | 252 | } |
252 | out: | 253 | out: |
@@ -255,8 +256,8 @@ out: | |||
255 | 256 | ||
256 | #endif /* CONFIG_CRYPTO_HMAC */ | 257 | #endif /* CONFIG_CRYPTO_HMAC */ |
257 | 258 | ||
258 | static void | 259 | static void test_cipher(char *algo, int mode, int enc, |
259 | test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, unsigned int tcount) | 260 | struct cipher_testvec *template, unsigned int tcount) |
260 | { | 261 | { |
261 | unsigned int ret, i, j, k, temp; | 262 | unsigned int ret, i, j, k, temp; |
262 | unsigned int tsize; | 263 | unsigned int tsize; |
@@ -270,17 +271,17 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un | |||
270 | if (enc == ENCRYPT) | 271 | if (enc == ENCRYPT) |
271 | strncpy(e, "encryption", 11); | 272 | strncpy(e, "encryption", 11); |
272 | else | 273 | else |
273 | strncpy(e, "decryption", 11); | 274 | strncpy(e, "decryption", 11); |
274 | if (mode == MODE_ECB) | 275 | if (mode == MODE_ECB) |
275 | strncpy(m, "ECB", 4); | 276 | strncpy(m, "ECB", 4); |
276 | else | 277 | else |
277 | strncpy(m, "CBC", 4); | 278 | strncpy(m, "CBC", 4); |
278 | 279 | ||
279 | printk("\ntesting %s %s %s \n", algo, m, e); | 280 | printk("\ntesting %s %s %s\n", algo, m, e); |
280 | 281 | ||
281 | tsize = sizeof (struct cipher_testvec); | 282 | tsize = sizeof (struct cipher_testvec); |
282 | tsize *= tcount; | 283 | tsize *= tcount; |
283 | 284 | ||
284 | if (tsize > TVMEMSIZE) { | 285 | if (tsize > TVMEMSIZE) { |
285 | printk("template (%u) too big for tvmem (%u)\n", tsize, | 286 | printk("template (%u) too big for tvmem (%u)\n", tsize, |
286 | TVMEMSIZE); | 287 | TVMEMSIZE); |
@@ -288,112 +289,113 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un | |||
288 | } | 289 | } |
289 | 290 | ||
290 | memcpy(tvmem, template, tsize); | 291 | memcpy(tvmem, template, tsize); |
291 | cipher_tv = (void *) tvmem; | 292 | cipher_tv = (void *)tvmem; |
293 | |||
294 | if (mode) | ||
295 | tfm = crypto_alloc_tfm(algo, 0); | ||
296 | else | ||
297 | tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC); | ||
292 | 298 | ||
293 | if (mode) | ||
294 | tfm = crypto_alloc_tfm (algo, 0); | ||
295 | else | ||
296 | tfm = crypto_alloc_tfm (algo, CRYPTO_TFM_MODE_CBC); | ||
297 | |||
298 | if (tfm == NULL) { | 299 | if (tfm == NULL) { |
299 | printk("failed to load transform for %s %s\n", algo, m); | 300 | printk("failed to load transform for %s %s\n", algo, m); |
300 | return; | 301 | return; |
301 | } | 302 | } |
302 | 303 | ||
303 | j = 0; | 304 | j = 0; |
304 | for (i = 0; i < tcount; i++) { | 305 | for (i = 0; i < tcount; i++) { |
305 | if (!(cipher_tv[i].np)) { | 306 | if (!(cipher_tv[i].np)) { |
306 | j++; | 307 | j++; |
307 | printk("test %u (%d bit key):\n", | 308 | printk("test %u (%d bit key):\n", |
308 | j, cipher_tv[i].klen * 8); | 309 | j, cipher_tv[i].klen * 8); |
309 | 310 | ||
310 | tfm->crt_flags = 0; | 311 | tfm->crt_flags = 0; |
311 | if (cipher_tv[i].wk) | 312 | if (cipher_tv[i].wk) |
312 | tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; | 313 | tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; |
313 | key = cipher_tv[i].key; | 314 | key = cipher_tv[i].key; |
314 | 315 | ||
315 | ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); | 316 | ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); |
316 | if (ret) { | 317 | if (ret) { |
317 | printk("setkey() failed flags=%x\n", tfm->crt_flags); | 318 | printk("setkey() failed flags=%x\n", tfm->crt_flags); |
318 | 319 | ||
319 | if (!cipher_tv[i].fail) | 320 | if (!cipher_tv[i].fail) |
320 | goto out; | 321 | goto out; |
321 | } | 322 | } |
322 | 323 | ||
323 | p = cipher_tv[i].input; | 324 | p = cipher_tv[i].input; |
324 | sg[0].page = virt_to_page(p); | 325 | sg[0].page = virt_to_page(p); |
325 | sg[0].offset = offset_in_page(p); | 326 | sg[0].offset = offset_in_page(p); |
326 | sg[0].length = cipher_tv[i].ilen; | 327 | sg[0].length = cipher_tv[i].ilen; |
327 | 328 | ||
328 | if (!mode) { | 329 | if (!mode) { |
329 | crypto_cipher_set_iv(tfm, cipher_tv[i].iv, | 330 | crypto_cipher_set_iv(tfm, cipher_tv[i].iv, |
330 | crypto_tfm_alg_ivsize (tfm)); | 331 | crypto_tfm_alg_ivsize(tfm)); |
331 | } | 332 | } |
332 | 333 | ||
333 | if (enc) | 334 | if (enc) |
334 | ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen); | 335 | ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen); |
335 | else | 336 | else |
336 | ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen); | 337 | ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen); |
337 | 338 | ||
338 | 339 | ||
339 | if (ret) { | 340 | if (ret) { |
340 | printk("%s () failed flags=%x\n", e, tfm->crt_flags); | 341 | printk("%s () failed flags=%x\n", e, tfm->crt_flags); |
341 | goto out; | 342 | goto out; |
342 | } | 343 | } |
343 | 344 | ||
344 | q = kmap(sg[0].page) + sg[0].offset; | 345 | q = kmap(sg[0].page) + sg[0].offset; |
345 | hexdump(q, cipher_tv[i].rlen); | 346 | hexdump(q, cipher_tv[i].rlen); |
346 | 347 | ||
347 | printk("%s\n", | 348 | printk("%s\n", |
348 | memcmp(q, cipher_tv[i].result, cipher_tv[i].rlen) ? "fail" : | 349 | memcmp(q, cipher_tv[i].result, |
349 | "pass"); | 350 | cipher_tv[i].rlen) ? "fail" : "pass"); |
350 | } | 351 | } |
351 | } | 352 | } |
352 | 353 | ||
353 | printk("\ntesting %s %s %s across pages (chunking) \n", algo, m, e); | 354 | printk("\ntesting %s %s %s across pages (chunking)\n", algo, m, e); |
354 | memset(xbuf, 0, XBUFSIZE); | 355 | memset(xbuf, 0, XBUFSIZE); |
355 | 356 | ||
356 | j = 0; | 357 | j = 0; |
357 | for (i = 0; i < tcount; i++) { | 358 | for (i = 0; i < tcount; i++) { |
358 | if (cipher_tv[i].np) { | 359 | if (cipher_tv[i].np) { |
359 | j++; | 360 | j++; |
360 | printk("test %u (%d bit key):\n", | 361 | printk("test %u (%d bit key):\n", |
361 | j, cipher_tv[i].klen * 8); | 362 | j, cipher_tv[i].klen * 8); |
362 | 363 | ||
363 | tfm->crt_flags = 0; | 364 | tfm->crt_flags = 0; |
364 | if (cipher_tv[i].wk) | 365 | if (cipher_tv[i].wk) |
365 | tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; | 366 | tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; |
366 | key = cipher_tv[i].key; | 367 | key = cipher_tv[i].key; |
367 | 368 | ||
368 | ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); | 369 | ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); |
369 | if (ret) { | 370 | if (ret) { |
370 | printk("setkey() failed flags=%x\n", tfm->crt_flags); | 371 | printk("setkey() failed flags=%x\n", tfm->crt_flags); |
371 | 372 | ||
372 | if (!cipher_tv[i].fail) | 373 | if (!cipher_tv[i].fail) |
373 | goto out; | 374 | goto out; |
374 | } | 375 | } |
375 | 376 | ||
376 | temp = 0; | 377 | temp = 0; |
377 | for (k = 0; k < cipher_tv[i].np; k++) { | 378 | for (k = 0; k < cipher_tv[i].np; k++) { |
378 | memcpy (&xbuf[IDX[k]], cipher_tv[i].input + temp, | 379 | memcpy(&xbuf[IDX[k]], |
379 | cipher_tv[i].tap[k]); | 380 | cipher_tv[i].input + temp, |
381 | cipher_tv[i].tap[k]); | ||
380 | temp += cipher_tv[i].tap[k]; | 382 | temp += cipher_tv[i].tap[k]; |
381 | p = &xbuf[IDX[k]]; | 383 | p = &xbuf[IDX[k]]; |
382 | sg[k].page = virt_to_page (p); | 384 | sg[k].page = virt_to_page(p); |
383 | sg[k].offset = offset_in_page (p); | 385 | sg[k].offset = offset_in_page(p); |
384 | sg[k].length = cipher_tv[i].tap[k]; | 386 | sg[k].length = cipher_tv[i].tap[k]; |
385 | } | 387 | } |
386 | 388 | ||
387 | if (!mode) { | 389 | if (!mode) { |
388 | crypto_cipher_set_iv(tfm, cipher_tv[i].iv, | 390 | crypto_cipher_set_iv(tfm, cipher_tv[i].iv, |
389 | crypto_tfm_alg_ivsize (tfm)); | 391 | crypto_tfm_alg_ivsize(tfm)); |
390 | } | 392 | } |
391 | 393 | ||
392 | if (enc) | 394 | if (enc) |
393 | ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen); | 395 | ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen); |
394 | else | 396 | else |
395 | ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen); | 397 | ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen); |
396 | 398 | ||
397 | if (ret) { | 399 | if (ret) { |
398 | printk("%s () failed flags=%x\n", e, tfm->crt_flags); | 400 | printk("%s () failed flags=%x\n", e, tfm->crt_flags); |
399 | goto out; | 401 | goto out; |
@@ -404,9 +406,9 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un | |||
404 | printk("page %u\n", k); | 406 | printk("page %u\n", k); |
405 | q = kmap(sg[k].page) + sg[k].offset; | 407 | q = kmap(sg[k].page) + sg[k].offset; |
406 | hexdump(q, cipher_tv[i].tap[k]); | 408 | hexdump(q, cipher_tv[i].tap[k]); |
407 | printk("%s\n", | 409 | printk("%s\n", |
408 | memcmp(q, cipher_tv[i].result + temp, | 410 | memcmp(q, cipher_tv[i].result + temp, |
409 | cipher_tv[i].tap[k]) ? "fail" : | 411 | cipher_tv[i].tap[k]) ? "fail" : |
410 | "pass"); | 412 | "pass"); |
411 | temp += cipher_tv[i].tap[k]; | 413 | temp += cipher_tv[i].tap[k]; |
412 | } | 414 | } |
@@ -417,8 +419,7 @@ out: | |||
417 | crypto_free_tfm(tfm); | 419 | crypto_free_tfm(tfm); |
418 | } | 420 | } |
419 | 421 | ||
420 | static void | 422 | static void test_deflate(void) |
421 | test_deflate(void) | ||
422 | { | 423 | { |
423 | unsigned int i; | 424 | unsigned int i; |
424 | char result[COMP_BUF_SIZE]; | 425 | char result[COMP_BUF_SIZE]; |
@@ -436,7 +437,7 @@ test_deflate(void) | |||
436 | } | 437 | } |
437 | 438 | ||
438 | memcpy(tvmem, deflate_comp_tv_template, tsize); | 439 | memcpy(tvmem, deflate_comp_tv_template, tsize); |
439 | tv = (void *) tvmem; | 440 | tv = (void *)tvmem; |
440 | 441 | ||
441 | tfm = crypto_alloc_tfm("deflate", 0); | 442 | tfm = crypto_alloc_tfm("deflate", 0); |
442 | if (tfm == NULL) { | 443 | if (tfm == NULL) { |
@@ -446,7 +447,7 @@ test_deflate(void) | |||
446 | 447 | ||
447 | for (i = 0; i < DEFLATE_COMP_TEST_VECTORS; i++) { | 448 | for (i = 0; i < DEFLATE_COMP_TEST_VECTORS; i++) { |
448 | int ilen, ret, dlen = COMP_BUF_SIZE; | 449 | int ilen, ret, dlen = COMP_BUF_SIZE; |
449 | 450 | ||
450 | printk("test %u:\n", i + 1); | 451 | printk("test %u:\n", i + 1); |
451 | memset(result, 0, sizeof (result)); | 452 | memset(result, 0, sizeof (result)); |
452 | 453 | ||
@@ -473,11 +474,11 @@ test_deflate(void) | |||
473 | } | 474 | } |
474 | 475 | ||
475 | memcpy(tvmem, deflate_decomp_tv_template, tsize); | 476 | memcpy(tvmem, deflate_decomp_tv_template, tsize); |
476 | tv = (void *) tvmem; | 477 | tv = (void *)tvmem; |
477 | 478 | ||
478 | for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) { | 479 | for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) { |
479 | int ilen, ret, dlen = COMP_BUF_SIZE; | 480 | int ilen, ret, dlen = COMP_BUF_SIZE; |
480 | 481 | ||
481 | printk("test %u:\n", i + 1); | 482 | printk("test %u:\n", i + 1); |
482 | memset(result, 0, sizeof (result)); | 483 | memset(result, 0, sizeof (result)); |
483 | 484 | ||
@@ -497,8 +498,7 @@ out: | |||
497 | crypto_free_tfm(tfm); | 498 | crypto_free_tfm(tfm); |
498 | } | 499 | } |
499 | 500 | ||
500 | static void | 501 | static void test_crc32c(void) |
501 | test_crc32c(void) | ||
502 | { | 502 | { |
503 | #define NUMVEC 6 | 503 | #define NUMVEC 6 |
504 | #define VECSIZE 40 | 504 | #define VECSIZE 40 |
@@ -511,7 +511,7 @@ test_crc32c(void) | |||
511 | 0xd579c862, 0xba979ad0, 0x2b29d913 | 511 | 0xd579c862, 0xba979ad0, 0x2b29d913 |
512 | }; | 512 | }; |
513 | static u32 tot_vec_results = 0x24c5d375; | 513 | static u32 tot_vec_results = 0x24c5d375; |
514 | 514 | ||
515 | struct scatterlist sg[NUMVEC]; | 515 | struct scatterlist sg[NUMVEC]; |
516 | struct crypto_tfm *tfm; | 516 | struct crypto_tfm *tfm; |
517 | char *fmtdata = "testing crc32c initialized to %08x: %s\n"; | 517 | char *fmtdata = "testing crc32c initialized to %08x: %s\n"; |
@@ -525,18 +525,18 @@ test_crc32c(void) | |||
525 | printk("failed to load transform for crc32c\n"); | 525 | printk("failed to load transform for crc32c\n"); |
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | 528 | ||
529 | crypto_digest_init(tfm); | 529 | crypto_digest_init(tfm); |
530 | crypto_digest_final(tfm, (u8*)&crc); | 530 | crypto_digest_final(tfm, (u8*)&crc); |
531 | printk(fmtdata, crc, (crc == 0) ? "pass" : "ERROR"); | 531 | printk(fmtdata, crc, (crc == 0) ? "pass" : "ERROR"); |
532 | 532 | ||
533 | /* | 533 | /* |
534 | * stuff test_vec with known values, simple incrementing | 534 | * stuff test_vec with known values, simple incrementing |
535 | * byte values. | 535 | * byte values. |
536 | */ | 536 | */ |
537 | b = 0; | 537 | b = 0; |
538 | for (i = 0; i < NUMVEC; i++) { | 538 | for (i = 0; i < NUMVEC; i++) { |
539 | for (j = 0; j < VECSIZE; j++) | 539 | for (j = 0; j < VECSIZE; j++) |
540 | test_vec[i][j] = ++b; | 540 | test_vec[i][j] = ++b; |
541 | sg[i].page = virt_to_page(test_vec[i]); | 541 | sg[i].page = virt_to_page(test_vec[i]); |
542 | sg[i].offset = offset_in_page(test_vec[i]); | 542 | sg[i].offset = offset_in_page(test_vec[i]); |
@@ -548,11 +548,11 @@ test_crc32c(void) | |||
548 | crypto_digest_final(tfm, (u8*)&crc); | 548 | crypto_digest_final(tfm, (u8*)&crc); |
549 | printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ? | 549 | printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ? |
550 | "pass" : "ERROR"); | 550 | "pass" : "ERROR"); |
551 | 551 | ||
552 | printk("testing crc32c using update/final:\n"); | 552 | printk("testing crc32c using update/final:\n"); |
553 | 553 | ||
554 | pass = 1; /* assume all is well */ | 554 | pass = 1; /* assume all is well */ |
555 | 555 | ||
556 | for (i = 0; i < NUMVEC; i++) { | 556 | for (i = 0; i < NUMVEC; i++) { |
557 | seed = ~(u32)0; | 557 | seed = ~(u32)0; |
558 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); | 558 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); |
@@ -591,66 +591,64 @@ test_crc32c(void) | |||
591 | printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results); | 591 | printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results); |
592 | pass = 0; | 592 | pass = 0; |
593 | } | 593 | } |
594 | 594 | ||
595 | printk("\n%s\n", pass ? "pass" : "ERROR"); | 595 | printk("\n%s\n", pass ? "pass" : "ERROR"); |
596 | 596 | ||
597 | crypto_free_tfm(tfm); | 597 | crypto_free_tfm(tfm); |
598 | printk("crc32c test complete\n"); | 598 | printk("crc32c test complete\n"); |
599 | } | 599 | } |
600 | 600 | ||
601 | static void | 601 | static void test_available(void) |
602 | test_available(void) | ||
603 | { | 602 | { |
604 | char **name = check; | 603 | char **name = check; |
605 | 604 | ||
606 | while (*name) { | 605 | while (*name) { |
607 | printk("alg %s ", *name); | 606 | printk("alg %s ", *name); |
608 | printk((crypto_alg_available(*name, 0)) ? | 607 | printk((crypto_alg_available(*name, 0)) ? |
609 | "found\n" : "not found\n"); | 608 | "found\n" : "not found\n"); |
610 | name++; | 609 | name++; |
611 | } | 610 | } |
612 | } | 611 | } |
613 | 612 | ||
614 | static void | 613 | static void do_test(void) |
615 | do_test(void) | ||
616 | { | 614 | { |
617 | switch (mode) { | 615 | switch (mode) { |
618 | 616 | ||
619 | case 0: | 617 | case 0: |
620 | test_hash("md5", md5_tv_template, MD5_TEST_VECTORS); | 618 | test_hash("md5", md5_tv_template, MD5_TEST_VECTORS); |
621 | 619 | ||
622 | test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS); | 620 | test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS); |
623 | 621 | ||
624 | //DES | 622 | //DES |
625 | test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS); | 623 | test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS); |
626 | test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS); | 624 | test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS); |
627 | test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS); | 625 | test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS); |
628 | test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS); | 626 | test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS); |
629 | 627 | ||
630 | //DES3_EDE | 628 | //DES3_EDE |
631 | test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS); | 629 | test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS); |
632 | test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); | 630 | test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); |
633 | 631 | ||
634 | test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); | 632 | test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); |
635 | 633 | ||
636 | test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); | 634 | test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); |
637 | 635 | ||
638 | //BLOWFISH | 636 | //BLOWFISH |
639 | test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS); | 637 | test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS); |
640 | test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS); | 638 | test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS); |
641 | test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS); | 639 | test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS); |
642 | test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS); | 640 | test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS); |
643 | 641 | ||
644 | //TWOFISH | 642 | //TWOFISH |
645 | test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS); | 643 | test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS); |
646 | test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS); | 644 | test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS); |
647 | test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS); | 645 | test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS); |
648 | test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS); | 646 | test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS); |
649 | 647 | ||
650 | //SERPENT | 648 | //SERPENT |
651 | test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS); | 649 | test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS); |
652 | test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS); | 650 | test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS); |
653 | 651 | ||
654 | //TNEPRES | 652 | //TNEPRES |
655 | test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS); | 653 | test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS); |
656 | test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS); | 654 | test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS); |
@@ -662,7 +660,7 @@ do_test(void) | |||
662 | //CAST5 | 660 | //CAST5 |
663 | test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS); | 661 | test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS); |
664 | test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS); | 662 | test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS); |
665 | 663 | ||
666 | //CAST6 | 664 | //CAST6 |
667 | test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS); | 665 | test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS); |
668 | test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS); | 666 | test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS); |
@@ -702,9 +700,9 @@ do_test(void) | |||
702 | test_crc32c(); | 700 | test_crc32c(); |
703 | #ifdef CONFIG_CRYPTO_HMAC | 701 | #ifdef CONFIG_CRYPTO_HMAC |
704 | test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); | 702 | test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); |
705 | test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); | 703 | test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); |
706 | test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS); | 704 | test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS); |
707 | #endif | 705 | #endif |
708 | 706 | ||
709 | test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS); | 707 | test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS); |
710 | break; | 708 | break; |
@@ -726,17 +724,17 @@ do_test(void) | |||
726 | 724 | ||
727 | case 4: | 725 | case 4: |
728 | test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS); | 726 | test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS); |
729 | test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); | 727 | test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); |
730 | break; | 728 | break; |
731 | 729 | ||
732 | case 5: | 730 | case 5: |
733 | test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); | 731 | test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); |
734 | break; | 732 | break; |
735 | 733 | ||
736 | case 6: | 734 | case 6: |
737 | test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); | 735 | test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); |
738 | break; | 736 | break; |
739 | 737 | ||
740 | case 7: | 738 | case 7: |
741 | test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS); | 739 | test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS); |
742 | test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS); | 740 | test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS); |
@@ -750,7 +748,7 @@ do_test(void) | |||
750 | test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS); | 748 | test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS); |
751 | test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS); | 749 | test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS); |
752 | break; | 750 | break; |
753 | 751 | ||
754 | case 9: | 752 | case 9: |
755 | test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS); | 753 | test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS); |
756 | test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS); | 754 | test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS); |
@@ -758,13 +756,13 @@ do_test(void) | |||
758 | 756 | ||
759 | case 10: | 757 | case 10: |
760 | test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS); | 758 | test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS); |
761 | test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS); | 759 | test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS); |
762 | break; | 760 | break; |
763 | 761 | ||
764 | case 11: | 762 | case 11: |
765 | test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); | 763 | test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); |
766 | break; | 764 | break; |
767 | 765 | ||
768 | case 12: | 766 | case 12: |
769 | test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); | 767 | test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); |
770 | break; | 768 | break; |
@@ -852,11 +850,11 @@ do_test(void) | |||
852 | case 100: | 850 | case 100: |
853 | test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); | 851 | test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); |
854 | break; | 852 | break; |
855 | 853 | ||
856 | case 101: | 854 | case 101: |
857 | test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); | 855 | test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); |
858 | break; | 856 | break; |
859 | 857 | ||
860 | case 102: | 858 | case 102: |
861 | test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS); | 859 | test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS); |
862 | break; | 860 | break; |
@@ -866,7 +864,7 @@ do_test(void) | |||
866 | case 1000: | 864 | case 1000: |
867 | test_available(); | 865 | test_available(); |
868 | break; | 866 | break; |
869 | 867 | ||
870 | default: | 868 | default: |
871 | /* useful for debugging */ | 869 | /* useful for debugging */ |
872 | printk("not testing anything\n"); | 870 | printk("not testing anything\n"); |
@@ -874,8 +872,7 @@ do_test(void) | |||
874 | } | 872 | } |
875 | } | 873 | } |
876 | 874 | ||
877 | static int __init | 875 | static int __init init(void) |
878 | init(void) | ||
879 | { | 876 | { |
880 | tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL); | 877 | tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL); |
881 | if (tvmem == NULL) | 878 | if (tvmem == NULL) |