diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2023-10-11 13:10:14 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2023-10-11 13:10:14 +0000 |
commit | 1f66e13af01f3e1e3be41146b340db60382a1372 (patch) | |
tree | 973424f9e777036bca9f61027fccbffd5a876425 /lib | |
parent | ee5e760e7da8244f068c15c420e9b9b2d90aea53 (diff) |
Rewrite X509_ALGOR_get0()
Make the logic slightly less convoluted. Preserve the behavior that
*ppval remains unset if pptype == NULL for now. However, ensure that
*ppval is set to NULL if pptype is V_ASN1_UNDER.
ok jsing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/asn1/x_algor.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/libcrypto/asn1/x_algor.c b/lib/libcrypto/asn1/x_algor.c index 092ad80d2dc..47bde7b97e2 100644 --- a/lib/libcrypto/asn1/x_algor.c +++ b/lib/libcrypto/asn1/x_algor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_algor.c,v 1.27 2023/10/11 13:05:18 tb Exp $ */ +/* $OpenBSD: x_algor.c,v 1.28 2023/10/11 13:10:13 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -176,20 +176,26 @@ X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) } void -X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, const void **ppval, - const X509_ALGOR *algor) +X509_ALGOR_get0(const ASN1_OBJECT **out_aobj, int *out_type, + const void **out_value, const X509_ALGOR *alg) { - if (paobj) - *paobj = algor->algorithm; - if (pptype) { - if (algor->parameter == NULL) { - *pptype = V_ASN1_UNDEF; - return; - } else - *pptype = algor->parameter->type; - if (ppval) - *ppval = algor->parameter->value.ptr; + int type = V_ASN1_UNDEF; + const void *value = NULL; + + if (out_aobj != NULL) + *out_aobj = alg->algorithm; + + if (out_type == NULL) + return; + + if (alg->parameter != NULL) { + type = alg->parameter->type; + value = alg->parameter->value.ptr; } + + *out_type = type; + if (out_value != NULL) + *out_value = value; } int |