diff options
-rw-r--r-- | crypto/tcrypt.c | 79 |
1 files changed, 57 insertions, 22 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 414ef5e71171..401d25ac214f 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -427,9 +427,10 @@ out: | |||
427 | } | 427 | } |
428 | 428 | ||
429 | static void test_cipher_speed(char *algo, int mode, int enc, unsigned int sec, | 429 | static void test_cipher_speed(char *algo, int mode, int enc, unsigned int sec, |
430 | struct cipher_speed *speed) | 430 | struct cipher_testvec *template, |
431 | unsigned int tcount, struct cipher_speed *speed) | ||
431 | { | 432 | { |
432 | unsigned int ret, i, iv_len; | 433 | unsigned int ret, i, j, iv_len; |
433 | unsigned char *key, *p, iv[128]; | 434 | unsigned char *key, *p, iv[128]; |
434 | struct crypto_tfm *tfm; | 435 | struct crypto_tfm *tfm; |
435 | struct scatterlist sg[8]; | 436 | struct scatterlist sg[8]; |
@@ -471,6 +472,12 @@ static void test_cipher_speed(char *algo, int mode, int enc, unsigned int sec, | |||
471 | 472 | ||
472 | /* set key, plain text and IV */ | 473 | /* set key, plain text and IV */ |
473 | key = (unsigned char *)tvmem; | 474 | key = (unsigned char *)tvmem; |
475 | for (j = 0; j < tcount; j++) { | ||
476 | if (template[j].klen == speed[i].klen) { | ||
477 | key = template[j].key; | ||
478 | break; | ||
479 | } | ||
480 | } | ||
474 | p = (unsigned char *)tvmem + speed[i].klen; | 481 | p = (unsigned char *)tvmem + speed[i].klen; |
475 | 482 | ||
476 | ret = crypto_cipher_setkey(tfm, key, speed[i].klen); | 483 | ret = crypto_cipher_setkey(tfm, key, speed[i].klen); |
@@ -953,38 +960,66 @@ static void do_test(void) | |||
953 | #endif | 960 | #endif |
954 | 961 | ||
955 | case 200: | 962 | case 200: |
956 | test_cipher_speed("aes", MODE_ECB, ENCRYPT, sec, aes_speed_template); | 963 | test_cipher_speed("aes", MODE_ECB, ENCRYPT, sec, NULL, 0, |
957 | test_cipher_speed("aes", MODE_ECB, DECRYPT, sec, aes_speed_template); | 964 | aes_speed_template); |
958 | test_cipher_speed("aes", MODE_CBC, ENCRYPT, sec, aes_speed_template); | 965 | test_cipher_speed("aes", MODE_ECB, DECRYPT, sec, NULL, 0, |
959 | test_cipher_speed("aes", MODE_CBC, DECRYPT, sec, aes_speed_template); | 966 | aes_speed_template); |
967 | test_cipher_speed("aes", MODE_CBC, ENCRYPT, sec, NULL, 0, | ||
968 | aes_speed_template); | ||
969 | test_cipher_speed("aes", MODE_CBC, DECRYPT, sec, NULL, 0, | ||
970 | aes_speed_template); | ||
960 | break; | 971 | break; |
961 | 972 | ||
962 | case 201: | 973 | case 201: |
963 | test_cipher_speed("des3_ede", MODE_ECB, ENCRYPT, sec, des3_ede_speed_template); | 974 | test_cipher_speed("des3_ede", MODE_ECB, ENCRYPT, sec, |
964 | test_cipher_speed("des3_ede", MODE_ECB, DECRYPT, sec, des3_ede_speed_template); | 975 | des3_ede_enc_tv_template, |
965 | test_cipher_speed("des3_ede", MODE_CBC, ENCRYPT, sec, des3_ede_speed_template); | 976 | DES3_EDE_ENC_TEST_VECTORS, |
966 | test_cipher_speed("des3_ede", MODE_CBC, DECRYPT, sec, des3_ede_speed_template); | 977 | des3_ede_speed_template); |
978 | test_cipher_speed("des3_ede", MODE_ECB, DECRYPT, sec, | ||
979 | des3_ede_dec_tv_template, | ||
980 | DES3_EDE_DEC_TEST_VECTORS, | ||
981 | des3_ede_speed_template); | ||
982 | test_cipher_speed("des3_ede", MODE_CBC, ENCRYPT, sec, | ||
983 | des3_ede_enc_tv_template, | ||
984 | DES3_EDE_ENC_TEST_VECTORS, | ||
985 | des3_ede_speed_template); | ||
986 | test_cipher_speed("des3_ede", MODE_CBC, DECRYPT, sec, | ||
987 | des3_ede_dec_tv_template, | ||
988 | DES3_EDE_DEC_TEST_VECTORS, | ||
989 | des3_ede_speed_template); | ||
967 | break; | 990 | break; |
968 | 991 | ||
969 | case 202: | 992 | case 202: |
970 | test_cipher_speed("twofish", MODE_ECB, ENCRYPT, sec, twofish_speed_template); | 993 | test_cipher_speed("twofish", MODE_ECB, ENCRYPT, sec, NULL, 0, |
971 | test_cipher_speed("twofish", MODE_ECB, DECRYPT, sec, twofish_speed_template); | 994 | twofish_speed_template); |
972 | test_cipher_speed("twofish", MODE_CBC, ENCRYPT, sec, twofish_speed_template); | 995 | test_cipher_speed("twofish", MODE_ECB, DECRYPT, sec, NULL, 0, |
973 | test_cipher_speed("twofish", MODE_CBC, DECRYPT, sec, twofish_speed_template); | 996 | twofish_speed_template); |
997 | test_cipher_speed("twofish", MODE_CBC, ENCRYPT, sec, NULL, 0, | ||
998 | twofish_speed_template); | ||
999 | test_cipher_speed("twofish", MODE_CBC, DECRYPT, sec, NULL, 0, | ||
1000 | twofish_speed_template); | ||
974 | break; | 1001 | break; |
975 | 1002 | ||
976 | case 203: | 1003 | case 203: |
977 | test_cipher_speed("blowfish", MODE_ECB, ENCRYPT, sec, blowfish_speed_template); | 1004 | test_cipher_speed("blowfish", MODE_ECB, ENCRYPT, sec, NULL, 0, |
978 | test_cipher_speed("blowfish", MODE_ECB, DECRYPT, sec, blowfish_speed_template); | 1005 | blowfish_speed_template); |
979 | test_cipher_speed("blowfish", MODE_CBC, ENCRYPT, sec, blowfish_speed_template); | 1006 | test_cipher_speed("blowfish", MODE_ECB, DECRYPT, sec, NULL, 0, |
980 | test_cipher_speed("blowfish", MODE_CBC, DECRYPT, sec, blowfish_speed_template); | 1007 | blowfish_speed_template); |
1008 | test_cipher_speed("blowfish", MODE_CBC, ENCRYPT, sec, NULL, 0, | ||
1009 | blowfish_speed_template); | ||
1010 | test_cipher_speed("blowfish", MODE_CBC, DECRYPT, sec, NULL, 0, | ||
1011 | blowfish_speed_template); | ||
981 | break; | 1012 | break; |
982 | 1013 | ||
983 | case 204: | 1014 | case 204: |
984 | test_cipher_speed("des", MODE_ECB, ENCRYPT, sec, des_speed_template); | 1015 | test_cipher_speed("des", MODE_ECB, ENCRYPT, sec, NULL, 0, |
985 | test_cipher_speed("des", MODE_ECB, DECRYPT, sec, des_speed_template); | 1016 | des_speed_template); |
986 | test_cipher_speed("des", MODE_CBC, ENCRYPT, sec, des_speed_template); | 1017 | test_cipher_speed("des", MODE_ECB, DECRYPT, sec, NULL, 0, |
987 | test_cipher_speed("des", MODE_CBC, DECRYPT, sec, des_speed_template); | 1018 | des_speed_template); |
1019 | test_cipher_speed("des", MODE_CBC, ENCRYPT, sec, NULL, 0, | ||
1020 | des_speed_template); | ||
1021 | test_cipher_speed("des", MODE_CBC, DECRYPT, sec, NULL, 0, | ||
1022 | des_speed_template); | ||
988 | break; | 1023 | break; |
989 | 1024 | ||
990 | case 1000: | 1025 | case 1000: |