projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Win32 build.
[oweals/openssl.git]
/
crypto
/
sha
/
sha1test.c
diff --git
a/crypto/sha/sha1test.c
b/crypto/sha/sha1test.c
index 831a3441a46ddd335e1cd423edfb22b58eaf4f19..6feb3964c7577f6083532d098fff25b45f213962 100644
(file)
--- a/
crypto/sha/sha1test.c
+++ b/
crypto/sha/sha1test.c
@@
-59,55
+59,72
@@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+
+#include "../e_os.h"
+
+#ifdef OPENSSL_NO_SHA
+int main(int argc, char *argv[])
+{
+ printf("No SHA support\n");
+ return(0);
+}
+#else
+#include <openssl/evp.h>
#include <openssl/sha.h>
#include <openssl/sha.h>
+#ifdef CHARSET_EBCDIC
+#include <openssl/ebcdic.h>
+#endif
+
#undef SHA_0 /* FIPS 180 */
#define SHA_1 /* FIPS 180-1 */
#undef SHA_0 /* FIPS 180 */
#define SHA_1 /* FIPS 180-1 */
-char *test[]={
+
static
char *test[]={
"abc",
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
NULL,
};
#ifdef SHA_0
"abc",
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
NULL,
};
#ifdef SHA_0
-char *ret[]={
+
static
char *ret[]={
"0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
"d2516ee1acfa5baf33dfc1c471e438449ef134c8",
};
"0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
"d2516ee1acfa5baf33dfc1c471e438449ef134c8",
};
-char *bigret=
+
static
char *bigret=
"3232affa48628a26653b5aaa44541fd90d690603";
#endif
#ifdef SHA_1
"3232affa48628a26653b5aaa44541fd90d690603";
#endif
#ifdef SHA_1
-char *ret[]={
+
static
char *ret[]={
"a9993e364706816aba3e25717850c26c9cd0d89d",
"84983e441c3bd26ebaae4aa1f95129e5e54670f1",
};
"a9993e364706816aba3e25717850c26c9cd0d89d",
"84983e441c3bd26ebaae4aa1f95129e5e54670f1",
};
-char *bigret=
+
static
char *bigret=
"34aa973cd4c4daa4f61eeb2bdbad27316534016f";
#endif
"34aa973cd4c4daa4f61eeb2bdbad27316534016f";
#endif
-#ifndef NOPROTO
static char *pt(unsigned char *md);
static char *pt(unsigned char *md);
-#else
-static char *pt();
-#endif
-
int main(int argc, char *argv[])
{
int i,err=0;
int main(int argc, char *argv[])
{
int i,err=0;
-
unsigned
char **P,**R;
+ char **P,**R;
static unsigned char buf[1000];
char *p,*r;
static unsigned char buf[1000];
char *p,*r;
-
SHA
_CTX c;
+
EVP_MD
_CTX c;
unsigned char md[SHA_DIGEST_LENGTH];
unsigned char md[SHA_DIGEST_LENGTH];
- P=(unsigned char **)test;
- R=(unsigned char **)ret;
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(test[0], test[0], strlen(test[0]));
+ ebcdic2ascii(test[1], test[1], strlen(test[1]));
+#endif
+
+ EVP_MD_CTX_init(&c);
+ P=test;
+ R=ret;
i=1;
while (*P != NULL)
{
i=1;
while (*P != NULL)
{
- p=pt(SHA1(*P,(unsigned long)strlen((char *)*P),NULL));
+ EVP_Digest(*P,strlen((char *)*P),md,NULL,EVP_sha1(), NULL);
+ p=pt(md);
if (strcmp(p,(char *)*R) != 0)
{
printf("error calculating SHA1 on '%s'\n",*P);
if (strcmp(p,(char *)*R) != 0)
{
printf("error calculating SHA1 on '%s'\n",*P);
@@
-122,10
+139,13
@@
int main(int argc, char *argv[])
}
memset(buf,'a',1000);
}
memset(buf,'a',1000);
- SHA1_Init(&c);
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(buf, buf, 1000);
+#endif /*CHARSET_EBCDIC*/
+ EVP_DigestInit_ex(&c,EVP_sha1(), NULL);
for (i=0; i<1000; i++)
for (i=0; i<1000; i++)
-
SHA1_
Update(&c,buf,1000);
-
SHA1_Final(md,&c
);
+
EVP_Digest
Update(&c,buf,1000);
+
EVP_DigestFinal_ex(&c,md,NULL
);
p=pt(md);
r=bigret;
p=pt(md);
r=bigret;
@@
-137,7
+157,12
@@
int main(int argc, char *argv[])
}
else
printf("test 3 ok\n");
}
else
printf("test 3 ok\n");
- exit(err);
+
+#ifdef OPENSSL_SYS_NETWARE
+ if (err) printf("ERROR: %d\n", err);
+#endif
+ EXIT(err);
+ EVP_MD_CTX_cleanup(&c);
return(0);
}
return(0);
}
@@
-150,3
+175,4
@@
static char *pt(unsigned char *md)
sprintf(&(buf[i*2]),"%02x",md[i]);
return(buf);
}
sprintf(&(buf[i*2]),"%02x",md[i]);
return(buf);
}
+#endif