summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/sha1/Makefile9
-rw-r--r--src/regress/lib/libcrypto/sha1/sha1test.c157
-rw-r--r--src/regress/lib/libcrypto/sha256/Makefile9
-rw-r--r--src/regress/lib/libcrypto/sha256/sha256test.c183
-rw-r--r--src/regress/lib/libcrypto/sha512/Makefile9
-rw-r--r--src/regress/lib/libcrypto/sha512/sha512test.c242
6 files changed, 0 insertions, 609 deletions
diff --git a/src/regress/lib/libcrypto/sha1/Makefile b/src/regress/lib/libcrypto/sha1/Makefile
deleted file mode 100644
index 2bb0b45ec9..0000000000
--- a/src/regress/lib/libcrypto/sha1/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1# $OpenBSD: Makefile,v 1.3 2014/07/08 15:53:53 jsing Exp $
2
3PROG= sha1test
4LDADD= -lcrypto
5DPADD= ${LIBCRYPTO}
6WARNINGS= Yes
7CFLAGS+= -DLIBRESSL_INTERNAL -Werror
8
9.include <bsd.regress.mk>
diff --git a/src/regress/lib/libcrypto/sha1/sha1test.c b/src/regress/lib/libcrypto/sha1/sha1test.c
deleted file mode 100644
index 168b422d7a..0000000000
--- a/src/regress/lib/libcrypto/sha1/sha1test.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/* $OpenBSD: sha1test.c,v 1.6 2021/12/29 22:54:41 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <string.h>
61#include <stdlib.h>
62
63#include <openssl/evp.h>
64#include <openssl/sha.h>
65
66static char *test[] = {
67 "abc",
68 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
69 NULL,
70};
71
72static char *ret[] = {
73 "a9993e364706816aba3e25717850c26c9cd0d89d",
74 "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
75};
76static char *bigret =
77 "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
78
79static char *pt(unsigned char *md);
80int
81main(int argc, char *argv[])
82{
83 int i, err = 0;
84 char **P, **R;
85 static unsigned char buf[1000];
86 char *p, *r;
87 EVP_MD_CTX *c;
88 unsigned char md[SHA_DIGEST_LENGTH];
89
90 if ((c = EVP_MD_CTX_new()) == NULL) {
91 printf("EVP_MD_CTX_new() failed\n");
92 return 1;
93 }
94 P = test;
95 R = ret;
96 i = 1;
97 while (*P != NULL) {
98 if (!EVP_Digest(*P, strlen((char *)*P), md, NULL, EVP_sha1(),
99 NULL)) {
100 printf("EVP_Digest failed\n");
101 goto err;
102 }
103 p = pt(md);
104 if (strcmp(p, (char *)*R) != 0) {
105 printf("error calculating SHA1 on '%s'\n", *P);
106 printf("got %s instead of %s\n", p, *R);
107 err++;
108 } else
109 printf("test %d ok\n", i);
110 i++;
111 R++;
112 P++;
113 }
114
115 memset(buf, 'a', 1000);
116 if (!EVP_DigestInit_ex(c, EVP_sha1(), NULL)) {
117 printf("EVP_DigestInit_ex failed\n");
118 goto err;
119 }
120 for (i = 0; i < 1000; i++) {
121 if (!EVP_DigestUpdate(c, buf, 1000)) {
122 printf("EVP_DigestUpdate failed\n");
123 goto err;
124 }
125 }
126 if (!EVP_DigestFinal_ex(c, md, NULL)) {
127 printf("EVP_DigestFinal_ex failed\n");
128 goto err;
129 }
130 p = pt(md);
131
132 r = bigret;
133 if (strcmp(p, r) != 0) {
134 printf("error calculating SHA1 on 'a' * 1000\n");
135 printf("got %s instead of %s\n", p, r);
136 err++;
137 } else
138 printf("test 3 ok\n");
139
140 EVP_MD_CTX_free(c);
141 exit(err);
142
143 err:
144 EVP_MD_CTX_free(c);
145 exit(1);
146}
147
148static char *
149pt(unsigned char *md)
150{
151 int i;
152 static char buf[80];
153
154 for (i = 0; i < SHA_DIGEST_LENGTH; i++)
155 snprintf(buf + i*2, sizeof(buf) - i*2, "%02x", md[i]);
156 return (buf);
157}
diff --git a/src/regress/lib/libcrypto/sha256/Makefile b/src/regress/lib/libcrypto/sha256/Makefile
deleted file mode 100644
index 6e5f9d714b..0000000000
--- a/src/regress/lib/libcrypto/sha256/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1# $OpenBSD: Makefile,v 1.3 2014/07/08 15:53:53 jsing Exp $
2
3PROG= sha256test
4LDADD= -lcrypto
5DPADD= ${LIBCRYPTO}
6WARNINGS= Yes
7CFLAGS+= -DLIBRESSL_INTERNAL -Werror
8
9.include <bsd.regress.mk>
diff --git a/src/regress/lib/libcrypto/sha256/sha256test.c b/src/regress/lib/libcrypto/sha256/sha256test.c
deleted file mode 100644
index dbba2abe3c..0000000000
--- a/src/regress/lib/libcrypto/sha256/sha256test.c
+++ /dev/null
@@ -1,183 +0,0 @@
1/* $OpenBSD: sha256test.c,v 1.7 2021/12/29 22:56:25 tb Exp $ */
2/* ====================================================================
3 * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
4 * ====================================================================
5 */
6#include <stdio.h>
7#include <string.h>
8#include <stdlib.h>
9
10#include <openssl/sha.h>
11#include <openssl/evp.h>
12
13#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA256)
14int
15main(int argc, char *argv[])
16{
17 printf("No SHA256 support\n");
18 return (0);
19}
20#else
21
22unsigned char app_b1[SHA256_DIGEST_LENGTH] = {
23 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
24 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
25 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
26 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad,
27};
28
29unsigned char app_b2[SHA256_DIGEST_LENGTH] = {
30 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
31 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
32 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
33 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1,
34};
35
36unsigned char app_b3[SHA256_DIGEST_LENGTH] = {
37 0xcd, 0xc7, 0x6e, 0x5c, 0x99, 0x14, 0xfb, 0x92,
38 0x81, 0xa1, 0xc7, 0xe2, 0x84, 0xd7, 0x3e, 0x67,
39 0xf1, 0x80, 0x9a, 0x48, 0xa4, 0x97, 0x20, 0x0e,
40 0x04, 0x6d, 0x39, 0xcc, 0xc7, 0x11, 0x2c, 0xd0,
41};
42
43unsigned char addenum_1[SHA224_DIGEST_LENGTH] = {
44 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22,
45 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3,
46 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7,
47 0xe3, 0x6c, 0x9d, 0xa7,
48};
49
50unsigned char addenum_2[SHA224_DIGEST_LENGTH] = {
51 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc,
52 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50,
53 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19,
54 0x52, 0x52, 0x25, 0x25,
55};
56
57unsigned char addenum_3[SHA224_DIGEST_LENGTH] = {
58 0x20, 0x79, 0x46, 0x55, 0x98, 0x0c, 0x91, 0xd8,
59 0xbb, 0xb4, 0xc1, 0xea, 0x97, 0x61, 0x8a, 0x4b,
60 0xf0, 0x3f, 0x42, 0x58, 0x19, 0x48, 0xb2, 0xee,
61 0x4e, 0xe7, 0xad, 0x67,
62};
63
64int
65main(int argc, char **argv) {
66 unsigned char md[SHA256_DIGEST_LENGTH];
67 int i;
68 int ret = 1;
69 EVP_MD_CTX *evp = NULL;
70
71 fprintf(stdout, "Testing SHA-256 ");
72
73 EVP_Digest("abc",3,md,NULL,EVP_sha256(),NULL);
74 if (memcmp(md, app_b1, sizeof(app_b1))) {
75 fflush(stdout);
76 fprintf(stderr, "\nTEST 1 of 3 failed.\n");
77 goto err;
78 }
79 fprintf(stdout, ".");
80 fflush(stdout);
81
82 EVP_Digest(
83 "abcdbcde""cdefdefg""efghfghi""ghijhijk"
84 "ijkljklm""klmnlmno""mnopnopq",
85 56, md, NULL, EVP_sha256(), NULL);
86 if (memcmp(md, app_b2, sizeof(app_b2))) {
87 fflush(stdout);
88 fprintf(stderr, "\nTEST 2 of 3 failed.\n");
89 goto err;
90 }
91 fprintf(stdout, ".");
92 fflush(stdout);
93
94 if ((evp = EVP_MD_CTX_new()) == NULL) {
95 fflush(stdout);
96 fprintf(stderr, "\nEVP_MD_CTX_new() failed.\n");
97 goto err;
98 }
99 if (!EVP_DigestInit_ex(evp, EVP_sha256(), NULL))
100 goto err;
101 for (i = 0; i < 1000000; i += 160) {
102 if (!EVP_DigestUpdate(evp,
103 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
104 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
105 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
106 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
107 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
108 (1000000 - i) < 160 ? 1000000 - i : 160))
109 goto err;
110 }
111 if (!EVP_DigestFinal_ex(evp, md, NULL))
112 goto err;
113 if (!EVP_MD_CTX_reset(evp))
114 goto err;
115
116 if (memcmp(md, app_b3, sizeof(app_b3))) {
117 fflush(stdout);
118 fprintf(stderr, "\nTEST 3 of 3 failed.\n");
119 goto err;
120 }
121 fprintf(stdout, ".");
122 fflush(stdout);
123
124 fprintf(stdout, " passed.\n"); fflush(stdout);
125
126 fprintf(stdout, "Testing SHA-224 ");
127
128 if (!EVP_Digest("abc",3,md,NULL,EVP_sha224(),NULL))
129 goto err;
130 if (memcmp(md, addenum_1, sizeof(addenum_1))) {
131 fflush(stdout);
132 fprintf(stderr, "\nTEST 1 of 3 failed.\n");
133 goto err;
134 }
135 fprintf(stdout, ".");
136 fflush(stdout);
137
138 if (!EVP_Digest(
139 "abcdbcde""cdefdefg""efghfghi""ghijhijk"
140 "ijkljklm""klmnlmno""mnopnopq",
141 56, md, NULL, EVP_sha224(), NULL))
142 goto err;
143 if (memcmp(md, addenum_2, sizeof(addenum_2))) {
144 fflush(stdout);
145 fprintf(stderr, "\nTEST 2 of 3 failed.\n");
146 goto err;
147 }
148 fprintf(stdout, ".");
149 fflush(stdout);
150
151 if (!EVP_DigestInit_ex (evp, EVP_sha224(), NULL))
152 goto err;
153 for (i = 0; i < 1000000; i += 64) {
154 if (!EVP_DigestUpdate(evp,
155 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
156 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
157 (1000000 - i) < 64 ? 1000000 - i : 64))
158 goto err;
159 }
160 if (!EVP_DigestFinal_ex(evp, md, NULL))
161 goto err;
162 if (!EVP_MD_CTX_reset(evp))
163 goto err;
164
165 if (memcmp(md, addenum_3, sizeof(addenum_3))) {
166 fflush(stdout);
167 fprintf(stderr, "\nTEST 3 of 3 failed.\n");
168 goto err;
169 }
170 fprintf(stdout, ".");
171 fflush(stdout);
172
173 fprintf(stdout, " passed.\n");
174 fflush(stdout);
175
176 ret = 0;
177
178 err:
179 EVP_MD_CTX_free(evp);
180
181 return ret;
182}
183#endif
diff --git a/src/regress/lib/libcrypto/sha512/Makefile b/src/regress/lib/libcrypto/sha512/Makefile
deleted file mode 100644
index 354860eae1..0000000000
--- a/src/regress/lib/libcrypto/sha512/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1# $OpenBSD: Makefile,v 1.3 2014/07/08 15:53:53 jsing Exp $
2
3PROG= sha512test
4LDADD= -lcrypto
5DPADD= ${LIBCRYPTO}
6WARNINGS= Yes
7CFLAGS+= -DLIBRESSL_INTERNAL -Werror
8
9.include <bsd.regress.mk>
diff --git a/src/regress/lib/libcrypto/sha512/sha512test.c b/src/regress/lib/libcrypto/sha512/sha512test.c
deleted file mode 100644
index 0d5121036b..0000000000
--- a/src/regress/lib/libcrypto/sha512/sha512test.c
+++ /dev/null
@@ -1,242 +0,0 @@
1/* $OpenBSD: sha512test.c,v 1.7 2021/12/29 23:02:00 tb Exp $ */
2/* ====================================================================
3 * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
4 * ====================================================================
5 */
6#include <stdio.h>
7#include <string.h>
8#include <stdlib.h>
9
10#include <openssl/sha.h>
11#include <openssl/evp.h>
12#include <openssl/crypto.h>
13
14#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA512)
15int
16main(int argc, char *argv[])
17{
18 printf("No SHA512 support\n");
19 return (0);
20}
21#else
22
23unsigned char app_c1[SHA512_DIGEST_LENGTH] = {
24 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
25 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
26 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
27 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
28 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
29 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
30 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
31 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f,
32};
33
34unsigned char app_c2[SHA512_DIGEST_LENGTH] = {
35 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
36 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
37 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
38 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
39 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
40 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
41 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
42 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09,
43};
44
45unsigned char app_c3[SHA512_DIGEST_LENGTH] = {
46 0xe7, 0x18, 0x48, 0x3d, 0x0c, 0xe7, 0x69, 0x64,
47 0x4e, 0x2e, 0x42, 0xc7, 0xbc, 0x15, 0xb4, 0x63,
48 0x8e, 0x1f, 0x98, 0xb1, 0x3b, 0x20, 0x44, 0x28,
49 0x56, 0x32, 0xa8, 0x03, 0xaf, 0xa9, 0x73, 0xeb,
50 0xde, 0x0f, 0xf2, 0x44, 0x87, 0x7e, 0xa6, 0x0a,
51 0x4c, 0xb0, 0x43, 0x2c, 0xe5, 0x77, 0xc3, 0x1b,
52 0xeb, 0x00, 0x9c, 0x5c, 0x2c, 0x49, 0xaa, 0x2e,
53 0x4e, 0xad, 0xb2, 0x17, 0xad, 0x8c, 0xc0, 0x9b,
54};
55
56unsigned char app_d1[SHA384_DIGEST_LENGTH] = {
57 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
58 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
59 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
60 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
61 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
62 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7,
63};
64
65unsigned char app_d2[SHA384_DIGEST_LENGTH] = {
66 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
67 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
68 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
69 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
70 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
71 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39,
72};
73
74unsigned char app_d3[SHA384_DIGEST_LENGTH] = {
75 0x9d, 0x0e, 0x18, 0x09, 0x71, 0x64, 0x74, 0xcb,
76 0x08, 0x6e, 0x83, 0x4e, 0x31, 0x0a, 0x4a, 0x1c,
77 0xed, 0x14, 0x9e, 0x9c, 0x00, 0xf2, 0x48, 0x52,
78 0x79, 0x72, 0xce, 0xc5, 0x70, 0x4c, 0x2a, 0x5b,
79 0x07, 0xb8, 0xb3, 0xdc, 0x38, 0xec, 0xc4, 0xeb,
80 0xae, 0x97, 0xdd, 0xd8, 0x7f, 0x3d, 0x89, 0x85,
81};
82
83int
84main(int argc, char **argv)
85{
86 unsigned char md[SHA512_DIGEST_LENGTH];
87 int i;
88 EVP_MD_CTX *evp = NULL;
89
90#ifdef OPENSSL_IA32_SSE2
91 /* Alternative to this is to call OpenSSL_add_all_algorithms...
92 * The below code is retained exclusively for debugging purposes. */
93 {
94 char *env;
95
96 if ((env=getenv("OPENSSL_ia32cap")))
97 OPENSSL_ia32cap = strtoul (env, NULL, 0);
98 }
99#endif
100
101 fprintf(stdout, "Testing SHA-512 ");
102
103 if (!EVP_Digest("abc", 3, md, NULL, EVP_sha512(), NULL))
104 goto err;
105 if (memcmp(md, app_c1, sizeof(app_c1))) {
106 fflush(stdout);
107 fprintf(stderr, "\nTEST 1 of 3 failed.\n");
108 goto err;
109 }
110 fprintf(stdout, ".");
111 fflush(stdout);
112
113 EVP_Digest(
114 "abcdefgh""bcdefghi""cdefghij""defghijk"
115 "efghijkl""fghijklm""ghijklmn""hijklmno"
116 "ijklmnop""jklmnopq""klmnopqr""lmnopqrs"
117 "mnopqrst""nopqrstu",
118 112, md, NULL, EVP_sha512(), NULL);
119 if (memcmp(md, app_c2, sizeof(app_c2))) {
120 fflush(stdout);
121 fprintf(stderr, "\nTEST 2 of 3 failed.\n");
122 goto err;
123 }
124 fprintf(stdout, ".");
125 fflush(stdout);
126
127 if ((evp = EVP_MD_CTX_new()) == NULL) {
128 fflush(stdout);
129 fprintf(stderr, "\nEVP_MD_CTX_new() failed.\n");
130 goto err;
131 }
132 if (!EVP_DigestInit_ex(evp, EVP_sha512(), NULL)) {
133 fflush(stdout);
134 fprintf(stderr, "\nEVP_DigestInit_ex failed.\n");
135 goto err;
136 }
137
138 for (i = 0; i < 1000000; i += 288) {
139 if (!EVP_DigestUpdate(evp,
140 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
141 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
142 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
143 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
144 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
145 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
146 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
147 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
148 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
149 (1000000 - i) < 288 ? 1000000 - i : 288)) {
150 fflush(stdout);
151 fprintf(stderr, "\nEVP_DigestUpdate failed.\n");
152 goto err;
153 }
154 }
155 if (!EVP_DigestFinal_ex(evp, md, NULL)) {
156 fflush(stdout);
157 fprintf(stderr, "\nEVP_DigestFinal failed.\n");
158 goto err;
159 }
160 if (!EVP_MD_CTX_reset(evp)) {
161 fflush(stdout);
162 fprintf(stderr, "\nEVP_MD_CTX_reset failed.\n");
163 goto err;
164 }
165
166 if (memcmp(md, app_c3, sizeof(app_c3))) {
167 fflush(stdout);
168 fprintf(stderr, "\nTEST 3 of 3 failed.\n");
169 goto err;
170 }
171 fprintf(stdout, ".");
172 fflush(stdout);
173
174 fprintf(stdout, " passed.\n");
175 fflush(stdout);
176
177 fprintf(stdout, "Testing SHA-384 ");
178
179 EVP_Digest("abc", 3, md, NULL, EVP_sha384(), NULL);
180 if (memcmp(md, app_d1, sizeof(app_d1))) {
181 fflush(stdout);
182 fprintf(stderr, "\nTEST 1 of 3 failed.\n");
183 goto err;
184 }
185 fprintf(stdout, ".");
186 fflush(stdout);
187
188 EVP_Digest(
189 "abcdefgh""bcdefghi""cdefghij""defghijk"
190 "efghijkl""fghijklm""ghijklmn""hijklmno"
191 "ijklmnop""jklmnopq""klmnopqr""lmnopqrs"
192 "mnopqrst""nopqrstu",
193 112, md, NULL, EVP_sha384(), NULL);
194 if (memcmp(md, app_d2, sizeof(app_d2))) {
195 fflush(stdout);
196 fprintf(stderr, "\nTEST 2 of 3 failed.\n");
197 goto err;
198 }
199 fprintf(stdout, ".");
200 fflush(stdout);
201
202 if (!EVP_DigestInit_ex(evp, EVP_sha384(), NULL)) {
203 fflush(stdout);
204 fprintf(stderr, "\nEVP_DigestInit_ex failed.\n");
205 goto err;
206 }
207 for (i = 0; i < 1000000; i += 64) {
208 if (!EVP_DigestUpdate(evp,
209 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
210 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
211 (1000000 - i) < 64 ? 1000000 - i : 64)) {
212 fflush(stdout);
213 fprintf(stderr, "\nEVP_DigestUpdate failed.\n");
214 goto err;
215 }
216 }
217 if (!EVP_DigestFinal_ex(evp, md, NULL)) {
218 fflush(stdout);
219 fprintf(stderr, "\nEVP_DigestFinal_ex failed.\n");
220 goto err;
221 }
222 EVP_MD_CTX_free(evp);
223 evp = NULL;
224
225 if (memcmp(md, app_d3, sizeof(app_d3))) {
226 fflush(stdout);
227 fprintf(stderr, "\nTEST 3 of 3 failed.\n");
228 goto err;
229 }
230 fprintf(stdout, ".");
231 fflush(stdout);
232
233 fprintf(stdout, " passed.\n");
234 fflush(stdout);
235
236 return 0;
237
238 err:
239 EVP_MD_CTX_free(evp);
240 return 1;
241}
242#endif