*David von Oheimb*
+* `X509_ALGOR_set_md()` now returns a value indicating success or failure.
+
+ *David von Oheimb*
+
* Drop darwin-i386{,-cc} and darwin-ppc{,64}{,-cc} targets from Configurations.
*Daniel Kubec and Eugene Syromiatnikov*
}
/* 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_md(X509_ALGOR *alg, const EVP_MD *md)
{
int type = md->flags & EVP_MD_FLAG_DIGALGID_ABSENT ? V_ASN1_UNDEF
: V_ASN1_NULL;
- (void)X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_get_type(md)), type, NULL);
+ return X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_get_type(md)), type, NULL);
}
int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b)
return 1;
if ((alg = X509_ALGOR_new()) == NULL)
return 0;
- X509_ALGOR_set_md(alg, md);
+ if (!X509_ALGOR_set_md(alg, md)) {
+ X509_ALGOR_free(alg);
+ return 0;
+ }
*palg = alg;
return 1;
}
dd->version = 0;
dd->encapContentInfo->eContentType = OBJ_nid2obj(NID_pkcs7_data);
- X509_ALGOR_set_md(dd->digestAlgorithm, md);
+ if (!X509_ALGOR_set_md(dd->digestAlgorithm, md))
+ goto err;
return cms;
if (ossl_cms_adjust_md(pk, &md, flags) != 1)
goto err;
- X509_ALGOR_set_md(si->digestAlgorithm, md);
+ if (!X509_ALGOR_set_md(si->digestAlgorithm, md))
+ goto err;
/* See if digest is present in digestAlgorithms */
for (i = 0; i < sk_X509_ALGOR_num(sd->digestAlgorithms); i++) {
break;
}
if (i == sk_X509_ALGOR_num(sd->digestAlgorithms)) {
- if ((alg = X509_ALGOR_new()) == NULL) {
- ERR_raise(ERR_LIB_CMS, ERR_R_ASN1_LIB);
- goto err;
- }
- X509_ALGOR_set_md(alg, md);
- if (!sk_X509_ALGOR_push(sd->digestAlgorithms, alg)) {
+ if ((alg = X509_ALGOR_new()) == NULL
+ || !X509_ALGOR_set_md(alg, md)
+ || !sk_X509_ALGOR_push(sd->digestAlgorithms, alg)) {
X509_ALGOR_free(alg);
ERR_raise(ERR_LIB_CMS, ERR_R_CRYPTO_LIB);
goto err;
if (!EVP_MD_is_a(hash_alg, SN_sha256)) {
alg = X509_ALGOR_new();
- if (alg == NULL) {
- ERR_raise(ERR_LIB_ESS, ERR_R_ASN1_LIB);
- goto err;
- }
- X509_ALGOR_set_md(alg, hash_alg);
- if (alg->algorithm == NULL) {
+ if (alg == NULL || !X509_ALGOR_set_md(alg, hash_alg) || alg->algorithm == NULL) {
ERR_raise(ERR_LIB_ESS, ERR_R_ASN1_LIB);
goto err;
}
int 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 *alg);
- void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
+ int X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
int X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src);
X509_ALGOR_dup() returns a valid B<X509_ALGOR> structure or NULL if an error
occurred.
-X509_ALGOR_set0() and X509_ALGOR_copy() return 1 on success or 0 on error.
+X509_ALGOR_set0(), X509_ALGOR_set_md(), and X509_ALGOR_copy()
+return 1 on success or 0 on error.
-X509_ALGOR_get0() and X509_ALGOR_set_md() return no values.
+X509_ALGOR_get0() returns no values.
X509_ALGOR_cmp() returns 0 if the two parameters have identical encodings and
nonzero otherwise.
=head1 HISTORY
-The X509_ALGOR_copy() was added in 1.1.1e.
+X509_ALGOR_copy() was added in OpenSSL 1.1.1e.
+
+X509_ALGOR_set_md() returns a value since OpenSSL 4.0.
=head1 COPYRIGHT
void *pval);
void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype,
const void **ppval, const X509_ALGOR *algor);
-void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
+int X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
int X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src);