From 00ee6dc427d95fe592c72cbcf5ff01b806355374 Mon Sep 17 00:00:00 2001 From: tb Date: Thu, 29 Feb 2024 20:03:47 +0000 Subject: [PATCH] Link x509_algor test statically and switch to the internal X509_ALGOR_set0_evp_md() --- regress/lib/libcrypto/asn1/Makefile | 3 ++- regress/lib/libcrypto/asn1/x509_algor.c | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/regress/lib/libcrypto/asn1/Makefile b/regress/lib/libcrypto/asn1/Makefile index 16a84c19bb8..1ba2fecf236 100644 --- a/regress/lib/libcrypto/asn1/Makefile +++ b/regress/lib/libcrypto/asn1/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.27 2024/02/18 16:32:29 tb Exp $ +# $OpenBSD: Makefile,v 1.28 2024/02/29 20:03:47 tb Exp $ PROGS = \ asn1api \ @@ -25,5 +25,6 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/libcrypto/bytestring LDADD_asn1basic = ${CRYPTO_INT} LDADD_asn1object = ${CRYPTO_INT} LDADD_asn1time = ${CRYPTO_INT} +LDADD_x509_algor = ${CRYPTO_INT} .include diff --git a/regress/lib/libcrypto/asn1/x509_algor.c b/regress/lib/libcrypto/asn1/x509_algor.c index 47d73056630..abe492ea257 100644 --- a/regress/lib/libcrypto/asn1/x509_algor.c +++ b/regress/lib/libcrypto/asn1/x509_algor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_algor.c,v 1.6 2023/10/26 08:01:38 tb Exp $ */ +/* $OpenBSD: x509_algor.c,v 1.7 2024/02/29 20:03:47 tb Exp $ */ /* * Copyright (c) 2023 Theo Buehler * @@ -23,7 +23,7 @@ #include #include -void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md); +int X509_ALGOR_set_evp_md(X509_ALGOR *alg, const EVP_MD *md); static int x509_algor_new_test(void) @@ -321,7 +321,7 @@ x509_algor_get0_test(void) } static int -x509_algor_set_md_test(void) +x509_algor_set_evp_md_test(void) { X509_ALGOR *alg = NULL; const ASN1_OBJECT *aobj; @@ -331,7 +331,11 @@ x509_algor_set_md_test(void) if ((alg = X509_ALGOR_new()) == NULL) errx(1, "%s: X509_ALGOR_new", __func__); - X509_ALGOR_set_md(alg, EVP_sm3()); + if (!X509_ALGOR_set_evp_md(alg, EVP_sm3())) { + fprintf(stderr, "%s: X509_ALGOR_set_evp_md to sm3 failed\n", + __func__); + goto failure; + } X509_ALGOR_get0(&aobj, &ptype, NULL, alg); if ((nid = OBJ_obj2nid(aobj)) != NID_sm3) { fprintf(stderr, "%s: sm3 want %d, got %d\n", __func__, @@ -348,15 +352,19 @@ x509_algor_set_md_test(void) if (!X509_ALGOR_set0(alg, NULL, 0, NULL)) errx(1, "%s: X509_ALGOR_set0", __func__); - X509_ALGOR_set_md(alg, EVP_md5()); + if (!X509_ALGOR_set_evp_md(alg, EVP_md5())) { + fprintf(stderr, "%s: X509_ALGOR_set_evp_md to md5 failed\n", + __func__); + goto failure; + } X509_ALGOR_get0(&aobj, &ptype, NULL, alg); if ((nid = OBJ_obj2nid(aobj)) != NID_md5) { - fprintf(stderr, "%s: sm3 want %d, got %d\n", __func__, + fprintf(stderr, "%s: md5 want %d, got %d\n", __func__, NID_sm3, nid); goto failure; } if (ptype != V_ASN1_NULL) { - fprintf(stderr, "%s: sm3 want %d, got %d\n", __func__, + fprintf(stderr, "%s: md5 want %d, got %d\n", __func__, V_ASN1_NULL, ptype); goto failure; } @@ -377,7 +385,7 @@ main(void) failed |= x509_algor_new_test(); failed |= x509_algor_set0_test(); failed |= x509_algor_get0_test(); - failed |= x509_algor_set_md_test(); + failed |= x509_algor_set_evp_md_test(); return failed; } -- 2.20.1