comparison demos/hashsum.c @ 143:5d99163f7e32 libtomcrypt-orig

import of libtomcrypt 0.99
author Matt Johnston <matt@ucc.asn.au>
date Sun, 19 Dec 2004 11:34:45 +0000
parents 7faae8f46238
children 1c15b283127b
comparison
equal deleted inserted replaced
15:6362d3854bb4 143:5d99163f7e32
5 * Compile with 'gcc hashsum.c -o hashsum -ltomcrypt' 5 * Compile with 'gcc hashsum.c -o hashsum -ltomcrypt'
6 * This example isn't really big enough to warrent splitting into 6 * This example isn't really big enough to warrent splitting into
7 * more functions ;) 7 * more functions ;)
8 */ 8 */
9 9
10 #include <mycrypt_custom.h> 10 #include <mycrypt.h>
11 11
12 int errno; 12 int errno;
13 13
14 void register_algs(); 14 void register_algs();
15 15
24 register_algs(); 24 register_algs();
25 if (argc < 2) { 25 if (argc < 2) {
26 printf("usage: ./hash algorithm file [file ...]\n"); 26 printf("usage: ./hash algorithm file [file ...]\n");
27 printf("Algorithms:\n"); 27 printf("Algorithms:\n");
28 for (x = 0; hash_descriptor[x].name != NULL; x++) { 28 for (x = 0; hash_descriptor[x].name != NULL; x++) {
29 printf(" %s\n", hash_descriptor[x].name); 29 printf(" %s (%d)\n", hash_descriptor[x].name, hash_descriptor[x].ID);
30 } 30 }
31 exit(EXIT_SUCCESS); 31 exit(EXIT_SUCCESS);
32 } 32 }
33 33
34 idx = find_hash(argv[1]); 34 idx = find_hash(argv[1]);
64 return EXIT_SUCCESS; 64 return EXIT_SUCCESS;
65 } 65 }
66 66
67 void register_algs(void) 67 void register_algs(void)
68 { 68 {
69 int err;
70
69 #ifdef TIGER 71 #ifdef TIGER
70 register_hash (&tiger_desc); 72 register_hash (&tiger_desc);
71 #endif 73 #endif
72 #ifdef MD2 74 #ifdef MD2
73 register_hash (&md2_desc); 75 register_hash (&md2_desc);
100 register_hash (&rmd160_desc); 102 register_hash (&rmd160_desc);
101 #endif 103 #endif
102 #ifdef WHIRLPOOL 104 #ifdef WHIRLPOOL
103 register_hash (&whirlpool_desc); 105 register_hash (&whirlpool_desc);
104 #endif 106 #endif
107 #ifdef CHC_HASH
108 register_hash(&chc_desc);
109 if ((err = chc_register(register_cipher(&aes_enc_desc))) != CRYPT_OK) {
110 printf("chc_register error: %s\n", error_to_string(err));
111 exit(EXIT_FAILURE);
112 }
113 #endif
105 114
106 } 115 }