diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/md5/md5test.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/lib/libcrypto/md5/md5test.c b/src/lib/libcrypto/md5/md5test.c index 74b84bc67f..862b89658a 100644 --- a/src/lib/libcrypto/md5/md5test.c +++ b/src/lib/libcrypto/md5/md5test.c | |||
| @@ -59,9 +59,18 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <string.h> | 60 | #include <string.h> |
| 61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
| 62 | #include "md5.h" | ||
| 63 | 62 | ||
| 64 | char *test[]={ | 63 | #ifdef OPENSSL_NO_MD5 |
| 64 | int main(int argc, char *argv[]) | ||
| 65 | { | ||
| 66 | printf("No MD5 support\n"); | ||
| 67 | return(0); | ||
| 68 | } | ||
| 69 | #else | ||
| 70 | #include <openssl/evp.h> | ||
| 71 | #include <openssl/md5.h> | ||
| 72 | |||
| 73 | static char *test[]={ | ||
| 65 | "", | 74 | "", |
| 66 | "a", | 75 | "a", |
| 67 | "abc", | 76 | "abc", |
| @@ -72,7 +81,7 @@ char *test[]={ | |||
| 72 | NULL, | 81 | NULL, |
| 73 | }; | 82 | }; |
| 74 | 83 | ||
| 75 | char *ret[]={ | 84 | static char *ret[]={ |
| 76 | "d41d8cd98f00b204e9800998ecf8427e", | 85 | "d41d8cd98f00b204e9800998ecf8427e", |
| 77 | "0cc175b9c0f1b6a831c399e269772661", | 86 | "0cc175b9c0f1b6a831c399e269772661", |
| 78 | "900150983cd24fb0d6963f7d28e17f72", | 87 | "900150983cd24fb0d6963f7d28e17f72", |
| @@ -82,26 +91,21 @@ char *ret[]={ | |||
| 82 | "57edf4a22be3c955ac49da2e2107b67a", | 91 | "57edf4a22be3c955ac49da2e2107b67a", |
| 83 | }; | 92 | }; |
| 84 | 93 | ||
| 85 | #ifndef NOPROTO | ||
| 86 | static char *pt(unsigned char *md); | 94 | static char *pt(unsigned char *md); |
| 87 | #else | 95 | int main(int argc, char *argv[]) |
| 88 | static char *pt(); | ||
| 89 | #endif | ||
| 90 | |||
| 91 | int main(argc,argv) | ||
| 92 | int argc; | ||
| 93 | char *argv[]; | ||
| 94 | { | 96 | { |
| 95 | int i,err=0; | 97 | int i,err=0; |
| 96 | unsigned char **P,**R; | 98 | unsigned char **P,**R; |
| 97 | char *p; | 99 | char *p; |
| 100 | unsigned char md[MD5_DIGEST_LENGTH]; | ||
| 98 | 101 | ||
| 99 | P=(unsigned char **)test; | 102 | P=(unsigned char **)test; |
| 100 | R=(unsigned char **)ret; | 103 | R=(unsigned char **)ret; |
| 101 | i=1; | 104 | i=1; |
| 102 | while (*P != NULL) | 105 | while (*P != NULL) |
| 103 | { | 106 | { |
| 104 | p=pt(MD5(&(P[0][0]),(unsigned long)strlen((char *)*P),NULL)); | 107 | EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_md5(), NULL); |
| 108 | p=pt(md); | ||
| 105 | if (strcmp(p,(char *)*R) != 0) | 109 | if (strcmp(p,(char *)*R) != 0) |
| 106 | { | 110 | { |
| 107 | printf("error calculating MD5 on '%s'\n",*P); | 111 | printf("error calculating MD5 on '%s'\n",*P); |
| @@ -118,8 +122,7 @@ char *argv[]; | |||
| 118 | return(0); | 122 | return(0); |
| 119 | } | 123 | } |
| 120 | 124 | ||
| 121 | static char *pt(md) | 125 | static char *pt(unsigned char *md) |
| 122 | unsigned char *md; | ||
| 123 | { | 126 | { |
| 124 | int i; | 127 | int i; |
| 125 | static char buf[80]; | 128 | static char buf[80]; |
| @@ -128,3 +131,4 @@ unsigned char *md; | |||
| 128 | sprintf(&(buf[i*2]),"%02x",md[i]); | 131 | sprintf(&(buf[i*2]),"%02x",md[i]); |
| 129 | return(buf); | 132 | return(buf); |
| 130 | } | 133 | } |
| 134 | #endif | ||
