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

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