diff options
author | beck <> | 2002-05-15 02:29:21 +0000 |
---|---|---|
committer | beck <> | 2002-05-15 02:29:21 +0000 |
commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/sha/shatest.c | |
parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/sha/shatest.c')
-rw-r--r-- | src/lib/libcrypto/sha/shatest.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/libcrypto/sha/shatest.c b/src/lib/libcrypto/sha/shatest.c index a5786bbf76..331294a74f 100644 --- a/src/lib/libcrypto/sha/shatest.c +++ b/src/lib/libcrypto/sha/shatest.c | |||
@@ -60,13 +60,14 @@ | |||
60 | #include <string.h> | 60 | #include <string.h> |
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | 62 | ||
63 | #ifdef NO_SHA | 63 | #ifdef OPENSSL_NO_SHA |
64 | int main(int argc, char *argv[]) | 64 | int main(int argc, char *argv[]) |
65 | { | 65 | { |
66 | printf("No SHA support\n"); | 66 | printf("No SHA support\n"); |
67 | return(0); | 67 | return(0); |
68 | } | 68 | } |
69 | #else | 69 | #else |
70 | #include <openssl/evp.h> | ||
70 | #include <openssl/sha.h> | 71 | #include <openssl/sha.h> |
71 | 72 | ||
72 | #ifdef CHARSET_EBCDIC | 73 | #ifdef CHARSET_EBCDIC |
@@ -106,7 +107,7 @@ int main(int argc, char *argv[]) | |||
106 | unsigned char **P,**R; | 107 | unsigned char **P,**R; |
107 | static unsigned char buf[1000]; | 108 | static unsigned char buf[1000]; |
108 | char *p,*r; | 109 | char *p,*r; |
109 | SHA_CTX c; | 110 | EVP_MD_CTX c; |
110 | unsigned char md[SHA_DIGEST_LENGTH]; | 111 | unsigned char md[SHA_DIGEST_LENGTH]; |
111 | 112 | ||
112 | #ifdef CHARSET_EBCDIC | 113 | #ifdef CHARSET_EBCDIC |
@@ -114,12 +115,14 @@ int main(int argc, char *argv[]) | |||
114 | ebcdic2ascii(test[1], test[1], strlen(test[1])); | 115 | ebcdic2ascii(test[1], test[1], strlen(test[1])); |
115 | #endif | 116 | #endif |
116 | 117 | ||
118 | EVP_MD_CTX_init(&c); | ||
117 | P=(unsigned char **)test; | 119 | P=(unsigned char **)test; |
118 | R=(unsigned char **)ret; | 120 | R=(unsigned char **)ret; |
119 | i=1; | 121 | i=1; |
120 | while (*P != NULL) | 122 | while (*P != NULL) |
121 | { | 123 | { |
122 | p=pt(SHA(*P,(unsigned long)strlen((char *)*P),NULL)); | 124 | EVP_Digest(*P,(unsigned long)strlen((char *)*P),md,NULL,EVP_sha(), NULL); |
125 | p=pt(md); | ||
123 | if (strcmp(p,(char *)*R) != 0) | 126 | if (strcmp(p,(char *)*R) != 0) |
124 | { | 127 | { |
125 | printf("error calculating SHA on '%s'\n",*P); | 128 | printf("error calculating SHA on '%s'\n",*P); |
@@ -137,10 +140,10 @@ int main(int argc, char *argv[]) | |||
137 | #ifdef CHARSET_EBCDIC | 140 | #ifdef CHARSET_EBCDIC |
138 | ebcdic2ascii(buf, buf, 1000); | 141 | ebcdic2ascii(buf, buf, 1000); |
139 | #endif /*CHARSET_EBCDIC*/ | 142 | #endif /*CHARSET_EBCDIC*/ |
140 | SHA_Init(&c); | 143 | EVP_DigestInit_ex(&c,EVP_sha(), NULL); |
141 | for (i=0; i<1000; i++) | 144 | for (i=0; i<1000; i++) |
142 | SHA_Update(&c,buf,1000); | 145 | EVP_DigestUpdate(&c,buf,1000); |
143 | SHA_Final(md,&c); | 146 | EVP_DigestFinal_ex(&c,md,NULL); |
144 | p=pt(md); | 147 | p=pt(md); |
145 | 148 | ||
146 | r=bigret; | 149 | r=bigret; |
@@ -152,6 +155,7 @@ int main(int argc, char *argv[]) | |||
152 | } | 155 | } |
153 | else | 156 | else |
154 | printf("test 3 ok\n"); | 157 | printf("test 3 ok\n"); |
158 | EVP_MD_CTX_cleanup(&c); | ||
155 | exit(err); | 159 | exit(err); |
156 | return(0); | 160 | return(0); |
157 | } | 161 | } |