Skip to content

Commit 34b6ad9

Browse files
authored
Merge pull request #707 from libtom/improve-tests
Improve tests
2 parents 03881e4 + dda1c7e commit 34b6ad9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+321
-321
lines changed

src/ciphers/aes/aes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ int ECB_TEST(void)
677677

678678
rijndael_ecb_encrypt(tests[i].pt, tmp[0], &key);
679679
rijndael_ecb_decrypt(tmp[0], tmp[1], &key);
680-
if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i) ||
681-
compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
680+
if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i) ||
681+
ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
682682
return CRYPT_FAIL_TESTVECTOR;
683683
}
684684

src/ciphers/aes/aes_desc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ int AES_TEST(void)
209209
}
210210

211211
AES_ENC(tests[i].pt, tmp[0], &key);
212-
if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i)) {
212+
if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i)) {
213213
return CRYPT_FAIL_TESTVECTOR;
214214
}
215215
#ifndef ENCRYPT_ONLY
216216
AES_DEC(tmp[0], tmp[1], &key);
217-
if (compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
217+
if (ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
218218
return CRYPT_FAIL_TESTVECTOR;
219219
}
220220

src/ciphers/aes/aesni.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ int aesni_test(void)
320320

321321
aesni_ecb_encrypt(tests[i].pt, tmp[0], &key);
322322
aesni_ecb_decrypt(tmp[0], tmp[1], &key);
323-
if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES-NI Encrypt", i) ||
324-
compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES-NI Decrypt", i)) {
323+
if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES-NI Encrypt", i) ||
324+
ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES-NI Decrypt", i)) {
325325
return CRYPT_FAIL_TESTVECTOR;
326326
}
327327

src/ciphers/anubis.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,14 +1502,14 @@ int anubis_test(void)
15021502
anubis_setup(tests[x].key, tests[x].keylen, 0, &skey);
15031503
anubis_ecb_encrypt(tests[x].pt, buf[0], &skey);
15041504
anubis_ecb_decrypt(buf[0], buf[1], &skey);
1505-
if (compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis Encrypt", x) ||
1506-
compare_testvector(buf[1], 16, tests[x].pt, 16, "Anubis Decrypt", x)) {
1505+
if (ltc_compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis Encrypt", x) ||
1506+
ltc_compare_testvector(buf[1], 16, tests[x].pt, 16, "Anubis Decrypt", x)) {
15071507
return CRYPT_FAIL_TESTVECTOR;
15081508
}
15091509

15101510
for (y = 0; y < 1000; y++) anubis_ecb_encrypt(buf[0], buf[0], &skey);
15111511
for (y = 0; y < 1000; y++) anubis_ecb_decrypt(buf[0], buf[0], &skey);
1512-
if (compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis 1000", 1000)) {
1512+
if (ltc_compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis 1000", 1000)) {
15131513
return CRYPT_FAIL_TESTVECTOR;
15141514
}
15151515

src/ciphers/blowfish.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ int blowfish_test(void)
611611
blowfish_ecb_decrypt(tmp[0], tmp[1], &key);
612612

613613
/* compare */
614-
if ((compare_testvector(tmp[0], 8, tests[x].ct, 8, "Blowfish Encrypt", x) != 0) ||
615-
(compare_testvector(tmp[1], 8, tests[x].pt, 8, "Blowfish Decrypt", x) != 0)) {
614+
if ((ltc_compare_testvector(tmp[0], 8, tests[x].ct, 8, "Blowfish Encrypt", x) != 0) ||
615+
(ltc_compare_testvector(tmp[1], 8, tests[x].pt, 8, "Blowfish Decrypt", x) != 0)) {
616616
return CRYPT_FAIL_TESTVECTOR;
617617
}
618618

src/ciphers/camellia.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ int camellia_test(void)
694694
return err;
695695
}
696696
camellia_done(&skey);
697-
if (compare_testvector(tests[x].ct, 16, buf[0], 16, "Camellia Encrypt", x) ||
698-
compare_testvector(tests[x].pt, 16, buf[1], 16, "Camellia Decrypt", x)) {
697+
if (ltc_compare_testvector(tests[x].ct, 16, buf[0], 16, "Camellia Encrypt", x) ||
698+
ltc_compare_testvector(tests[x].pt, 16, buf[1], 16, "Camellia Decrypt", x)) {
699699
return CRYPT_FAIL_TESTVECTOR;
700700
}
701701
}

src/ciphers/cast5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,8 @@ int cast5_test(void)
663663
}
664664
cast5_ecb_encrypt(tests[i].pt, tmp[0], &key);
665665
cast5_ecb_decrypt(tmp[0], tmp[1], &key);
666-
if ((compare_testvector(tmp[0], 8, tests[i].ct, 8, "CAST5 Encrypt", i) != 0) ||
667-
(compare_testvector(tmp[1], 8, tests[i].pt, 8, "CAST5 Decrypt", i) != 0)) {
666+
if ((ltc_compare_testvector(tmp[0], 8, tests[i].ct, 8, "CAST5 Encrypt", i) != 0) ||
667+
(ltc_compare_testvector(tmp[1], 8, tests[i].pt, 8, "CAST5 Decrypt", i) != 0)) {
668668
return CRYPT_FAIL_TESTVECTOR;
669669
}
670670
/* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */

src/ciphers/des.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,13 +2026,13 @@ int des_test(void)
20262026

20272027
des_ecb_encrypt(cases[i].txt, ct, &skey);
20282028

2029-
if (compare_testvector(ct, sizeof(ct), cases[i].out, 8, "DES Encrypt", i) != 0) {
2029+
if (ltc_compare_testvector(ct, sizeof(ct), cases[i].out, 8, "DES Encrypt", i) != 0) {
20302030
return CRYPT_FAIL_TESTVECTOR;
20312031
}
20322032

20332033
des_ecb_decrypt(ct, pt, &skey);
20342034

2035-
if (compare_testvector(pt, sizeof(pt), cases[i].txt, 8, "DES Decrypt", i) != 0) {
2035+
if (ltc_compare_testvector(pt, sizeof(pt), cases[i].txt, 8, "DES Decrypt", i) != 0) {
20362036
return CRYPT_FAIL_TESTVECTOR;
20372037
}
20382038
}
@@ -2049,7 +2049,7 @@ int des_test(void)
20492049
for (i = 0; i < 1000; i++) des_ecb_encrypt(tmp, tmp, &skey);
20502050
for (i = 0; i < 1000; i++) des_ecb_decrypt(tmp, tmp, &skey);
20512051

2052-
if (compare_testvector(tmp, 8, pt, 8, "DES", 0) != 0) {
2052+
if (ltc_compare_testvector(tmp, 8, pt, 8, "DES", 0) != 0) {
20532053
return CRYPT_FAIL_TESTVECTOR;
20542054
}
20552055

@@ -2082,7 +2082,7 @@ int desx_test(void)
20822082
for (i = 0; i < 1000; i++) desx_ecb_encrypt(tmp, tmp, &skey);
20832083
for (i = 0; i < 1000; i++) desx_ecb_decrypt(tmp, tmp, &skey);
20842084

2085-
if (compare_testvector(tmp, 8, pt, 8, "DES-X", 0) != 0) {
2085+
if (ltc_compare_testvector(tmp, 8, pt, 8, "DES-X", 0) != 0) {
20862086
return CRYPT_FAIL_TESTVECTOR;
20872087
}
20882088

@@ -2133,13 +2133,13 @@ int des3_test(void)
21332133

21342134
des3_ecb_encrypt(cases[i].txt, ct, &skey);
21352135

2136-
if (compare_testvector(ct, sizeof(ct), cases[i].out, 8, "3DES Encrypt", i) != 0) {
2136+
if (ltc_compare_testvector(ct, sizeof(ct), cases[i].out, 8, "3DES Encrypt", i) != 0) {
21372137
return CRYPT_FAIL_TESTVECTOR;
21382138
}
21392139

21402140
des3_ecb_decrypt(ct, pt, &skey);
21412141

2142-
if (compare_testvector(pt, sizeof(pt), cases[i].txt, 8, "3DES Decrypt", i) != 0) {
2142+
if (ltc_compare_testvector(pt, sizeof(pt), cases[i].txt, 8, "3DES Decrypt", i) != 0) {
21432143
return CRYPT_FAIL_TESTVECTOR;
21442144
}
21452145
}
@@ -2156,7 +2156,7 @@ int des3_test(void)
21562156
for (i = 0; i < 1000; i++) des3_ecb_encrypt(tmp, tmp, &skey);
21572157
for (i = 0; i < 1000; i++) des3_ecb_decrypt(tmp, tmp, &skey);
21582158

2159-
if (compare_testvector(tmp, 8, pt, 8, "3DES", 0) != 0) {
2159+
if (ltc_compare_testvector(tmp, 8, pt, 8, "3DES", 0) != 0) {
21602160
return CRYPT_FAIL_TESTVECTOR;
21612161
}
21622162

src/ciphers/idea.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ int idea_test(void)
233233
if ((err = idea_ecb_encrypt(tests[x].pt, buf[0], &key)) != CRYPT_OK) {
234234
return err;
235235
}
236-
if (compare_testvector(buf[0], 8, tests[x].ct, 8, "IDEA Encrypt", x)) {
236+
if (ltc_compare_testvector(buf[0], 8, tests[x].ct, 8, "IDEA Encrypt", x)) {
237237
return CRYPT_FAIL_TESTVECTOR;
238238
}
239239
if ((err = idea_ecb_decrypt(tests[x].ct, buf[1], &key)) != CRYPT_OK) {
240240
return err;
241241
}
242-
if (compare_testvector(buf[1], 8, tests[x].pt, 8, "IDEA Decrypt", x)) {
242+
if (ltc_compare_testvector(buf[1], 8, tests[x].pt, 8, "IDEA Decrypt", x)) {
243243
return CRYPT_FAIL_TESTVECTOR;
244244
}
245245
}

src/ciphers/kasumi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ int kasumi_test(void)
296296
if ((err = kasumi_ecb_decrypt(tests[x].ct, buf[1], &key)) != CRYPT_OK) {
297297
return err;
298298
}
299-
if (compare_testvector(buf[1], 8, tests[x].pt, 8, "Kasumi Decrypt", x) ||
300-
compare_testvector(buf[0], 8, tests[x].ct, 8, "Kasumi Encrypt", x)) {
299+
if (ltc_compare_testvector(buf[1], 8, tests[x].pt, 8, "Kasumi Decrypt", x) ||
300+
ltc_compare_testvector(buf[0], 8, tests[x].ct, 8, "Kasumi Encrypt", x)) {
301301
return CRYPT_FAIL_TESTVECTOR;
302302
}
303303
}

0 commit comments

Comments
 (0)