comparison libtomcrypt/demos/tv_gen.c @ 285:1b9e69c058d2

propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 20dccfc09627970a312d77fb41dc2970b62689c3) to branch 'au.asn.ucc.matt.dropbear' (head fdf4a7a3b97ae5046139915de7e40399cceb2c01)
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 13:23:58 +0000
parents
children 0cbe8f6dbf9e
comparison
equal deleted inserted replaced
281:997e6f7dc01e 285:1b9e69c058d2
1 #include <tomcrypt.h>
2
3 void reg_algs(void)
4 {
5 int err;
6
7 #ifdef RIJNDAEL
8 register_cipher (&aes_desc);
9 #endif
10 #ifdef BLOWFISH
11 register_cipher (&blowfish_desc);
12 #endif
13 #ifdef XTEA
14 register_cipher (&xtea_desc);
15 #endif
16 #ifdef RC5
17 register_cipher (&rc5_desc);
18 #endif
19 #ifdef RC6
20 register_cipher (&rc6_desc);
21 #endif
22 #ifdef SAFERP
23 register_cipher (&saferp_desc);
24 #endif
25 #ifdef TWOFISH
26 register_cipher (&twofish_desc);
27 #endif
28 #ifdef SAFER
29 register_cipher (&safer_k64_desc);
30 register_cipher (&safer_sk64_desc);
31 register_cipher (&safer_k128_desc);
32 register_cipher (&safer_sk128_desc);
33 #endif
34 #ifdef RC2
35 register_cipher (&rc2_desc);
36 #endif
37 #ifdef DES
38 register_cipher (&des_desc);
39 register_cipher (&des3_desc);
40 #endif
41 #ifdef CAST5
42 register_cipher (&cast5_desc);
43 #endif
44 #ifdef NOEKEON
45 register_cipher (&noekeon_desc);
46 #endif
47 #ifdef SKIPJACK
48 register_cipher (&skipjack_desc);
49 #endif
50 #ifdef ANUBIS
51 register_cipher (&anubis_desc);
52 #endif
53 #ifdef KHAZAD
54 register_cipher (&khazad_desc);
55 #endif
56
57 #ifdef TIGER
58 register_hash (&tiger_desc);
59 #endif
60 #ifdef MD2
61 register_hash (&md2_desc);
62 #endif
63 #ifdef MD4
64 register_hash (&md4_desc);
65 #endif
66 #ifdef MD5
67 register_hash (&md5_desc);
68 #endif
69 #ifdef SHA1
70 register_hash (&sha1_desc);
71 #endif
72 #ifdef SHA224
73 register_hash (&sha224_desc);
74 #endif
75 #ifdef SHA256
76 register_hash (&sha256_desc);
77 #endif
78 #ifdef SHA384
79 register_hash (&sha384_desc);
80 #endif
81 #ifdef SHA512
82 register_hash (&sha512_desc);
83 #endif
84 #ifdef RIPEMD128
85 register_hash (&rmd128_desc);
86 #endif
87 #ifdef RIPEMD160
88 register_hash (&rmd160_desc);
89 #endif
90 #ifdef WHIRLPOOL
91 register_hash (&whirlpool_desc);
92 #endif
93 #ifdef CHC_HASH
94 register_hash(&chc_desc);
95 if ((err = chc_register(register_cipher(&aes_desc))) != CRYPT_OK) {
96 printf("chc_register error: %s\n", error_to_string(err));
97 exit(EXIT_FAILURE);
98 }
99 #endif
100
101 }
102
103 void hash_gen(void)
104 {
105 unsigned char md[MAXBLOCKSIZE], *buf;
106 unsigned long outlen, x, y, z;
107 FILE *out;
108 int err;
109
110 out = fopen("hash_tv.txt", "w");
111 if (out == NULL) {
112 perror("can't open hash_tv");
113 }
114
115 fprintf(out, "Hash Test Vectors:\n\nThese are the hashes of nn bytes '00 01 02 03 .. (nn-1)'\n\n");
116 for (x = 0; hash_descriptor[x].name != NULL; x++) {
117 buf = XMALLOC(2 * hash_descriptor[x].blocksize + 1);
118 if (buf == NULL) {
119 perror("can't alloc mem");
120 exit(EXIT_FAILURE);
121 }
122 fprintf(out, "Hash: %s\n", hash_descriptor[x].name);
123 for (y = 0; y <= (hash_descriptor[x].blocksize * 2); y++) {
124 for (z = 0; z < y; z++) {
125 buf[z] = (unsigned char)(z & 255);
126 }
127 outlen = sizeof(md);
128 if ((err = hash_memory(x, buf, y, md, &outlen)) != CRYPT_OK) {
129 printf("hash_memory error: %s\n", error_to_string(err));
130 exit(EXIT_FAILURE);
131 }
132 fprintf(out, "%3lu: ", y);
133 for (z = 0; z < outlen; z++) {
134 fprintf(out, "%02X", md[z]);
135 }
136 fprintf(out, "\n");
137 }
138 fprintf(out, "\n");
139 XFREE(buf);
140 }
141 fclose(out);
142 }
143
144 void cipher_gen(void)
145 {
146 unsigned char *key, pt[MAXBLOCKSIZE];
147 unsigned long x, y, z, w;
148 int err, kl, lastkl;
149 FILE *out;
150 symmetric_key skey;
151
152 out = fopen("cipher_tv.txt", "w");
153
154 fprintf(out,
155 "Cipher Test Vectors\n\nThese are test encryptions with key of nn bytes '00 01 02 03 .. (nn-1)' and original PT of the same style.\n"
156 "The output of step N is used as the key and plaintext for step N+1 (key bytes repeated as required to fill the key)\n\n");
157
158 for (x = 0; cipher_descriptor[x].name != NULL; x++) {
159 fprintf(out, "Cipher: %s\n", cipher_descriptor[x].name);
160
161 /* three modes, smallest, medium, large keys */
162 lastkl = 10000;
163 for (y = 0; y < 3; y++) {
164 switch (y) {
165 case 0: kl = cipher_descriptor[x].min_key_length; break;
166 case 1: kl = (cipher_descriptor[x].min_key_length + cipher_descriptor[x].max_key_length)/2; break;
167 case 2: kl = cipher_descriptor[x].max_key_length; break;
168 }
169 if ((err = cipher_descriptor[x].keysize(&kl)) != CRYPT_OK) {
170 printf("keysize error: %s\n", error_to_string(err));
171 exit(EXIT_FAILURE);
172 }
173 if (kl == lastkl) break;
174 lastkl = kl;
175 fprintf(out, "Key Size: %d bytes\n", kl);
176
177 key = XMALLOC(kl);
178 if (key == NULL) {
179 perror("can't malloc memory");
180 exit(EXIT_FAILURE);
181 }
182
183 for (z = 0; (int)z < kl; z++) {
184 key[z] = (unsigned char)z;
185 }
186 if ((err = cipher_descriptor[x].setup(key, kl, 0, &skey)) != CRYPT_OK) {
187 printf("setup error: %s\n", error_to_string(err));
188 exit(EXIT_FAILURE);
189 }
190
191 for (z = 0; (int)z < cipher_descriptor[x].block_length; z++) {
192 pt[z] = (unsigned char)z;
193 }
194 for (w = 0; w < 50; w++) {
195 cipher_descriptor[x].ecb_encrypt(pt, pt, &skey);
196 fprintf(out, "%2lu: ", w);
197 for (z = 0; (int)z < cipher_descriptor[x].block_length; z++) {
198 fprintf(out, "%02X", pt[z]);
199 }
200 fprintf(out, "\n");
201
202 /* reschedule a new key */
203 for (z = 0; z < (unsigned long)kl; z++) {
204 key[z] = pt[z % cipher_descriptor[x].block_length];
205 }
206 if ((err = cipher_descriptor[x].setup(key, kl, 0, &skey)) != CRYPT_OK) {
207 printf("cipher setup2 error: %s\n", error_to_string(err));
208 exit(EXIT_FAILURE);
209 }
210 }
211 fprintf(out, "\n");
212 XFREE(key);
213 }
214 fprintf(out, "\n");
215 }
216 fclose(out);
217 }
218
219 void hmac_gen(void)
220 {
221 unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], *input;
222 int x, y, z, err;
223 FILE *out;
224 unsigned long len;
225
226 out = fopen("hmac_tv.txt", "w");
227
228 fprintf(out,
229 "HMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are HMACed. The initial key is\n"
230 "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"
231 "step N.\n\n");
232
233 for (x = 0; hash_descriptor[x].name != NULL; x++) {
234 fprintf(out, "HMAC-%s\n", hash_descriptor[x].name);
235
236 /* initial key */
237 for (y = 0; y < (int)hash_descriptor[x].hashsize; y++) {
238 key[y] = (y&255);
239 }
240
241 input = XMALLOC(hash_descriptor[x].blocksize * 2 + 1);
242 if (input == NULL) {
243 perror("Can't malloc memory");
244 exit(EXIT_FAILURE);
245 }
246
247 for (y = 0; y <= (int)(hash_descriptor[x].blocksize * 2); y++) {
248 for (z = 0; z < y; z++) {
249 input[z] = (unsigned char)(z & 255);
250 }
251 len = sizeof(output);
252 if ((err = hmac_memory(x, key, hash_descriptor[x].hashsize, input, y, output, &len)) != CRYPT_OK) {
253 printf("Error hmacing: %s\n", error_to_string(err));
254 exit(EXIT_FAILURE);
255 }
256 fprintf(out, "%3d: ", y);
257 for (z = 0; z <(int) len; z++) {
258 fprintf(out, "%02X", output[z]);
259 }
260 fprintf(out, "\n");
261
262 /* forward the key */
263 memcpy(key, output, hash_descriptor[x].hashsize);
264 }
265 XFREE(input);
266 fprintf(out, "\n");
267 }
268 fclose(out);
269 }
270
271 void omac_gen(void)
272 {
273 unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
274 int err, x, y, z, kl;
275 FILE *out;
276 unsigned long len;
277
278 out = fopen("omac_tv.txt", "w");
279
280 fprintf(out,
281 "OMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are OMAC'ed. The initial key is\n"
282 "of the same format (length specified per cipher). The OMAC key in step N+1 is the OMAC output of\n"
283 "step N (repeated as required to fill the array).\n\n");
284
285 for (x = 0; cipher_descriptor[x].name != NULL; x++) {
286 kl = cipher_descriptor[x].block_length;
287
288 /* skip ciphers which do not have 64 or 128 bit block sizes */
289 if (kl != 8 && kl != 16) continue;
290
291 if (cipher_descriptor[x].keysize(&kl) != CRYPT_OK) {
292 kl = cipher_descriptor[x].max_key_length;
293 }
294 fprintf(out, "OMAC-%s (%d byte key)\n", cipher_descriptor[x].name, kl);
295
296 /* initial key/block */
297 for (y = 0; y < kl; y++) {
298 key[y] = (y & 255);
299 }
300
301 for (y = 0; y <= (int)(cipher_descriptor[x].block_length*2); y++) {
302 for (z = 0; z < y; z++) {
303 input[z] = (unsigned char)(z & 255);
304 }
305 len = sizeof(output);
306 if ((err = omac_memory(x, key, kl, input, y, output, &len)) != CRYPT_OK) {
307 printf("Error omacing: %s\n", error_to_string(err));
308 exit(EXIT_FAILURE);
309 }
310 fprintf(out, "%3d: ", y);
311 for (z = 0; z <(int)len; z++) {
312 fprintf(out, "%02X", output[z]);
313 }
314 fprintf(out, "\n");
315
316 /* forward the key */
317 for (z = 0; z < kl; z++) {
318 key[z] = output[z % len];
319 }
320 }
321 fprintf(out, "\n");
322 }
323 fclose(out);
324 }
325
326 void pmac_gen(void)
327 {
328 unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
329 int err, x, y, z, kl;
330 FILE *out;
331 unsigned long len;
332
333 out = fopen("pmac_tv.txt", "w");
334
335 fprintf(out,
336 "PMAC Tests. In these tests messages of N bytes long (00,01,02,...,NN-1) are OMAC'ed. The initial key is\n"
337 "of the same format (length specified per cipher). The OMAC key in step N+1 is the OMAC output of\n"
338 "step N (repeated as required to fill the array).\n\n");
339
340 for (x = 0; cipher_descriptor[x].name != NULL; x++) {
341 kl = cipher_descriptor[x].block_length;
342
343 /* skip ciphers which do not have 64 or 128 bit block sizes */
344 if (kl != 8 && kl != 16) continue;
345
346 if (cipher_descriptor[x].keysize(&kl) != CRYPT_OK) {
347 kl = cipher_descriptor[x].max_key_length;
348 }
349 fprintf(out, "PMAC-%s (%d byte key)\n", cipher_descriptor[x].name, kl);
350
351 /* initial key/block */
352 for (y = 0; y < kl; y++) {
353 key[y] = (y & 255);
354 }
355
356 for (y = 0; y <= (int)(cipher_descriptor[x].block_length*2); y++) {
357 for (z = 0; z < y; z++) {
358 input[z] = (unsigned char)(z & 255);
359 }
360 len = sizeof(output);
361 if ((err = pmac_memory(x, key, kl, input, y, output, &len)) != CRYPT_OK) {
362 printf("Error omacing: %s\n", error_to_string(err));
363 exit(EXIT_FAILURE);
364 }
365 fprintf(out, "%3d: ", y);
366 for (z = 0; z <(int)len; z++) {
367 fprintf(out, "%02X", output[z]);
368 }
369 fprintf(out, "\n");
370
371 /* forward the key */
372 for (z = 0; z < kl; z++) {
373 key[z] = output[z % len];
374 }
375 }
376 fprintf(out, "\n");
377 }
378 fclose(out);
379 }
380
381 void eax_gen(void)
382 {
383 int err, kl, x, y1, z;
384 FILE *out;
385 unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2], header[MAXBLOCKSIZE*2],
386 plaintext[MAXBLOCKSIZE*2], tag[MAXBLOCKSIZE];
387 unsigned long len;
388
389 out = fopen("eax_tv.txt", "w");
390 fprintf(out, "EAX Test Vectors. Uses the 00010203...NN-1 pattern for header/nonce/plaintext/key. The outputs\n"
391 "are of the form ciphertext,tag for a given NN. The key for step N>1 is the tag of the previous\n"
392 "step repeated sufficiently.\n\n");
393
394 for (x = 0; cipher_descriptor[x].name != NULL; x++) {
395 kl = cipher_descriptor[x].block_length;
396
397 /* skip ciphers which do not have 64 or 128 bit block sizes */
398 if (kl != 8 && kl != 16) continue;
399
400 if (cipher_descriptor[x].keysize(&kl) != CRYPT_OK) {
401 kl = cipher_descriptor[x].max_key_length;
402 }
403 fprintf(out, "EAX-%s (%d byte key)\n", cipher_descriptor[x].name, kl);
404
405 /* the key */
406 for (z = 0; z < kl; z++) {
407 key[z] = (z & 255);
408 }
409
410 for (y1 = 0; y1 <= (int)(cipher_descriptor[x].block_length*2); y1++){
411 for (z = 0; z < y1; z++) {
412 plaintext[z] = (unsigned char)(z & 255);
413 nonce[z] = (unsigned char)(z & 255);
414 header[z] = (unsigned char)(z & 255);
415 }
416 len = sizeof(tag);
417 if ((err = eax_encrypt_authenticate_memory(x, key, kl, nonce, y1, header, y1, plaintext, y1, plaintext, tag, &len)) != CRYPT_OK) {
418 printf("Error EAX'ing: %s\n", error_to_string(err));
419 exit(EXIT_FAILURE);
420 }
421 fprintf(out, "%3d: ", y1);
422 for (z = 0; z < y1; z++) {
423 fprintf(out, "%02X", plaintext[z]);
424 }
425 fprintf(out, ", ");
426 for (z = 0; z <(int)len; z++) {
427 fprintf(out, "%02X", tag[z]);
428 }
429 fprintf(out, "\n");
430
431 /* forward the key */
432 for (z = 0; z < kl; z++) {
433 key[z] = tag[z % len];
434 }
435 }
436 fprintf(out, "\n");
437 }
438 fclose(out);
439 }
440
441 void ocb_gen(void)
442 {
443 int err, kl, x, y1, z;
444 FILE *out;
445 unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
446 plaintext[MAXBLOCKSIZE*2], tag[MAXBLOCKSIZE];
447 unsigned long len;
448
449 out = fopen("ocb_tv.txt", "w");
450 fprintf(out, "OCB Test Vectors. Uses the 00010203...NN-1 pattern for nonce/plaintext/key. The outputs\n"
451 "are of the form ciphertext,tag for a given NN. The key for step N>1 is the tag of the previous\n"
452 "step repeated sufficiently. The nonce is fixed throughout.\n\n");
453
454 for (x = 0; cipher_descriptor[x].name != NULL; x++) {
455 kl = cipher_descriptor[x].block_length;
456
457 /* skip ciphers which do not have 64 or 128 bit block sizes */
458 if (kl != 8 && kl != 16) continue;
459
460 if (cipher_descriptor[x].keysize(&kl) != CRYPT_OK) {
461 kl = cipher_descriptor[x].max_key_length;
462 }
463 fprintf(out, "OCB-%s (%d byte key)\n", cipher_descriptor[x].name, kl);
464
465 /* the key */
466 for (z = 0; z < kl; z++) {
467 key[z] = (z & 255);
468 }
469
470 /* fixed nonce */
471 for (z = 0; z < cipher_descriptor[x].block_length; z++) {
472 nonce[z] = z;
473 }
474
475 for (y1 = 0; y1 <= (int)(cipher_descriptor[x].block_length*2); y1++){
476 for (z = 0; z < y1; z++) {
477 plaintext[z] = (unsigned char)(z & 255);
478 }
479 len = sizeof(tag);
480 if ((err = ocb_encrypt_authenticate_memory(x, key, kl, nonce, plaintext, y1, plaintext, tag, &len)) != CRYPT_OK) {
481 printf("Error OCB'ing: %s\n", error_to_string(err));
482 exit(EXIT_FAILURE);
483 }
484 fprintf(out, "%3d: ", y1);
485 for (z = 0; z < y1; z++) {
486 fprintf(out, "%02X", plaintext[z]);
487 }
488 fprintf(out, ", ");
489 for (z = 0; z <(int)len; z++) {
490 fprintf(out, "%02X", tag[z]);
491 }
492 fprintf(out, "\n");
493
494 /* forward the key */
495 for (z = 0; z < kl; z++) {
496 key[z] = tag[z % len];
497 }
498 }
499 fprintf(out, "\n");
500 }
501 fclose(out);
502 }
503
504
505 void ccm_gen(void)
506 {
507 int err, kl, x, y1, z;
508 FILE *out;
509 unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
510 plaintext[MAXBLOCKSIZE*2], tag[MAXBLOCKSIZE];
511 unsigned long len;
512
513 out = fopen("ccm_tv.txt", "w");
514 fprintf(out, "CCM Test Vectors. Uses the 00010203...NN-1 pattern for nonce/header/plaintext/key. The outputs\n"
515 "are of the form ciphertext,tag for a given NN. The key for step N>1 is the tag of the previous\n"
516 "step repeated sufficiently. The nonce is fixed throughout at 13 bytes 000102...\n\n");
517
518 for (x = 0; cipher_descriptor[x].name != NULL; x++) {
519 kl = cipher_descriptor[x].block_length;
520
521 /* skip ciphers which do not have 128 bit block sizes */
522 if (kl != 16) continue;
523
524 if (cipher_descriptor[x].keysize(&kl) != CRYPT_OK) {
525 kl = cipher_descriptor[x].max_key_length;
526 }
527 fprintf(out, "CCM-%s (%d byte key)\n", cipher_descriptor[x].name, kl);
528
529 /* the key */
530 for (z = 0; z < kl; z++) {
531 key[z] = (z & 255);
532 }
533
534 /* fixed nonce */
535 for (z = 0; z < cipher_descriptor[x].block_length; z++) {
536 nonce[z] = z;
537 }
538
539 for (y1 = 0; y1 <= (int)(cipher_descriptor[x].block_length*2); y1++){
540 for (z = 0; z < y1; z++) {
541 plaintext[z] = (unsigned char)(z & 255);
542 }
543 len = sizeof(tag);
544 if ((err = ccm_memory(x, key, kl, nonce, 13, plaintext, y1, plaintext, y1, plaintext, tag, &len, CCM_ENCRYPT)) != CRYPT_OK) {
545 printf("Error CCM'ing: %s\n", error_to_string(err));
546 exit(EXIT_FAILURE);
547 }
548 fprintf(out, "%3d: ", y1);
549 for (z = 0; z < y1; z++) {
550 fprintf(out, "%02X", plaintext[z]);
551 }
552 fprintf(out, ", ");
553 for (z = 0; z <(int)len; z++) {
554 fprintf(out, "%02X", tag[z]);
555 }
556 fprintf(out, "\n");
557
558 /* forward the key */
559 for (z = 0; z < kl; z++) {
560 key[z] = tag[z % len];
561 }
562 }
563 fprintf(out, "\n");
564 }
565 fclose(out);
566 }
567
568 void gcm_gen(void)
569 {
570 int err, kl, x, y1, z;
571 FILE *out;
572 unsigned char key[MAXBLOCKSIZE], plaintext[MAXBLOCKSIZE*2], tag[MAXBLOCKSIZE];
573 unsigned long len;
574
575 out = fopen("gcm_tv.txt", "w");
576 fprintf(out, "GCM Test Vectors. Uses the 00010203...NN-1 pattern for nonce/header/plaintext/key. The outputs\n"
577 "are of the form ciphertext,tag for a given NN. The key for step N>1 is the tag of the previous\n"
578 "step repeated sufficiently. The nonce is fixed throughout at 13 bytes 000102...\n\n");
579
580 for (x = 0; cipher_descriptor[x].name != NULL; x++) {
581 kl = cipher_descriptor[x].block_length;
582
583 /* skip ciphers which do not have 128 bit block sizes */
584 if (kl != 16) continue;
585
586 if (cipher_descriptor[x].keysize(&kl) != CRYPT_OK) {
587 kl = cipher_descriptor[x].max_key_length;
588 }
589 fprintf(out, "GCM-%s (%d byte key)\n", cipher_descriptor[x].name, kl);
590
591 /* the key */
592 for (z = 0; z < kl; z++) {
593 key[z] = (z & 255);
594 }
595
596 for (y1 = 0; y1 <= (int)(cipher_descriptor[x].block_length*2); y1++){
597 for (z = 0; z < y1; z++) {
598 plaintext[z] = (unsigned char)(z & 255);
599 }
600 len = sizeof(tag);
601 if ((err = gcm_memory(x, key, kl, plaintext, y1, plaintext, y1, plaintext, y1, plaintext, tag, &len, GCM_ENCRYPT)) != CRYPT_OK) {
602 printf("Error GCM'ing: %s\n", error_to_string(err));
603 exit(EXIT_FAILURE);
604 }
605 fprintf(out, "%3d: ", y1);
606 for (z = 0; z < y1; z++) {
607 fprintf(out, "%02X", plaintext[z]);
608 }
609 fprintf(out, ", ");
610 for (z = 0; z <(int)len; z++) {
611 fprintf(out, "%02X", tag[z]);
612 }
613 fprintf(out, "\n");
614
615 /* forward the key */
616 for (z = 0; z < kl; z++) {
617 key[z] = tag[z % len];
618 }
619 }
620 fprintf(out, "\n");
621 }
622 fclose(out);
623 }
624
625 void base64_gen(void)
626 {
627 FILE *out;
628 unsigned char dst[256], src[32];
629 unsigned long x, y, len;
630
631 out = fopen("base64_tv.txt", "w");
632 fprintf(out, "Base64 vectors. These are the base64 encodings of the strings 00,01,02...NN-1\n\n");
633 for (x = 0; x <= 32; x++) {
634 for (y = 0; y < x; y++) {
635 src[y] = y;
636 }
637 len = sizeof(dst);
638 base64_encode(src, x, dst, &len);
639 fprintf(out, "%2lu: %s\n", x, dst);
640 }
641 fclose(out);
642 }
643
644 int main(void)
645 {
646 reg_algs();
647 printf("Generating hash vectors..."); fflush(stdout); hash_gen(); printf("done\n");
648 printf("Generating cipher vectors..."); fflush(stdout); cipher_gen(); printf("done\n");
649 printf("Generating HMAC vectors..."); fflush(stdout); hmac_gen(); printf("done\n");
650 printf("Generating OMAC vectors..."); fflush(stdout); omac_gen(); printf("done\n");
651 printf("Generating PMAC vectors..."); fflush(stdout); pmac_gen(); printf("done\n");
652 printf("Generating EAX vectors..."); fflush(stdout); eax_gen(); printf("done\n");
653 printf("Generating OCB vectors..."); fflush(stdout); ocb_gen(); printf("done\n");
654 printf("Generating CCM vectors..."); fflush(stdout); ccm_gen(); printf("done\n");
655 printf("Generating GCM vectors..."); fflush(stdout); gcm_gen(); printf("done\n");
656 printf("Generating BASE64 vectors..."); fflush(stdout); base64_gen(); printf("done\n");
657 return 0;
658 }
659
660
661
662
663
664
665
666
667
668 /* $Source: /cvs/libtom/libtomcrypt/demos/tv_gen.c,v $ */
669 /* $Revision: 1.4 $ */
670 /* $Date: 2005/05/05 14:35:56 $ */