diff options
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r-- | crypto/testmgr.c | 214 |
1 files changed, 168 insertions, 46 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index e8666b3ead67..b828c6cf1b1d 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -541,9 +541,74 @@ out: | |||
541 | return ret; | 541 | return ret; |
542 | } | 542 | } |
543 | 543 | ||
544 | static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | 544 | static int test_cipher(struct crypto_cipher *tfm, int enc, |
545 | struct cipher_testvec *template, unsigned int tcount) | 545 | struct cipher_testvec *template, unsigned int tcount) |
546 | { | 546 | { |
547 | const char *algo = crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm)); | ||
548 | unsigned int i, j, k; | ||
549 | int ret; | ||
550 | char *q; | ||
551 | const char *e; | ||
552 | void *data; | ||
553 | |||
554 | if (enc == ENCRYPT) | ||
555 | e = "encryption"; | ||
556 | else | ||
557 | e = "decryption"; | ||
558 | |||
559 | j = 0; | ||
560 | for (i = 0; i < tcount; i++) { | ||
561 | if (template[i].np) | ||
562 | continue; | ||
563 | |||
564 | j++; | ||
565 | |||
566 | data = xbuf[0]; | ||
567 | memcpy(data, template[i].input, template[i].ilen); | ||
568 | |||
569 | crypto_cipher_clear_flags(tfm, ~0); | ||
570 | if (template[i].wk) | ||
571 | crypto_cipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY); | ||
572 | |||
573 | ret = crypto_cipher_setkey(tfm, template[i].key, | ||
574 | template[i].klen); | ||
575 | if (!ret == template[i].fail) { | ||
576 | printk(KERN_ERR "alg: cipher: setkey failed " | ||
577 | "on test %d for %s: flags=%x\n", j, | ||
578 | algo, crypto_cipher_get_flags(tfm)); | ||
579 | goto out; | ||
580 | } else if (ret) | ||
581 | continue; | ||
582 | |||
583 | for (k = 0; k < template[i].ilen; | ||
584 | k += crypto_cipher_blocksize(tfm)) { | ||
585 | if (enc) | ||
586 | crypto_cipher_encrypt_one(tfm, data + k, | ||
587 | data + k); | ||
588 | else | ||
589 | crypto_cipher_decrypt_one(tfm, data + k, | ||
590 | data + k); | ||
591 | } | ||
592 | |||
593 | q = data; | ||
594 | if (memcmp(q, template[i].result, template[i].rlen)) { | ||
595 | printk(KERN_ERR "alg: cipher: Test %d failed " | ||
596 | "on %s for %s\n", j, e, algo); | ||
597 | hexdump(q, template[i].rlen); | ||
598 | ret = -EINVAL; | ||
599 | goto out; | ||
600 | } | ||
601 | } | ||
602 | |||
603 | ret = 0; | ||
604 | |||
605 | out: | ||
606 | return ret; | ||
607 | } | ||
608 | |||
609 | static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | ||
610 | struct cipher_testvec *template, unsigned int tcount) | ||
611 | { | ||
547 | const char *algo = | 612 | const char *algo = |
548 | crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm)); | 613 | crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm)); |
549 | unsigned int i, j, k, n, temp; | 614 | unsigned int i, j, k, n, temp; |
@@ -565,8 +630,8 @@ static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | |||
565 | 630 | ||
566 | req = ablkcipher_request_alloc(tfm, GFP_KERNEL); | 631 | req = ablkcipher_request_alloc(tfm, GFP_KERNEL); |
567 | if (!req) { | 632 | if (!req) { |
568 | printk(KERN_ERR "alg: cipher: Failed to allocate request for " | 633 | printk(KERN_ERR "alg: skcipher: Failed to allocate request " |
569 | "%s\n", algo); | 634 | "for %s\n", algo); |
570 | ret = -ENOMEM; | 635 | ret = -ENOMEM; |
571 | goto out; | 636 | goto out; |
572 | } | 637 | } |
@@ -595,7 +660,7 @@ static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | |||
595 | ret = crypto_ablkcipher_setkey(tfm, template[i].key, | 660 | ret = crypto_ablkcipher_setkey(tfm, template[i].key, |
596 | template[i].klen); | 661 | template[i].klen); |
597 | if (!ret == template[i].fail) { | 662 | if (!ret == template[i].fail) { |
598 | printk(KERN_ERR "alg: cipher: setkey failed " | 663 | printk(KERN_ERR "alg: skcipher: setkey failed " |
599 | "on test %d for %s: flags=%x\n", j, | 664 | "on test %d for %s: flags=%x\n", j, |
600 | algo, crypto_ablkcipher_get_flags(tfm)); | 665 | algo, crypto_ablkcipher_get_flags(tfm)); |
601 | goto out; | 666 | goto out; |
@@ -623,7 +688,7 @@ static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | |||
623 | } | 688 | } |
624 | /* fall through */ | 689 | /* fall through */ |
625 | default: | 690 | default: |
626 | printk(KERN_ERR "alg: cipher: %s failed on " | 691 | printk(KERN_ERR "alg: skcipher: %s failed on " |
627 | "test %d for %s: ret=%d\n", e, j, algo, | 692 | "test %d for %s: ret=%d\n", e, j, algo, |
628 | -ret); | 693 | -ret); |
629 | goto out; | 694 | goto out; |
@@ -631,8 +696,8 @@ static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | |||
631 | 696 | ||
632 | q = data; | 697 | q = data; |
633 | if (memcmp(q, template[i].result, template[i].rlen)) { | 698 | if (memcmp(q, template[i].result, template[i].rlen)) { |
634 | printk(KERN_ERR "alg: cipher: Test %d failed " | 699 | printk(KERN_ERR "alg: skcipher: Test %d " |
635 | "on %s for %s\n", j, e, algo); | 700 | "failed on %s for %s\n", j, e, algo); |
636 | hexdump(q, template[i].rlen); | 701 | hexdump(q, template[i].rlen); |
637 | ret = -EINVAL; | 702 | ret = -EINVAL; |
638 | goto out; | 703 | goto out; |
@@ -659,7 +724,7 @@ static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | |||
659 | ret = crypto_ablkcipher_setkey(tfm, template[i].key, | 724 | ret = crypto_ablkcipher_setkey(tfm, template[i].key, |
660 | template[i].klen); | 725 | template[i].klen); |
661 | if (!ret == template[i].fail) { | 726 | if (!ret == template[i].fail) { |
662 | printk(KERN_ERR "alg: cipher: setkey failed " | 727 | printk(KERN_ERR "alg: skcipher: setkey failed " |
663 | "on chunk test %d for %s: flags=%x\n", | 728 | "on chunk test %d for %s: flags=%x\n", |
664 | j, algo, | 729 | j, algo, |
665 | crypto_ablkcipher_get_flags(tfm)); | 730 | crypto_ablkcipher_get_flags(tfm)); |
@@ -710,7 +775,7 @@ static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | |||
710 | } | 775 | } |
711 | /* fall through */ | 776 | /* fall through */ |
712 | default: | 777 | default: |
713 | printk(KERN_ERR "alg: cipher: %s failed on " | 778 | printk(KERN_ERR "alg: skcipher: %s failed on " |
714 | "chunk test %d for %s: ret=%d\n", e, j, | 779 | "chunk test %d for %s: ret=%d\n", e, j, |
715 | algo, -ret); | 780 | algo, -ret); |
716 | goto out; | 781 | goto out; |
@@ -724,7 +789,7 @@ static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | |||
724 | 789 | ||
725 | if (memcmp(q, template[i].result + temp, | 790 | if (memcmp(q, template[i].result + temp, |
726 | template[i].tap[k])) { | 791 | template[i].tap[k])) { |
727 | printk(KERN_ERR "alg: cipher: Chunk " | 792 | printk(KERN_ERR "alg: skcipher: Chunk " |
728 | "test %d failed on %s at page " | 793 | "test %d failed on %s at page " |
729 | "%u for %s\n", j, e, k, algo); | 794 | "%u for %s\n", j, e, k, algo); |
730 | hexdump(q, template[i].tap[k]); | 795 | hexdump(q, template[i].tap[k]); |
@@ -735,7 +800,7 @@ static int test_cipher(struct crypto_ablkcipher *tfm, int enc, | |||
735 | for (n = 0; offset_in_page(q + n) && q[n]; n++) | 800 | for (n = 0; offset_in_page(q + n) && q[n]; n++) |
736 | ; | 801 | ; |
737 | if (n) { | 802 | if (n) { |
738 | printk(KERN_ERR "alg: cipher: " | 803 | printk(KERN_ERR "alg: skcipher: " |
739 | "Result buffer corruption in " | 804 | "Result buffer corruption in " |
740 | "chunk test %d on %s at page " | 805 | "chunk test %d on %s at page " |
741 | "%u for %s: %u bytes:\n", j, e, | 806 | "%u for %s: %u bytes:\n", j, e, |
@@ -849,10 +914,10 @@ out: | |||
849 | static int alg_test_cipher(const struct alg_test_desc *desc, | 914 | static int alg_test_cipher(const struct alg_test_desc *desc, |
850 | const char *driver, u32 type, u32 mask) | 915 | const char *driver, u32 type, u32 mask) |
851 | { | 916 | { |
852 | struct crypto_ablkcipher *tfm; | 917 | struct crypto_cipher *tfm; |
853 | int err = 0; | 918 | int err = 0; |
854 | 919 | ||
855 | tfm = crypto_alloc_ablkcipher(driver, type, mask); | 920 | tfm = crypto_alloc_cipher(driver, type, mask); |
856 | if (IS_ERR(tfm)) { | 921 | if (IS_ERR(tfm)) { |
857 | printk(KERN_ERR "alg: cipher: Failed to load transform for " | 922 | printk(KERN_ERR "alg: cipher: Failed to load transform for " |
858 | "%s: %ld\n", driver, PTR_ERR(tfm)); | 923 | "%s: %ld\n", driver, PTR_ERR(tfm)); |
@@ -871,6 +936,35 @@ static int alg_test_cipher(const struct alg_test_desc *desc, | |||
871 | desc->suite.cipher.dec.count); | 936 | desc->suite.cipher.dec.count); |
872 | 937 | ||
873 | out: | 938 | out: |
939 | crypto_free_cipher(tfm); | ||
940 | return err; | ||
941 | } | ||
942 | |||
943 | static int alg_test_skcipher(const struct alg_test_desc *desc, | ||
944 | const char *driver, u32 type, u32 mask) | ||
945 | { | ||
946 | struct crypto_ablkcipher *tfm; | ||
947 | int err = 0; | ||
948 | |||
949 | tfm = crypto_alloc_ablkcipher(driver, type, mask); | ||
950 | if (IS_ERR(tfm)) { | ||
951 | printk(KERN_ERR "alg: skcipher: Failed to load transform for " | ||
952 | "%s: %ld\n", driver, PTR_ERR(tfm)); | ||
953 | return PTR_ERR(tfm); | ||
954 | } | ||
955 | |||
956 | if (desc->suite.cipher.enc.vecs) { | ||
957 | err = test_skcipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs, | ||
958 | desc->suite.cipher.enc.count); | ||
959 | if (err) | ||
960 | goto out; | ||
961 | } | ||
962 | |||
963 | if (desc->suite.cipher.dec.vecs) | ||
964 | err = test_skcipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs, | ||
965 | desc->suite.cipher.dec.count); | ||
966 | |||
967 | out: | ||
874 | crypto_free_ablkcipher(tfm); | 968 | crypto_free_ablkcipher(tfm); |
875 | return err; | 969 | return err; |
876 | } | 970 | } |
@@ -920,7 +1014,7 @@ static int alg_test_hash(const struct alg_test_desc *desc, const char *driver, | |||
920 | static const struct alg_test_desc alg_test_descs[] = { | 1014 | static const struct alg_test_desc alg_test_descs[] = { |
921 | { | 1015 | { |
922 | .alg = "cbc(aes)", | 1016 | .alg = "cbc(aes)", |
923 | .test = alg_test_cipher, | 1017 | .test = alg_test_skcipher, |
924 | .suite = { | 1018 | .suite = { |
925 | .cipher = { | 1019 | .cipher = { |
926 | .enc = { | 1020 | .enc = { |
@@ -935,7 +1029,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
935 | } | 1029 | } |
936 | }, { | 1030 | }, { |
937 | .alg = "cbc(anubis)", | 1031 | .alg = "cbc(anubis)", |
938 | .test = alg_test_cipher, | 1032 | .test = alg_test_skcipher, |
939 | .suite = { | 1033 | .suite = { |
940 | .cipher = { | 1034 | .cipher = { |
941 | .enc = { | 1035 | .enc = { |
@@ -950,7 +1044,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
950 | } | 1044 | } |
951 | }, { | 1045 | }, { |
952 | .alg = "cbc(blowfish)", | 1046 | .alg = "cbc(blowfish)", |
953 | .test = alg_test_cipher, | 1047 | .test = alg_test_skcipher, |
954 | .suite = { | 1048 | .suite = { |
955 | .cipher = { | 1049 | .cipher = { |
956 | .enc = { | 1050 | .enc = { |
@@ -965,7 +1059,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
965 | } | 1059 | } |
966 | }, { | 1060 | }, { |
967 | .alg = "cbc(camellia)", | 1061 | .alg = "cbc(camellia)", |
968 | .test = alg_test_cipher, | 1062 | .test = alg_test_skcipher, |
969 | .suite = { | 1063 | .suite = { |
970 | .cipher = { | 1064 | .cipher = { |
971 | .enc = { | 1065 | .enc = { |
@@ -980,7 +1074,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
980 | } | 1074 | } |
981 | }, { | 1075 | }, { |
982 | .alg = "cbc(des)", | 1076 | .alg = "cbc(des)", |
983 | .test = alg_test_cipher, | 1077 | .test = alg_test_skcipher, |
984 | .suite = { | 1078 | .suite = { |
985 | .cipher = { | 1079 | .cipher = { |
986 | .enc = { | 1080 | .enc = { |
@@ -995,7 +1089,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
995 | } | 1089 | } |
996 | }, { | 1090 | }, { |
997 | .alg = "cbc(des3_ede)", | 1091 | .alg = "cbc(des3_ede)", |
998 | .test = alg_test_cipher, | 1092 | .test = alg_test_skcipher, |
999 | .suite = { | 1093 | .suite = { |
1000 | .cipher = { | 1094 | .cipher = { |
1001 | .enc = { | 1095 | .enc = { |
@@ -1010,7 +1104,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1010 | } | 1104 | } |
1011 | }, { | 1105 | }, { |
1012 | .alg = "cbc(twofish)", | 1106 | .alg = "cbc(twofish)", |
1013 | .test = alg_test_cipher, | 1107 | .test = alg_test_skcipher, |
1014 | .suite = { | 1108 | .suite = { |
1015 | .cipher = { | 1109 | .cipher = { |
1016 | .enc = { | 1110 | .enc = { |
@@ -1049,7 +1143,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1049 | } | 1143 | } |
1050 | }, { | 1144 | }, { |
1051 | .alg = "cts(cbc(aes))", | 1145 | .alg = "cts(cbc(aes))", |
1052 | .test = alg_test_cipher, | 1146 | .test = alg_test_skcipher, |
1053 | .suite = { | 1147 | .suite = { |
1054 | .cipher = { | 1148 | .cipher = { |
1055 | .enc = { | 1149 | .enc = { |
@@ -1079,7 +1173,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1079 | } | 1173 | } |
1080 | }, { | 1174 | }, { |
1081 | .alg = "ecb(aes)", | 1175 | .alg = "ecb(aes)", |
1082 | .test = alg_test_cipher, | 1176 | .test = alg_test_skcipher, |
1083 | .suite = { | 1177 | .suite = { |
1084 | .cipher = { | 1178 | .cipher = { |
1085 | .enc = { | 1179 | .enc = { |
@@ -1094,7 +1188,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1094 | } | 1188 | } |
1095 | }, { | 1189 | }, { |
1096 | .alg = "ecb(anubis)", | 1190 | .alg = "ecb(anubis)", |
1097 | .test = alg_test_cipher, | 1191 | .test = alg_test_skcipher, |
1098 | .suite = { | 1192 | .suite = { |
1099 | .cipher = { | 1193 | .cipher = { |
1100 | .enc = { | 1194 | .enc = { |
@@ -1109,7 +1203,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1109 | } | 1203 | } |
1110 | }, { | 1204 | }, { |
1111 | .alg = "ecb(arc4)", | 1205 | .alg = "ecb(arc4)", |
1112 | .test = alg_test_cipher, | 1206 | .test = alg_test_skcipher, |
1113 | .suite = { | 1207 | .suite = { |
1114 | .cipher = { | 1208 | .cipher = { |
1115 | .enc = { | 1209 | .enc = { |
@@ -1124,7 +1218,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1124 | } | 1218 | } |
1125 | }, { | 1219 | }, { |
1126 | .alg = "ecb(blowfish)", | 1220 | .alg = "ecb(blowfish)", |
1127 | .test = alg_test_cipher, | 1221 | .test = alg_test_skcipher, |
1128 | .suite = { | 1222 | .suite = { |
1129 | .cipher = { | 1223 | .cipher = { |
1130 | .enc = { | 1224 | .enc = { |
@@ -1139,7 +1233,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1139 | } | 1233 | } |
1140 | }, { | 1234 | }, { |
1141 | .alg = "ecb(camellia)", | 1235 | .alg = "ecb(camellia)", |
1142 | .test = alg_test_cipher, | 1236 | .test = alg_test_skcipher, |
1143 | .suite = { | 1237 | .suite = { |
1144 | .cipher = { | 1238 | .cipher = { |
1145 | .enc = { | 1239 | .enc = { |
@@ -1154,7 +1248,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1154 | } | 1248 | } |
1155 | }, { | 1249 | }, { |
1156 | .alg = "ecb(cast5)", | 1250 | .alg = "ecb(cast5)", |
1157 | .test = alg_test_cipher, | 1251 | .test = alg_test_skcipher, |
1158 | .suite = { | 1252 | .suite = { |
1159 | .cipher = { | 1253 | .cipher = { |
1160 | .enc = { | 1254 | .enc = { |
@@ -1169,7 +1263,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1169 | } | 1263 | } |
1170 | }, { | 1264 | }, { |
1171 | .alg = "ecb(cast6)", | 1265 | .alg = "ecb(cast6)", |
1172 | .test = alg_test_cipher, | 1266 | .test = alg_test_skcipher, |
1173 | .suite = { | 1267 | .suite = { |
1174 | .cipher = { | 1268 | .cipher = { |
1175 | .enc = { | 1269 | .enc = { |
@@ -1184,7 +1278,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1184 | } | 1278 | } |
1185 | }, { | 1279 | }, { |
1186 | .alg = "ecb(des)", | 1280 | .alg = "ecb(des)", |
1187 | .test = alg_test_cipher, | 1281 | .test = alg_test_skcipher, |
1188 | .suite = { | 1282 | .suite = { |
1189 | .cipher = { | 1283 | .cipher = { |
1190 | .enc = { | 1284 | .enc = { |
@@ -1199,7 +1293,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1199 | } | 1293 | } |
1200 | }, { | 1294 | }, { |
1201 | .alg = "ecb(des3_ede)", | 1295 | .alg = "ecb(des3_ede)", |
1202 | .test = alg_test_cipher, | 1296 | .test = alg_test_skcipher, |
1203 | .suite = { | 1297 | .suite = { |
1204 | .cipher = { | 1298 | .cipher = { |
1205 | .enc = { | 1299 | .enc = { |
@@ -1214,7 +1308,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1214 | } | 1308 | } |
1215 | }, { | 1309 | }, { |
1216 | .alg = "ecb(khazad)", | 1310 | .alg = "ecb(khazad)", |
1217 | .test = alg_test_cipher, | 1311 | .test = alg_test_skcipher, |
1218 | .suite = { | 1312 | .suite = { |
1219 | .cipher = { | 1313 | .cipher = { |
1220 | .enc = { | 1314 | .enc = { |
@@ -1229,7 +1323,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1229 | } | 1323 | } |
1230 | }, { | 1324 | }, { |
1231 | .alg = "ecb(seed)", | 1325 | .alg = "ecb(seed)", |
1232 | .test = alg_test_cipher, | 1326 | .test = alg_test_skcipher, |
1233 | .suite = { | 1327 | .suite = { |
1234 | .cipher = { | 1328 | .cipher = { |
1235 | .enc = { | 1329 | .enc = { |
@@ -1244,7 +1338,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1244 | } | 1338 | } |
1245 | }, { | 1339 | }, { |
1246 | .alg = "ecb(serpent)", | 1340 | .alg = "ecb(serpent)", |
1247 | .test = alg_test_cipher, | 1341 | .test = alg_test_skcipher, |
1248 | .suite = { | 1342 | .suite = { |
1249 | .cipher = { | 1343 | .cipher = { |
1250 | .enc = { | 1344 | .enc = { |
@@ -1259,7 +1353,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1259 | } | 1353 | } |
1260 | }, { | 1354 | }, { |
1261 | .alg = "ecb(tea)", | 1355 | .alg = "ecb(tea)", |
1262 | .test = alg_test_cipher, | 1356 | .test = alg_test_skcipher, |
1263 | .suite = { | 1357 | .suite = { |
1264 | .cipher = { | 1358 | .cipher = { |
1265 | .enc = { | 1359 | .enc = { |
@@ -1274,7 +1368,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1274 | } | 1368 | } |
1275 | }, { | 1369 | }, { |
1276 | .alg = "ecb(tnepres)", | 1370 | .alg = "ecb(tnepres)", |
1277 | .test = alg_test_cipher, | 1371 | .test = alg_test_skcipher, |
1278 | .suite = { | 1372 | .suite = { |
1279 | .cipher = { | 1373 | .cipher = { |
1280 | .enc = { | 1374 | .enc = { |
@@ -1289,7 +1383,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1289 | } | 1383 | } |
1290 | }, { | 1384 | }, { |
1291 | .alg = "ecb(twofish)", | 1385 | .alg = "ecb(twofish)", |
1292 | .test = alg_test_cipher, | 1386 | .test = alg_test_skcipher, |
1293 | .suite = { | 1387 | .suite = { |
1294 | .cipher = { | 1388 | .cipher = { |
1295 | .enc = { | 1389 | .enc = { |
@@ -1304,7 +1398,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1304 | } | 1398 | } |
1305 | }, { | 1399 | }, { |
1306 | .alg = "ecb(xeta)", | 1400 | .alg = "ecb(xeta)", |
1307 | .test = alg_test_cipher, | 1401 | .test = alg_test_skcipher, |
1308 | .suite = { | 1402 | .suite = { |
1309 | .cipher = { | 1403 | .cipher = { |
1310 | .enc = { | 1404 | .enc = { |
@@ -1319,7 +1413,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1319 | } | 1413 | } |
1320 | }, { | 1414 | }, { |
1321 | .alg = "ecb(xtea)", | 1415 | .alg = "ecb(xtea)", |
1322 | .test = alg_test_cipher, | 1416 | .test = alg_test_skcipher, |
1323 | .suite = { | 1417 | .suite = { |
1324 | .cipher = { | 1418 | .cipher = { |
1325 | .enc = { | 1419 | .enc = { |
@@ -1421,7 +1515,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1421 | } | 1515 | } |
1422 | }, { | 1516 | }, { |
1423 | .alg = "lrw(aes)", | 1517 | .alg = "lrw(aes)", |
1424 | .test = alg_test_cipher, | 1518 | .test = alg_test_skcipher, |
1425 | .suite = { | 1519 | .suite = { |
1426 | .cipher = { | 1520 | .cipher = { |
1427 | .enc = { | 1521 | .enc = { |
@@ -1478,7 +1572,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1478 | } | 1572 | } |
1479 | }, { | 1573 | }, { |
1480 | .alg = "pcbc(fcrypt)", | 1574 | .alg = "pcbc(fcrypt)", |
1481 | .test = alg_test_cipher, | 1575 | .test = alg_test_skcipher, |
1482 | .suite = { | 1576 | .suite = { |
1483 | .cipher = { | 1577 | .cipher = { |
1484 | .enc = { | 1578 | .enc = { |
@@ -1493,7 +1587,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1493 | } | 1587 | } |
1494 | }, { | 1588 | }, { |
1495 | .alg = "rfc3686(ctr(aes))", | 1589 | .alg = "rfc3686(ctr(aes))", |
1496 | .test = alg_test_cipher, | 1590 | .test = alg_test_skcipher, |
1497 | .suite = { | 1591 | .suite = { |
1498 | .cipher = { | 1592 | .cipher = { |
1499 | .enc = { | 1593 | .enc = { |
@@ -1544,7 +1638,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1544 | } | 1638 | } |
1545 | }, { | 1639 | }, { |
1546 | .alg = "salsa20", | 1640 | .alg = "salsa20", |
1547 | .test = alg_test_cipher, | 1641 | .test = alg_test_skcipher, |
1548 | .suite = { | 1642 | .suite = { |
1549 | .cipher = { | 1643 | .cipher = { |
1550 | .enc = { | 1644 | .enc = { |
@@ -1663,7 +1757,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1663 | } | 1757 | } |
1664 | }, { | 1758 | }, { |
1665 | .alg = "xts(aes)", | 1759 | .alg = "xts(aes)", |
1666 | .test = alg_test_cipher, | 1760 | .test = alg_test_skcipher, |
1667 | .suite = { | 1761 | .suite = { |
1668 | .cipher = { | 1762 | .cipher = { |
1669 | .enc = { | 1763 | .enc = { |
@@ -1679,7 +1773,7 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1679 | } | 1773 | } |
1680 | }; | 1774 | }; |
1681 | 1775 | ||
1682 | int alg_test(const char *driver, const char *alg, u32 type, u32 mask) | 1776 | static int alg_find_test(const char *alg) |
1683 | { | 1777 | { |
1684 | int start = 0; | 1778 | int start = 0; |
1685 | int end = ARRAY_SIZE(alg_test_descs); | 1779 | int end = ARRAY_SIZE(alg_test_descs); |
@@ -1698,10 +1792,38 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask) | |||
1698 | continue; | 1792 | continue; |
1699 | } | 1793 | } |
1700 | 1794 | ||
1701 | return alg_test_descs[i].test(alg_test_descs + i, driver, | 1795 | return i; |
1702 | type, mask); | 1796 | } |
1797 | |||
1798 | return -1; | ||
1799 | } | ||
1800 | |||
1801 | int alg_test(const char *driver, const char *alg, u32 type, u32 mask) | ||
1802 | { | ||
1803 | int i; | ||
1804 | |||
1805 | if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { | ||
1806 | char nalg[CRYPTO_MAX_ALG_NAME]; | ||
1807 | |||
1808 | if (snprintf(nalg, sizeof(nalg), "ecb(%s)", alg) >= | ||
1809 | sizeof(nalg)) | ||
1810 | return -ENAMETOOLONG; | ||
1811 | |||
1812 | i = alg_find_test(nalg); | ||
1813 | if (i < 0) | ||
1814 | goto notest; | ||
1815 | |||
1816 | return alg_test_cipher(alg_test_descs + i, driver, type, mask); | ||
1703 | } | 1817 | } |
1704 | 1818 | ||
1819 | i = alg_find_test(alg); | ||
1820 | if (i < 0) | ||
1821 | goto notest; | ||
1822 | |||
1823 | return alg_test_descs[i].test(alg_test_descs + i, driver, | ||
1824 | type, mask); | ||
1825 | |||
1826 | notest: | ||
1705 | printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver); | 1827 | printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver); |
1706 | return 0; | 1828 | return 0; |
1707 | } | 1829 | } |