Mercurial > dropbear
comparison libtomcrypt/demos/tv_gen.c @ 1439:8d24733026c5 coverity
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 24 Jun 2017 23:33:16 +0800 |
parents | f849a5ca2efc |
children | 6dba84798cd5 |
comparison
equal
deleted
inserted
replaced
1400:238a439670f5 | 1439:8d24733026c5 |
---|---|
2 | 2 |
3 void reg_algs(void) | 3 void reg_algs(void) |
4 { | 4 { |
5 int err; | 5 int err; |
6 | 6 |
7 #ifdef RIJNDAEL | 7 #ifdef LTC_RIJNDAEL |
8 register_cipher (&aes_desc); | 8 register_cipher (&aes_desc); |
9 #endif | 9 #endif |
10 #ifdef BLOWFISH | 10 #ifdef LTC_BLOWFISH |
11 register_cipher (&blowfish_desc); | 11 register_cipher (&blowfish_desc); |
12 #endif | 12 #endif |
13 #ifdef XTEA | 13 #ifdef LTC_XTEA |
14 register_cipher (&xtea_desc); | 14 register_cipher (&xtea_desc); |
15 #endif | 15 #endif |
16 #ifdef RC5 | 16 #ifdef LTC_RC5 |
17 register_cipher (&rc5_desc); | 17 register_cipher (&rc5_desc); |
18 #endif | 18 #endif |
19 #ifdef RC6 | 19 #ifdef LTC_RC6 |
20 register_cipher (&rc6_desc); | 20 register_cipher (&rc6_desc); |
21 #endif | 21 #endif |
22 #ifdef SAFERP | 22 #ifdef LTC_SAFERP |
23 register_cipher (&saferp_desc); | 23 register_cipher (&saferp_desc); |
24 #endif | 24 #endif |
25 #ifdef TWOFISH | 25 #ifdef LTC_TWOFISH |
26 register_cipher (&twofish_desc); | 26 register_cipher (&twofish_desc); |
27 #endif | 27 #endif |
28 #ifdef SAFER | 28 #ifdef LTC_SAFER |
29 register_cipher (&safer_k64_desc); | 29 register_cipher (&safer_k64_desc); |
30 register_cipher (&safer_sk64_desc); | 30 register_cipher (&safer_sk64_desc); |
31 register_cipher (&safer_k128_desc); | 31 register_cipher (&safer_k128_desc); |
32 register_cipher (&safer_sk128_desc); | 32 register_cipher (&safer_sk128_desc); |
33 #endif | 33 #endif |
34 #ifdef RC2 | 34 #ifdef LTC_RC2 |
35 register_cipher (&rc2_desc); | 35 register_cipher (&rc2_desc); |
36 #endif | 36 #endif |
37 #ifdef DES | 37 #ifdef LTC_DES |
38 register_cipher (&des_desc); | 38 register_cipher (&des_desc); |
39 register_cipher (&des3_desc); | 39 register_cipher (&des3_desc); |
40 #endif | 40 #endif |
41 #ifdef CAST5 | 41 #ifdef LTC_CAST5 |
42 register_cipher (&cast5_desc); | 42 register_cipher (&cast5_desc); |
43 #endif | 43 #endif |
44 #ifdef NOEKEON | 44 #ifdef LTC_NOEKEON |
45 register_cipher (&noekeon_desc); | 45 register_cipher (&noekeon_desc); |
46 #endif | 46 #endif |
47 #ifdef SKIPJACK | 47 #ifdef LTC_SKIPJACK |
48 register_cipher (&skipjack_desc); | 48 register_cipher (&skipjack_desc); |
49 #endif | 49 #endif |
50 #ifdef ANUBIS | 50 #ifdef LTC_ANUBIS |
51 register_cipher (&anubis_desc); | 51 register_cipher (&anubis_desc); |
52 #endif | 52 #endif |
53 #ifdef KHAZAD | 53 #ifdef LTC_KHAZAD |
54 register_cipher (&khazad_desc); | 54 register_cipher (&khazad_desc); |
55 #endif | 55 #endif |
56 | 56 |
57 #ifdef TIGER | 57 #ifdef LTC_TIGER |
58 register_hash (&tiger_desc); | 58 register_hash (&tiger_desc); |
59 #endif | 59 #endif |
60 #ifdef MD2 | 60 #ifdef LTC_MD2 |
61 register_hash (&md2_desc); | 61 register_hash (&md2_desc); |
62 #endif | 62 #endif |
63 #ifdef MD4 | 63 #ifdef LTC_MD4 |
64 register_hash (&md4_desc); | 64 register_hash (&md4_desc); |
65 #endif | 65 #endif |
66 #ifdef MD5 | 66 #ifdef LTC_MD5 |
67 register_hash (&md5_desc); | 67 register_hash (&md5_desc); |
68 #endif | 68 #endif |
69 #ifdef SHA1 | 69 #ifdef LTC_SHA1 |
70 register_hash (&sha1_desc); | 70 register_hash (&sha1_desc); |
71 #endif | 71 #endif |
72 #ifdef SHA224 | 72 #ifdef LTC_SHA224 |
73 register_hash (&sha224_desc); | 73 register_hash (&sha224_desc); |
74 #endif | 74 #endif |
75 #ifdef SHA256 | 75 #ifdef LTC_SHA256 |
76 register_hash (&sha256_desc); | 76 register_hash (&sha256_desc); |
77 #endif | 77 #endif |
78 #ifdef SHA384 | 78 #ifdef LTC_SHA384 |
79 register_hash (&sha384_desc); | 79 register_hash (&sha384_desc); |
80 #endif | 80 #endif |
81 #ifdef SHA512 | 81 #ifdef LTC_SHA512 |
82 register_hash (&sha512_desc); | 82 register_hash (&sha512_desc); |
83 #endif | 83 #endif |
84 #ifdef RIPEMD128 | 84 #ifdef LTC_RIPEMD128 |
85 register_hash (&rmd128_desc); | 85 register_hash (&rmd128_desc); |
86 #endif | 86 #endif |
87 #ifdef RIPEMD160 | 87 #ifdef LTC_RIPEMD160 |
88 register_hash (&rmd160_desc); | 88 register_hash (&rmd160_desc); |
89 #endif | 89 #endif |
90 #ifdef WHIRLPOOL | 90 #ifdef LTC_WHIRLPOOL |
91 register_hash (&whirlpool_desc); | 91 register_hash (&whirlpool_desc); |
92 #endif | 92 #endif |
93 #ifdef CHC_HASH | 93 #ifdef LTC_CHC_HASH |
94 register_hash(&chc_desc); | 94 register_hash(&chc_desc); |
95 if ((err = chc_register(register_cipher(&aes_desc))) != CRYPT_OK) { | 95 if ((err = chc_register(register_cipher(&aes_desc))) != CRYPT_OK) { |
96 printf("chc_register error: %s\n", error_to_string(err)); | 96 printf("chc_register error: %s\n", error_to_string(err)); |
97 exit(EXIT_FAILURE); | 97 exit(EXIT_FAILURE); |
98 } | 98 } |
236 unsigned long len; | 236 unsigned long len; |
237 | 237 |
238 out = fopen("hmac_tv.txt", "w"); | 238 out = fopen("hmac_tv.txt", "w"); |
239 | 239 |
240 fprintf(out, | 240 fprintf(out, |
241 "HMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are HMACed. The initial key is\n" | 241 "LTC_HMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are LTC_HMACed. The initial key is\n" |
242 "of the same format (the same length as the HASH output size). The HMAC key in step N+1 is the HMAC output of\n" | 242 "of the same format (the same length as the HASH output size). The LTC_HMAC key in step N+1 is the LTC_HMAC output of\n" |
243 "step N.\n\n"); | 243 "step N.\n\n"); |
244 | 244 |
245 for (x = 0; hash_descriptor[x].name != NULL; x++) { | 245 for (x = 0; hash_descriptor[x].name != NULL; x++) { |
246 fprintf(out, "HMAC-%s\n", hash_descriptor[x].name); | 246 fprintf(out, "LTC_HMAC-%s\n", hash_descriptor[x].name); |
247 | 247 |
248 /* initial key */ | 248 /* initial key */ |
249 for (y = 0; y < (int)hash_descriptor[x].hashsize; y++) { | 249 for (y = 0; y < (int)hash_descriptor[x].hashsize; y++) { |
250 key[y] = (y&255); | 250 key[y] = (y&255); |
251 } | 251 } |
288 unsigned long len; | 288 unsigned long len; |
289 | 289 |
290 out = fopen("omac_tv.txt", "w"); | 290 out = fopen("omac_tv.txt", "w"); |
291 | 291 |
292 fprintf(out, | 292 fprintf(out, |
293 "OMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are OMAC'ed. The initial key is\n" | 293 "LTC_OMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are LTC_OMAC'ed. The initial key is\n" |
294 "of the same format (length specified per cipher). The OMAC key in step N+1 is the OMAC output of\n" | 294 "of the same format (length specified per cipher). The LTC_OMAC key in step N+1 is the LTC_OMAC output of\n" |
295 "step N (repeated as required to fill the array).\n\n"); | 295 "step N (repeated as required to fill the array).\n\n"); |
296 | 296 |
297 for (x = 0; cipher_descriptor[x].name != NULL; x++) { | 297 for (x = 0; cipher_descriptor[x].name != NULL; x++) { |
298 kl = cipher_descriptor[x].block_length; | 298 kl = cipher_descriptor[x].block_length; |
299 | 299 |
301 if (kl != 8 && kl != 16) continue; | 301 if (kl != 8 && kl != 16) continue; |
302 | 302 |
303 if (cipher_descriptor[x].keysize(&kl) != CRYPT_OK) { | 303 if (cipher_descriptor[x].keysize(&kl) != CRYPT_OK) { |
304 kl = cipher_descriptor[x].max_key_length; | 304 kl = cipher_descriptor[x].max_key_length; |
305 } | 305 } |
306 fprintf(out, "OMAC-%s (%d byte key)\n", cipher_descriptor[x].name, kl); | 306 fprintf(out, "LTC_OMAC-%s (%d byte key)\n", cipher_descriptor[x].name, kl); |
307 | 307 |
308 /* initial key/block */ | 308 /* initial key/block */ |
309 for (y = 0; y < kl; y++) { | 309 for (y = 0; y < kl; y++) { |
310 key[y] = (y & 255); | 310 key[y] = (y & 255); |
311 } | 311 } |
343 unsigned long len; | 343 unsigned long len; |
344 | 344 |
345 out = fopen("pmac_tv.txt", "w"); | 345 out = fopen("pmac_tv.txt", "w"); |
346 | 346 |
347 fprintf(out, | 347 fprintf(out, |
348 "PMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are OMAC'ed. The initial key is\n" | 348 "PMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are LTC_OMAC'ed. The initial key is\n" |
349 "of the same format (length specified per cipher). The OMAC key in step N+1 is the OMAC output of\n" | 349 "of the same format (length specified per cipher). The LTC_OMAC key in step N+1 is the LTC_OMAC output of\n" |
350 "step N (repeated as required to fill the array).\n\n"); | 350 "step N (repeated as required to fill the array).\n\n"); |
351 | 351 |
352 for (x = 0; cipher_descriptor[x].name != NULL; x++) { | 352 for (x = 0; cipher_descriptor[x].name != NULL; x++) { |
353 kl = cipher_descriptor[x].block_length; | 353 kl = cipher_descriptor[x].block_length; |
354 | 354 |
765 int main(void) | 765 int main(void) |
766 { | 766 { |
767 reg_algs(); | 767 reg_algs(); |
768 printf("Generating hash vectors..."); fflush(stdout); hash_gen(); printf("done\n"); | 768 printf("Generating hash vectors..."); fflush(stdout); hash_gen(); printf("done\n"); |
769 printf("Generating cipher vectors..."); fflush(stdout); cipher_gen(); printf("done\n"); | 769 printf("Generating cipher vectors..."); fflush(stdout); cipher_gen(); printf("done\n"); |
770 printf("Generating HMAC vectors..."); fflush(stdout); hmac_gen(); printf("done\n"); | 770 printf("Generating LTC_HMAC vectors..."); fflush(stdout); hmac_gen(); printf("done\n"); |
771 printf("Generating OMAC vectors..."); fflush(stdout); omac_gen(); printf("done\n"); | 771 printf("Generating LTC_OMAC vectors..."); fflush(stdout); omac_gen(); printf("done\n"); |
772 printf("Generating PMAC vectors..."); fflush(stdout); pmac_gen(); printf("done\n"); | 772 printf("Generating PMAC vectors..."); fflush(stdout); pmac_gen(); printf("done\n"); |
773 printf("Generating EAX vectors..."); fflush(stdout); eax_gen(); printf("done\n"); | 773 printf("Generating EAX vectors..."); fflush(stdout); eax_gen(); printf("done\n"); |
774 printf("Generating OCB vectors..."); fflush(stdout); ocb_gen(); printf("done\n"); | 774 printf("Generating OCB vectors..."); fflush(stdout); ocb_gen(); printf("done\n"); |
775 printf("Generating CCM vectors..."); fflush(stdout); ccm_gen(); printf("done\n"); | 775 printf("Generating CCM vectors..."); fflush(stdout); ccm_gen(); printf("done\n"); |
776 printf("Generating GCM vectors..."); fflush(stdout); gcm_gen(); printf("done\n"); | 776 printf("Generating GCM vectors..."); fflush(stdout); gcm_gen(); printf("done\n"); |
777 printf("Generating BASE64 vectors..."); fflush(stdout); base64_gen(); printf("done\n"); | 777 printf("Generating LTC_BASE64 vectors..."); fflush(stdout); base64_gen(); printf("done\n"); |
778 printf("Generating MATH vectors..."); fflush(stdout); math_gen(); printf("done\n"); | 778 printf("Generating MATH vectors..."); fflush(stdout); math_gen(); printf("done\n"); |
779 printf("Generating ECC vectors..."); fflush(stdout); ecc_gen(); printf("done\n"); | 779 printf("Generating ECC vectors..."); fflush(stdout); ecc_gen(); printf("done\n"); |
780 printf("Generating LRW vectors..."); fflush(stdout); lrw_gen(); printf("done\n"); | 780 printf("Generating LRW vectors..."); fflush(stdout); lrw_gen(); printf("done\n"); |
781 return 0; | 781 return 0; |
782 } | 782 } |
783 | 783 |
784 /* $Source: /cvs/libtom/libtomcrypt/demos/tv_gen.c,v $ */ | 784 /* $Source$ */ |
785 /* $Revision: 1.15 $ */ | 785 /* $Revision$ */ |
786 /* $Date: 2006/06/09 22:10:27 $ */ | 786 /* $Date$ */ |