Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6

+919 -480
+406 -172
crypto/tcrypt.c
··· 1 - /* 1 + /* 2 2 * Quick & dirty crypto testing module. 3 3 * 4 4 * This will only exist until we have a better testing mechanism ··· 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify it 11 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 13 * any later version. 14 14 * 15 - * 14 - 09 - 2003 16 - * Rewritten by Kartikey Mahendra Bhatt 15 + * 2004-08-09 Added cipher speed tests (Reyk Floeter <reyk@vantronix.net>) 16 + * 2003-09-14 Rewritten by Kartikey Mahendra Bhatt 17 + * 17 18 */ 18 19 19 20 #include <linux/init.h> ··· 26 25 #include <linux/crypto.h> 27 26 #include <linux/highmem.h> 28 27 #include <linux/moduleparam.h> 28 + #include <linux/jiffies.h> 29 + #include <linux/timex.h> 30 + #include <linux/interrupt.h> 29 31 #include "tcrypt.h" 30 32 31 33 /* 32 34 * Need to kmalloc() memory for testing kmap(). 33 35 */ 34 - #define TVMEMSIZE 4096 36 + #define TVMEMSIZE 16384 35 37 #define XBUFSIZE 32768 36 38 37 39 /* ··· 59 55 60 56 static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 }; 61 57 58 + /* 59 + * Used by test_cipher_speed() 60 + */ 61 + static unsigned int sec; 62 + 62 63 static int mode; 63 64 static char *xbuf; 64 65 static char *tvmem; 65 66 66 67 static char *check[] = { 67 68 "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish", 68 - "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", 69 - "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", 69 + "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", 70 + "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", 70 71 "khazad", "wp512", "wp384", "wp256", "tnepres", NULL 71 72 }; 72 73 73 - static void 74 - hexdump(unsigned char *buf, unsigned int len) 74 + static void hexdump(unsigned char *buf, unsigned int len) 75 75 { 76 76 while (len--) 77 77 printk("%02x", *buf++); ··· 83 75 printk("\n"); 84 76 } 85 77 86 - static void 87 - test_hash (char * algo, struct hash_testvec * template, unsigned int tcount) 78 + static void test_hash(char *algo, struct hash_testvec *template, 79 + unsigned int tcount) 88 80 { 89 - char *p; 90 - unsigned int i, j, k, temp; 91 - struct scatterlist sg[8]; 92 - char result[64]; 93 - struct crypto_tfm *tfm; 94 - struct hash_testvec *hash_tv; 95 - unsigned int tsize; 96 - 97 - printk("\ntesting %s\n", algo); 81 + char *p; 82 + unsigned int i, j, k, temp; 83 + struct scatterlist sg[8]; 84 + char result[64]; 85 + struct crypto_tfm *tfm; 86 + struct hash_testvec *hash_tv; 87 + unsigned int tsize; 98 88 99 - tsize = sizeof (struct hash_testvec); 89 + printk("\ntesting %s\n", algo); 90 + 91 + tsize = sizeof(struct hash_testvec); 100 92 tsize *= tcount; 101 - 93 + 102 94 if (tsize > TVMEMSIZE) { 103 95 printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); 104 96 return; 105 97 } 106 98 107 99 memcpy(tvmem, template, tsize); 108 - hash_tv = (void *) tvmem; 100 + hash_tv = (void *)tvmem; 109 101 tfm = crypto_alloc_tfm(algo, 0); 110 102 if (tfm == NULL) { 111 103 printk("failed to load transform for %s\n", algo); ··· 113 105 } 114 106 115 107 for (i = 0; i < tcount; i++) { 116 - printk ("test %u:\n", i + 1); 117 - memset (result, 0, 64); 108 + printk("test %u:\n", i + 1); 109 + memset(result, 0, 64); 118 110 119 111 p = hash_tv[i].plaintext; 120 - sg[0].page = virt_to_page (p); 121 - sg[0].offset = offset_in_page (p); 112 + sg[0].page = virt_to_page(p); 113 + sg[0].offset = offset_in_page(p); 122 114 sg[0].length = hash_tv[i].psize; 123 115 124 - crypto_digest_init (tfm); 116 + crypto_digest_init(tfm); 125 117 if (tfm->crt_u.digest.dit_setkey) { 126 - crypto_digest_setkey (tfm, hash_tv[i].key, 127 - hash_tv[i].ksize); 118 + crypto_digest_setkey(tfm, hash_tv[i].key, 119 + hash_tv[i].ksize); 128 120 } 129 - crypto_digest_update (tfm, sg, 1); 130 - crypto_digest_final (tfm, result); 121 + crypto_digest_update(tfm, sg, 1); 122 + crypto_digest_final(tfm, result); 131 123 132 - hexdump (result, crypto_tfm_alg_digestsize (tfm)); 124 + hexdump(result, crypto_tfm_alg_digestsize(tfm)); 133 125 printk("%s\n", 134 - memcmp(result, hash_tv[i].digest, 135 - crypto_tfm_alg_digestsize(tfm)) ? "fail" : 136 - "pass"); 126 + memcmp(result, hash_tv[i].digest, 127 + crypto_tfm_alg_digestsize(tfm)) ? 128 + "fail" : "pass"); 137 129 } 138 130 139 - printk ("testing %s across pages\n", algo); 131 + printk("testing %s across pages\n", algo); 140 132 141 133 /* setup the dummy buffer first */ 142 - memset(xbuf, 0, XBUFSIZE); 134 + memset(xbuf, 0, XBUFSIZE); 143 135 144 136 j = 0; 145 137 for (i = 0; i < tcount; i++) { 146 138 if (hash_tv[i].np) { 147 139 j++; 148 - printk ("test %u:\n", j); 149 - memset (result, 0, 64); 140 + printk("test %u:\n", j); 141 + memset(result, 0, 64); 150 142 151 143 temp = 0; 152 144 for (k = 0; k < hash_tv[i].np; k++) { 153 - memcpy (&xbuf[IDX[k]], hash_tv[i].plaintext + temp, 154 - hash_tv[i].tap[k]); 145 + memcpy(&xbuf[IDX[k]], 146 + hash_tv[i].plaintext + temp, 147 + hash_tv[i].tap[k]); 155 148 temp += hash_tv[i].tap[k]; 156 149 p = &xbuf[IDX[k]]; 157 - sg[k].page = virt_to_page (p); 158 - sg[k].offset = offset_in_page (p); 150 + sg[k].page = virt_to_page(p); 151 + sg[k].offset = offset_in_page(p); 159 152 sg[k].length = hash_tv[i].tap[k]; 160 153 } 161 154 162 - crypto_digest_digest (tfm, sg, hash_tv[i].np, result); 163 - 164 - hexdump (result, crypto_tfm_alg_digestsize (tfm)); 155 + crypto_digest_digest(tfm, sg, hash_tv[i].np, result); 156 + 157 + hexdump(result, crypto_tfm_alg_digestsize(tfm)); 165 158 printk("%s\n", 166 - memcmp(result, hash_tv[i].digest, 167 - crypto_tfm_alg_digestsize(tfm)) ? "fail" : 168 - "pass"); 159 + memcmp(result, hash_tv[i].digest, 160 + crypto_tfm_alg_digestsize(tfm)) ? 161 + "fail" : "pass"); 169 162 } 170 163 } 171 - 172 - crypto_free_tfm (tfm); 164 + 165 + crypto_free_tfm(tfm); 173 166 } 174 167 175 168 176 169 #ifdef CONFIG_CRYPTO_HMAC 177 170 178 - static void 179 - test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount) 171 + static void test_hmac(char *algo, struct hmac_testvec *template, 172 + unsigned int tcount) 180 173 { 181 174 char *p; 182 175 unsigned int i, j, k, temp; ··· 194 185 } 195 186 196 187 printk("\ntesting hmac_%s\n", algo); 197 - 198 - tsize = sizeof (struct hmac_testvec); 188 + 189 + tsize = sizeof(struct hmac_testvec); 199 190 tsize *= tcount; 200 191 if (tsize > TVMEMSIZE) { 201 192 printk("template (%u) too big for tvmem (%u)\n", tsize, ··· 204 195 } 205 196 206 197 memcpy(tvmem, template, tsize); 207 - hmac_tv = (void *) tvmem; 198 + hmac_tv = (void *)tvmem; 208 199 209 200 for (i = 0; i < tcount; i++) { 210 201 printk("test %u:\n", i + 1); ··· 228 219 printk("\ntesting hmac_%s across pages\n", algo); 229 220 230 221 memset(xbuf, 0, XBUFSIZE); 231 - 222 + 232 223 j = 0; 233 224 for (i = 0; i < tcount; i++) { 234 225 if (hmac_tv[i].np) { 235 226 j++; 236 - printk ("test %u:\n",j); 237 - memset (result, 0, 64); 227 + printk("test %u:\n",j); 228 + memset(result, 0, 64); 238 229 239 230 temp = 0; 240 231 klen = hmac_tv[i].ksize; 241 232 for (k = 0; k < hmac_tv[i].np; k++) { 242 - memcpy (&xbuf[IDX[k]], hmac_tv[i].plaintext + temp, 243 - hmac_tv[i].tap[k]); 233 + memcpy(&xbuf[IDX[k]], 234 + hmac_tv[i].plaintext + temp, 235 + hmac_tv[i].tap[k]); 244 236 temp += hmac_tv[i].tap[k]; 245 237 p = &xbuf[IDX[k]]; 246 - sg[k].page = virt_to_page (p); 247 - sg[k].offset = offset_in_page (p); 238 + sg[k].page = virt_to_page(p); 239 + sg[k].offset = offset_in_page(p); 248 240 sg[k].length = hmac_tv[i].tap[k]; 249 241 } 250 242 251 - crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, hmac_tv[i].np, 252 - result); 243 + crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 244 + hmac_tv[i].np, result); 253 245 hexdump(result, crypto_tfm_alg_digestsize(tfm)); 254 - 246 + 255 247 printk("%s\n", 256 - memcmp(result, hmac_tv[i].digest, 257 - crypto_tfm_alg_digestsize(tfm)) ? "fail" : 258 - "pass"); 248 + memcmp(result, hmac_tv[i].digest, 249 + crypto_tfm_alg_digestsize(tfm)) ? 250 + "fail" : "pass"); 259 251 } 260 252 } 261 253 out: ··· 265 255 266 256 #endif /* CONFIG_CRYPTO_HMAC */ 267 257 268 - static void 269 - test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, unsigned int tcount) 258 + static void test_cipher(char *algo, int mode, int enc, 259 + struct cipher_testvec *template, unsigned int tcount) 270 260 { 271 261 unsigned int ret, i, j, k, temp; 272 262 unsigned int tsize; ··· 275 265 char *key; 276 266 struct cipher_testvec *cipher_tv; 277 267 struct scatterlist sg[8]; 278 - char e[11], m[4]; 268 + const char *e, *m; 279 269 280 270 if (enc == ENCRYPT) 281 - strncpy(e, "encryption", 11); 271 + e = "encryption"; 282 272 else 283 - strncpy(e, "decryption", 11); 273 + e = "decryption"; 284 274 if (mode == MODE_ECB) 285 - strncpy(m, "ECB", 4); 275 + m = "ECB"; 286 276 else 287 - strncpy(m, "CBC", 4); 277 + m = "CBC"; 288 278 289 - printk("\ntesting %s %s %s \n", algo, m, e); 279 + printk("\ntesting %s %s %s\n", algo, m, e); 290 280 291 - tsize = sizeof (struct cipher_testvec); 281 + tsize = sizeof (struct cipher_testvec); 292 282 tsize *= tcount; 293 - 283 + 294 284 if (tsize > TVMEMSIZE) { 295 285 printk("template (%u) too big for tvmem (%u)\n", tsize, 296 286 TVMEMSIZE); ··· 298 288 } 299 289 300 290 memcpy(tvmem, template, tsize); 301 - cipher_tv = (void *) tvmem; 291 + cipher_tv = (void *)tvmem; 302 292 303 - if (mode) 304 - tfm = crypto_alloc_tfm (algo, 0); 305 - else 306 - tfm = crypto_alloc_tfm (algo, CRYPTO_TFM_MODE_CBC); 307 - 293 + if (mode) 294 + tfm = crypto_alloc_tfm(algo, 0); 295 + else 296 + tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC); 297 + 308 298 if (tfm == NULL) { 309 299 printk("failed to load transform for %s %s\n", algo, m); 310 300 return; 311 301 } 312 - 302 + 313 303 j = 0; 314 304 for (i = 0; i < tcount; i++) { 315 305 if (!(cipher_tv[i].np)) { 316 - j++; 306 + j++; 317 307 printk("test %u (%d bit key):\n", 318 308 j, cipher_tv[i].klen * 8); 319 309 320 310 tfm->crt_flags = 0; 321 - if (cipher_tv[i].wk) 311 + if (cipher_tv[i].wk) 322 312 tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; 323 313 key = cipher_tv[i].key; 324 - 314 + 325 315 ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); 326 316 if (ret) { 327 317 printk("setkey() failed flags=%x\n", tfm->crt_flags); 328 - 318 + 329 319 if (!cipher_tv[i].fail) 330 320 goto out; 331 - } 321 + } 332 322 333 323 p = cipher_tv[i].input; 334 324 sg[0].page = virt_to_page(p); 335 325 sg[0].offset = offset_in_page(p); 336 326 sg[0].length = cipher_tv[i].ilen; 337 - 327 + 338 328 if (!mode) { 339 329 crypto_cipher_set_iv(tfm, cipher_tv[i].iv, 340 - crypto_tfm_alg_ivsize (tfm)); 330 + crypto_tfm_alg_ivsize(tfm)); 341 331 } 342 - 332 + 343 333 if (enc) 344 334 ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen); 345 335 else 346 336 ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen); 347 - 348 - 337 + 338 + 349 339 if (ret) { 350 340 printk("%s () failed flags=%x\n", e, tfm->crt_flags); 351 341 goto out; 352 - } 353 - 342 + } 343 + 354 344 q = kmap(sg[0].page) + sg[0].offset; 355 345 hexdump(q, cipher_tv[i].rlen); 356 - 357 - printk("%s\n", 358 - memcmp(q, cipher_tv[i].result, cipher_tv[i].rlen) ? "fail" : 359 - "pass"); 346 + 347 + printk("%s\n", 348 + memcmp(q, cipher_tv[i].result, 349 + cipher_tv[i].rlen) ? "fail" : "pass"); 360 350 } 361 351 } 362 - 363 - printk("\ntesting %s %s %s across pages (chunking) \n", algo, m, e); 352 + 353 + printk("\ntesting %s %s %s across pages (chunking)\n", algo, m, e); 364 354 memset(xbuf, 0, XBUFSIZE); 365 - 355 + 366 356 j = 0; 367 357 for (i = 0; i < tcount; i++) { 368 358 if (cipher_tv[i].np) { 369 - j++; 359 + j++; 370 360 printk("test %u (%d bit key):\n", 371 361 j, cipher_tv[i].klen * 8); 372 362 373 - tfm->crt_flags = 0; 374 - if (cipher_tv[i].wk) 363 + tfm->crt_flags = 0; 364 + if (cipher_tv[i].wk) 375 365 tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; 376 366 key = cipher_tv[i].key; 377 - 378 - ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); 367 + 368 + ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); 379 369 if (ret) { 380 370 printk("setkey() failed flags=%x\n", tfm->crt_flags); 381 - 371 + 382 372 if (!cipher_tv[i].fail) 383 373 goto out; 384 374 } 385 375 386 376 temp = 0; 387 377 for (k = 0; k < cipher_tv[i].np; k++) { 388 - memcpy (&xbuf[IDX[k]], cipher_tv[i].input + temp, 389 - cipher_tv[i].tap[k]); 378 + memcpy(&xbuf[IDX[k]], 379 + cipher_tv[i].input + temp, 380 + cipher_tv[i].tap[k]); 390 381 temp += cipher_tv[i].tap[k]; 391 382 p = &xbuf[IDX[k]]; 392 - sg[k].page = virt_to_page (p); 393 - sg[k].offset = offset_in_page (p); 383 + sg[k].page = virt_to_page(p); 384 + sg[k].offset = offset_in_page(p); 394 385 sg[k].length = cipher_tv[i].tap[k]; 395 386 } 396 - 387 + 397 388 if (!mode) { 398 389 crypto_cipher_set_iv(tfm, cipher_tv[i].iv, 399 - crypto_tfm_alg_ivsize (tfm)); 390 + crypto_tfm_alg_ivsize(tfm)); 400 391 } 401 - 392 + 402 393 if (enc) 403 394 ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen); 404 395 else 405 396 ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen); 406 - 397 + 407 398 if (ret) { 408 399 printk("%s () failed flags=%x\n", e, tfm->crt_flags); 409 400 goto out; ··· 415 404 printk("page %u\n", k); 416 405 q = kmap(sg[k].page) + sg[k].offset; 417 406 hexdump(q, cipher_tv[i].tap[k]); 418 - printk("%s\n", 419 - memcmp(q, cipher_tv[i].result + temp, 420 - cipher_tv[i].tap[k]) ? "fail" : 407 + printk("%s\n", 408 + memcmp(q, cipher_tv[i].result + temp, 409 + cipher_tv[i].tap[k]) ? "fail" : 421 410 "pass"); 422 411 temp += cipher_tv[i].tap[k]; 423 412 } ··· 428 417 crypto_free_tfm(tfm); 429 418 } 430 419 431 - static void 432 - test_deflate(void) 420 + static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p, 421 + int blen, int sec) 422 + { 423 + struct scatterlist sg[8]; 424 + unsigned long start, end; 425 + int bcount; 426 + int ret; 427 + 428 + sg[0].page = virt_to_page(p); 429 + sg[0].offset = offset_in_page(p); 430 + sg[0].length = blen; 431 + 432 + for (start = jiffies, end = start + sec * HZ, bcount = 0; 433 + time_before(jiffies, end); bcount++) { 434 + if (enc) 435 + ret = crypto_cipher_encrypt(tfm, sg, sg, blen); 436 + else 437 + ret = crypto_cipher_decrypt(tfm, sg, sg, blen); 438 + 439 + if (ret) 440 + return ret; 441 + } 442 + 443 + printk("%d operations in %d seconds (%ld bytes)\n", 444 + bcount, sec, (long)bcount * blen); 445 + return 0; 446 + } 447 + 448 + static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p, 449 + int blen) 450 + { 451 + struct scatterlist sg[8]; 452 + unsigned long cycles = 0; 453 + int ret = 0; 454 + int i; 455 + 456 + sg[0].page = virt_to_page(p); 457 + sg[0].offset = offset_in_page(p); 458 + sg[0].length = blen; 459 + 460 + local_bh_disable(); 461 + local_irq_disable(); 462 + 463 + /* Warm-up run. */ 464 + for (i = 0; i < 4; i++) { 465 + if (enc) 466 + ret = crypto_cipher_encrypt(tfm, sg, sg, blen); 467 + else 468 + ret = crypto_cipher_decrypt(tfm, sg, sg, blen); 469 + 470 + if (ret) 471 + goto out; 472 + } 473 + 474 + /* The real thing. */ 475 + for (i = 0; i < 8; i++) { 476 + cycles_t start, end; 477 + 478 + start = get_cycles(); 479 + if (enc) 480 + ret = crypto_cipher_encrypt(tfm, sg, sg, blen); 481 + else 482 + ret = crypto_cipher_decrypt(tfm, sg, sg, blen); 483 + end = get_cycles(); 484 + 485 + if (ret) 486 + goto out; 487 + 488 + cycles += end - start; 489 + } 490 + 491 + out: 492 + local_irq_enable(); 493 + local_bh_enable(); 494 + 495 + if (ret == 0) 496 + printk("1 operation in %lu cycles (%d bytes)\n", 497 + (cycles + 4) / 8, blen); 498 + 499 + return ret; 500 + } 501 + 502 + static void test_cipher_speed(char *algo, int mode, int enc, unsigned int sec, 503 + struct cipher_testvec *template, 504 + unsigned int tcount, struct cipher_speed *speed) 505 + { 506 + unsigned int ret, i, j, iv_len; 507 + unsigned char *key, *p, iv[128]; 508 + struct crypto_tfm *tfm; 509 + const char *e, *m; 510 + 511 + if (enc == ENCRYPT) 512 + e = "encryption"; 513 + else 514 + e = "decryption"; 515 + if (mode == MODE_ECB) 516 + m = "ECB"; 517 + else 518 + m = "CBC"; 519 + 520 + printk("\ntesting speed of %s %s %s\n", algo, m, e); 521 + 522 + if (mode) 523 + tfm = crypto_alloc_tfm(algo, 0); 524 + else 525 + tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC); 526 + 527 + if (tfm == NULL) { 528 + printk("failed to load transform for %s %s\n", algo, m); 529 + return; 530 + } 531 + 532 + for (i = 0; speed[i].klen != 0; i++) { 533 + if ((speed[i].blen + speed[i].klen) > TVMEMSIZE) { 534 + printk("template (%u) too big for tvmem (%u)\n", 535 + speed[i].blen + speed[i].klen, TVMEMSIZE); 536 + goto out; 537 + } 538 + 539 + printk("test %u (%d bit key, %d byte blocks): ", i, 540 + speed[i].klen * 8, speed[i].blen); 541 + 542 + memset(tvmem, 0xff, speed[i].klen + speed[i].blen); 543 + 544 + /* set key, plain text and IV */ 545 + key = (unsigned char *)tvmem; 546 + for (j = 0; j < tcount; j++) { 547 + if (template[j].klen == speed[i].klen) { 548 + key = template[j].key; 549 + break; 550 + } 551 + } 552 + p = (unsigned char *)tvmem + speed[i].klen; 553 + 554 + ret = crypto_cipher_setkey(tfm, key, speed[i].klen); 555 + if (ret) { 556 + printk("setkey() failed flags=%x\n", tfm->crt_flags); 557 + goto out; 558 + } 559 + 560 + if (!mode) { 561 + iv_len = crypto_tfm_alg_ivsize(tfm); 562 + memset(&iv, 0xff, iv_len); 563 + crypto_cipher_set_iv(tfm, iv, iv_len); 564 + } 565 + 566 + if (sec) 567 + ret = test_cipher_jiffies(tfm, enc, p, speed[i].blen, 568 + sec); 569 + else 570 + ret = test_cipher_cycles(tfm, enc, p, speed[i].blen); 571 + 572 + if (ret) { 573 + printk("%s() failed flags=%x\n", e, tfm->crt_flags); 574 + break; 575 + } 576 + } 577 + 578 + out: 579 + crypto_free_tfm(tfm); 580 + } 581 + 582 + static void test_deflate(void) 433 583 { 434 584 unsigned int i; 435 585 char result[COMP_BUF_SIZE]; ··· 608 436 } 609 437 610 438 memcpy(tvmem, deflate_comp_tv_template, tsize); 611 - tv = (void *) tvmem; 439 + tv = (void *)tvmem; 612 440 613 441 tfm = crypto_alloc_tfm("deflate", 0); 614 442 if (tfm == NULL) { ··· 618 446 619 447 for (i = 0; i < DEFLATE_COMP_TEST_VECTORS; i++) { 620 448 int ilen, ret, dlen = COMP_BUF_SIZE; 621 - 449 + 622 450 printk("test %u:\n", i + 1); 623 451 memset(result, 0, sizeof (result)); 624 452 ··· 645 473 } 646 474 647 475 memcpy(tvmem, deflate_decomp_tv_template, tsize); 648 - tv = (void *) tvmem; 476 + tv = (void *)tvmem; 649 477 650 478 for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) { 651 479 int ilen, ret, dlen = COMP_BUF_SIZE; 652 - 480 + 653 481 printk("test %u:\n", i + 1); 654 482 memset(result, 0, sizeof (result)); 655 483 ··· 669 497 crypto_free_tfm(tfm); 670 498 } 671 499 672 - static void 673 - test_crc32c(void) 500 + static void test_crc32c(void) 674 501 { 675 502 #define NUMVEC 6 676 503 #define VECSIZE 40 ··· 682 511 0xd579c862, 0xba979ad0, 0x2b29d913 683 512 }; 684 513 static u32 tot_vec_results = 0x24c5d375; 685 - 514 + 686 515 struct scatterlist sg[NUMVEC]; 687 516 struct crypto_tfm *tfm; 688 517 char *fmtdata = "testing crc32c initialized to %08x: %s\n"; ··· 696 525 printk("failed to load transform for crc32c\n"); 697 526 return; 698 527 } 699 - 528 + 700 529 crypto_digest_init(tfm); 701 530 crypto_digest_final(tfm, (u8*)&crc); 702 531 printk(fmtdata, crc, (crc == 0) ? "pass" : "ERROR"); 703 - 532 + 704 533 /* 705 534 * stuff test_vec with known values, simple incrementing 706 535 * byte values. 707 536 */ 708 537 b = 0; 709 538 for (i = 0; i < NUMVEC; i++) { 710 - for (j = 0; j < VECSIZE; j++) 539 + for (j = 0; j < VECSIZE; j++) 711 540 test_vec[i][j] = ++b; 712 541 sg[i].page = virt_to_page(test_vec[i]); 713 542 sg[i].offset = offset_in_page(test_vec[i]); ··· 719 548 crypto_digest_final(tfm, (u8*)&crc); 720 549 printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ? 721 550 "pass" : "ERROR"); 722 - 551 + 723 552 printk("testing crc32c using update/final:\n"); 724 553 725 554 pass = 1; /* assume all is well */ 726 - 555 + 727 556 for (i = 0; i < NUMVEC; i++) { 728 557 seed = ~(u32)0; 729 558 (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); ··· 762 591 printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results); 763 592 pass = 0; 764 593 } 765 - 594 + 766 595 printk("\n%s\n", pass ? "pass" : "ERROR"); 767 596 768 597 crypto_free_tfm(tfm); 769 598 printk("crc32c test complete\n"); 770 599 } 771 600 772 - static void 773 - test_available(void) 601 + static void test_available(void) 774 602 { 775 603 char **name = check; 776 - 604 + 777 605 while (*name) { 778 606 printk("alg %s ", *name); 779 607 printk((crypto_alg_available(*name, 0)) ? 780 608 "found\n" : "not found\n"); 781 609 name++; 782 - } 610 + } 783 611 } 784 612 785 - static void 786 - do_test(void) 613 + static void do_test(void) 787 614 { 788 615 switch (mode) { 789 616 790 617 case 0: 791 618 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS); 792 - 619 + 793 620 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS); 794 - 621 + 795 622 //DES 796 623 test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS); 797 - test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS); 798 - test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS); 799 - test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS); 800 - 624 + test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS); 625 + test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS); 626 + test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS); 627 + 801 628 //DES3_EDE 802 629 test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS); 803 - test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); 804 - 630 + test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); 631 + 805 632 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); 806 - 633 + 807 634 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); 808 - 635 + 809 636 //BLOWFISH 810 637 test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS); 811 638 test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS); 812 639 test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS); 813 640 test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS); 814 - 641 + 815 642 //TWOFISH 816 643 test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS); 817 644 test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS); 818 645 test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS); 819 646 test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS); 820 - 647 + 821 648 //SERPENT 822 649 test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS); 823 650 test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS); 824 - 651 + 825 652 //TNEPRES 826 653 test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS); 827 654 test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS); ··· 831 662 //CAST5 832 663 test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS); 833 664 test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS); 834 - 665 + 835 666 //CAST6 836 667 test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS); 837 668 test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS); ··· 871 702 test_crc32c(); 872 703 #ifdef CONFIG_CRYPTO_HMAC 873 704 test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); 874 - test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); 705 + test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); 875 706 test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS); 876 - #endif 707 + #endif 877 708 878 709 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS); 879 710 break; ··· 895 726 896 727 case 4: 897 728 test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS); 898 - test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); 729 + test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); 899 730 break; 900 731 901 732 case 5: 902 733 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); 903 734 break; 904 - 735 + 905 736 case 6: 906 737 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); 907 738 break; 908 - 739 + 909 740 case 7: 910 741 test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS); 911 742 test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS); ··· 919 750 test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS); 920 751 test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS); 921 752 break; 922 - 753 + 923 754 case 9: 924 755 test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS); 925 756 test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS); ··· 927 758 928 759 case 10: 929 760 test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS); 930 - test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS); 761 + test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS); 931 762 break; 932 763 933 764 case 11: 934 765 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); 935 766 break; 936 - 767 + 937 768 case 12: 938 769 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); 939 770 break; ··· 1021 852 case 100: 1022 853 test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); 1023 854 break; 1024 - 855 + 1025 856 case 101: 1026 - test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); 857 + test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); 1027 858 break; 1028 - 859 + 1029 860 case 102: 1030 861 test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS); 1031 862 break; 1032 863 1033 864 #endif 1034 865 866 + case 200: 867 + test_cipher_speed("aes", MODE_ECB, ENCRYPT, sec, NULL, 0, 868 + aes_speed_template); 869 + test_cipher_speed("aes", MODE_ECB, DECRYPT, sec, NULL, 0, 870 + aes_speed_template); 871 + test_cipher_speed("aes", MODE_CBC, ENCRYPT, sec, NULL, 0, 872 + aes_speed_template); 873 + test_cipher_speed("aes", MODE_CBC, DECRYPT, sec, NULL, 0, 874 + aes_speed_template); 875 + break; 876 + 877 + case 201: 878 + test_cipher_speed("des3_ede", MODE_ECB, ENCRYPT, sec, 879 + des3_ede_enc_tv_template, 880 + DES3_EDE_ENC_TEST_VECTORS, 881 + des3_ede_speed_template); 882 + test_cipher_speed("des3_ede", MODE_ECB, DECRYPT, sec, 883 + des3_ede_dec_tv_template, 884 + DES3_EDE_DEC_TEST_VECTORS, 885 + des3_ede_speed_template); 886 + test_cipher_speed("des3_ede", MODE_CBC, ENCRYPT, sec, 887 + des3_ede_enc_tv_template, 888 + DES3_EDE_ENC_TEST_VECTORS, 889 + des3_ede_speed_template); 890 + test_cipher_speed("des3_ede", MODE_CBC, DECRYPT, sec, 891 + des3_ede_dec_tv_template, 892 + DES3_EDE_DEC_TEST_VECTORS, 893 + des3_ede_speed_template); 894 + break; 895 + 896 + case 202: 897 + test_cipher_speed("twofish", MODE_ECB, ENCRYPT, sec, NULL, 0, 898 + twofish_speed_template); 899 + test_cipher_speed("twofish", MODE_ECB, DECRYPT, sec, NULL, 0, 900 + twofish_speed_template); 901 + test_cipher_speed("twofish", MODE_CBC, ENCRYPT, sec, NULL, 0, 902 + twofish_speed_template); 903 + test_cipher_speed("twofish", MODE_CBC, DECRYPT, sec, NULL, 0, 904 + twofish_speed_template); 905 + break; 906 + 907 + case 203: 908 + test_cipher_speed("blowfish", MODE_ECB, ENCRYPT, sec, NULL, 0, 909 + blowfish_speed_template); 910 + test_cipher_speed("blowfish", MODE_ECB, DECRYPT, sec, NULL, 0, 911 + blowfish_speed_template); 912 + test_cipher_speed("blowfish", MODE_CBC, ENCRYPT, sec, NULL, 0, 913 + blowfish_speed_template); 914 + test_cipher_speed("blowfish", MODE_CBC, DECRYPT, sec, NULL, 0, 915 + blowfish_speed_template); 916 + break; 917 + 918 + case 204: 919 + test_cipher_speed("des", MODE_ECB, ENCRYPT, sec, NULL, 0, 920 + des_speed_template); 921 + test_cipher_speed("des", MODE_ECB, DECRYPT, sec, NULL, 0, 922 + des_speed_template); 923 + test_cipher_speed("des", MODE_CBC, ENCRYPT, sec, NULL, 0, 924 + des_speed_template); 925 + test_cipher_speed("des", MODE_CBC, DECRYPT, sec, NULL, 0, 926 + des_speed_template); 927 + break; 928 + 1035 929 case 1000: 1036 930 test_available(); 1037 931 break; 1038 - 932 + 1039 933 default: 1040 934 /* useful for debugging */ 1041 935 printk("not testing anything\n"); ··· 1106 874 } 1107 875 } 1108 876 1109 - static int __init 1110 - init(void) 877 + static int __init init(void) 1111 878 { 1112 879 tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL); 1113 880 if (tvmem == NULL) ··· 1135 904 module_exit(fini); 1136 905 1137 906 module_param(mode, int, 0); 907 + module_param(sec, uint, 0); 908 + MODULE_PARM_DESC(sec, "Length in seconds of speed tests " 909 + "(defaults to zero which uses CPU cycles instead)"); 1138 910 1139 911 MODULE_LICENSE("GPL"); 1140 912 MODULE_DESCRIPTION("Quick & dirty crypto testing module");
+262 -187
crypto/tcrypt.h
··· 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify it 11 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 13 * any later version. 14 14 * 15 - * 14 - 09 - 2003 Changes by Kartikey Mahendra Bhatt 15 + * 2004-08-09 Cipher speed tests by Reyk Floeter <reyk@vantronix.net> 16 + * 2003-09-14 Changes by Kartikey Mahendra Bhatt 16 17 * 17 18 */ 18 19 #ifndef _CRYPTO_TCRYPT_H ··· 30 29 unsigned char psize; 31 30 char digest[MAX_DIGEST_SIZE]; 32 31 unsigned char np; 33 - unsigned char tap[MAX_TAP]; 32 + unsigned char tap[MAX_TAP]; 34 33 char key[128]; /* only used with keyed hash algorithms */ 35 34 unsigned char ksize; 36 35 }; 37 36 38 - struct hmac_testvec { 37 + struct hmac_testvec { 39 38 char key[128]; 40 39 unsigned char ksize; 41 40 char plaintext[128]; 42 41 unsigned char psize; 43 42 char digest[MAX_DIGEST_SIZE]; 44 43 unsigned char np; 45 - unsigned char tap[MAX_TAP]; 44 + unsigned char tap[MAX_TAP]; 46 45 }; 47 46 48 47 struct cipher_testvec { ··· 56 55 char result[48]; 57 56 unsigned char rlen; 58 57 int np; 59 - unsigned char tap[MAX_TAP]; 58 + unsigned char tap[MAX_TAP]; 59 + }; 60 + 61 + struct cipher_speed { 62 + unsigned char klen; 63 + unsigned int blen; 60 64 }; 61 65 62 66 /* ··· 161 155 #define SHA1_TEST_VECTORS 2 162 156 163 157 static struct hash_testvec sha1_tv_template[] = { 164 - { 158 + { 165 159 .plaintext = "abc", 166 160 .psize = 3, 167 161 .digest = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, ··· 181 175 */ 182 176 #define SHA256_TEST_VECTORS 2 183 177 184 - static struct hash_testvec sha256_tv_template[] = { 185 - { 178 + static struct hash_testvec sha256_tv_template[] = { 179 + { 186 180 .plaintext = "abc", 187 181 .psize = 3, 188 182 .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, ··· 207 201 #define SHA384_TEST_VECTORS 4 208 202 209 203 static struct hash_testvec sha384_tv_template[] = { 210 - { 204 + { 211 205 .plaintext= "abc", 212 206 .psize = 3, 213 207 .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, ··· 227 221 0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b}, 228 222 }, { 229 223 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" 230 - "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 224 + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 231 225 .psize = 112, 232 226 .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, 233 227 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, ··· 256 250 #define SHA512_TEST_VECTORS 4 257 251 258 252 static struct hash_testvec sha512_tv_template[] = { 259 - { 253 + { 260 254 .plaintext = "abc", 261 255 .psize = 3, 262 256 .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, ··· 309 303 310 304 311 305 /* 312 - * WHIRLPOOL test vectors from Whirlpool package 306 + * WHIRLPOOL test vectors from Whirlpool package 313 307 * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE 314 308 * submission 315 309 */ 316 310 #define WP512_TEST_VECTORS 8 317 311 318 312 static struct hash_testvec wp512_tv_template[] = { 319 - { 313 + { 320 314 .plaintext = "", 321 315 .psize = 0, 322 316 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66, ··· 354 348 }, { 355 349 .plaintext = "message digest", 356 350 .psize = 14, 357 - .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 358 - 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 359 - 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 360 - 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B, 361 - 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1, 362 - 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6, 363 - 0x92, 0xED, 0x92, 0x00, 0x52, 0x83, 0x8F, 0x33, 351 + .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 352 + 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 353 + 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 354 + 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B, 355 + 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1, 356 + 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6, 357 + 0x92, 0xED, 0x92, 0x00, 0x52, 0x83, 0x8F, 0x33, 364 358 0x62, 0xE8, 0x6D, 0xBD, 0x37, 0xA8, 0x90, 0x3E }, 365 359 }, { 366 360 .plaintext = "abcdefghijklmnopqrstuvwxyz", ··· 400 394 }, { 401 395 .plaintext = "abcdbcdecdefdefgefghfghighijhijk", 402 396 .psize = 32, 403 - .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 397 + .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 404 398 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48, 405 399 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62, 406 400 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69, ··· 414 408 #define WP384_TEST_VECTORS 8 415 409 416 410 static struct hash_testvec wp384_tv_template[] = { 417 - { 411 + { 418 412 .plaintext = "", 419 413 .psize = 0, 420 414 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66, ··· 446 440 }, { 447 441 .plaintext = "message digest", 448 442 .psize = 14, 449 - .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 450 - 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 451 - 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 452 - 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B, 453 - 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1, 443 + .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 444 + 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 445 + 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 446 + 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B, 447 + 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1, 454 448 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6 }, 455 449 }, { 456 450 .plaintext = "abcdefghijklmnopqrstuvwxyz", ··· 484 478 }, { 485 479 .plaintext = "abcdbcdecdefdefgefghfghighijhijk", 486 480 .psize = 32, 487 - .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 481 + .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 488 482 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48, 489 483 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62, 490 484 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69, ··· 496 490 #define WP256_TEST_VECTORS 8 497 491 498 492 static struct hash_testvec wp256_tv_template[] = { 499 - { 493 + { 500 494 .plaintext = "", 501 495 .psize = 0, 502 496 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66, ··· 522 516 }, { 523 517 .plaintext = "message digest", 524 518 .psize = 14, 525 - .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 526 - 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 527 - 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 519 + .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 520 + 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 521 + 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 528 522 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B }, 529 523 }, { 530 524 .plaintext = "abcdefghijklmnopqrstuvwxyz", ··· 552 546 }, { 553 547 .plaintext = "abcdbcdecdefdefgefghfghighijhijk", 554 548 .psize = 32, 555 - .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 549 + .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 556 550 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48, 557 551 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62, 558 552 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69 }, ··· 560 554 }; 561 555 562 556 /* 563 - * TIGER test vectors from Tiger website 557 + * TIGER test vectors from Tiger website 564 558 */ 565 559 #define TGR192_TEST_VECTORS 6 566 560 ··· 699 693 #define HMAC_MD5_TEST_VECTORS 7 700 694 701 695 static struct hmac_testvec hmac_md5_tv_template[] = 702 - { 696 + { 703 697 { 704 698 .key = { [0 ... 15] = 0x0b }, 705 699 .ksize = 16, ··· 762 756 */ 763 757 #define HMAC_SHA1_TEST_VECTORS 7 764 758 765 - static struct hmac_testvec hmac_sha1_tv_template[] = { 759 + static struct hmac_testvec hmac_sha1_tv_template[] = { 766 760 { 767 761 .key = { [0 ... 19] = 0x0b }, 768 762 .ksize = 20, ··· 772 766 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, 0xf1, 773 767 0x46, 0xbe }, 774 768 }, { 775 - .key = { 'J', 'e', 'f', 'e' }, 769 + .key = { 'J', 'e', 'f', 'e' }, 776 770 .ksize = 4, 777 771 .plaintext = "what do ya want for nothing?", 778 772 .psize = 28, 779 - .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74, 773 + .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74, 780 774 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, 0x25, 0x9a, 0x7c, 0x79 }, 781 775 .np = 2, 782 776 .tap = { 14, 14 } ··· 785 779 .ksize = 20, 786 780 .plaintext = { [0 ... 49] = 0xdd }, 787 781 .psize = 50, 788 - .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3, 782 + .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3, 789 783 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, 0x63, 0xf1, 0x75, 0xd3 }, 790 784 }, { 791 785 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 792 - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 786 + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 793 787 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 }, 794 788 .ksize = 25, 795 789 .plaintext = { [0 ... 49] = 0xcd }, 796 790 .psize = 50, 797 - .digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84, 791 + .digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84, 798 792 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, 0x2d, 0x72, 0x35, 0xda }, 799 793 }, { 800 794 .key = { [0 ... 19] = 0x0c }, 801 795 .ksize = 20, 802 796 .plaintext = "Test With Truncation", 803 797 .psize = 20, 804 - .digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2, 798 + .digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2, 805 799 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, 0x4a, 0x9a, 0x5a, 0x04 }, 806 800 }, { 807 801 .key = { [0 ... 79] = 0xaa }, 808 802 .ksize = 80, 809 803 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First", 810 804 .psize = 54, 811 - .digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70, 805 + .digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70, 812 806 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12 }, 813 807 }, { 814 808 .key = { [0 ... 79] = 0xaa }, ··· 816 810 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One " 817 811 "Block-Size Data", 818 812 .psize = 73, 819 - .digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b, 813 + .digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b, 820 814 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91 }, 821 815 }, 822 816 }; ··· 1017 1011 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b }, 1018 1012 .rlen = 32, 1019 1013 .np = 3, 1020 - .tap = { 14, 10, 8 } 1014 + .tap = { 14, 10, 8 } 1021 1015 }, { 1022 1016 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1023 1017 .klen = 8, ··· 1030 1024 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 }, 1031 1025 .rlen = 24, 1032 1026 .np = 4, 1033 - .tap = { 2, 1, 3, 18 } 1027 + .tap = { 2, 1, 3, 18 } 1034 1028 }, { 1035 1029 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1036 1030 .klen = 8, ··· 1041 1035 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b }, 1042 1036 .rlen = 16, 1043 1037 .np = 5, 1044 - .tap = { 2, 2, 2, 2, 8 } 1038 + .tap = { 2, 2, 2, 2, 8 } 1045 1039 }, { 1046 1040 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1047 1041 .klen = 8, ··· 1050 1044 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d }, 1051 1045 .rlen = 8, 1052 1046 .np = 8, 1053 - .tap = { 1, 1, 1, 1, 1, 1, 1, 1 } 1047 + .tap = { 1, 1, 1, 1, 1, 1, 1, 1 } 1054 1048 }, 1055 1049 }; 1056 1050 ··· 1063 1057 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 }, 1064 1058 .rlen = 8, 1065 1059 }, { /* Sbox test from NBS */ 1066 - .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 }, 1060 + .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 }, 1067 1061 .klen = 8, 1068 1062 .input = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b }, 1069 1063 .ilen = 8, ··· 1098 1092 { /* From OpenSSL */ 1099 1093 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}, 1100 1094 .klen = 8, 1101 - .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, 1102 - .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 1103 - 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 1104 - 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1095 + .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, 1096 + .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 1097 + 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 1098 + 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1105 1099 .ilen = 24, 1106 - .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4, 1107 - 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb, 1108 - 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 }, 1100 + .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4, 1101 + 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb, 1102 + 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 }, 1109 1103 .rlen = 24, 1110 1104 }, { /* FIPS Pub 81 */ 1111 1105 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1112 1106 .klen = 8, 1113 - .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }, 1107 + .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }, 1114 1108 .input = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 }, 1115 1109 .ilen = 8, 1116 1110 .result = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c }, ··· 1123 1117 .ilen = 8, 1124 1118 .result = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1125 1119 .rlen = 8, 1126 - }, { 1120 + }, { 1127 1121 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1128 1122 .klen = 8, 1129 1123 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, ··· 1131 1125 .ilen = 8, 1132 1126 .result = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 }, 1133 1127 .rlen = 8, 1134 - }, { /* Copy of openssl vector for chunk testing */ 1128 + }, { /* Copy of openssl vector for chunk testing */ 1135 1129 /* From OpenSSL */ 1136 1130 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}, 1137 1131 .klen = 8, 1138 - .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, 1139 - .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 1140 - 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 1141 - 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1132 + .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, 1133 + .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 1134 + 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 1135 + 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1142 1136 .ilen = 24, 1143 - .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4, 1144 - 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb, 1145 - 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 }, 1137 + .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4, 1138 + 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb, 1139 + 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 }, 1146 1140 .rlen = 24, 1147 1141 .np = 2, 1148 1142 .tap = { 13, 11 } ··· 1161 1155 }, { 1162 1156 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1163 1157 .klen = 8, 1164 - .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c }, 1158 + .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c }, 1165 1159 .input = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1166 1160 .ilen = 8, 1167 - .result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1161 + .result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1168 1162 .rlen = 8, 1169 1163 }, { 1170 1164 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1171 1165 .klen = 8, 1172 1166 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1173 - .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 }, 1167 + .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 }, 1174 1168 .ilen = 8, 1175 1169 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 }, 1176 1170 .rlen = 8, 1177 - }, { /* Copy of above, for chunk testing */ 1171 + }, { /* Copy of above, for chunk testing */ 1178 1172 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1179 1173 .klen = 8, 1180 1174 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1181 - .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 }, 1175 + .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 }, 1182 1176 .ilen = 8, 1183 1177 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 }, 1184 1178 .rlen = 8, ··· 1282 1276 .ilen = 8, 1283 1277 .result = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 }, 1284 1278 .rlen = 8, 1285 - }, { /* Vary the keylength... */ 1279 + }, { /* Vary the keylength... */ 1286 1280 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 1287 1281 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f }, 1288 1282 .klen = 16, ··· 1303 1297 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 1304 1298 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f, 1305 1299 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1306 - 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f, 1307 - 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76, 1308 - 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e, 1300 + 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f, 1301 + 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76, 1302 + 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e, 1309 1303 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, 1310 1304 .klen = 56, 1311 1305 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, ··· 1337 1331 .ilen = 8, 1338 1332 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1339 1333 .rlen = 8, 1340 - }, { /* Vary the keylength... */ 1334 + }, { /* Vary the keylength... */ 1341 1335 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 1342 1336 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f }, 1343 1337 .klen = 16, ··· 1358 1352 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 1359 1353 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f, 1360 1354 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1361 - 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f, 1362 - 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76, 1363 - 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e, 1355 + 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f, 1356 + 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76, 1357 + 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e, 1364 1358 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, 1365 1359 .klen = 56, 1366 1360 .input = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 }, ··· 1375 1369 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 1376 1370 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 }, 1377 1371 .klen = 16, 1378 - .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1372 + .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1379 1373 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 1380 1374 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 1381 1375 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, ··· 1394 1388 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 1395 1389 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 }, 1396 1390 .klen = 16, 1397 - .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1391 + .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1398 1392 .input = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6, 1399 1393 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93, 1400 1394 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9, ··· 1496 1490 .key = { [0 ... 15] = 0x00 }, 1497 1491 .klen = 16, 1498 1492 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32, 1499 - 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a }, 1493 + 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a }, 1500 1494 .input = { [0 ... 15] = 0x00 }, 1501 1495 .ilen = 16, 1502 1496 .result = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e, ··· 1534 1528 .klen = 16, 1535 1529 .iv = { [0 ... 15] = 0x00 }, 1536 1530 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32, 1537 - 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a }, 1531 + 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a }, 1538 1532 .ilen = 16, 1539 1533 .result = { [0 ... 15] = 0x00 }, 1540 1534 .rlen = 16, ··· 1584 1578 #define TNEPRES_ENC_TEST_VECTORS 4 1585 1579 #define TNEPRES_DEC_TEST_VECTORS 4 1586 1580 1587 - static struct cipher_testvec serpent_enc_tv_template[] = 1588 - { 1581 + static struct cipher_testvec serpent_enc_tv_template[] = { 1589 1582 { 1590 1583 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1591 1584 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, ··· 1625 1620 }, 1626 1621 }; 1627 1622 1628 - static struct cipher_testvec tnepres_enc_tv_template[] = 1629 - { 1623 + static struct cipher_testvec tnepres_enc_tv_template[] = { 1630 1624 { /* KeySize=128, PT=0, I=1 */ 1631 1625 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1632 1626 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, ··· 1633 1629 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 1634 1630 .klen = 16, 1635 1631 .ilen = 16, 1636 - .result = { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05, 1632 + .result = { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05, 1637 1633 0x2c, 0xd8, 0xff, 0xa5, 0x98, 0x6b, 0xd2, 0xdd }, 1638 1634 .rlen = 16, 1639 1635 }, { /* KeySize=192, PT=0, I=1 */ ··· 1644 1640 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1645 1641 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 1646 1642 .ilen = 16, 1647 - .result = { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68, 1643 + .result = { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68, 1648 1644 0xac, 0x36, 0x78, 0xf7, 0xa3, 0xf6, 0x0c, 0x66 }, 1649 1645 .rlen = 16, 1650 1646 }, { /* KeySize=256, PT=0, I=1 */ ··· 1656 1652 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1657 1653 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 1658 1654 .ilen = 16, 1659 - .result = { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb, 1655 + .result = { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb, 1660 1656 0xc0, 0xeb, 0xd2, 0x1a, 0x82, 0xef, 0x08, 0x19 }, 1661 1657 .rlen = 16, 1662 1658 }, { /* KeySize=256, I=257 */ ··· 1668 1664 .input = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 1669 1665 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 }, 1670 1666 .ilen = 16, 1671 - .result = { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b, 1667 + .result = { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b, 1672 1668 0xb8, 0x32, 0xe4, 0x33, 0xf8, 0x9f, 0x26, 0xde }, 1673 1669 .rlen = 16, 1674 1670 }, 1675 1671 }; 1676 1672 1677 1673 1678 - static struct cipher_testvec serpent_dec_tv_template[] = 1679 - { 1674 + static struct cipher_testvec serpent_dec_tv_template[] = { 1680 1675 { 1681 1676 .input = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47, 1682 1677 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 }, ··· 1716 1713 }, 1717 1714 }; 1718 1715 1719 - static struct cipher_testvec tnepres_dec_tv_template[] = 1720 - { 1716 + static struct cipher_testvec tnepres_dec_tv_template[] = { 1721 1717 { 1722 1718 .input = { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97, 1723 1719 0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 }, ··· 1728 1726 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1729 1727 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, 1730 1728 .klen = 16, 1731 - .input = { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47, 1729 + .input = { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47, 1732 1730 0x81, 0x45, 0x0b, 0xfa, 0x0c, 0xd6, 0xad, 0x6e }, 1733 1731 .ilen = 16, 1734 1732 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, ··· 1740 1738 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 1741 1739 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, 1742 1740 .klen = 32, 1743 - .input = { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49, 1741 + .input = { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49, 1744 1742 0xa8, 0x4e, 0x76, 0xd6, 0xf5, 0x0d, 0x78, 0xee }, 1745 1743 .ilen = 16, 1746 1744 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, ··· 1749 1747 }, { /* KeySize=128, I=121 */ 1750 1748 .key = { [15] = 0x80 }, 1751 1749 .klen = 16, 1752 - .input = { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06, 1750 + .input = { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06, 1753 1751 0x46, 0x2a, 0xf4, 0xef, 0x81, 0x54, 0x4e, 0x26 }, 1754 1752 .ilen = 16, 1755 1753 .result = { [0 ... 15] = 0x00 }, ··· 1762 1760 #define CAST6_ENC_TEST_VECTORS 3 1763 1761 #define CAST6_DEC_TEST_VECTORS 3 1764 1762 1765 - static struct cipher_testvec cast6_enc_tv_template[] = 1766 - { 1763 + static struct cipher_testvec cast6_enc_tv_template[] = { 1767 1764 { 1768 - .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1765 + .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1769 1766 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d }, 1770 1767 .klen = 16, 1771 1768 .input = { [0 ... 15] = 0x00 }, 1772 1769 .ilen = 16, 1773 - .result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20, 1770 + .result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20, 1774 1771 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b }, 1775 1772 .rlen = 16, 1776 1773 }, { 1777 - .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1778 - 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1774 + .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1775 + 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1779 1776 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 }, 1780 1777 .klen = 24, 1781 1778 .input = { [0 ... 15] = 0x00 }, 1782 1779 .ilen = 16, 1783 - .result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb, 1780 + .result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb, 1784 1781 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 }, 1785 1782 .rlen = 16, 1786 1783 }, { 1787 1784 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1788 1785 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1789 1786 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46, 1790 - 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 }, 1787 + 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 }, 1791 1788 .klen = 32, 1792 1789 .input = { [0 ... 15] = 0x00 }, 1793 1790 .ilen = 16, 1794 - .result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9, 1791 + .result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9, 1795 1792 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa }, 1796 1793 .rlen = 16, 1797 1794 }, 1798 1795 }; 1799 1796 1800 - static struct cipher_testvec cast6_dec_tv_template[] = 1801 - { 1797 + static struct cipher_testvec cast6_dec_tv_template[] = { 1802 1798 { 1803 - .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1799 + .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1804 1800 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d }, 1805 1801 .klen = 16, 1806 - .input = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20, 1802 + .input = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20, 1807 1803 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b }, 1808 1804 .ilen = 16, 1809 1805 .result = { [0 ... 15] = 0x00 }, 1810 1806 .rlen = 16, 1811 1807 }, { 1812 - .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1813 - 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1808 + .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1809 + 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1814 1810 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 }, 1815 1811 .klen = 24, 1816 - .input = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb, 1812 + .input = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb, 1817 1813 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 }, 1818 1814 .ilen = 16, 1819 1815 .result = { [0 ... 15] = 0x00 }, ··· 1820 1820 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1821 1821 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1822 1822 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46, 1823 - 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 }, 1823 + 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 }, 1824 1824 .klen = 32, 1825 - .input = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9, 1825 + .input = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9, 1826 1826 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa }, 1827 1827 .ilen = 16, 1828 1828 .result = { [0 ... 15] = 0x00 }, ··· 1837 1837 #define AES_ENC_TEST_VECTORS 3 1838 1838 #define AES_DEC_TEST_VECTORS 3 1839 1839 1840 - static struct cipher_testvec aes_enc_tv_template[] = { 1840 + static struct cipher_testvec aes_enc_tv_template[] = { 1841 1841 { /* From FIPS-197 */ 1842 - .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1842 + .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1843 1843 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, 1844 1844 .klen = 16, 1845 1845 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, ··· 1853 1853 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 1854 1854 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }, 1855 1855 .klen = 24, 1856 - .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1856 + .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1857 1857 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1858 1858 .ilen = 16, 1859 1859 .result = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, ··· 1865 1865 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 1866 1866 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, 1867 1867 .klen = 32, 1868 - .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1868 + .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1869 1869 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1870 1870 .ilen = 16, 1871 1871 .result = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, ··· 1874 1874 }, 1875 1875 }; 1876 1876 1877 - static struct cipher_testvec aes_dec_tv_template[] = { 1877 + static struct cipher_testvec aes_dec_tv_template[] = { 1878 1878 { /* From FIPS-197 */ 1879 - .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1879 + .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1880 1880 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, 1881 1881 .klen = 16, 1882 1882 .input = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, ··· 1893 1893 .input = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, 1894 1894 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 }, 1895 1895 .ilen = 16, 1896 - .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1897 - 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1896 + .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1897 + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1898 1898 .rlen = 16, 1899 1899 }, { 1900 1900 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, ··· 1905 1905 .input = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 1906 1906 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 }, 1907 1907 .ilen = 16, 1908 - .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1908 + .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1909 1909 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1910 1910 .rlen = 16, 1911 1911 }, ··· 1915 1915 #define CAST5_ENC_TEST_VECTORS 3 1916 1916 #define CAST5_DEC_TEST_VECTORS 3 1917 1917 1918 - static struct cipher_testvec cast5_enc_tv_template[] = 1919 - { 1918 + static struct cipher_testvec cast5_enc_tv_template[] = { 1920 1919 { 1921 1920 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 1922 1921 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a }, ··· 1942 1943 }, 1943 1944 }; 1944 1945 1945 - static struct cipher_testvec cast5_dec_tv_template[] = 1946 - { 1946 + static struct cipher_testvec cast5_dec_tv_template[] = { 1947 1947 { 1948 1948 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 1949 1949 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a }, ··· 1969 1971 }, 1970 1972 }; 1971 1973 1972 - /* 1973 - * ARC4 test vectors from OpenSSL 1974 + /* 1975 + * ARC4 test vectors from OpenSSL 1974 1976 */ 1975 1977 #define ARC4_ENC_TEST_VECTORS 7 1976 1978 #define ARC4_DEC_TEST_VECTORS 7 1977 1979 1978 - static struct cipher_testvec arc4_enc_tv_template[] = 1979 - { 1980 + static struct cipher_testvec arc4_enc_tv_template[] = { 1980 1981 { 1981 1982 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1982 1983 .klen = 8, ··· 2041 2044 }, 2042 2045 }; 2043 2046 2044 - static struct cipher_testvec arc4_dec_tv_template[] = 2045 - { 2047 + static struct cipher_testvec arc4_dec_tv_template[] = { 2046 2048 { 2047 2049 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 2048 2050 .klen = 8, ··· 2107 2111 }, 2108 2112 }; 2109 2113 2110 - /* 2114 + /* 2111 2115 * TEA test vectors 2112 2116 */ 2113 2117 #define TEA_ENC_TEST_VECTORS 4 2114 2118 #define TEA_DEC_TEST_VECTORS 4 2115 2119 2116 - static struct cipher_testvec tea_enc_tv_template[] = 2117 - { 2120 + static struct cipher_testvec tea_enc_tv_template[] = { 2118 2121 { 2119 2122 .key = { [0 ... 15] = 0x00 }, 2120 2123 .klen = 16, ··· 2133 2138 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, 2134 2139 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, 2135 2140 .klen = 16, 2136 - .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2141 + .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2137 2142 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, 2138 2143 .ilen = 16, 2139 - .result = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e, 2144 + .result = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e, 2140 2145 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 }, 2141 2146 .rlen = 16, 2142 2147 }, { 2143 2148 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, 2144 2149 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, 2145 2150 .klen = 16, 2146 - .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2147 - 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2148 - 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2151 + .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2152 + 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2153 + 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2149 2154 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, 2150 2155 .ilen = 32, 2151 - .result = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47, 2152 - 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8, 2153 - 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a, 2156 + .result = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47, 2157 + 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8, 2158 + 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a, 2154 2159 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 }, 2155 2160 .rlen = 32, 2156 2161 } 2157 2162 }; 2158 2163 2159 - static struct cipher_testvec tea_dec_tv_template[] = 2160 - { 2164 + static struct cipher_testvec tea_dec_tv_template[] = { 2161 2165 { 2162 2166 .key = { [0 ... 15] = 0x00 }, 2163 2167 .klen = 16, ··· 2177 2183 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, 2178 2184 .klen = 16, 2179 2185 .input = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e, 2180 - 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 }, 2181 - .ilen = 16, 2182 - .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2186 + 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 }, 2187 + .ilen = 16, 2188 + .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2183 2189 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, 2184 2190 .rlen = 16, 2185 2191 }, { ··· 2187 2193 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, 2188 2194 .klen = 16, 2189 2195 .input = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47, 2190 - 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8, 2191 - 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a, 2192 - 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 }, 2196 + 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8, 2197 + 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a, 2198 + 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 }, 2193 2199 .ilen = 32, 2194 - .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2195 - 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2196 - 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2200 + .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2201 + 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2202 + 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2197 2203 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, 2198 2204 .rlen = 32, 2199 2205 } 2200 2206 }; 2201 2207 2202 - /* 2203 - * XTEA test vectors 2208 + /* 2209 + * XTEA test vectors 2204 2210 */ 2205 2211 #define XTEA_ENC_TEST_VECTORS 4 2206 2212 #define XTEA_DEC_TEST_VECTORS 4 2207 2213 2208 - static struct cipher_testvec xtea_enc_tv_template[] = 2209 - { 2214 + static struct cipher_testvec xtea_enc_tv_template[] = { 2210 2215 { 2211 2216 .key = { [0 ... 15] = 0x00 }, 2212 2217 .klen = 16, ··· 2225 2232 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, 2226 2233 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, 2227 2234 .klen = 16, 2228 - .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2235 + .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2229 2236 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, 2230 2237 .ilen = 16, 2231 - .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 2238 + .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 2232 2239 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, 2233 2240 .rlen = 16, 2234 2241 }, { 2235 2242 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, 2236 2243 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, 2237 2244 .klen = 16, 2238 - .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2239 - 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2240 - 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2245 + .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2246 + 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2247 + 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2241 2248 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, 2242 2249 .ilen = 32, 2243 - .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 2244 - 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 2245 - 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 2250 + .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 2251 + 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 2252 + 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 2246 2253 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 }, 2247 2254 .rlen = 32, 2248 2255 } 2249 2256 }; 2250 2257 2251 - static struct cipher_testvec xtea_dec_tv_template[] = 2252 - { 2258 + static struct cipher_testvec xtea_dec_tv_template[] = { 2253 2259 { 2254 2260 .key = { [0 ... 15] = 0x00 }, 2255 2261 .klen = 16, ··· 2268 2276 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, 2269 2277 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, 2270 2278 .klen = 16, 2271 - .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 2279 + .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 2272 2280 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, 2273 2281 .ilen = 16, 2274 - .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2282 + .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2275 2283 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, 2276 2284 .rlen = 16, 2277 2285 }, { 2278 2286 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, 2279 2287 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, 2280 2288 .klen = 16, 2281 - .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 2282 - 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 2283 - 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 2289 + .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 2290 + 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 2291 + 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 2284 2292 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 }, 2285 2293 .ilen = 32, 2286 - .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2287 - 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2288 - 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2294 + .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2295 + 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2296 + 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2289 2297 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, 2290 2298 .rlen = 32, 2291 2299 } ··· 2297 2305 #define KHAZAD_ENC_TEST_VECTORS 5 2298 2306 #define KHAZAD_DEC_TEST_VECTORS 5 2299 2307 2300 - static struct cipher_testvec khazad_enc_tv_template[] = { 2301 - { 2302 - .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2308 + static struct cipher_testvec khazad_enc_tv_template[] = { 2309 + { 2310 + .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2303 2311 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 2304 2312 .klen = 16, 2305 2313 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, ··· 2343 2351 }, 2344 2352 }; 2345 2353 2346 - static struct cipher_testvec khazad_dec_tv_template[] = { 2354 + static struct cipher_testvec khazad_dec_tv_template[] = { 2347 2355 { 2348 - .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2356 + .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2349 2357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 2350 2358 .klen = 16, 2351 2359 .input = { 0X49, 0Xa4, 0Xce, 0X32, 0Xac, 0X19, 0X0e, 0X3f }, ··· 2689 2697 */ 2690 2698 #define MICHAEL_MIC_TEST_VECTORS 6 2691 2699 2692 - static struct hash_testvec michael_mic_tv_template[] = 2693 - { 2700 + static struct hash_testvec michael_mic_tv_template[] = { 2694 2701 { 2695 2702 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 2696 2703 .ksize = 8, ··· 2732 2741 .psize = 7, 2733 2742 .digest = { 0x0a, 0x94, 0x2b, 0x12, 0x4e, 0xca, 0xa5, 0x46 }, 2734 2743 } 2744 + }; 2745 + 2746 + /* 2747 + * Cipher speed tests 2748 + */ 2749 + static struct cipher_speed aes_speed_template[] = { 2750 + { .klen = 16, .blen = 16, }, 2751 + { .klen = 16, .blen = 64, }, 2752 + { .klen = 16, .blen = 256, }, 2753 + { .klen = 16, .blen = 1024, }, 2754 + { .klen = 16, .blen = 8192, }, 2755 + { .klen = 24, .blen = 16, }, 2756 + { .klen = 24, .blen = 64, }, 2757 + { .klen = 24, .blen = 256, }, 2758 + { .klen = 24, .blen = 1024, }, 2759 + { .klen = 24, .blen = 8192, }, 2760 + { .klen = 32, .blen = 16, }, 2761 + { .klen = 32, .blen = 64, }, 2762 + { .klen = 32, .blen = 256, }, 2763 + { .klen = 32, .blen = 1024, }, 2764 + { .klen = 32, .blen = 8192, }, 2765 + 2766 + /* End marker */ 2767 + { .klen = 0, .blen = 0, } 2768 + }; 2769 + 2770 + static struct cipher_speed des3_ede_speed_template[] = { 2771 + { .klen = 24, .blen = 16, }, 2772 + { .klen = 24, .blen = 64, }, 2773 + { .klen = 24, .blen = 256, }, 2774 + { .klen = 24, .blen = 1024, }, 2775 + { .klen = 24, .blen = 8192, }, 2776 + 2777 + /* End marker */ 2778 + { .klen = 0, .blen = 0, } 2779 + }; 2780 + 2781 + static struct cipher_speed twofish_speed_template[] = { 2782 + { .klen = 16, .blen = 16, }, 2783 + { .klen = 16, .blen = 64, }, 2784 + { .klen = 16, .blen = 256, }, 2785 + { .klen = 16, .blen = 1024, }, 2786 + { .klen = 16, .blen = 8192, }, 2787 + { .klen = 24, .blen = 16, }, 2788 + { .klen = 24, .blen = 64, }, 2789 + { .klen = 24, .blen = 256, }, 2790 + { .klen = 24, .blen = 1024, }, 2791 + { .klen = 24, .blen = 8192, }, 2792 + { .klen = 32, .blen = 16, }, 2793 + { .klen = 32, .blen = 64, }, 2794 + { .klen = 32, .blen = 256, }, 2795 + { .klen = 32, .blen = 1024, }, 2796 + { .klen = 32, .blen = 8192, }, 2797 + 2798 + /* End marker */ 2799 + { .klen = 0, .blen = 0, } 2800 + }; 2801 + 2802 + static struct cipher_speed blowfish_speed_template[] = { 2803 + /* Don't support blowfish keys > 256 bit in this test */ 2804 + { .klen = 8, .blen = 16, }, 2805 + { .klen = 8, .blen = 64, }, 2806 + { .klen = 8, .blen = 256, }, 2807 + { .klen = 8, .blen = 1024, }, 2808 + { .klen = 8, .blen = 8192, }, 2809 + { .klen = 32, .blen = 16, }, 2810 + { .klen = 32, .blen = 64, }, 2811 + { .klen = 32, .blen = 256, }, 2812 + { .klen = 32, .blen = 1024, }, 2813 + { .klen = 32, .blen = 8192, }, 2814 + 2815 + /* End marker */ 2816 + { .klen = 0, .blen = 0, } 2817 + }; 2818 + 2819 + static struct cipher_speed des_speed_template[] = { 2820 + { .klen = 8, .blen = 16, }, 2821 + { .klen = 8, .blen = 64, }, 2822 + { .klen = 8, .blen = 256, }, 2823 + { .klen = 8, .blen = 1024, }, 2824 + { .klen = 8, .blen = 8192, }, 2825 + 2826 + /* End marker */ 2827 + { .klen = 0, .blen = 0, } 2735 2828 }; 2736 2829 2737 2830 #endif /* _CRYPTO_TCRYPT_H */
+2 -4
drivers/net/appletalk/ltpc.c
··· 1109 1109 inb_p(io+1); 1110 1110 inb_p(io+3); 1111 1111 1112 - set_current_state(TASK_UNINTERRUPTIBLE); 1113 - schedule_timeout(2*HZ/100); 1112 + msleep(20); 1114 1113 1115 1114 inb_p(io+0); 1116 1115 inb_p(io+2); ··· 1119 1120 inb_p(io+5); /* enable dma */ 1120 1121 inb_p(io+6); /* tri-state interrupt line */ 1121 1122 1122 - set_current_state(TASK_UNINTERRUPTIBLE); 1123 - schedule_timeout(HZ); 1123 + ssleep(1); 1124 1124 1125 1125 /* now, figure out which dma channel we're using, unless it's 1126 1126 already been specified */
+2 -2
include/linux/netdevice.h
··· 41 41 struct divert_blk; 42 42 struct vlan_group; 43 43 struct ethtool_ops; 44 - struct netpoll; 44 + struct netpoll_info; 45 45 /* source back-compat hooks */ 46 46 #define SET_ETHTOOL_OPS(netdev,ops) \ 47 47 ( (netdev)->ethtool_ops = (ops) ) ··· 468 468 unsigned char *haddr); 469 469 int (*neigh_setup)(struct net_device *dev, struct neigh_parms *); 470 470 #ifdef CONFIG_NETPOLL 471 - struct netpoll *np; 471 + struct netpoll_info *npinfo; 472 472 #endif 473 473 #ifdef CONFIG_NET_POLL_CONTROLLER 474 474 void (*poll_controller)(struct net_device *dev);
+2 -1
include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
··· 18 18 struct ipt_clusterip_tgt_info { 19 19 20 20 u_int32_t flags; 21 - struct clusterip_config *config; 22 21 23 22 /* only relevant for new ones */ 24 23 u_int8_t clustermac[6]; ··· 26 27 u_int16_t local_nodes[CLUSTERIP_MAX_NODES]; 27 28 enum clusterip_hashmode hash_mode; 28 29 u_int32_t hash_initval; 30 + 31 + struct clusterip_config *config; 29 32 }; 30 33 31 34 #endif /*_IPT_CLUSTERIP_H_target*/
+26 -8
include/linux/netpoll.h
··· 16 16 struct netpoll { 17 17 struct net_device *dev; 18 18 char dev_name[16], *name; 19 - int rx_flags; 20 19 void (*rx_hook)(struct netpoll *, int, char *, int); 21 20 void (*drop)(struct sk_buff *skb); 22 21 u32 local_ip, remote_ip; 23 22 u16 local_port, remote_port; 24 23 unsigned char local_mac[6], remote_mac[6]; 24 + }; 25 + 26 + struct netpoll_info { 25 27 spinlock_t poll_lock; 26 28 int poll_owner; 29 + int rx_flags; 30 + spinlock_t rx_lock; 31 + struct netpoll *rx_np; /* netpoll that registered an rx_hook */ 27 32 }; 28 33 29 34 void netpoll_poll(struct netpoll *np); ··· 44 39 #ifdef CONFIG_NETPOLL 45 40 static inline int netpoll_rx(struct sk_buff *skb) 46 41 { 47 - return skb->dev->np && skb->dev->np->rx_flags && __netpoll_rx(skb); 42 + struct netpoll_info *npinfo = skb->dev->npinfo; 43 + unsigned long flags; 44 + int ret = 0; 45 + 46 + if (!npinfo || (!npinfo->rx_np && !npinfo->rx_flags)) 47 + return 0; 48 + 49 + spin_lock_irqsave(&npinfo->rx_lock, flags); 50 + /* check rx_flags again with the lock held */ 51 + if (npinfo->rx_flags && __netpoll_rx(skb)) 52 + ret = 1; 53 + spin_unlock_irqrestore(&npinfo->rx_lock, flags); 54 + 55 + return ret; 48 56 } 49 57 50 58 static inline void netpoll_poll_lock(struct net_device *dev) 51 59 { 52 - if (dev->np) { 53 - spin_lock(&dev->np->poll_lock); 54 - dev->np->poll_owner = smp_processor_id(); 60 + if (dev->npinfo) { 61 + spin_lock(&dev->npinfo->poll_lock); 62 + dev->npinfo->poll_owner = smp_processor_id(); 55 63 } 56 64 } 57 65 58 66 static inline void netpoll_poll_unlock(struct net_device *dev) 59 67 { 60 - if (dev->np) { 61 - spin_unlock(&dev->np->poll_lock); 62 - dev->np->poll_owner = -1; 68 + if (dev->npinfo) { 69 + dev->npinfo->poll_owner = -1; 70 + spin_unlock(&dev->npinfo->poll_lock); 63 71 } 64 72 } 65 73
+12
include/linux/x25.h
··· 4 4 * History 5 5 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities 6 6 * negotiation. 7 + * apr/02/05 Shaun Pereira Selective sub address matching with 8 + * call user data 7 9 */ 8 10 9 11 #ifndef X25_KERNEL_H ··· 18 16 #define SIOCX25GCALLUSERDATA (SIOCPROTOPRIVATE + 4) 19 17 #define SIOCX25SCALLUSERDATA (SIOCPROTOPRIVATE + 5) 20 18 #define SIOCX25GCAUSEDIAG (SIOCPROTOPRIVATE + 6) 19 + #define SIOCX25SCUDMATCHLEN (SIOCPROTOPRIVATE + 7) 20 + #define SIOCX25CALLACCPTAPPRV (SIOCPROTOPRIVATE + 8) 21 + #define SIOCX25SENDCALLACCPT (SIOCPROTOPRIVATE + 9) 21 22 22 23 /* 23 24 * Values for {get,set}sockopt. ··· 112 107 struct x25_causediag { 113 108 unsigned char cause; 114 109 unsigned char diagnostic; 110 + }; 111 + 112 + /* 113 + * Further optional call user data match length selection 114 + */ 115 + struct x25_subaddr { 116 + unsigned int cudmatchlength; 115 117 }; 116 118 117 119 #endif
+5 -4
include/net/x25.h
··· 79 79 #define X25_DEFAULT_PACKET_SIZE X25_PS128 /* Default Packet Size */ 80 80 #define X25_DEFAULT_THROUGHPUT 0x0A /* Deafult Throughput */ 81 81 #define X25_DEFAULT_REVERSE 0x00 /* Default Reverse Charging */ 82 + #define X25_DENY_ACCPT_APPRV 0x01 /* Default value */ 83 + #define X25_ALLOW_ACCPT_APPRV 0x00 /* Control enabled */ 82 84 83 85 #define X25_SMODULUS 8 84 86 #define X25_EMODULUS 128 ··· 96 94 #define X25_FAC_CLASS_C 0x80 97 95 #define X25_FAC_CLASS_D 0xC0 98 96 99 - #define X25_FAC_REVERSE 0x01 97 + #define X25_FAC_REVERSE 0x01 /* also fast select */ 100 98 #define X25_FAC_THROUGHPUT 0x02 101 99 #define X25_FAC_PACKET_SIZE 0x42 102 100 #define X25_FAC_WINDOW_SIZE 0x43 ··· 136 134 struct sock sk; 137 135 struct x25_address source_addr, dest_addr; 138 136 struct x25_neigh *neighbour; 139 - unsigned int lci; 140 - unsigned char state, condition, qbitincl, intflag; 137 + unsigned int lci, cudmatchlength; 138 + unsigned char state, condition, qbitincl, intflag, accptapprv; 141 139 unsigned short vs, vr, va, vl; 142 140 unsigned long t2, t21, t22, t23; 143 141 unsigned short fraglen; ··· 244 242 extern void x25_write_internal(struct sock *, int); 245 243 extern int x25_decode(struct sock *, struct sk_buff *, int *, int *, int *, int *, int *); 246 244 extern void x25_disconnect(struct sock *, int, unsigned char, unsigned char); 247 - extern int x25_check_calluserdata(struct x25_calluserdata *,struct x25_calluserdata *); 248 245 249 246 /* x25_timer.c */ 250 247 extern void x25_start_heartbeat(struct sock *);
+3 -4
net/appletalk/aarp.c
··· 35 35 #include <net/datalink.h> 36 36 #include <net/psnap.h> 37 37 #include <linux/atalk.h> 38 + #include <linux/delay.h> 38 39 #include <linux/init.h> 39 40 #include <linux/proc_fs.h> 40 41 #include <linux/seq_file.h> ··· 463 462 aarp_send_probe(atif->dev, &atif->address); 464 463 465 464 /* Defer 1/10th */ 466 - current->state = TASK_INTERRUPTIBLE; 467 - schedule_timeout(HZ / 10); 465 + msleep(100); 468 466 469 467 if (atif->status & ATIF_PROBE_FAIL) 470 468 break; ··· 510 510 aarp_send_probe(atif->dev, sa); 511 511 512 512 /* Defer 1/10th */ 513 - current->state = TASK_INTERRUPTIBLE; 514 513 write_unlock_bh(&aarp_lock); 515 - schedule_timeout(HZ / 10); 514 + msleep(100); 516 515 write_lock_bh(&aarp_lock); 517 516 518 517 if (entry->status & ATIF_PROBE_FAIL)
+7 -14
net/bridge/netfilter/ebtables.c
··· 859 859 if (repl->valid_hooks & (1 << i)) 860 860 if (check_chainloops(newinfo->hook_entry[i], 861 861 cl_s, udc_cnt, i, newinfo->entries)) { 862 - if (cl_s) 863 - vfree(cl_s); 862 + vfree(cl_s); 864 863 return -EINVAL; 865 864 } 866 865 ··· 882 883 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 883 884 ebt_cleanup_entry, &i); 884 885 } 885 - if (cl_s) 886 - vfree(cl_s); 886 + vfree(cl_s); 887 887 return ret; 888 888 } 889 889 ··· 1028 1030 } 1029 1031 vfree(table); 1030 1032 1031 - if (counterstmp) 1032 - vfree(counterstmp); 1033 + vfree(counterstmp); 1033 1034 return ret; 1034 1035 1035 1036 free_unlock: ··· 1037 1040 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 1038 1041 ebt_cleanup_entry, NULL); 1039 1042 free_counterstmp: 1040 - if (counterstmp) 1041 - vfree(counterstmp); 1043 + vfree(counterstmp); 1042 1044 /* can be initialized in translate_table() */ 1043 1045 if (newinfo->chainstack) { 1044 1046 for (i = 0; i < num_possible_cpus(); i++) ··· 1045 1049 vfree(newinfo->chainstack); 1046 1050 } 1047 1051 free_entries: 1048 - if (newinfo->entries) 1049 - vfree(newinfo->entries); 1052 + vfree(newinfo->entries); 1050 1053 free_newinfo: 1051 - if (newinfo) 1052 - vfree(newinfo); 1054 + vfree(newinfo); 1053 1055 return ret; 1054 1056 } 1055 1057 ··· 1207 1213 down(&ebt_mutex); 1208 1214 LIST_DELETE(&ebt_tables, table); 1209 1215 up(&ebt_mutex); 1210 - if (table->private->entries) 1211 - vfree(table->private->entries); 1216 + vfree(table->private->entries); 1212 1217 if (table->private->chainstack) { 1213 1218 for (i = 0; i < num_possible_cpus(); i++) 1214 1219 vfree(table->private->chainstack[i]);
+59 -21
net/core/netpoll.c
··· 130 130 */ 131 131 static void poll_napi(struct netpoll *np) 132 132 { 133 + struct netpoll_info *npinfo = np->dev->npinfo; 133 134 int budget = 16; 134 135 135 136 if (test_bit(__LINK_STATE_RX_SCHED, &np->dev->state) && 136 - np->poll_owner != smp_processor_id() && 137 - spin_trylock(&np->poll_lock)) { 138 - np->rx_flags |= NETPOLL_RX_DROP; 137 + npinfo->poll_owner != smp_processor_id() && 138 + spin_trylock(&npinfo->poll_lock)) { 139 + npinfo->rx_flags |= NETPOLL_RX_DROP; 139 140 atomic_inc(&trapped); 140 141 141 142 np->dev->poll(np->dev, &budget); 142 143 143 144 atomic_dec(&trapped); 144 - np->rx_flags &= ~NETPOLL_RX_DROP; 145 - spin_unlock(&np->poll_lock); 145 + npinfo->rx_flags &= ~NETPOLL_RX_DROP; 146 + spin_unlock(&npinfo->poll_lock); 146 147 } 147 148 } 148 149 ··· 246 245 static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) 247 246 { 248 247 int status; 248 + struct netpoll_info *npinfo; 249 249 250 250 repeat: 251 251 if(!np || !np->dev || !netif_running(np->dev)) { ··· 255 253 } 256 254 257 255 /* avoid recursion */ 258 - if(np->poll_owner == smp_processor_id() || 259 - np->dev->xmit_lock_owner == smp_processor_id()) { 256 + npinfo = np->dev->npinfo; 257 + if (npinfo->poll_owner == smp_processor_id() || 258 + np->dev->xmit_lock_owner == smp_processor_id()) { 260 259 if (np->drop) 261 260 np->drop(skb); 262 261 else ··· 344 341 345 342 static void arp_reply(struct sk_buff *skb) 346 343 { 344 + struct netpoll_info *npinfo = skb->dev->npinfo; 347 345 struct arphdr *arp; 348 346 unsigned char *arp_ptr; 349 347 int size, type = ARPOP_REPLY, ptype = ETH_P_ARP; 350 348 u32 sip, tip; 349 + unsigned long flags; 351 350 struct sk_buff *send_skb; 352 - struct netpoll *np = skb->dev->np; 351 + struct netpoll *np = NULL; 353 352 354 - if (!np) return; 353 + spin_lock_irqsave(&npinfo->rx_lock, flags); 354 + if (npinfo->rx_np && npinfo->rx_np->dev == skb->dev) 355 + np = npinfo->rx_np; 356 + spin_unlock_irqrestore(&npinfo->rx_lock, flags); 357 + 358 + if (!np) 359 + return; 355 360 356 361 /* No arp on this interface */ 357 362 if (skb->dev->flags & IFF_NOARP) ··· 440 429 int proto, len, ulen; 441 430 struct iphdr *iph; 442 431 struct udphdr *uh; 443 - struct netpoll *np = skb->dev->np; 432 + struct netpoll *np = skb->dev->npinfo->rx_np; 444 433 445 - if (!np->rx_hook) 434 + if (!np) 446 435 goto out; 447 436 if (skb->dev->type != ARPHRD_ETHER) 448 437 goto out; ··· 622 611 { 623 612 struct net_device *ndev = NULL; 624 613 struct in_device *in_dev; 625 - 626 - np->poll_lock = SPIN_LOCK_UNLOCKED; 627 - np->poll_owner = -1; 614 + struct netpoll_info *npinfo; 615 + unsigned long flags; 628 616 629 617 if (np->dev_name) 630 618 ndev = dev_get_by_name(np->dev_name); ··· 634 624 } 635 625 636 626 np->dev = ndev; 637 - ndev->np = np; 627 + if (!ndev->npinfo) { 628 + npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL); 629 + if (!npinfo) 630 + goto release; 631 + 632 + npinfo->rx_np = NULL; 633 + npinfo->poll_lock = SPIN_LOCK_UNLOCKED; 634 + npinfo->poll_owner = -1; 635 + npinfo->rx_lock = SPIN_LOCK_UNLOCKED; 636 + } else 637 + npinfo = ndev->npinfo; 638 638 639 639 if (!ndev->poll_controller) { 640 640 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", ··· 712 692 np->name, HIPQUAD(np->local_ip)); 713 693 } 714 694 715 - if(np->rx_hook) 716 - np->rx_flags = NETPOLL_RX_ENABLED; 695 + if (np->rx_hook) { 696 + spin_lock_irqsave(&npinfo->rx_lock, flags); 697 + npinfo->rx_flags |= NETPOLL_RX_ENABLED; 698 + npinfo->rx_np = np; 699 + spin_unlock_irqrestore(&npinfo->rx_lock, flags); 700 + } 701 + /* last thing to do is link it to the net device structure */ 702 + ndev->npinfo = npinfo; 717 703 718 704 return 0; 719 705 720 706 release: 721 - ndev->np = NULL; 707 + if (!ndev->npinfo) 708 + kfree(npinfo); 722 709 np->dev = NULL; 723 710 dev_put(ndev); 724 711 return -1; ··· 733 706 734 707 void netpoll_cleanup(struct netpoll *np) 735 708 { 736 - if (np->dev) 737 - np->dev->np = NULL; 738 - dev_put(np->dev); 709 + struct netpoll_info *npinfo; 710 + unsigned long flags; 711 + 712 + if (np->dev) { 713 + npinfo = np->dev->npinfo; 714 + if (npinfo && npinfo->rx_np == np) { 715 + spin_lock_irqsave(&npinfo->rx_lock, flags); 716 + npinfo->rx_np = NULL; 717 + npinfo->rx_flags &= ~NETPOLL_RX_ENABLED; 718 + spin_unlock_irqrestore(&npinfo->rx_lock, flags); 719 + } 720 + dev_put(np->dev); 721 + } 722 + 739 723 np->dev = NULL; 740 724 } 741 725
+1 -1
net/ipv4/netfilter/ipt_CLUSTERIP.c
··· 339 339 * error messages (RELATED) and information requests (see below) */ 340 340 if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP 341 341 && (ctinfo == IP_CT_RELATED 342 - || ctinfo == IP_CT_IS_REPLY+IP_CT_IS_REPLY)) 342 + || ctinfo == IP_CT_RELATED+IP_CT_IS_REPLY)) 343 343 return IPT_CONTINUE; 344 344 345 345 /* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO,
+4 -4
net/ipv4/route.c
··· 1767 1767 struct in_device *in_dev, 1768 1768 u32 daddr, u32 saddr, u32 tos) 1769 1769 { 1770 - struct rtable* rth; 1770 + struct rtable* rth = NULL; 1771 1771 int err; 1772 1772 unsigned hash; 1773 1773 ··· 1794 1794 u32 daddr, u32 saddr, u32 tos) 1795 1795 { 1796 1796 #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED 1797 - struct rtable* rth; 1797 + struct rtable* rth = NULL; 1798 1798 unsigned char hop, hopcount, lasthop; 1799 1799 int err = -EINVAL; 1800 1800 unsigned int hash; ··· 2239 2239 struct net_device *dev_out, 2240 2240 unsigned flags) 2241 2241 { 2242 - struct rtable *rth; 2242 + struct rtable *rth = NULL; 2243 2243 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags); 2244 2244 unsigned hash; 2245 2245 if (err == 0) { ··· 2267 2267 unsigned char hop; 2268 2268 unsigned hash; 2269 2269 int err = -EINVAL; 2270 - struct rtable *rth; 2270 + struct rtable *rth = NULL; 2271 2271 2272 2272 if (res->fi && res->fi->fib_nhs > 1) { 2273 2273 unsigned char hopcount = res->fi->fib_nhs;
+1 -2
net/socket.c
··· 383 383 goto out; 384 384 } 385 385 386 - sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino); 386 + this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino); 387 387 this.name = name; 388 - this.len = strlen(name); 389 388 this.hash = SOCK_INODE(sock)->i_ino; 390 389 391 390 file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
+80 -28
net/x25/af_x25.c
··· 29 29 * 2000-11-14 Henner Eisen Closing datalink from NETDEV_GOING_DOWN 30 30 * 2002-10-06 Arnaldo C. Melo Get rid of cli/sti, move proc stuff to 31 31 * x25_proc.c, using seq_file 32 + * 2005-04-02 Shaun Pereira Selective sub address matching 33 + * with call user data 34 + * 2005-04-15 Shaun Pereira Fast select with no restriction on 35 + * response 32 36 */ 33 37 34 38 #include <linux/config.h> ··· 223 219 * Note: if a listening socket has cud set it must only get calls 224 220 * with matching cud. 225 221 */ 226 - static struct sock *x25_find_listener(struct x25_address *addr, struct x25_calluserdata *calluserdata) 222 + static struct sock *x25_find_listener(struct x25_address *addr, 223 + struct sk_buff *skb) 227 224 { 228 225 struct sock *s; 229 226 struct sock *next_best; ··· 235 230 236 231 sk_for_each(s, node, &x25_list) 237 232 if ((!strcmp(addr->x25_addr, 238 - x25_sk(s)->source_addr.x25_addr) || 239 - !strcmp(addr->x25_addr, 240 - null_x25_address.x25_addr)) && 241 - s->sk_state == TCP_LISTEN) { 242 - 233 + x25_sk(s)->source_addr.x25_addr) || 234 + !strcmp(addr->x25_addr, 235 + null_x25_address.x25_addr)) && 236 + s->sk_state == TCP_LISTEN) { 243 237 /* 244 238 * Found a listening socket, now check the incoming 245 239 * call user data vs this sockets call user data 246 240 */ 247 - if (x25_check_calluserdata(&x25_sk(s)->calluserdata, calluserdata)) { 248 - sock_hold(s); 249 - goto found; 250 - } 251 - if (x25_sk(s)->calluserdata.cudlength == 0) { 241 + if(skb->len > 0 && x25_sk(s)->cudmatchlength > 0) { 242 + if((memcmp(x25_sk(s)->calluserdata.cuddata, 243 + skb->data, 244 + x25_sk(s)->cudmatchlength)) == 0) { 245 + sock_hold(s); 246 + goto found; 247 + } 248 + } else 252 249 next_best = s; 253 - } 254 250 } 255 251 if (next_best) { 256 252 s = next_best; ··· 503 497 x25->t23 = sysctl_x25_clear_request_timeout; 504 498 x25->t2 = sysctl_x25_ack_holdback_timeout; 505 499 x25->state = X25_STATE_0; 500 + x25->cudmatchlength = 0; 501 + x25->accptapprv = X25_DENY_ACCPT_APPRV; /* normally no cud */ 502 + /* on call accept */ 506 503 507 504 x25->facilities.winsize_in = X25_DEFAULT_WINDOW_SIZE; 508 505 x25->facilities.winsize_out = X25_DEFAULT_WINDOW_SIZE; ··· 554 545 x25->t2 = ox25->t2; 555 546 x25->facilities = ox25->facilities; 556 547 x25->qbitincl = ox25->qbitincl; 548 + x25->cudmatchlength = ox25->cudmatchlength; 549 + x25->accptapprv = ox25->accptapprv; 557 550 558 551 x25_init_timers(sk); 559 552 out: ··· 833 822 struct x25_sock *makex25; 834 823 struct x25_address source_addr, dest_addr; 835 824 struct x25_facilities facilities; 836 - struct x25_calluserdata calluserdata; 837 825 int len, rc; 838 826 839 827 /* ··· 855 845 skb_pull(skb,len); 856 846 857 847 /* 858 - * Incoming Call User Data. 859 - */ 860 - if (skb->len >= 0) { 861 - memcpy(calluserdata.cuddata, skb->data, skb->len); 862 - calluserdata.cudlength = skb->len; 863 - } 864 - 865 - skb_push(skb,len); 866 - 867 - /* 868 848 * Find a listener for the particular address/cud pair. 869 849 */ 870 - sk = x25_find_listener(&source_addr,&calluserdata); 850 + sk = x25_find_listener(&source_addr,skb); 851 + skb_push(skb,len); 871 852 872 853 /* 873 854 * We can't accept the Call Request. ··· 901 900 makex25->neighbour = nb; 902 901 makex25->facilities = facilities; 903 902 makex25->vc_facil_mask = x25_sk(sk)->vc_facil_mask; 904 - makex25->calluserdata = calluserdata; 903 + /* ensure no reverse facil on accept */ 904 + makex25->vc_facil_mask &= ~X25_MASK_REVERSE; 905 + makex25->cudmatchlength = x25_sk(sk)->cudmatchlength; 905 906 906 - x25_write_internal(make, X25_CALL_ACCEPTED); 907 + /* Normally all calls are accepted immediatly */ 908 + if(makex25->accptapprv & X25_DENY_ACCPT_APPRV) { 909 + x25_write_internal(make, X25_CALL_ACCEPTED); 910 + makex25->state = X25_STATE_3; 911 + } 907 912 908 - makex25->state = X25_STATE_3; 913 + /* 914 + * Incoming Call User Data. 915 + */ 916 + if (skb->len >= 0) { 917 + memcpy(makex25->calluserdata.cuddata, skb->data, skb->len); 918 + makex25->calluserdata.cudlength = skb->len; 919 + } 909 920 910 921 sk->sk_ack_backlog++; 911 922 ··· 1301 1288 if (facilities.throughput < 0x03 || 1302 1289 facilities.throughput > 0xDD) 1303 1290 break; 1304 - if (facilities.reverse && facilities.reverse != 1) 1291 + if (facilities.reverse && 1292 + (facilities.reverse | 0x81)!= 0x81) 1305 1293 break; 1306 1294 x25->facilities = facilities; 1307 1295 rc = 0; ··· 1336 1322 causediag = x25->causediag; 1337 1323 rc = copy_to_user(argp, &causediag, 1338 1324 sizeof(causediag)) ? -EFAULT : 0; 1325 + break; 1326 + } 1327 + 1328 + case SIOCX25SCUDMATCHLEN: { 1329 + struct x25_subaddr sub_addr; 1330 + rc = -EINVAL; 1331 + if(sk->sk_state != TCP_CLOSE) 1332 + break; 1333 + rc = -EFAULT; 1334 + if (copy_from_user(&sub_addr, argp, 1335 + sizeof(sub_addr))) 1336 + break; 1337 + rc = -EINVAL; 1338 + if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN) 1339 + break; 1340 + x25->cudmatchlength = sub_addr.cudmatchlength; 1341 + rc = 0; 1342 + break; 1343 + } 1344 + 1345 + case SIOCX25CALLACCPTAPPRV: { 1346 + rc = -EINVAL; 1347 + if (sk->sk_state != TCP_CLOSE) 1348 + break; 1349 + x25->accptapprv = X25_ALLOW_ACCPT_APPRV; 1350 + rc = 0; 1351 + break; 1352 + } 1353 + 1354 + case SIOCX25SENDCALLACCPT: { 1355 + rc = -EINVAL; 1356 + if (sk->sk_state != TCP_ESTABLISHED) 1357 + break; 1358 + if (x25->accptapprv) /* must call accptapprv above */ 1359 + break; 1360 + x25_write_internal(sk, X25_CALL_ACCEPTED); 1361 + x25->state = X25_STATE_3; 1362 + rc = 0; 1339 1363 break; 1340 1364 } 1341 1365
+29 -5
net/x25/x25_facilities.c
··· 17 17 * X.25 001 Split from x25_subr.c 18 18 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities 19 19 * negotiation. 20 + * apr/14/05 Shaun Pereira - Allow fast select with no restriction 21 + * on response. 20 22 */ 21 23 22 24 #include <linux/kernel.h> ··· 45 43 case X25_FAC_CLASS_A: 46 44 switch (*p) { 47 45 case X25_FAC_REVERSE: 48 - facilities->reverse = p[1] & 0x01; 49 - *vc_fac_mask |= X25_MASK_REVERSE; 50 - break; 46 + if((p[1] & 0x81) == 0x81) { 47 + facilities->reverse = p[1] & 0x81; 48 + *vc_fac_mask |= X25_MASK_REVERSE; 49 + break; 50 + } 51 + 52 + if((p[1] & 0x01) == 0x01) { 53 + facilities->reverse = p[1] & 0x01; 54 + *vc_fac_mask |= X25_MASK_REVERSE; 55 + break; 56 + } 57 + 58 + if((p[1] & 0x80) == 0x80) { 59 + facilities->reverse = p[1] & 0x80; 60 + *vc_fac_mask |= X25_MASK_REVERSE; 61 + break; 62 + } 63 + 64 + if(p[1] == 0x00) { 65 + facilities->reverse 66 + = X25_DEFAULT_REVERSE; 67 + *vc_fac_mask |= X25_MASK_REVERSE; 68 + break; 69 + } 70 + 51 71 case X25_FAC_THROUGHPUT: 52 72 facilities->throughput = p[1]; 53 73 *vc_fac_mask |= X25_MASK_THROUGHPUT; ··· 146 122 147 123 if (facilities->reverse && (facil_mask & X25_MASK_REVERSE)) { 148 124 *p++ = X25_FAC_REVERSE; 149 - *p++ = !!facilities->reverse; 125 + *p++ = facilities->reverse; 150 126 } 151 127 152 128 if (facilities->throughput && (facil_mask & X25_MASK_THROUGHPUT)) { ··· 195 171 /* 196 172 * They want reverse charging, we won't accept it. 197 173 */ 198 - if (theirs.reverse && ours->reverse) { 174 + if ((theirs.reverse & 0x01 ) && (ours->reverse & 0x01)) { 199 175 SOCK_DEBUG(sk, "X.25: rejecting reverse charging request"); 200 176 return -1; 201 177 }
+18 -23
net/x25/x25_subr.c
··· 19 19 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities 20 20 * negotiation. 21 21 * jun/24/01 Arnaldo C. Melo use skb_queue_purge, cleanups 22 + * apr/04/15 Shaun Pereira Fast select with no 23 + * restriction on response. 22 24 */ 23 25 24 26 #include <linux/kernel.h> ··· 129 127 len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + 130 128 X25_MAX_CUD_LEN; 131 129 break; 132 - case X25_CALL_ACCEPTED: 133 - len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; 130 + case X25_CALL_ACCEPTED: /* fast sel with no restr on resp */ 131 + if(x25->facilities.reverse & 0x80) { 132 + len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; 133 + } else { 134 + len += 1 + X25_MAX_FAC_LEN; 135 + } 134 136 break; 135 137 case X25_CLEAR_REQUEST: 136 138 case X25_RESET_REQUEST: ··· 209 203 x25->vc_facil_mask); 210 204 dptr = skb_put(skb, len); 211 205 memcpy(dptr, facilities, len); 212 - dptr = skb_put(skb, x25->calluserdata.cudlength); 213 - memcpy(dptr, x25->calluserdata.cuddata, 214 - x25->calluserdata.cudlength); 206 + 207 + /* fast select with no restriction on response 208 + allows call user data. Userland must 209 + ensure it is ours and not theirs */ 210 + if(x25->facilities.reverse & 0x80) { 211 + dptr = skb_put(skb, 212 + x25->calluserdata.cudlength); 213 + memcpy(dptr, x25->calluserdata.cuddata, 214 + x25->calluserdata.cudlength); 215 + } 215 216 x25->calluserdata.cudlength = 0; 216 217 break; 217 218 ··· 365 352 x25_write_internal(sk, X25_RR); 366 353 x25_stop_timer(sk); 367 354 } 368 - } 369 - 370 - /* 371 - * Compare 2 calluserdata structures, used to find correct listening sockets 372 - * when call user data is used. 373 - */ 374 - int x25_check_calluserdata(struct x25_calluserdata *ours, struct x25_calluserdata *theirs) 375 - { 376 - int i; 377 - if (ours->cudlength != theirs->cudlength) 378 - return 0; 379 - 380 - for (i=0;i<ours->cudlength;i++) { 381 - if (ours->cuddata[i] != theirs->cuddata[i]) { 382 - return 0; 383 - } 384 - } 385 - return 1; 386 355 } 387 356