projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Redirect FIPS memory allocation to FIPS_malloc() routine, remove
[oweals/openssl.git]
/
crypto
/
sha
/
shatest.c
diff --git
a/crypto/sha/shatest.c
b/crypto/sha/shatest.c
index 9224e88dd81c9335c45390d50c1d6fc5acd5e0cf..27614646d1548463dc66e0d728d12c8782a3e548 100644
(file)
--- a/
crypto/sha/shatest.c
+++ b/
crypto/sha/shatest.c
@@
-59,56
+59,73
@@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+
+#include "../e_os.h"
+
+#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA0)
+int main(int argc, char *argv[])
+{
+ printf("No SHA0 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
+
#define SHA_0 /* FIPS 180 */
#undef SHA_1 /* FIPS 180-1 */
#define SHA_0 /* FIPS 180 */
#undef 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(SHA(*P,(unsigned long)strlen((char *)*P),NULL));
- if (strcmp(p,(char *)*R) != 0)
+ EVP_Digest(*P,strlen(*P),md,NULL,EVP_sha(), NULL);
+ p=pt(md);
+ if (strcmp(p,*R) != 0)
{
printf("error calculating SHA on '%s'\n",*P);
printf("got %s instead of %s\n",p,*R);
{
printf("error calculating SHA on '%s'\n",*P);
printf("got %s instead of %s\n",p,*R);
@@
-122,10
+139,13
@@
int main(int argc, char *argv[])
}
memset(buf,'a',1000);
}
memset(buf,'a',1000);
- SHA_Init(&c);
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(buf, buf, 1000);
+#endif /*CHARSET_EBCDIC*/
+ EVP_DigestInit_ex(&c,EVP_sha(), NULL);
for (i=0; i<1000; i++)
for (i=0; i<1000; i++)
-
SHA_
Update(&c,buf,1000);
-
SHA_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
+ EVP_MD_CTX_cleanup(&c);
+ EXIT(err);
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