diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/sha1/sha1test.c | 17 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/sha256/sha256test.c | 28 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/sha512/sha512test.c | 28 |
3 files changed, 42 insertions, 31 deletions
diff --git a/src/regress/lib/libcrypto/sha1/sha1test.c b/src/regress/lib/libcrypto/sha1/sha1test.c index 7f28ba676f..537454851b 100644 --- a/src/regress/lib/libcrypto/sha1/sha1test.c +++ b/src/regress/lib/libcrypto/sha1/sha1test.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: sha1test.c,v 1.3 2018/07/17 17:06:50 tb Exp $ */ | 1 | /* $OpenBSD: sha1test.c,v 1.4 2021/11/18 15:23:24 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -83,10 +83,13 @@ int main(int argc, char *argv[]) | |||
| 83 | char **P,**R; | 83 | char **P,**R; |
| 84 | static unsigned char buf[1000]; | 84 | static unsigned char buf[1000]; |
| 85 | char *p,*r; | 85 | char *p,*r; |
| 86 | EVP_MD_CTX c; | 86 | EVP_MD_CTX *c; |
| 87 | unsigned char md[SHA_DIGEST_LENGTH]; | 87 | unsigned char md[SHA_DIGEST_LENGTH]; |
| 88 | 88 | ||
| 89 | EVP_MD_CTX_init(&c); | 89 | if ((c = EVP_MD_CTX_new()) == NULL) { |
| 90 | printf("EVP_MD_CTX_new() failed\n"); | ||
| 91 | return 1; | ||
| 92 | } | ||
| 90 | P=test; | 93 | P=test; |
| 91 | R=ret; | 94 | R=ret; |
| 92 | i=1; | 95 | i=1; |
| @@ -108,10 +111,10 @@ int main(int argc, char *argv[]) | |||
| 108 | } | 111 | } |
| 109 | 112 | ||
| 110 | memset(buf,'a',1000); | 113 | memset(buf,'a',1000); |
| 111 | EVP_DigestInit_ex(&c,EVP_sha1(), NULL); | 114 | EVP_DigestInit_ex(c,EVP_sha1(), NULL); |
| 112 | for (i=0; i<1000; i++) | 115 | for (i=0; i<1000; i++) |
| 113 | EVP_DigestUpdate(&c,buf,1000); | 116 | EVP_DigestUpdate(c,buf,1000); |
| 114 | EVP_DigestFinal_ex(&c,md,NULL); | 117 | EVP_DigestFinal_ex(c,md,NULL); |
| 115 | p=pt(md); | 118 | p=pt(md); |
| 116 | 119 | ||
| 117 | r=bigret; | 120 | r=bigret; |
| @@ -124,7 +127,7 @@ int main(int argc, char *argv[]) | |||
| 124 | else | 127 | else |
| 125 | printf("test 3 ok\n"); | 128 | printf("test 3 ok\n"); |
| 126 | 129 | ||
| 127 | EVP_MD_CTX_cleanup(&c); | 130 | EVP_MD_CTX_free(c); |
| 128 | exit(err); | 131 | exit(err); |
| 129 | } | 132 | } |
| 130 | 133 | ||
diff --git a/src/regress/lib/libcrypto/sha256/sha256test.c b/src/regress/lib/libcrypto/sha256/sha256test.c index 9c22bc7664..1bd23a9273 100644 --- a/src/regress/lib/libcrypto/sha256/sha256test.c +++ b/src/regress/lib/libcrypto/sha256/sha256test.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: sha256test.c,v 1.3 2018/07/17 17:06:50 tb Exp $ */ | 1 | /* $OpenBSD: sha256test.c,v 1.4 2021/11/18 15:23:24 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 2004 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2004 The OpenSSL Project. All rights reserved. |
| 4 | * ==================================================================== | 4 | * ==================================================================== |
| @@ -65,7 +65,7 @@ int | |||
| 65 | main(int argc, char **argv) { | 65 | main(int argc, char **argv) { |
| 66 | unsigned char md[SHA256_DIGEST_LENGTH]; | 66 | unsigned char md[SHA256_DIGEST_LENGTH]; |
| 67 | int i; | 67 | int i; |
| 68 | EVP_MD_CTX evp; | 68 | EVP_MD_CTX *evp; |
| 69 | 69 | ||
| 70 | fprintf(stdout, "Testing SHA-256 "); | 70 | fprintf(stdout, "Testing SHA-256 "); |
| 71 | 71 | ||
| @@ -90,18 +90,22 @@ main(int argc, char **argv) { | |||
| 90 | fprintf(stdout, "."); | 90 | fprintf(stdout, "."); |
| 91 | fflush(stdout); | 91 | fflush(stdout); |
| 92 | 92 | ||
| 93 | EVP_MD_CTX_init(&evp); | 93 | if ((evp = EVP_MD_CTX_new()) == NULL) { |
| 94 | EVP_DigestInit_ex(&evp, EVP_sha256(), NULL); | 94 | fflush(stdout); |
| 95 | fprintf(stderr, "\nEVP_MD_CTX_new() failed.\n"); | ||
| 96 | return 1; | ||
| 97 | } | ||
| 98 | EVP_DigestInit_ex(evp, EVP_sha256(), NULL); | ||
| 95 | for (i = 0; i < 1000000; i += 160) | 99 | for (i = 0; i < 1000000; i += 160) |
| 96 | EVP_DigestUpdate(&evp, | 100 | EVP_DigestUpdate(evp, |
| 97 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 101 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 98 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 102 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 99 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 103 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 100 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 104 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 101 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", | 105 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", |
| 102 | (1000000 - i) < 160 ? 1000000 - i : 160); | 106 | (1000000 - i) < 160 ? 1000000 - i : 160); |
| 103 | EVP_DigestFinal_ex(&evp, md, NULL); | 107 | EVP_DigestFinal_ex(evp, md, NULL); |
| 104 | EVP_MD_CTX_cleanup(&evp); | 108 | EVP_MD_CTX_cleanup(evp); |
| 105 | 109 | ||
| 106 | if (memcmp(md, app_b3, sizeof(app_b3))) { | 110 | if (memcmp(md, app_b3, sizeof(app_b3))) { |
| 107 | fflush(stdout); | 111 | fflush(stdout); |
| @@ -136,15 +140,15 @@ main(int argc, char **argv) { | |||
| 136 | fprintf(stdout, "."); | 140 | fprintf(stdout, "."); |
| 137 | fflush(stdout); | 141 | fflush(stdout); |
| 138 | 142 | ||
| 139 | EVP_MD_CTX_init(&evp); | 143 | EVP_MD_CTX_init(evp); |
| 140 | EVP_DigestInit_ex (&evp, EVP_sha224(), NULL); | 144 | EVP_DigestInit_ex (evp, EVP_sha224(), NULL); |
| 141 | for (i = 0; i < 1000000; i += 64) | 145 | for (i = 0; i < 1000000; i += 64) |
| 142 | EVP_DigestUpdate(&evp, | 146 | EVP_DigestUpdate(evp, |
| 143 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 147 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 144 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", | 148 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", |
| 145 | (1000000 - i) < 64 ? 1000000 - i : 64); | 149 | (1000000 - i) < 64 ? 1000000 - i : 64); |
| 146 | EVP_DigestFinal_ex(&evp, md, NULL); | 150 | EVP_DigestFinal_ex(evp, md, NULL); |
| 147 | EVP_MD_CTX_cleanup(&evp); | 151 | EVP_MD_CTX_cleanup(evp); |
| 148 | 152 | ||
| 149 | if (memcmp(md, addenum_3, sizeof(addenum_3))) { | 153 | if (memcmp(md, addenum_3, sizeof(addenum_3))) { |
| 150 | fflush(stdout); | 154 | fflush(stdout); |
diff --git a/src/regress/lib/libcrypto/sha512/sha512test.c b/src/regress/lib/libcrypto/sha512/sha512test.c index bbcec93a2b..9f0e7419d7 100644 --- a/src/regress/lib/libcrypto/sha512/sha512test.c +++ b/src/regress/lib/libcrypto/sha512/sha512test.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: sha512test.c,v 1.4 2018/07/17 17:06:50 tb Exp $ */ | 1 | /* $OpenBSD: sha512test.c,v 1.5 2021/11/18 15:23:24 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 2004 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2004 The OpenSSL Project. All rights reserved. |
| 4 | * ==================================================================== | 4 | * ==================================================================== |
| @@ -84,7 +84,7 @@ int | |||
| 84 | main(int argc, char **argv) { | 84 | main(int argc, char **argv) { |
| 85 | unsigned char md[SHA512_DIGEST_LENGTH]; | 85 | unsigned char md[SHA512_DIGEST_LENGTH]; |
| 86 | int i; | 86 | int i; |
| 87 | EVP_MD_CTX evp; | 87 | EVP_MD_CTX *evp; |
| 88 | 88 | ||
| 89 | #ifdef OPENSSL_IA32_SSE2 | 89 | #ifdef OPENSSL_IA32_SSE2 |
| 90 | /* Alternative to this is to call OpenSSL_add_all_algorithms... | 90 | /* Alternative to this is to call OpenSSL_add_all_algorithms... |
| @@ -122,10 +122,14 @@ main(int argc, char **argv) { | |||
| 122 | fprintf(stdout, "."); | 122 | fprintf(stdout, "."); |
| 123 | fflush(stdout); | 123 | fflush(stdout); |
| 124 | 124 | ||
| 125 | EVP_MD_CTX_init(&evp); | 125 | if ((evp = EVP_MD_CTX_new()) == NULL) { |
| 126 | EVP_DigestInit_ex(&evp, EVP_sha512(), NULL); | 126 | fflush(stdout); |
| 127 | fprintf(stderr, "\nEVP_MD_CTX_new() failed.\n"); | ||
| 128 | return 1; | ||
| 129 | } | ||
| 130 | EVP_DigestInit_ex(evp, EVP_sha512(), NULL); | ||
| 127 | for (i = 0; i < 1000000; i += 288) | 131 | for (i = 0; i < 1000000; i += 288) |
| 128 | EVP_DigestUpdate(&evp, | 132 | EVP_DigestUpdate(evp, |
| 129 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 133 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 130 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 134 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 131 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 135 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| @@ -136,8 +140,8 @@ main(int argc, char **argv) { | |||
| 136 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 140 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 137 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", | 141 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", |
| 138 | (1000000 - i) < 288 ? 1000000 - i : 288); | 142 | (1000000 - i) < 288 ? 1000000 - i : 288); |
| 139 | EVP_DigestFinal_ex(&evp, md, NULL); | 143 | EVP_DigestFinal_ex(evp, md, NULL); |
| 140 | EVP_MD_CTX_cleanup(&evp); | 144 | EVP_MD_CTX_cleanup(evp); |
| 141 | 145 | ||
| 142 | if (memcmp(md, app_c3, sizeof(app_c3))) { | 146 | if (memcmp(md, app_c3, sizeof(app_c3))) { |
| 143 | fflush(stdout); | 147 | fflush(stdout); |
| @@ -175,15 +179,15 @@ main(int argc, char **argv) { | |||
| 175 | fprintf(stdout, "."); | 179 | fprintf(stdout, "."); |
| 176 | fflush(stdout); | 180 | fflush(stdout); |
| 177 | 181 | ||
| 178 | EVP_MD_CTX_init(&evp); | 182 | EVP_MD_CTX_init(evp); |
| 179 | EVP_DigestInit_ex(&evp, EVP_sha384(), NULL); | 183 | EVP_DigestInit_ex(evp, EVP_sha384(), NULL); |
| 180 | for (i = 0; i < 1000000; i += 64) | 184 | for (i = 0; i < 1000000; i += 64) |
| 181 | EVP_DigestUpdate(&evp, | 185 | EVP_DigestUpdate(evp, |
| 182 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" | 186 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" |
| 183 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", | 187 | "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", |
| 184 | (1000000 - i) < 64 ? 1000000 - i : 64); | 188 | (1000000 - i) < 64 ? 1000000 - i : 64); |
| 185 | EVP_DigestFinal_ex(&evp, md, NULL); | 189 | EVP_DigestFinal_ex(evp, md, NULL); |
| 186 | EVP_MD_CTX_cleanup(&evp); | 190 | EVP_MD_CTX_free(evp); |
| 187 | 191 | ||
| 188 | if (memcmp(md, app_d3, sizeof(app_d3))) { | 192 | if (memcmp(md, app_d3, sizeof(app_d3))) { |
| 189 | fflush(stdout); | 193 | fflush(stdout); |
