summaryrefslogtreecommitdiff
path: root/regress/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to 'regress/lib/libcrypto')
-rw-r--r--regress/lib/libcrypto/sha1/Makefile9
-rw-r--r--regress/lib/libcrypto/sha1/sha1test.c157
-rw-r--r--regress/lib/libcrypto/sha256/Makefile9
-rw-r--r--regress/lib/libcrypto/sha256/sha256test.c183
-rw-r--r--regress/lib/libcrypto/sha512/Makefile9
-rw-r--r--regress/lib/libcrypto/sha512/sha512test.c242
6 files changed, 0 insertions, 609 deletions
diff --git a/regress/lib/libcrypto/sha1/Makefile b/regress/lib/libcrypto/sha1/Makefile
deleted file mode 100644
index 2bb0b45ec9b..00000000000
--- a/regress/lib/libcrypto/sha1/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $OpenBSD: Makefile,v 1.3 2014/07/08 15:53:53 jsing Exp $
-
-PROG= sha1test
-LDADD= -lcrypto
-DPADD= ${LIBCRYPTO}
-WARNINGS= Yes
-CFLAGS+= -DLIBRESSL_INTERNAL -Werror
-
-.include <bsd.regress.mk>
diff --git a/regress/lib/libcrypto/sha1/sha1test.c b/regress/lib/libcrypto/sha1/sha1test.c
deleted file mode 100644
index 168b422d7aa..00000000000
--- a/regress/lib/libcrypto/sha1/sha1test.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* $OpenBSD: sha1test.c,v 1.6 2021/12/29 22:54:41 tb Exp $ */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the rouines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.]
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <openssl/evp.h>
-#include <openssl/sha.h>
-
-static char *test[] = {
- "abc",
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- NULL,
-};
-
-static char *ret[] = {
- "a9993e364706816aba3e25717850c26c9cd0d89d",
- "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
-};
-static char *bigret =
- "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
-
-static char *pt(unsigned char *md);
-int
-main(int argc, char *argv[])
-{
- int i, err = 0;
- char **P, **R;
- static unsigned char buf[1000];
- char *p, *r;
- EVP_MD_CTX *c;
- unsigned char md[SHA_DIGEST_LENGTH];
-
- if ((c = EVP_MD_CTX_new()) == NULL) {
- printf("EVP_MD_CTX_new() failed\n");
- return 1;
- }
- P = test;
- R = ret;
- i = 1;
- while (*P != NULL) {
- if (!EVP_Digest(*P, strlen((char *)*P), md, NULL, EVP_sha1(),
- NULL)) {
- printf("EVP_Digest failed\n");
- goto err;
- }
- p = pt(md);
- if (strcmp(p, (char *)*R) != 0) {
- printf("error calculating SHA1 on '%s'\n", *P);
- printf("got %s instead of %s\n", p, *R);
- err++;
- } else
- printf("test %d ok\n", i);
- i++;
- R++;
- P++;
- }
-
- memset(buf, 'a', 1000);
- if (!EVP_DigestInit_ex(c, EVP_sha1(), NULL)) {
- printf("EVP_DigestInit_ex failed\n");
- goto err;
- }
- for (i = 0; i < 1000; i++) {
- if (!EVP_DigestUpdate(c, buf, 1000)) {
- printf("EVP_DigestUpdate failed\n");
- goto err;
- }
- }
- if (!EVP_DigestFinal_ex(c, md, NULL)) {
- printf("EVP_DigestFinal_ex failed\n");
- goto err;
- }
- p = pt(md);
-
- r = bigret;
- if (strcmp(p, r) != 0) {
- printf("error calculating SHA1 on 'a' * 1000\n");
- printf("got %s instead of %s\n", p, r);
- err++;
- } else
- printf("test 3 ok\n");
-
- EVP_MD_CTX_free(c);
- exit(err);
-
- err:
- EVP_MD_CTX_free(c);
- exit(1);
-}
-
-static char *
-pt(unsigned char *md)
-{
- int i;
- static char buf[80];
-
- for (i = 0; i < SHA_DIGEST_LENGTH; i++)
- snprintf(buf + i*2, sizeof(buf) - i*2, "%02x", md[i]);
- return (buf);
-}
diff --git a/regress/lib/libcrypto/sha256/Makefile b/regress/lib/libcrypto/sha256/Makefile
deleted file mode 100644
index 6e5f9d714b2..00000000000
--- a/regress/lib/libcrypto/sha256/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $OpenBSD: Makefile,v 1.3 2014/07/08 15:53:53 jsing Exp $
-
-PROG= sha256test
-LDADD= -lcrypto
-DPADD= ${LIBCRYPTO}
-WARNINGS= Yes
-CFLAGS+= -DLIBRESSL_INTERNAL -Werror
-
-.include <bsd.regress.mk>
diff --git a/regress/lib/libcrypto/sha256/sha256test.c b/regress/lib/libcrypto/sha256/sha256test.c
deleted file mode 100644
index dbba2abe3c5..00000000000
--- a/regress/lib/libcrypto/sha256/sha256test.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* $OpenBSD: sha256test.c,v 1.7 2021/12/29 22:56:25 tb Exp $ */
-/* ====================================================================
- * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
- * ====================================================================
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <openssl/sha.h>
-#include <openssl/evp.h>
-
-#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA256)
-int
-main(int argc, char *argv[])
-{
- printf("No SHA256 support\n");
- return (0);
-}
-#else
-
-unsigned char app_b1[SHA256_DIGEST_LENGTH] = {
- 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
- 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
- 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
- 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad,
-};
-
-unsigned char app_b2[SHA256_DIGEST_LENGTH] = {
- 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
- 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
- 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
- 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1,
-};
-
-unsigned char app_b3[SHA256_DIGEST_LENGTH] = {
- 0xcd, 0xc7, 0x6e, 0x5c, 0x99, 0x14, 0xfb, 0x92,
- 0x81, 0xa1, 0xc7, 0xe2, 0x84, 0xd7, 0x3e, 0x67,
- 0xf1, 0x80, 0x9a, 0x48, 0xa4, 0x97, 0x20, 0x0e,
- 0x04, 0x6d, 0x39, 0xcc, 0xc7, 0x11, 0x2c, 0xd0,
-};
-
-unsigned char addenum_1[SHA224_DIGEST_LENGTH] = {
- 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22,
- 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3,
- 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7,
- 0xe3, 0x6c, 0x9d, 0xa7,
-};
-
-unsigned char addenum_2[SHA224_DIGEST_LENGTH] = {
- 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc,
- 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50,
- 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19,
- 0x52, 0x52, 0x25, 0x25,
-};
-
-unsigned char addenum_3[SHA224_DIGEST_LENGTH] = {
- 0x20, 0x79, 0x46, 0x55, 0x98, 0x0c, 0x91, 0xd8,
- 0xbb, 0xb4, 0xc1, 0xea, 0x97, 0x61, 0x8a, 0x4b,
- 0xf0, 0x3f, 0x42, 0x58, 0x19, 0x48, 0xb2, 0xee,
- 0x4e, 0xe7, 0xad, 0x67,
-};
-
-int
-main(int argc, char **argv) {
- unsigned char md[SHA256_DIGEST_LENGTH];
- int i;
- int ret = 1;
- EVP_MD_CTX *evp = NULL;
-
- fprintf(stdout, "Testing SHA-256 ");
-
- EVP_Digest("abc",3,md,NULL,EVP_sha256(),NULL);
- if (memcmp(md, app_b1, sizeof(app_b1))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 1 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- EVP_Digest(
- "abcdbcde""cdefdefg""efghfghi""ghijhijk"
- "ijkljklm""klmnlmno""mnopnopq",
- 56, md, NULL, EVP_sha256(), NULL);
- if (memcmp(md, app_b2, sizeof(app_b2))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 2 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- if ((evp = EVP_MD_CTX_new()) == NULL) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_MD_CTX_new() failed.\n");
- goto err;
- }
- if (!EVP_DigestInit_ex(evp, EVP_sha256(), NULL))
- goto err;
- for (i = 0; i < 1000000; i += 160) {
- if (!EVP_DigestUpdate(evp,
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
- (1000000 - i) < 160 ? 1000000 - i : 160))
- goto err;
- }
- if (!EVP_DigestFinal_ex(evp, md, NULL))
- goto err;
- if (!EVP_MD_CTX_reset(evp))
- goto err;
-
- if (memcmp(md, app_b3, sizeof(app_b3))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 3 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- fprintf(stdout, " passed.\n"); fflush(stdout);
-
- fprintf(stdout, "Testing SHA-224 ");
-
- if (!EVP_Digest("abc",3,md,NULL,EVP_sha224(),NULL))
- goto err;
- if (memcmp(md, addenum_1, sizeof(addenum_1))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 1 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- if (!EVP_Digest(
- "abcdbcde""cdefdefg""efghfghi""ghijhijk"
- "ijkljklm""klmnlmno""mnopnopq",
- 56, md, NULL, EVP_sha224(), NULL))
- goto err;
- if (memcmp(md, addenum_2, sizeof(addenum_2))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 2 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- if (!EVP_DigestInit_ex (evp, EVP_sha224(), NULL))
- goto err;
- for (i = 0; i < 1000000; i += 64) {
- if (!EVP_DigestUpdate(evp,
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
- (1000000 - i) < 64 ? 1000000 - i : 64))
- goto err;
- }
- if (!EVP_DigestFinal_ex(evp, md, NULL))
- goto err;
- if (!EVP_MD_CTX_reset(evp))
- goto err;
-
- if (memcmp(md, addenum_3, sizeof(addenum_3))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 3 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- fprintf(stdout, " passed.\n");
- fflush(stdout);
-
- ret = 0;
-
- err:
- EVP_MD_CTX_free(evp);
-
- return ret;
-}
-#endif
diff --git a/regress/lib/libcrypto/sha512/Makefile b/regress/lib/libcrypto/sha512/Makefile
deleted file mode 100644
index 354860eae1a..00000000000
--- a/regress/lib/libcrypto/sha512/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $OpenBSD: Makefile,v 1.3 2014/07/08 15:53:53 jsing Exp $
-
-PROG= sha512test
-LDADD= -lcrypto
-DPADD= ${LIBCRYPTO}
-WARNINGS= Yes
-CFLAGS+= -DLIBRESSL_INTERNAL -Werror
-
-.include <bsd.regress.mk>
diff --git a/regress/lib/libcrypto/sha512/sha512test.c b/regress/lib/libcrypto/sha512/sha512test.c
deleted file mode 100644
index 0d5121036be..00000000000
--- a/regress/lib/libcrypto/sha512/sha512test.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/* $OpenBSD: sha512test.c,v 1.7 2021/12/29 23:02:00 tb Exp $ */
-/* ====================================================================
- * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
- * ====================================================================
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <openssl/sha.h>
-#include <openssl/evp.h>
-#include <openssl/crypto.h>
-
-#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA512)
-int
-main(int argc, char *argv[])
-{
- printf("No SHA512 support\n");
- return (0);
-}
-#else
-
-unsigned char app_c1[SHA512_DIGEST_LENGTH] = {
- 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
- 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
- 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
- 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
- 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
- 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
- 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
- 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f,
-};
-
-unsigned char app_c2[SHA512_DIGEST_LENGTH] = {
- 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
- 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
- 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
- 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
- 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
- 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
- 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
- 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09,
-};
-
-unsigned char app_c3[SHA512_DIGEST_LENGTH] = {
- 0xe7, 0x18, 0x48, 0x3d, 0x0c, 0xe7, 0x69, 0x64,
- 0x4e, 0x2e, 0x42, 0xc7, 0xbc, 0x15, 0xb4, 0x63,
- 0x8e, 0x1f, 0x98, 0xb1, 0x3b, 0x20, 0x44, 0x28,
- 0x56, 0x32, 0xa8, 0x03, 0xaf, 0xa9, 0x73, 0xeb,
- 0xde, 0x0f, 0xf2, 0x44, 0x87, 0x7e, 0xa6, 0x0a,
- 0x4c, 0xb0, 0x43, 0x2c, 0xe5, 0x77, 0xc3, 0x1b,
- 0xeb, 0x00, 0x9c, 0x5c, 0x2c, 0x49, 0xaa, 0x2e,
- 0x4e, 0xad, 0xb2, 0x17, 0xad, 0x8c, 0xc0, 0x9b,
-};
-
-unsigned char app_d1[SHA384_DIGEST_LENGTH] = {
- 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
- 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
- 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
- 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
- 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
- 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7,
-};
-
-unsigned char app_d2[SHA384_DIGEST_LENGTH] = {
- 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
- 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
- 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
- 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
- 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
- 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39,
-};
-
-unsigned char app_d3[SHA384_DIGEST_LENGTH] = {
- 0x9d, 0x0e, 0x18, 0x09, 0x71, 0x64, 0x74, 0xcb,
- 0x08, 0x6e, 0x83, 0x4e, 0x31, 0x0a, 0x4a, 0x1c,
- 0xed, 0x14, 0x9e, 0x9c, 0x00, 0xf2, 0x48, 0x52,
- 0x79, 0x72, 0xce, 0xc5, 0x70, 0x4c, 0x2a, 0x5b,
- 0x07, 0xb8, 0xb3, 0xdc, 0x38, 0xec, 0xc4, 0xeb,
- 0xae, 0x97, 0xdd, 0xd8, 0x7f, 0x3d, 0x89, 0x85,
-};
-
-int
-main(int argc, char **argv)
-{
- unsigned char md[SHA512_DIGEST_LENGTH];
- int i;
- EVP_MD_CTX *evp = NULL;
-
-#ifdef OPENSSL_IA32_SSE2
- /* Alternative to this is to call OpenSSL_add_all_algorithms...
- * The below code is retained exclusively for debugging purposes. */
- {
- char *env;
-
- if ((env=getenv("OPENSSL_ia32cap")))
- OPENSSL_ia32cap = strtoul (env, NULL, 0);
- }
-#endif
-
- fprintf(stdout, "Testing SHA-512 ");
-
- if (!EVP_Digest("abc", 3, md, NULL, EVP_sha512(), NULL))
- goto err;
- if (memcmp(md, app_c1, sizeof(app_c1))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 1 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- EVP_Digest(
- "abcdefgh""bcdefghi""cdefghij""defghijk"
- "efghijkl""fghijklm""ghijklmn""hijklmno"
- "ijklmnop""jklmnopq""klmnopqr""lmnopqrs"
- "mnopqrst""nopqrstu",
- 112, md, NULL, EVP_sha512(), NULL);
- if (memcmp(md, app_c2, sizeof(app_c2))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 2 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- if ((evp = EVP_MD_CTX_new()) == NULL) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_MD_CTX_new() failed.\n");
- goto err;
- }
- if (!EVP_DigestInit_ex(evp, EVP_sha512(), NULL)) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_DigestInit_ex failed.\n");
- goto err;
- }
-
- for (i = 0; i < 1000000; i += 288) {
- if (!EVP_DigestUpdate(evp,
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
- (1000000 - i) < 288 ? 1000000 - i : 288)) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_DigestUpdate failed.\n");
- goto err;
- }
- }
- if (!EVP_DigestFinal_ex(evp, md, NULL)) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_DigestFinal failed.\n");
- goto err;
- }
- if (!EVP_MD_CTX_reset(evp)) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_MD_CTX_reset failed.\n");
- goto err;
- }
-
- if (memcmp(md, app_c3, sizeof(app_c3))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 3 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- fprintf(stdout, " passed.\n");
- fflush(stdout);
-
- fprintf(stdout, "Testing SHA-384 ");
-
- EVP_Digest("abc", 3, md, NULL, EVP_sha384(), NULL);
- if (memcmp(md, app_d1, sizeof(app_d1))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 1 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- EVP_Digest(
- "abcdefgh""bcdefghi""cdefghij""defghijk"
- "efghijkl""fghijklm""ghijklmn""hijklmno"
- "ijklmnop""jklmnopq""klmnopqr""lmnopqrs"
- "mnopqrst""nopqrstu",
- 112, md, NULL, EVP_sha384(), NULL);
- if (memcmp(md, app_d2, sizeof(app_d2))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 2 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- if (!EVP_DigestInit_ex(evp, EVP_sha384(), NULL)) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_DigestInit_ex failed.\n");
- goto err;
- }
- for (i = 0; i < 1000000; i += 64) {
- if (!EVP_DigestUpdate(evp,
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
- "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
- (1000000 - i) < 64 ? 1000000 - i : 64)) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_DigestUpdate failed.\n");
- goto err;
- }
- }
- if (!EVP_DigestFinal_ex(evp, md, NULL)) {
- fflush(stdout);
- fprintf(stderr, "\nEVP_DigestFinal_ex failed.\n");
- goto err;
- }
- EVP_MD_CTX_free(evp);
- evp = NULL;
-
- if (memcmp(md, app_d3, sizeof(app_d3))) {
- fflush(stdout);
- fprintf(stderr, "\nTEST 3 of 3 failed.\n");
- goto err;
- }
- fprintf(stdout, ".");
- fflush(stdout);
-
- fprintf(stdout, " passed.\n");
- fflush(stdout);
-
- return 0;
-
- err:
- EVP_MD_CTX_free(evp);
- return 1;
-}
-#endif