diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2021-11-18 15:23:25 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2021-11-18 15:23:25 +0000 |
commit | e437cdc2b320d2326535e143d6cf3040e62a005b (patch) | |
tree | de8bffe8a8ca639c35c1847e24cc01ee30692a0e /regress/lib | |
parent | ed3b060fb60d75c558d04bdb54ac493790bb3e2d (diff) |
sha*test: convert these tests to work with opaque EVP_MD_CTX.
Diffstat (limited to 'regress/lib')
-rw-r--r-- | regress/lib/libcrypto/sha1/sha1test.c | 17 | ||||
-rw-r--r-- | regress/lib/libcrypto/sha256/sha256test.c | 28 | ||||
-rw-r--r-- | regress/lib/libcrypto/sha512/sha512test.c | 28 |
3 files changed, 42 insertions, 31 deletions
diff --git a/regress/lib/libcrypto/sha1/sha1test.c b/regress/lib/libcrypto/sha1/sha1test.c index 7f28ba676f2..537454851bd 100644 --- a/regress/lib/libcrypto/sha1/sha1test.c +++ b/regress/lib/libcrypto/sha1/sha1test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha1test.c,v 1.3 2018/07/17 17:06:50 tb Exp $ */ +/* $OpenBSD: sha1test.c,v 1.4 2021/11/18 15:23:24 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -83,10 +83,13 @@ int main(int argc, char *argv[]) char **P,**R; static unsigned char buf[1000]; char *p,*r; - EVP_MD_CTX c; + EVP_MD_CTX *c; unsigned char md[SHA_DIGEST_LENGTH]; - EVP_MD_CTX_init(&c); + if ((c = EVP_MD_CTX_new()) == NULL) { + printf("EVP_MD_CTX_new() failed\n"); + return 1; + } P=test; R=ret; i=1; @@ -108,10 +111,10 @@ int main(int argc, char *argv[]) } memset(buf,'a',1000); - EVP_DigestInit_ex(&c,EVP_sha1(), NULL); + EVP_DigestInit_ex(c,EVP_sha1(), NULL); for (i=0; i<1000; i++) - EVP_DigestUpdate(&c,buf,1000); - EVP_DigestFinal_ex(&c,md,NULL); + EVP_DigestUpdate(c,buf,1000); + EVP_DigestFinal_ex(c,md,NULL); p=pt(md); r=bigret; @@ -124,7 +127,7 @@ int main(int argc, char *argv[]) else printf("test 3 ok\n"); - EVP_MD_CTX_cleanup(&c); + EVP_MD_CTX_free(c); exit(err); } diff --git a/regress/lib/libcrypto/sha256/sha256test.c b/regress/lib/libcrypto/sha256/sha256test.c index 9c22bc7664d..1bd23a92733 100644 --- a/regress/lib/libcrypto/sha256/sha256test.c +++ b/regress/lib/libcrypto/sha256/sha256test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha256test.c,v 1.3 2018/07/17 17:06:50 tb Exp $ */ +/* $OpenBSD: sha256test.c,v 1.4 2021/11/18 15:23:24 tb Exp $ */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * ==================================================================== @@ -65,7 +65,7 @@ int main(int argc, char **argv) { unsigned char md[SHA256_DIGEST_LENGTH]; int i; - EVP_MD_CTX evp; + EVP_MD_CTX *evp; fprintf(stdout, "Testing SHA-256 "); @@ -90,18 +90,22 @@ main(int argc, char **argv) { fprintf(stdout, "."); fflush(stdout); - EVP_MD_CTX_init(&evp); - EVP_DigestInit_ex(&evp, EVP_sha256(), NULL); + if ((evp = EVP_MD_CTX_new()) == NULL) { + fflush(stdout); + fprintf(stderr, "\nEVP_MD_CTX_new() failed.\n"); + return 1; + } + EVP_DigestInit_ex(evp, EVP_sha256(), NULL); for (i = 0; i < 1000000; i += 160) - EVP_DigestUpdate(&evp, + 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); - EVP_DigestFinal_ex(&evp, md, NULL); - EVP_MD_CTX_cleanup(&evp); + EVP_DigestFinal_ex(evp, md, NULL); + EVP_MD_CTX_cleanup(evp); if (memcmp(md, app_b3, sizeof(app_b3))) { fflush(stdout); @@ -136,15 +140,15 @@ main(int argc, char **argv) { fprintf(stdout, "."); fflush(stdout); - EVP_MD_CTX_init(&evp); - EVP_DigestInit_ex (&evp, EVP_sha224(), NULL); + EVP_MD_CTX_init(evp); + EVP_DigestInit_ex (evp, EVP_sha224(), NULL); for (i = 0; i < 1000000; i += 64) - EVP_DigestUpdate(&evp, + EVP_DigestUpdate(evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", (1000000 - i) < 64 ? 1000000 - i : 64); - EVP_DigestFinal_ex(&evp, md, NULL); - EVP_MD_CTX_cleanup(&evp); + EVP_DigestFinal_ex(evp, md, NULL); + EVP_MD_CTX_cleanup(evp); if (memcmp(md, addenum_3, sizeof(addenum_3))) { fflush(stdout); diff --git a/regress/lib/libcrypto/sha512/sha512test.c b/regress/lib/libcrypto/sha512/sha512test.c index bbcec93a2b3..9f0e7419d7a 100644 --- a/regress/lib/libcrypto/sha512/sha512test.c +++ b/regress/lib/libcrypto/sha512/sha512test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha512test.c,v 1.4 2018/07/17 17:06:50 tb Exp $ */ +/* $OpenBSD: sha512test.c,v 1.5 2021/11/18 15:23:24 tb Exp $ */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * ==================================================================== @@ -84,7 +84,7 @@ int main(int argc, char **argv) { unsigned char md[SHA512_DIGEST_LENGTH]; int i; - EVP_MD_CTX evp; + EVP_MD_CTX *evp; #ifdef OPENSSL_IA32_SSE2 /* Alternative to this is to call OpenSSL_add_all_algorithms... @@ -122,10 +122,14 @@ main(int argc, char **argv) { fprintf(stdout, "."); fflush(stdout); - EVP_MD_CTX_init(&evp); - EVP_DigestInit_ex(&evp, EVP_sha512(), NULL); + if ((evp = EVP_MD_CTX_new()) == NULL) { + fflush(stdout); + fprintf(stderr, "\nEVP_MD_CTX_new() failed.\n"); + return 1; + } + EVP_DigestInit_ex(evp, EVP_sha512(), NULL); for (i = 0; i < 1000000; i += 288) - EVP_DigestUpdate(&evp, + EVP_DigestUpdate(evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" @@ -136,8 +140,8 @@ main(int argc, char **argv) { "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", (1000000 - i) < 288 ? 1000000 - i : 288); - EVP_DigestFinal_ex(&evp, md, NULL); - EVP_MD_CTX_cleanup(&evp); + EVP_DigestFinal_ex(evp, md, NULL); + EVP_MD_CTX_cleanup(evp); if (memcmp(md, app_c3, sizeof(app_c3))) { fflush(stdout); @@ -175,15 +179,15 @@ main(int argc, char **argv) { fprintf(stdout, "."); fflush(stdout); - EVP_MD_CTX_init(&evp); - EVP_DigestInit_ex(&evp, EVP_sha384(), NULL); + EVP_MD_CTX_init(evp); + EVP_DigestInit_ex(evp, EVP_sha384(), NULL); for (i = 0; i < 1000000; i += 64) - EVP_DigestUpdate(&evp, + EVP_DigestUpdate(evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", (1000000 - i) < 64 ? 1000000 - i : 64); - EVP_DigestFinal_ex(&evp, md, NULL); - EVP_MD_CTX_cleanup(&evp); + EVP_DigestFinal_ex(evp, md, NULL); + EVP_MD_CTX_free(evp); if (memcmp(md, app_d3, sizeof(app_d3))) { fflush(stdout); |