-/* $OpenBSD: x_algor.c,v 1.26 2023/10/11 12:51:07 tb Exp $ */
+/* $OpenBSD: x_algor.c,v 1.27 2023/10/11 13:05:18 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
}
}
-/* Set up an X509_ALGOR DigestAlgorithmIdentifier from an EVP_MD */
-
-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)
{
+ ASN1_OBJECT *aobj;
int param_type = V_ASN1_NULL;
if ((EVP_MD_flags(md) & EVP_MD_FLAG_DIGALGID_ABSENT) != 0)
param_type = V_ASN1_UNDEF;
- X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_type(md)), param_type, NULL);
+ if ((aobj = OBJ_nid2obj(EVP_MD_type(md))) == NULL)
+ return 0;
+
+ return X509_ALGOR_set0(alg, aobj, param_type, NULL);
+}
+
+void
+X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md)
+{
+ (void)X509_ALGOR_set_evp_md(alg, md);
}
int
-/* $OpenBSD: x509_local.h,v 1.9 2023/05/28 05:25:24 tb Exp $ */
+/* $OpenBSD: x509_local.h,v 1.10 2023/10/11 13:05:18 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2013.
*/
int name_cmp(const char *name, const char *cmp);
+int X509_ALGOR_set_evp_md(X509_ALGOR *alg, const EVP_MD *md);
+
int X509_policy_check(const STACK_OF(X509) *certs,
const STACK_OF(ASN1_OBJECT) *user_policies, unsigned long flags,
X509 **out_current_cert);