/*
- * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
ASN1_STRING *seq;
if ((seq = ASN1_STRING_new()) == NULL) {
- PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_PKCS7, ERR_R_ASN1_LIB);
return 0;
}
seq->length = ASN1_item_i2d((ASN1_VALUE *)cap, &seq->data,
ASN1_ITEM_rptr(X509_ALGORS));
- return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,
- V_ASN1_SEQUENCE, seq);
+ if (!PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,
+ V_ASN1_SEQUENCE, seq)) {
+ ASN1_STRING_free(seq);
+ return 0;
+ }
+ return 1;
}
STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si)
X509_ALGOR *alg;
if ((alg = X509_ALGOR_new()) == NULL) {
- PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_PKCS7, ERR_R_ASN1_LIB);
return 0;
}
ASN1_OBJECT_free(alg->algorithm);
alg->algorithm = OBJ_nid2obj(nid);
if (arg > 0) {
if ((alg->parameter = ASN1_TYPE_new()) == NULL) {
+ ERR_raise(ERR_LIB_PKCS7, ERR_R_ASN1_LIB);
goto err;
}
if ((nbit = ASN1_INTEGER_new()) == NULL) {
+ ERR_raise(ERR_LIB_PKCS7, ERR_R_ASN1_LIB);
goto err;
}
if (!ASN1_INTEGER_set(nbit, arg)) {
+ ERR_raise(ERR_LIB_PKCS7, ERR_R_ASN1_LIB);
goto err;
}
alg->parameter->value.integer = nbit;
nbit = NULL;
}
if (!sk_X509_ALGOR_push(sk, alg)) {
+ ERR_raise(ERR_LIB_PKCS7, ERR_R_CRYPTO_LIB);
goto err;
}
return 1;
err:
- PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE);
ASN1_INTEGER_free(nbit);
X509_ALGOR_free(alg);
return 0;
int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t)
{
- if (t == NULL && (t = X509_gmtime_adj(NULL, 0)) == NULL) {
- PKCS7err(PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME,
- ERR_R_MALLOC_FAILURE);
+ ASN1_TIME *tmp = NULL;
+
+ if (t == NULL && (tmp = t = X509_gmtime_adj(NULL, 0)) == NULL) {
+ ERR_raise(ERR_LIB_PKCS7, ERR_R_X509_LIB);
return 0;
}
- return PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime,
- V_ASN1_UTCTIME, t);
+ if (!PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime,
+ V_ASN1_UTCTIME, t)) {
+ ASN1_TIME_free(tmp);
+ return 0;
+ }
+ return 1;
}
int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,