OLD | NEW |
1 /* crypto/sha/shatest.c */ | 1 /* crypto/sha/shatest.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 ebcdic2ascii(test[0], test[0], strlen(test[0])); | 116 ebcdic2ascii(test[0], test[0], strlen(test[0])); |
117 ebcdic2ascii(test[1], test[1], strlen(test[1])); | 117 ebcdic2ascii(test[1], test[1], strlen(test[1])); |
118 #endif | 118 #endif |
119 | 119 |
120 EVP_MD_CTX_init(&c); | 120 EVP_MD_CTX_init(&c); |
121 P=test; | 121 P=test; |
122 R=ret; | 122 R=ret; |
123 i=1; | 123 i=1; |
124 while (*P != NULL) | 124 while (*P != NULL) |
125 { | 125 { |
126 » » EVP_Digest(*P,strlen((char *)*P),md,NULL,EVP_sha(), NULL); | 126 » » EVP_Digest(*P,strlen(*P),md,NULL,EVP_sha(), NULL); |
127 p=pt(md); | 127 p=pt(md); |
128 » » if (strcmp(p,(char *)*R) != 0) | 128 » » if (strcmp(p,*R) != 0) |
129 { | 129 { |
130 printf("error calculating SHA on '%s'\n",*P); | 130 printf("error calculating SHA on '%s'\n",*P); |
131 printf("got %s instead of %s\n",p,*R); | 131 printf("got %s instead of %s\n",p,*R); |
132 err++; | 132 err++; |
133 } | 133 } |
134 else | 134 else |
135 printf("test %d ok\n",i); | 135 printf("test %d ok\n",i); |
136 i++; | 136 i++; |
137 R++; | 137 R++; |
138 P++; | 138 P++; |
(...skipping 30 matching lines...) Expand all Loading... |
169 static char *pt(unsigned char *md) | 169 static char *pt(unsigned char *md) |
170 { | 170 { |
171 int i; | 171 int i; |
172 static char buf[80]; | 172 static char buf[80]; |
173 | 173 |
174 for (i=0; i<SHA_DIGEST_LENGTH; i++) | 174 for (i=0; i<SHA_DIGEST_LENGTH; i++) |
175 sprintf(&(buf[i*2]),"%02x",md[i]); | 175 sprintf(&(buf[i*2]),"%02x",md[i]); |
176 return(buf); | 176 return(buf); |
177 } | 177 } |
178 #endif | 178 #endif |
OLD | NEW |