diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2019-08-11 10:38:28 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2019-08-11 10:38:28 +0000 |
commit | 1cbdcf0ad2d3a7b639ca9e956f91432c6cfcf133 (patch) | |
tree | e305cd73c49d4812427e4852267c94bc180dc9f7 /lib | |
parent | f763cb9b53c995e74362718a27d867fd8bf99ac5 (diff) |
Convert CMSerr() to CMSerror().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/cms/cms_cd.c | 11 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_dd.c | 10 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_enc.c | 33 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_env.c | 94 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_ess.c | 41 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_io.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_kari.c | 16 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_lib.c | 39 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_pwri.c | 43 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_sd.c | 67 | ||||
-rw-r--r-- | lib/libcrypto/cms/cms_smime.c | 73 |
11 files changed, 191 insertions, 240 deletions
diff --git a/lib/libcrypto/cms/cms_cd.c b/lib/libcrypto/cms/cms_cd.c index e3e9f78e5b8..752c808c655 100644 --- a/lib/libcrypto/cms/cms_cd.c +++ b/lib/libcrypto/cms/cms_cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_cd.c,v 1.13 2019/08/10 18:15:52 jsing Exp $ */ +/* $OpenBSD: cms_cd.c,v 1.14 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -77,8 +77,7 @@ cms_CompressedData_create(int comp_nid) * compression algorithm or parameters have some meaning... */ if (comp_nid != NID_zlib_compression) { - CMSerr(CMS_F_CMS_COMPRESSEDDATA_CREATE, - CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); + CMSerror(CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); return NULL; } cms = CMS_ContentInfo_new(); @@ -114,15 +113,13 @@ cms_CompressedData_init_bio(CMS_ContentInfo *cms) const ASN1_OBJECT *compoid; if (OBJ_obj2nid(cms->contentType) != NID_id_smime_ct_compressedData) { - CMSerr(CMS_F_CMS_COMPRESSEDDATA_INIT_BIO, - CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA); + CMSerror(CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA); return NULL; } cd = cms->d.compressedData; X509_ALGOR_get0(&compoid, NULL, NULL, cd->compressionAlgorithm); if (OBJ_obj2nid(compoid) != NID_zlib_compression) { - CMSerr(CMS_F_CMS_COMPRESSEDDATA_INIT_BIO, - CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); + CMSerror(CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); return NULL; } return BIO_new(BIO_f_zlib()); diff --git a/lib/libcrypto/cms/cms_dd.c b/lib/libcrypto/cms/cms_dd.c index b9422fab42b..ac2fdbb30fb 100644 --- a/lib/libcrypto/cms/cms_dd.c +++ b/lib/libcrypto/cms/cms_dd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_dd.c,v 1.11 2019/08/10 18:15:52 jsing Exp $ */ +/* $OpenBSD: cms_dd.c,v 1.12 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -113,7 +113,7 @@ cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify) CMS_DigestedData *dd; if (mctx == NULL) { - CMSerr(CMS_F_CMS_DIGESTEDDATA_DO_FINAL, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } @@ -127,14 +127,12 @@ cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify) if (verify) { if (mdlen != (unsigned int)dd->digest->length) { - CMSerr(CMS_F_CMS_DIGESTEDDATA_DO_FINAL, - CMS_R_MESSAGEDIGEST_WRONG_LENGTH); + CMSerror(CMS_R_MESSAGEDIGEST_WRONG_LENGTH); goto err; } if (memcmp(md, dd->digest->data, mdlen)) - CMSerr(CMS_F_CMS_DIGESTEDDATA_DO_FINAL, - CMS_R_VERIFICATION_FAILURE); + CMSerror(CMS_R_VERIFICATION_FAILURE); else r = 1; } else { diff --git a/lib/libcrypto/cms/cms_enc.c b/lib/libcrypto/cms/cms_enc.c index b3a00f67fa7..a04c831f959 100644 --- a/lib/libcrypto/cms/cms_enc.c +++ b/lib/libcrypto/cms/cms_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_enc.c,v 1.14 2019/08/10 18:15:52 jsing Exp $ */ +/* $OpenBSD: cms_enc.c,v 1.15 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -84,7 +84,7 @@ cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) b = BIO_new(BIO_f_cipher()); if (b == NULL) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return NULL; } @@ -101,14 +101,13 @@ cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) ciph = EVP_get_cipherbyobj(calg->algorithm); if (!ciph) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, CMS_R_UNKNOWN_CIPHER); + CMSerror(CMS_R_UNKNOWN_CIPHER); goto err; } } if (EVP_CipherInit_ex(ctx, ciph, NULL, NULL, NULL, enc) <= 0) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, - CMS_R_CIPHER_INITIALISATION_ERROR); + CMSerror(CMS_R_CIPHER_INITIALISATION_ERROR); goto err; } @@ -123,8 +122,7 @@ cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) piv = iv; } } else if (EVP_CIPHER_asn1_to_param(ctx, calg->parameter) <= 0) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, - CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); + CMSerror(CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); goto err; } tkeylen = EVP_CIPHER_CTX_key_length(ctx); @@ -132,7 +130,7 @@ cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) if (!enc || !ec->key) { tkey = OPENSSL_malloc(tkeylen); if (tkey == NULL) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (EVP_CIPHER_CTX_rand_key(ctx, tkey) <= 0) @@ -158,8 +156,7 @@ cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) * which may be useful in MMA. */ if (enc || ec->debug) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, - CMS_R_INVALID_KEY_LENGTH); + CMSerror(CMS_R_INVALID_KEY_LENGTH); goto err; } else { /* Use random key */ @@ -173,19 +170,17 @@ cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) } if (EVP_CipherInit_ex(ctx, NULL, NULL, ec->key, piv, enc) <= 0) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, - CMS_R_CIPHER_INITIALISATION_ERROR); + CMSerror(CMS_R_CIPHER_INITIALISATION_ERROR); goto err; } if (enc) { calg->parameter = ASN1_TYPE_new(); if (calg->parameter == NULL) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (EVP_CIPHER_param_to_asn1(ctx, calg->parameter) <= 0) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, - CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); + CMSerror(CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); goto err; } /* If parameter type not set omit parameter */ @@ -215,7 +210,7 @@ cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec, ec->cipher = cipher; if (key) { if ((ec->key = OPENSSL_malloc(keylen)) == NULL) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } memcpy(ec->key, key, keylen); @@ -234,19 +229,19 @@ CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph, CMS_EncryptedContentInfo *ec; if (!key || !keylen) { - CMSerr(CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY, CMS_R_NO_KEY); + CMSerror(CMS_R_NO_KEY); return 0; } if (ciph) { cms->d.encryptedData = M_ASN1_new_of(CMS_EncryptedData); if (!cms->d.encryptedData) { - CMSerr(CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } cms->contentType = OBJ_nid2obj(NID_pkcs7_encrypted); cms->d.encryptedData->version = 0; } else if (OBJ_obj2nid(cms->contentType) != NID_pkcs7_encrypted) { - CMSerr(CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY, CMS_R_NOT_ENCRYPTED_DATA); + CMSerror(CMS_R_NOT_ENCRYPTED_DATA); return 0; } ec = cms->d.encryptedData->encryptedContentInfo; diff --git a/lib/libcrypto/cms/cms_env.c b/lib/libcrypto/cms/cms_env.c index fbfbdd98caf..d6bf34c02a8 100644 --- a/lib/libcrypto/cms/cms_env.c +++ b/lib/libcrypto/cms/cms_env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_env.c,v 1.16 2019/08/10 18:15:52 jsing Exp $ */ +/* $OpenBSD: cms_env.c,v 1.17 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -69,8 +69,7 @@ CMS_EnvelopedData * cms_get0_enveloped(CMS_ContentInfo *cms) { if (OBJ_obj2nid(cms->contentType) != NID_pkcs7_enveloped) { - CMSerr(CMS_F_CMS_GET0_ENVELOPED, - CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA); + CMSerror(CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA); return NULL; } return cms->d.envelopedData; @@ -82,7 +81,7 @@ cms_enveloped_data_init(CMS_ContentInfo *cms) if (cms->d.other == NULL) { cms->d.envelopedData = M_ASN1_new_of(CMS_EnvelopedData); if (!cms->d.envelopedData) { - CMSerr(CMS_F_CMS_ENVELOPED_DATA_INIT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return NULL; } cms->d.envelopedData->version = 0; @@ -116,12 +115,11 @@ cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd) return 1; i = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_CMS_ENVELOPE, cmd, ri); if (i == -2) { - CMSerr(CMS_F_CMS_ENV_ASN1_CTRL, - CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); + CMSerror(CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); return 0; } if (i <= 0) { - CMSerr(CMS_F_CMS_ENV_ASN1_CTRL, CMS_R_CTRL_FAILURE); + CMSerror(CMS_R_CTRL_FAILURE); return 0; } @@ -177,7 +175,7 @@ CMS_EnvelopedData_create(const EVP_CIPHER *cipher) merr: CMS_ContentInfo_free(cms); - CMSerr(CMS_F_CMS_ENVELOPEDDATA_CREATE, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return NULL; } @@ -255,8 +253,7 @@ CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, unsigned int flags) pk = X509_get0_pubkey(recip); if (!pk) { - CMSerr(CMS_F_CMS_ADD1_RECIPIENT_CERT, - CMS_R_ERROR_GETTING_PUBLIC_KEY); + CMSerror(CMS_R_ERROR_GETTING_PUBLIC_KEY); goto err; } @@ -273,8 +270,7 @@ CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, unsigned int flags) break; default: - CMSerr(CMS_F_CMS_ADD1_RECIPIENT_CERT, - CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); + CMSerror(CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); goto err; } @@ -285,7 +281,7 @@ CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, unsigned int flags) return ri; merr: - CMSerr(CMS_F_CMS_ADD1_RECIPIENT_CERT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); err: M_ASN1_free_of(ri, CMS_RecipientInfo); return NULL; @@ -298,7 +294,7 @@ CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri, EVP_PKEY **pk, CMS_KeyTransRecipientInfo *ktri; if (ri->type != CMS_RECIPINFO_TRANS) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS, CMS_R_NOT_KEY_TRANSPORT); + CMSerror(CMS_R_NOT_KEY_TRANSPORT); return 0; } @@ -321,8 +317,7 @@ CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri, CMS_KeyTransRecipientInfo *ktri; if (ri->type != CMS_RECIPINFO_TRANS) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID, - CMS_R_NOT_KEY_TRANSPORT); + CMSerror(CMS_R_NOT_KEY_TRANSPORT); return 0; } ktri = ri->d.ktri; @@ -334,8 +329,7 @@ int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert) { if (ri->type != CMS_RECIPINFO_TRANS) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP, - CMS_R_NOT_KEY_TRANSPORT); + CMSerror(CMS_R_NOT_KEY_TRANSPORT); return -2; } @@ -346,7 +340,7 @@ int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey) { if (ri->type != CMS_RECIPINFO_TRANS) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_SET0_PKEY, CMS_R_NOT_KEY_TRANSPORT); + CMSerror(CMS_R_NOT_KEY_TRANSPORT); return 0; } EVP_PKEY_free(ri->d.ktri->pkey); @@ -369,7 +363,7 @@ cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) int ret = 0; if (ri->type != CMS_RECIPINFO_TRANS) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT, CMS_R_NOT_KEY_TRANSPORT); + CMSerror(CMS_R_NOT_KEY_TRANSPORT); return 0; } ktri = ri->d.ktri; @@ -391,7 +385,7 @@ cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_CMS_ENCRYPT, 0, ri) <= 0) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT, CMS_R_CTRL_ERROR); + CMSerror(CMS_R_CTRL_ERROR); goto err; } @@ -401,7 +395,7 @@ cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) ek = OPENSSL_malloc(eklen); if (ek == NULL) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } @@ -436,7 +430,7 @@ cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) ec = cms->d.envelopedData->encryptedContentInfo; if (ktri->pkey == NULL) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_NO_PRIVATE_KEY); + CMSerror(CMS_R_NO_PRIVATE_KEY); return 0; } @@ -452,7 +446,7 @@ cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) if (EVP_PKEY_CTX_ctrl(ktri->pctx, -1, EVP_PKEY_OP_DECRYPT, EVP_PKEY_CTRL_CMS_DECRYPT, 0, ri) <= 0) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CTRL_ERROR); + CMSerror(CMS_R_CTRL_ERROR); goto err; } @@ -463,13 +457,13 @@ cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) ek = OPENSSL_malloc(eklen); if (ek == NULL) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen, ktri->encryptedKey->data, ktri->encryptedKey->length) <= 0) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); + CMSerror(CMS_R_CMS_LIB); goto err; } @@ -498,7 +492,7 @@ CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, const unsigned char *id, CMS_KEKRecipientInfo *kekri; if (ri->type != CMS_RECIPINFO_KEK) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP, CMS_R_NOT_KEK); + CMSerror(CMS_R_NOT_KEK); return -2; } kekri = ri->d.kekri; @@ -558,7 +552,7 @@ CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, unsigned char *key, break; default: - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_KEY, CMS_R_INVALID_KEY_LENGTH); + CMSerror(CMS_R_INVALID_KEY_LENGTH); goto err; } @@ -567,13 +561,12 @@ CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, unsigned char *key, size_t exp_keylen = aes_wrap_keylen(nid); if (!exp_keylen) { - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_KEY, - CMS_R_UNSUPPORTED_KEK_ALGORITHM); + CMSerror(CMS_R_UNSUPPORTED_KEK_ALGORITHM); goto err; } if (keylen != exp_keylen) { - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_KEY, CMS_R_INVALID_KEY_LENGTH); + CMSerror(CMS_R_INVALID_KEY_LENGTH); goto err; } @@ -622,7 +615,7 @@ CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, unsigned char *key, return ri; merr: - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_KEY, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); err: M_ASN1_free_of(ri, CMS_RecipientInfo); return NULL; @@ -636,7 +629,7 @@ CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, X509_ALGOR **palg, CMS_KEKIdentifier *rkid; if (ri->type != CMS_RECIPINFO_KEK) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID, CMS_R_NOT_KEK); + CMSerror(CMS_R_NOT_KEK); return 0; } rkid = ri->d.kekri->kekid; @@ -669,7 +662,7 @@ CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, unsigned char *key, CMS_KEKRecipientInfo *kekri; if (ri->type != CMS_RECIPINFO_KEK) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_SET0_KEY, CMS_R_NOT_KEK); + CMSerror(CMS_R_NOT_KEK); return 0; } @@ -695,25 +688,24 @@ cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) kekri = ri->d.kekri; if (!kekri->key) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT, CMS_R_NO_KEY); + CMSerror(CMS_R_NO_KEY); return 0; } if (AES_set_encrypt_key(kekri->key, kekri->keylen << 3, &actx)) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT, - CMS_R_ERROR_SETTING_KEY); + CMSerror(CMS_R_ERROR_SETTING_KEY); goto err; } wkey = OPENSSL_malloc(ec->keylen + 8); if (wkey == NULL) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } wkeylen = AES_wrap_key(&actx, NULL, wkey, ec->key, ec->keylen); if (wkeylen <= 0) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT, CMS_R_WRAP_ERROR); + CMSerror(CMS_R_WRAP_ERROR); goto err; } @@ -745,34 +737,31 @@ cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) kekri = ri->d.kekri; if (!kekri->key) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT, CMS_R_NO_KEY); + CMSerror(CMS_R_NO_KEY); return 0; } wrap_nid = OBJ_obj2nid(kekri->keyEncryptionAlgorithm->algorithm); if (aes_wrap_keylen(wrap_nid) != kekri->keylen) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT, - CMS_R_INVALID_KEY_LENGTH); + CMSerror(CMS_R_INVALID_KEY_LENGTH); return 0; } /* If encrypted key length is invalid don't bother */ if (kekri->encryptedKey->length < 16) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT, - CMS_R_INVALID_ENCRYPTED_KEY_LENGTH); + CMSerror(CMS_R_INVALID_ENCRYPTED_KEY_LENGTH); goto err; } if (AES_set_decrypt_key(kekri->key, kekri->keylen << 3, &actx)) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT, - CMS_R_ERROR_SETTING_KEY); + CMSerror(CMS_R_ERROR_SETTING_KEY); goto err; } ukey = OPENSSL_malloc(kekri->encryptedKey->length - 8); if (ukey == NULL) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } @@ -780,7 +769,7 @@ cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) kekri->encryptedKey->length); if (ukeylen <= 0) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT, CMS_R_UNWRAP_ERROR); + CMSerror(CMS_R_UNWRAP_ERROR); goto err; } @@ -812,8 +801,7 @@ CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) return cms_RecipientInfo_pwri_crypt(cms, ri, 0); default: - CMSerr(CMS_F_CMS_RECIPIENTINFO_DECRYPT, - CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE); + CMSerror(CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE); return 0; } } @@ -835,8 +823,7 @@ CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) return cms_RecipientInfo_pwri_crypt(cms, ri, 1); default: - CMSerr(CMS_F_CMS_RECIPIENTINFO_ENCRYPT, - CMS_R_UNSUPPORTED_RECIPIENT_TYPE); + CMSerror(CMS_R_UNSUPPORTED_RECIPIENT_TYPE); return 0; } } @@ -935,8 +922,7 @@ cms_EnvelopedData_init_bio(CMS_ContentInfo *cms) for (i = 0; i < sk_CMS_RecipientInfo_num(rinfos); i++) { ri = sk_CMS_RecipientInfo_value(rinfos, i); if (CMS_RecipientInfo_encrypt(cms, ri) <= 0) { - CMSerr(CMS_F_CMS_ENVELOPEDDATA_INIT_BIO, - CMS_R_ERROR_SETTING_RECIPIENTINFO); + CMSerror(CMS_R_ERROR_SETTING_RECIPIENTINFO); goto err; } } diff --git a/lib/libcrypto/cms/cms_ess.c b/lib/libcrypto/cms/cms_ess.c index 5f0ab4995be..1d3f092ae8b 100644 --- a/lib/libcrypto/cms/cms_ess.c +++ b/lib/libcrypto/cms/cms_ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_ess.c,v 1.15 2019/08/11 10:15:30 jsing Exp $ */ +/* $OpenBSD: cms_ess.c,v 1.16 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -145,7 +145,7 @@ CMS_ReceiptRequest_create0(unsigned char *id, int idlen, int allorfirst, return rr; merr: - CMSerr(CMS_F_CMS_RECEIPTREQUEST_CREATE0, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); err: CMS_ReceiptRequest_free(rr); @@ -170,7 +170,7 @@ CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr) merr: if (!r) - CMSerr(CMS_F_CMS_ADD1_RECEIPTREQUEST, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); OPENSSL_free(rrder); @@ -225,12 +225,12 @@ cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src) unsigned int diglen; if (!cms_msgSigDigest(src, dig, &diglen)) { - CMSerr(CMS_F_CMS_MSGSIGDIGEST_ADD1, CMS_R_MSGSIGDIGEST_ERROR); + CMSerror(CMS_R_MSGSIGDIGEST_ERROR); return 0; } if (!CMS_signed_add1_attr_by_NID(dest, NID_id_smime_aa_msgSigDigest, V_ASN1_OCTET_STRING, dig, diglen)) { - CMSerr(CMS_F_CMS_MSGSIGDIGEST_ADD1, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } @@ -259,27 +259,27 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) goto err; if (sk_CMS_SignerInfo_num(sis) != 1) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NEED_ONE_SIGNER); + CMSerror(CMS_R_NEED_ONE_SIGNER); goto err; } /* Check receipt content type */ if (OBJ_obj2nid(CMS_get0_eContentType(cms)) != NID_id_smime_ct_receipt) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NOT_A_SIGNED_RECEIPT); + CMSerror(CMS_R_NOT_A_SIGNED_RECEIPT); goto err; } /* Extract and decode receipt content */ pcont = CMS_get0_content(cms); if (!pcont || !*pcont) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_CONTENT); + CMSerror(CMS_R_NO_CONTENT); goto err; } rct = ASN1_item_unpack(*pcont, &CMS_Receipt_it); if (!rct) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_RECEIPT_DECODE_ERROR); + CMSerror(CMS_R_RECEIPT_DECODE_ERROR); goto err; } @@ -292,7 +292,7 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) } if (i == sk_CMS_SignerInfo_num(osis)) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_MATCHING_SIGNATURE); + CMSerror(CMS_R_NO_MATCHING_SIGNATURE); goto err; } @@ -304,23 +304,22 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) OBJ_nid2obj(NID_id_smime_aa_msgSigDigest), -3, V_ASN1_OCTET_STRING); if (!msig) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_MSGSIGDIGEST); + CMSerror(CMS_R_NO_MSGSIGDIGEST); goto err; } if (!cms_msgSigDigest(osi, dig, &diglen)) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_MSGSIGDIGEST_ERROR); + CMSerror(CMS_R_MSGSIGDIGEST_ERROR); goto err; } if (diglen != (unsigned int)msig->length) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_MSGSIGDIGEST_WRONG_LENGTH); + CMSerror(CMS_R_MSGSIGDIGEST_WRONG_LENGTH); goto err; } if (memcmp(dig, msig->data, diglen)) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, - CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE); + CMSerror(CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE); goto err; } @@ -329,27 +328,27 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) octype = CMS_signed_get0_data_by_OBJ(osi, OBJ_nid2obj(NID_pkcs9_contentType), -3, V_ASN1_OBJECT); if (!octype) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_CONTENT_TYPE); + CMSerror(CMS_R_NO_CONTENT_TYPE); goto err; } /* Compare details in receipt request */ if (OBJ_cmp(octype, rct->contentType)) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_CONTENT_TYPE_MISMATCH); + CMSerror(CMS_R_CONTENT_TYPE_MISMATCH); goto err; } /* Get original receipt request details */ if (CMS_get1_ReceiptRequest(osi, &rr) <= 0) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_RECEIPT_REQUEST); + CMSerror(CMS_R_NO_RECEIPT_REQUEST); goto err; } if (ASN1_STRING_cmp(rr->signedContentIdentifier, rct->signedContentIdentifier)) { - CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_CONTENTIDENTIFIER_MISMATCH); + CMSerror(CMS_R_CONTENTIDENTIFIER_MISMATCH); goto err; } @@ -379,7 +378,7 @@ cms_encode_Receipt(CMS_SignerInfo *si) /* Get original receipt request details */ if (CMS_get1_ReceiptRequest(si, &rr) <= 0) { - CMSerr(CMS_F_CMS_ENCODE_RECEIPT, CMS_R_NO_RECEIPT_REQUEST); + CMSerror(CMS_R_NO_RECEIPT_REQUEST); goto err; } @@ -388,7 +387,7 @@ cms_encode_Receipt(CMS_SignerInfo *si) ctype = CMS_signed_get0_data_by_OBJ(si, OBJ_nid2obj(NID_pkcs9_contentType), -3, V_ASN1_OBJECT); if (!ctype) { - CMSerr(CMS_F_CMS_ENCODE_RECEIPT, CMS_R_NO_CONTENT_TYPE); + CMSerror(CMS_R_NO_CONTENT_TYPE); goto err; } diff --git a/lib/libcrypto/cms/cms_io.c b/lib/libcrypto/cms/cms_io.c index 6eba8568675..4466d6acf20 100644 --- a/lib/libcrypto/cms/cms_io.c +++ b/lib/libcrypto/cms/cms_io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_io.c,v 1.10 2019/08/11 10:15:30 jsing Exp $ */ +/* $OpenBSD: cms_io.c,v 1.11 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -75,7 +75,7 @@ CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) *boundary = &(*pos)->data; return 1; } - CMSerr(CMS_F_CMS_STREAM, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } diff --git a/lib/libcrypto/cms/cms_kari.c b/lib/libcrypto/cms/cms_kari.c index 3605baac414..e1f22cc43a2 100644 --- a/lib/libcrypto/cms/cms_kari.c +++ b/lib/libcrypto/cms/cms_kari.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_kari.c,v 1.6 2019/08/10 18:15:52 jsing Exp $ */ +/* $OpenBSD: cms_kari.c,v 1.7 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -69,8 +69,7 @@ CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri, X509_ALGOR **palg, ASN1_OCTET_STRING **pukm) { if (ri->type != CMS_RECIPINFO_AGREE) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG, - CMS_R_NOT_KEY_AGREEMENT); + CMSerror(CMS_R_NOT_KEY_AGREEMENT); return 0; } if (palg) @@ -87,8 +86,7 @@ STACK_OF(CMS_RecipientEncryptedKey) * CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri) { if (ri->type != CMS_RECIPINFO_AGREE) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS, - CMS_R_NOT_KEY_AGREEMENT); + CMSerror(CMS_R_NOT_KEY_AGREEMENT); return NULL; } return ri->d.kari->recipientEncryptedKeys; @@ -102,8 +100,7 @@ CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri, X509_ALGOR **pubalg, CMS_OriginatorIdentifierOrKey *oik; if (ri->type != CMS_RECIPINFO_AGREE) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID, - CMS_R_NOT_KEY_AGREEMENT); + CMSerror(CMS_R_NOT_KEY_AGREEMENT); return 0; } oik = ri->d.kari->originator; @@ -142,8 +139,7 @@ CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert) CMS_OriginatorIdentifierOrKey *oik; if (ri->type != CMS_RECIPINFO_AGREE) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP, - CMS_R_NOT_KEY_AGREEMENT); + CMSerror(CMS_R_NOT_KEY_AGREEMENT); return -2; } oik = ri->d.kari->originator; @@ -439,7 +435,7 @@ cms_RecipientInfo_kari_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) int i; if (ri->type != CMS_RECIPINFO_AGREE) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT, CMS_R_NOT_KEY_AGREEMENT); + CMSerror(CMS_R_NOT_KEY_AGREEMENT); return 0; } kari = ri->d.kari; diff --git a/lib/libcrypto/cms/cms_lib.c b/lib/libcrypto/cms/cms_lib.c index 7f02d6daae8..b022d19d4b2 100644 --- a/lib/libcrypto/cms/cms_lib.c +++ b/lib/libcrypto/cms/cms_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_lib.c,v 1.11 2019/08/11 10:15:30 jsing Exp $ */ +/* $OpenBSD: cms_lib.c,v 1.12 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -144,7 +144,7 @@ CMS_dataInit(CMS_ContentInfo *cms, BIO *icont) else cont = cms_content_bio(cms); if (!cont) { - CMSerr(CMS_F_CMS_DATAINIT, CMS_R_NO_CONTENT); + CMSerror(CMS_R_NO_CONTENT); return NULL; } switch (OBJ_obj2nid(cms->contentType)) { @@ -174,7 +174,7 @@ CMS_dataInit(CMS_ContentInfo *cms, BIO *icont) break; default: - CMSerr(CMS_F_CMS_DATAINIT, CMS_R_UNSUPPORTED_TYPE); + CMSerror(CMS_R_UNSUPPORTED_TYPE); return NULL; } @@ -201,7 +201,7 @@ CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio) long contlen; mbio = BIO_find_type(cmsbio, BIO_TYPE_MEM); if (!mbio) { - CMSerr(CMS_F_CMS_DATAFINAL, CMS_R_CONTENT_NOT_FOUND); + CMSerror(CMS_R_CONTENT_NOT_FOUND); return 0; } contlen = BIO_get_mem_data(mbio, &cont); @@ -228,7 +228,7 @@ CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio) return cms_DigestedData_do_final(cms, cmsbio, 0); default: - CMSerr(CMS_F_CMS_DATAFINAL, CMS_R_UNSUPPORTED_TYPE); + CMSerror(CMS_R_UNSUPPORTED_TYPE); return 0; } } @@ -266,7 +266,7 @@ CMS_get0_content(CMS_ContentInfo *cms) default: if (cms->d.other->type == V_ASN1_OCTET_STRING) return &cms->d.other->value.octet_string; - CMSerr(CMS_F_CMS_GET0_CONTENT, CMS_R_UNSUPPORTED_CONTENT_TYPE); + CMSerror(CMS_R_UNSUPPORTED_CONTENT_TYPE); return NULL; } } @@ -299,7 +299,7 @@ cms_get0_econtent_type(CMS_ContentInfo *cms) return &cms->d.compressedData->encapContentInfo->eContentType; default: - CMSerr(CMS_F_CMS_GET0_ECONTENT_TYPE, CMS_R_UNSUPPORTED_CONTENT_TYPE); + CMSerror(CMS_R_UNSUPPORTED_CONTENT_TYPE); return NULL; } } @@ -371,7 +371,7 @@ CMS_set_detached(CMS_ContentInfo *cms, int detached) (*pos)->flags |= ASN1_STRING_FLAG_CONT; return 1; } - CMSerr(CMS_F_CMS_SET_DETACHED, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } @@ -388,13 +388,12 @@ cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm) X509_ALGOR_get0(&digestoid, NULL, NULL, digestAlgorithm); digest = EVP_get_digestbyobj(digestoid); if (!digest) { - CMSerr(CMS_F_CMS_DIGESTALGORITHM_INIT_BIO, - CMS_R_UNKNOWN_DIGEST_ALGORITHM); + CMSerror(CMS_R_UNKNOWN_DIGEST_ALGORITHM); goto err; } mdbio = BIO_new(BIO_f_md()); if (mdbio == NULL || !BIO_set_md(mdbio, digest)) { - CMSerr(CMS_F_CMS_DIGESTALGORITHM_INIT_BIO, CMS_R_MD_BIO_INIT_ERROR); + CMSerror(CMS_R_MD_BIO_INIT_ERROR); goto err; } return mdbio; @@ -420,8 +419,7 @@ cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain, X509_ALGOR *mdalg) EVP_MD_CTX *mtmp; chain = BIO_find_type(chain, BIO_TYPE_MD); if (chain == NULL) { - CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX, - CMS_R_NO_MATCHING_DIGEST); + CMSerror(CMS_R_NO_MATCHING_DIGEST); return 0; } BIO_get_md_ctx(chain, &mtmp); @@ -449,8 +447,7 @@ cms_get0_certificate_choices(CMS_ContentInfo *cms) return &cms->d.envelopedData->originatorInfo->certificates; default: - CMSerr(CMS_F_CMS_GET0_CERTIFICATE_CHOICES, - CMS_R_UNSUPPORTED_CONTENT_TYPE); + CMSerror(CMS_R_UNSUPPORTED_CONTENT_TYPE); return NULL; } } @@ -493,8 +490,7 @@ CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert) cch = sk_CMS_CertificateChoices_value(*pcerts, i); if (cch->type == CMS_CERTCHOICE_CERT) { if (!X509_cmp(cch->d.certificate, cert)) { - CMSerr(CMS_F_CMS_ADD0_CERT, - CMS_R_CERTIFICATE_ALREADY_PRESENT); + CMSerror(CMS_R_CERTIFICATE_ALREADY_PRESENT); return 0; } } @@ -533,8 +529,7 @@ cms_get0_revocation_choices(CMS_ContentInfo *cms) return &cms->d.envelopedData->originatorInfo->crls; default: - CMSerr(CMS_F_CMS_GET0_REVOCATION_CHOICES, - CMS_R_UNSUPPORTED_CONTENT_TYPE); + CMSerror(CMS_R_UNSUPPORTED_CONTENT_TYPE); return NULL; } } @@ -689,7 +684,7 @@ cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert) err: M_ASN1_free_of(ias, CMS_IssuerAndSerialNumber); - CMSerr(CMS_F_CMS_SET1_IAS, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } @@ -702,12 +697,12 @@ cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert) cert_keyid = X509_get0_subject_key_id(cert); if (cert_keyid == NULL) { - CMSerr(CMS_F_CMS_SET1_KEYID, CMS_R_CERTIFICATE_HAS_NO_KEYID); + CMSerror(CMS_R_CERTIFICATE_HAS_NO_KEYID); return 0; } keyid = ASN1_STRING_dup(cert_keyid); if (!keyid) { - CMSerr(CMS_F_CMS_SET1_KEYID, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } ASN1_OCTET_STRING_free(*pkeyid); diff --git a/lib/libcrypto/cms/cms_pwri.c b/lib/libcrypto/cms/cms_pwri.c index a3251f58b74..dd66541409e 100644 --- a/lib/libcrypto/cms/cms_pwri.c +++ b/lib/libcrypto/cms/cms_pwri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_pwri.c,v 1.19 2019/08/11 10:15:30 jsing Exp $ */ +/* $OpenBSD: cms_pwri.c,v 1.20 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -70,7 +70,7 @@ CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, unsigned char *pass, CMS_PasswordRecipientInfo *pwri; if (ri->type != CMS_RECIPINFO_PASS) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD, CMS_R_NOT_PWRI); + CMSerror(CMS_R_NOT_PWRI); return 0; } @@ -111,12 +111,11 @@ CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, kekciph = env->encryptedContentInfo->cipher; if (kekciph == NULL) { - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_PASSWORD, CMS_R_NO_CIPHER); + CMSerror(CMS_R_NO_CIPHER); return NULL; } if (wrap_nid != NID_id_alg_PWRI_KEK) { - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_PASSWORD, - CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM); + CMSerror(CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM); return NULL; } @@ -128,7 +127,7 @@ CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, ctx = EVP_CIPHER_CTX_new(); if (EVP_EncryptInit_ex(ctx, kekciph, NULL, NULL, NULL) <= 0) { - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_PASSWORD, ERR_R_EVP_LIB); + CMSerror(ERR_R_EVP_LIB); goto err; } @@ -138,17 +137,16 @@ CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, if (RAND_bytes(iv, ivlen) <= 0) goto err; if (EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv) <= 0) { - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_PASSWORD, ERR_R_EVP_LIB); + CMSerror(ERR_R_EVP_LIB); goto err; } encalg->parameter = ASN1_TYPE_new(); if (!encalg->parameter) { - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_PASSWORD, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (EVP_CIPHER_param_to_asn1(ctx, encalg->parameter) <= 0) { - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_PASSWORD, - CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); + CMSerror(CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); goto err; } } @@ -203,7 +201,7 @@ CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, return ri; merr: - CMSerr(CMS_F_CMS_ADD0_RECIPIENT_PASSWORD, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); err: EVP_CIPHER_CTX_free(ctx); if (ri) @@ -235,7 +233,7 @@ kek_unwrap_key(unsigned char *out, size_t *outlen, const unsigned char *in, return 0; } if ((tmp = OPENSSL_malloc(inlen)) == NULL) { - CMSerr(CMS_F_KEK_UNWRAP_KEY, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } @@ -339,14 +337,13 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, pwri = ri->d.pwri; if (!pwri->pass) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, CMS_R_NO_PASSWORD); + CMSerror(CMS_R_NO_PASSWORD); return 0; } algtmp = pwri->keyEncryptionAlgorithm; if (!algtmp || OBJ_obj2nid(algtmp->algorithm) != NID_id_alg_PWRI_KEK) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, - CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM); + CMSerror(CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM); return 0; } @@ -354,20 +351,19 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, algtmp->parameter); if (kekalg == NULL) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, - CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER); + CMSerror(CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER); return 0; } kekcipher = EVP_get_cipherbyobj(kekalg->algorithm); if (!kekcipher) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, CMS_R_UNKNOWN_CIPHER); + CMSerror(CMS_R_UNKNOWN_CIPHER); return 0; } kekctx = EVP_CIPHER_CTX_new(); if (kekctx == NULL) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } /* Fixup cipher based on AlgorithmIdentifier to set IV etc */ @@ -375,8 +371,7 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, goto err; EVP_CIPHER_CTX_set_padding(kekctx, 0); if (EVP_CIPHER_asn1_to_param(kekctx, kekalg->parameter) <= 0) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, - CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); + CMSerror(CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); goto err; } @@ -386,7 +381,7 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, if (EVP_PBE_CipherInit(algtmp->algorithm, (char *)pwri->pass, pwri->passlen, algtmp->parameter, kekctx, en_de) < 0) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, ERR_R_EVP_LIB); + CMSerror(ERR_R_EVP_LIB); goto err; } @@ -407,12 +402,12 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, } else { key = OPENSSL_malloc(pwri->encryptedKey->length); if (key == NULL) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (!kek_unwrap_key(key, &keylen, pwri->encryptedKey->data, pwri->encryptedKey->length, kekctx)) { - CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, CMS_R_UNWRAP_FAILURE); + CMSerror(CMS_R_UNWRAP_FAILURE); goto err; } diff --git a/lib/libcrypto/cms/cms_sd.c b/lib/libcrypto/cms/cms_sd.c index 2289c7e8a31..7072ce7dac7 100644 --- a/lib/libcrypto/cms/cms_sd.c +++ b/lib/libcrypto/cms/cms_sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_sd.c,v 1.18 2019/08/11 10:15:30 jsing Exp $ */ +/* $OpenBSD: cms_sd.c,v 1.19 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -69,7 +69,7 @@ static CMS_SignedData * cms_get0_signed(CMS_ContentInfo *cms) { if (OBJ_obj2nid(cms->contentType) != NID_pkcs7_signed) { - CMSerr(CMS_F_CMS_GET0_SIGNED, CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA); + CMSerror(CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA); return NULL; } return cms->d.signedData; @@ -81,7 +81,7 @@ cms_signed_data_init(CMS_ContentInfo *cms) if (cms->d.other == NULL) { cms->d.signedData = M_ASN1_new_of(CMS_SignedData); if (!cms->d.signedData) { - CMSerr(CMS_F_CMS_SIGNED_DATA_INIT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return NULL; } cms->d.signedData->version = 1; @@ -180,8 +180,7 @@ cms_copy_messageDigest(CMS_ContentInfo *cms, CMS_SignerInfo *si) messageDigest = CMS_signed_get0_data_by_OBJ(sitmp, OBJ_nid2obj(NID_pkcs9_messageDigest), -3, V_ASN1_OCTET_STRING); if (!messageDigest) { - CMSerr(CMS_F_CMS_COPY_MESSAGEDIGEST, - CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE); + CMSerror(CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE); return 0; } @@ -192,7 +191,7 @@ cms_copy_messageDigest(CMS_ContentInfo *cms, CMS_SignerInfo *si) return 0; } - CMSerr(CMS_F_CMS_COPY_MESSAGEDIGEST, CMS_R_NO_MATCHING_DIGEST); + CMSerror(CMS_R_NO_MATCHING_DIGEST); return 0; } @@ -212,7 +211,7 @@ cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert, int type) break; default: - CMSerr(CMS_F_CMS_SET1_SIGNERIDENTIFIER, CMS_R_UNKNOWN_ID); + CMSerror(CMS_R_UNKNOWN_ID); return 0; } @@ -260,11 +259,11 @@ cms_sd_asn1_ctrl(CMS_SignerInfo *si, int cmd) return 1; i = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_CMS_SIGN, cmd, si); if (i == -2) { - CMSerr(CMS_F_CMS_SD_ASN1_CTRL, CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); + CMSerror(CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); return 0; } if (i <= 0) { - CMSerr(CMS_F_CMS_SD_ASN1_CTRL, CMS_R_CTRL_FAILURE); + CMSerror(CMS_R_CTRL_FAILURE); return 0; } @@ -281,8 +280,7 @@ CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer, EVP_PKEY *pk, int i, type; if (!X509_check_private_key(signer, pk)) { - CMSerr(CMS_F_CMS_ADD1_SIGNER, - CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE); + CMSerror(CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE); return NULL; } sd = cms_signed_data_init(cms); @@ -303,7 +301,7 @@ CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer, EVP_PKEY *pk, si->pctx = NULL; if (si->mctx == NULL) { - CMSerr(CMS_F_CMS_ADD1_SIGNER, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } @@ -326,13 +324,13 @@ CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer, EVP_PKEY *pk, goto err; md = EVP_get_digestbynid(def_nid); if (md == NULL) { - CMSerr(CMS_F_CMS_ADD1_SIGNER, CMS_R_NO_DEFAULT_DIGEST); + CMSerror(CMS_R_NO_DEFAULT_DIGEST); goto err; } } if (!md) { - CMSerr(CMS_F_CMS_ADD1_SIGNER, CMS_R_NO_DIGEST_SET); + CMSerror(CMS_R_NO_DIGEST_SET); goto err; } @@ -418,7 +416,7 @@ CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer, EVP_PKEY *pk, return si; merr: - CMSerr(CMS_F_CMS_ADD1_SIGNER, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); err: M_ASN1_free_of(si, CMS_SignerInfo); @@ -449,7 +447,7 @@ cms_add1_signingTime(CMS_SignerInfo *si, ASN1_TIME *t) if (!t) ASN1_TIME_free(tt); if (!r) - CMSerr(CMS_F_CMS_ADD1_SIGNINGTIME, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return r; } @@ -606,12 +604,12 @@ cms_SignerInfo_content_sign(CMS_ContentInfo *cms, CMS_SignerInfo *si, BIO *chain EVP_PKEY_CTX *pctx = NULL; if (mctx == NULL) { - CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return 0; } if (!si->pkey) { - CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, CMS_R_NO_PRIVATE_KEY); + CMSerror(CMS_R_NO_PRIVATE_KEY); goto err; } @@ -654,7 +652,7 @@ cms_SignerInfo_content_sign(CMS_ContentInfo *cms, CMS_SignerInfo *si, BIO *chain siglen = EVP_PKEY_size(si->pkey); sig = OPENSSL_malloc(siglen); if (sig == NULL) { - CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (EVP_PKEY_sign(pctx, sig, &siglen, md, mdlen) <= 0) { @@ -668,11 +666,11 @@ cms_SignerInfo_content_sign(CMS_ContentInfo *cms, CMS_SignerInfo *si, BIO *chain sig = OPENSSL_malloc(EVP_PKEY_size(si->pkey)); if (sig == NULL) { - CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_SignFinal(mctx, sig, &siglen, si->pkey)) { - CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, CMS_R_SIGNFINAL_ERROR); + CMSerror(CMS_R_SIGNFINAL_ERROR); OPENSSL_free(sig); goto err; } @@ -736,7 +734,7 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si) if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_SIGN, EVP_PKEY_CTRL_CMS_SIGN, 0, si) <= 0) { - CMSerr(CMS_F_CMS_SIGNERINFO_SIGN, CMS_R_CTRL_ERROR); + CMSerror(CMS_R_CTRL_ERROR); goto err; } @@ -757,7 +755,7 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si) if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_SIGN, EVP_PKEY_CTRL_CMS_SIGN, 1, si) <= 0) { - CMSerr(CMS_F_CMS_SIGNERINFO_SIGN, CMS_R_CTRL_ERROR); + CMSerror(CMS_R_CTRL_ERROR); goto err; } @@ -783,7 +781,7 @@ CMS_SignerInfo_verify(CMS_SignerInfo *si) const EVP_MD *md = NULL; if (!si->pkey) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY, CMS_R_NO_PUBLIC_KEY); + CMSerror(CMS_R_NO_PUBLIC_KEY); return -1; } @@ -791,7 +789,7 @@ CMS_SignerInfo_verify(CMS_SignerInfo *si) if (md == NULL) return -1; if (si->mctx == NULL && (si->mctx = EVP_MD_CTX_new()) == NULL) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); return -1; } mctx = si->mctx; @@ -815,7 +813,7 @@ CMS_SignerInfo_verify(CMS_SignerInfo *si) r = EVP_DigestVerifyFinal(mctx, si->signature->data, si->signature->length); if (r <= 0) - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY, CMS_R_VERIFICATION_FAILURE); + CMSerror(CMS_R_VERIFICATION_FAILURE); err: EVP_MD_CTX_reset(mctx); @@ -869,7 +867,7 @@ CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain) unsigned int mlen; if (mctx == NULL) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } /* If we have any signed attributes look for messageDigest value */ @@ -878,8 +876,7 @@ CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain) OBJ_nid2obj(NID_pkcs9_messageDigest), -3, V_ASN1_OCTET_STRING); if (!os) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT, - CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE); + CMSerror(CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE); goto err; } } @@ -888,8 +885,7 @@ CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain) goto err; if (EVP_DigestFinal_ex(mctx, mval, &mlen) <= 0) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT, - CMS_R_UNABLE_TO_FINALIZE_CONTEXT); + CMSerror(CMS_R_UNABLE_TO_FINALIZE_CONTEXT); goto err; } @@ -897,14 +893,12 @@ CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain) if (os) { if (mlen != (unsigned int)os->length) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT, - CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH); + CMSerror(CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH); goto err; } if (memcmp(mval, os->data, mlen)) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT, - CMS_R_VERIFICATION_FAILURE); + CMSerror(CMS_R_VERIFICATION_FAILURE); r = 0; } else r = 1; @@ -924,8 +918,7 @@ CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain) r = EVP_PKEY_verify(pkctx, si->signature->data, si->signature->length, mval, mlen); if (r <= 0) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT, - CMS_R_VERIFICATION_FAILURE); + CMSerror(CMS_R_VERIFICATION_FAILURE); r = 0; } } diff --git a/lib/libcrypto/cms/cms_smime.c b/lib/libcrypto/cms/cms_smime.c index 6e546593e7c..2bb3c363c9c 100644 --- a/lib/libcrypto/cms/cms_smime.c +++ b/lib/libcrypto/cms/cms_smime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_smime.c,v 1.21 2019/08/11 06:47:18 jsing Exp $ */ +/* $OpenBSD: cms_smime.c,v 1.22 2019/08/11 10:38:27 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -87,7 +87,7 @@ cms_copy_content(BIO *out, BIO *in, unsigned int flags) tmpout = cms_get_text_bio(out, flags); if (tmpout == NULL) { - CMSerr(CMS_F_CMS_COPY_CONTENT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } @@ -110,7 +110,7 @@ cms_copy_content(BIO *out, BIO *in, unsigned int flags) if (flags & CMS_TEXT) { if (!SMIME_text(tmpout, out)) { - CMSerr(CMS_F_CMS_COPY_CONTENT, CMS_R_SMIME_TEXT_ERROR); + CMSerror(CMS_R_SMIME_TEXT_ERROR); goto err; } } @@ -130,7 +130,7 @@ check_content(CMS_ContentInfo *cms) ASN1_OCTET_STRING **pos = CMS_get0_content(cms); if (!pos || !*pos) { - CMSerr(CMS_F_CHECK_CONTENT, CMS_R_NO_CONTENT); + CMSerror(CMS_R_NO_CONTENT); return 0; } @@ -159,7 +159,7 @@ CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags) int r; if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_pkcs7_data) { - CMSerr(CMS_F_CMS_DATA, CMS_R_TYPE_NOT_DATA); + CMSerror(CMS_R_TYPE_NOT_DATA); return 0; } cont = CMS_dataInit(cms, NULL); @@ -195,7 +195,7 @@ CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out, unsigned int flags int r; if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_pkcs7_digest) { - CMSerr(CMS_F_CMS_DIGEST_VERIFY, CMS_R_TYPE_NOT_DIGESTED_DATA); + CMSerror(CMS_R_TYPE_NOT_DIGESTED_DATA); return 0; } @@ -243,8 +243,7 @@ CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, const unsigned char *key, int r; if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_pkcs7_encrypted) { - CMSerr(CMS_F_CMS_ENCRYPTEDDATA_DECRYPT, - CMS_R_TYPE_NOT_ENCRYPTED_DATA); + CMSerror(CMS_R_TYPE_NOT_ENCRYPTED_DATA); return 0; } @@ -269,7 +268,7 @@ CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, CMS_ContentInfo *cms; if (!cipher) { - CMSerr(CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT, CMS_R_NO_CIPHER); + CMSerror(CMS_R_NO_CIPHER); return NULL; } cms = CMS_ContentInfo_new(); @@ -299,12 +298,12 @@ cms_signerinfo_verify_cert(CMS_SignerInfo *si, X509_STORE *store, int i, j, r = 0; if (ctx == NULL) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CERT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } CMS_SignerInfo_get0_algs(si, NULL, &signer, NULL, NULL); if (!X509_STORE_CTX_init(ctx, store, signer, certs)) { - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CERT, CMS_R_STORE_INIT_ERROR); + CMSerror(CMS_R_STORE_INIT_ERROR); goto err; } X509_STORE_CTX_set_default(ctx, "smime_sign"); @@ -314,8 +313,7 @@ cms_signerinfo_verify_cert(CMS_SignerInfo *si, X509_STORE *store, i = X509_verify_cert(ctx); if (i <= 0) { j = X509_STORE_CTX_get_error(ctx); - CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CERT, - CMS_R_CERTIFICATE_VERIFY_ERROR); + CMSerror(CMS_R_CERTIFICATE_VERIFY_ERROR); ERR_add_error_data(2, "Verify error:", X509_verify_cert_error_string(j)); goto err; @@ -352,7 +350,7 @@ CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store, sinfos = CMS_get0_SignerInfos(cms); if (sk_CMS_SignerInfo_num(sinfos) <= 0) { - CMSerr(CMS_F_CMS_VERIFY, CMS_R_NO_SIGNERS); + CMSerror(CMS_R_NO_SIGNERS); goto err; } @@ -367,7 +365,7 @@ CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store, scount += CMS_set1_signers_certs(cms, certs, flags); if (scount != sk_CMS_SignerInfo_num(sinfos)) { - CMSerr(CMS_F_CMS_VERIFY, CMS_R_SIGNER_CERTIFICATE_NOT_FOUND); + CMSerror(CMS_R_SIGNER_CERTIFICATE_NOT_FOUND); goto err; } @@ -410,7 +408,7 @@ CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store, len = BIO_get_mem_data(dcont, &ptr); tmpin = BIO_new_mem_buf(ptr, len); if (tmpin == NULL) { - CMSerr(CMS_F_CMS_VERIFY, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err2; } } else @@ -427,7 +425,7 @@ CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store, */ tmpout = cms_get_text_bio(out, flags); if (!tmpout) { - CMSerr(CMS_F_CMS_VERIFY, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); goto err; } cmsbio = CMS_dataInit(cms, tmpout); @@ -441,7 +439,7 @@ CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store, if (flags & CMS_TEXT) { if (!SMIME_text(tmpout, out)) { - CMSerr(CMS_F_CMS_VERIFY, CMS_R_SMIME_TEXT_ERROR); + CMSerror(CMS_R_SMIME_TEXT_ERROR); goto err; } } @@ -458,7 +456,7 @@ CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store, for (i = 0; i < sk_CMS_SignerInfo_num(sinfos); i++) { si = sk_CMS_SignerInfo_value(sinfos, i); if (CMS_SignerInfo_verify_content(si, cmsbio) <= 0) { - CMSerr(CMS_F_CMS_VERIFY, CMS_R_CONTENT_VERIFY_ERROR); + CMSerror(CMS_R_CONTENT_VERIFY_ERROR); goto err; } } @@ -517,7 +515,7 @@ CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, goto err; if (pkey && !CMS_add1_signer(cms, signcert, pkey, NULL, flags)) { - CMSerr(CMS_F_CMS_SIGN, CMS_R_ADD_SIGNER_ERROR); + CMSerror(CMS_R_ADD_SIGNER_ERROR); goto err; } @@ -537,7 +535,7 @@ CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, goto err; merr: - CMSerr(CMS_F_CMS_SIGN, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); err: CMS_ContentInfo_free(cms); @@ -559,7 +557,7 @@ CMS_sign_receipt(CMS_SignerInfo *si, X509 *signcert, EVP_PKEY *pkey, /* Not really detached but avoids content being allocated */ flags |= CMS_PARTIAL | CMS_BINARY | CMS_DETACHED; if (!pkey || !signcert) { - CMSerr(CMS_F_CMS_SIGN_RECEIPT, CMS_R_NO_KEY_OR_CERT); + CMSerror(CMS_R_NO_KEY_OR_CERT); return NULL; } @@ -575,7 +573,7 @@ CMS_sign_receipt(CMS_SignerInfo *si, X509 *signcert, EVP_PKEY *pkey, rct_si = CMS_add1_signer(cms, signcert, pkey, NULL, flags); if (!rct_si) { - CMSerr(CMS_F_CMS_SIGN_RECEIPT, CMS_R_ADD_SIGNER_ERROR); + CMSerror(CMS_R_ADD_SIGNER_ERROR); goto err; } @@ -626,7 +624,7 @@ CMS_encrypt(STACK_OF(X509) *certs, BIO *data, const EVP_CIPHER *cipher, for (i = 0; i < sk_X509_num(certs); i++) { recip = sk_X509_value(certs, i); if (!CMS_add1_recipient_cert(cms, recip, flags)) { - CMSerr(CMS_F_CMS_ENCRYPT, CMS_R_RECIPIENT_ERROR); + CMSerror(CMS_R_RECIPIENT_ERROR); goto err; } } @@ -641,7 +639,7 @@ CMS_encrypt(STACK_OF(X509) *certs, BIO *data, const EVP_CIPHER *cipher, goto err; merr: - CMSerr(CMS_F_CMS_ENCRYPT, ERR_R_MALLOC_FAILURE); + CMSerror(ERR_R_MALLOC_FAILURE); err: CMS_ContentInfo_free(cms); @@ -687,8 +685,7 @@ CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert) debug = cms->d.envelopedData->encryptedContentInfo->debug; ri_type = cms_pkey_get_ri_type(pk); if (ri_type == CMS_RECIPINFO_NONE) { - CMSerr(CMS_F_CMS_DECRYPT_SET1_PKEY, - CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); + CMSerror(CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); return 0; } @@ -724,7 +721,7 @@ CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert) } if (r > 0) return 1; - CMSerr(CMS_F_CMS_DECRYPT_SET1_PKEY, CMS_R_DECRYPT_ERROR); + CMSerror(CMS_R_DECRYPT_ERROR); return 0; } /* @@ -742,7 +739,7 @@ CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert) return 1; } - CMSerr(CMS_F_CMS_DECRYPT_SET1_PKEY, CMS_R_NO_MATCHING_RECIPIENT); + CMSerror(CMS_R_NO_MATCHING_RECIPIENT); return 0; } @@ -772,14 +769,14 @@ CMS_decrypt_set1_key(CMS_ContentInfo *cms, unsigned char *key, size_t keylen, if (r > 0) return 1; if (id) { - CMSerr(CMS_F_CMS_DECRYPT_SET1_KEY, CMS_R_DECRYPT_ERROR); + CMSerror(CMS_R_DECRYPT_ERROR); return 0; } ERR_clear_error(); } } - CMSerr(CMS_F_CMS_DECRYPT_SET1_KEY, CMS_R_NO_MATCHING_RECIPIENT); + CMSerror(CMS_R_NO_MATCHING_RECIPIENT); return 0; } @@ -804,7 +801,7 @@ CMS_decrypt_set1_password(CMS_ContentInfo *cms, unsigned char *pass, return 1; } - CMSerr(CMS_F_CMS_DECRYPT_SET1_PASSWORD, CMS_R_NO_MATCHING_RECIPIENT); + CMSerror(CMS_R_NO_MATCHING_RECIPIENT); return 0; } @@ -817,7 +814,7 @@ CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert, BIO *dcont, BIO *cont; if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_pkcs7_enveloped) { - CMSerr(CMS_F_CMS_DECRYPT, CMS_R_TYPE_NOT_ENVELOPED_DATA); + CMSerror(CMS_R_TYPE_NOT_ENVELOPED_DATA); return 0; } if (!dcont && !check_content(cms)) @@ -846,7 +843,7 @@ CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags) int ret = 0; if ((cmsbio = CMS_dataInit(cms, dcont)) == NULL) { - CMSerr(CMS_F_CMS_FINAL, CMS_R_CMS_LIB); + CMSerror(CMS_R_CMS_LIB); return 0; } @@ -855,7 +852,7 @@ CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags) (void)BIO_flush(cmsbio); if (!CMS_dataFinal(cms, cmsbio)) { - CMSerr(CMS_F_CMS_FINAL, CMS_R_CMS_DATAFINAL_ERROR); + CMSerror(CMS_R_CMS_DATAFINAL_ERROR); goto err; } @@ -876,7 +873,7 @@ CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, unsigned int flags) int r; if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_id_smime_ct_compressedData) { - CMSerr(CMS_F_CMS_UNCOMPRESS, CMS_R_TYPE_NOT_COMPRESSED_DATA); + CMSerror(CMS_R_TYPE_NOT_COMPRESSED_DATA); return 0; } @@ -919,14 +916,14 @@ CMS_compress(BIO *in, int comp_nid, unsigned int flags) int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, unsigned int flags) { - CMSerr(CMS_F_CMS_UNCOMPRESS, CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); + CMSerror(CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); return 0; } CMS_ContentInfo * CMS_compress(BIO *in, int comp_nid, unsigned int flags) { - CMSerr(CMS_F_CMS_COMPRESS, CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); + CMSerror(CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); return NULL; } |