diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2017-01-29 17:49:24 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2017-01-29 17:49:24 +0000 |
commit | c95f3b2c0c39020aafaffd84899a33ece0210769 (patch) | |
tree | 6d6e55f6c8b4047319196f43823ad30170dfe061 /lib/libcrypto/pkcs12 | |
parent | b8dd3a8e12bfab2c15794994bc5bdc1397125536 (diff) |
Send the function codes from the error functions to the bit bucket,
as was done earlier in libssl. Thanks inoguchi@ for noticing
libssl had more reacharounds into this.
ok jsing@ inoguchi@
Diffstat (limited to 'lib/libcrypto/pkcs12')
-rw-r--r-- | lib/libcrypto/pkcs12/p12_add.c | 40 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_crpt.c | 12 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_crt.c | 5 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_decr.c | 27 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_init.c | 9 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_key.c | 6 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_kiss.c | 14 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_mutl.c | 35 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_npas.c | 9 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_p8e.c | 8 |
10 files changed, 69 insertions, 96 deletions
diff --git a/lib/libcrypto/pkcs12/p12_add.c b/lib/libcrypto/pkcs12/p12_add.c index 954ca03ebbf..5642a141f53 100644 --- a/lib/libcrypto/pkcs12/p12_add.c +++ b/lib/libcrypto/pkcs12/p12_add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_add.c,v 1.14 2016/12/30 15:34:35 jsing Exp $ */ +/* $OpenBSD: p12_add.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -70,20 +70,17 @@ PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, int nid2) PKCS12_SAFEBAG *safebag; if (!(bag = PKCS12_BAGS_new())) { - PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, - ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return NULL; } bag->type = OBJ_nid2obj(nid1); if (!ASN1_item_pack(obj, it, &bag->value.octet)) { - PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, - ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); PKCS12_BAGS_free(bag); return NULL; } if (!(safebag = PKCS12_SAFEBAG_new())) { - PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, - ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); PKCS12_BAGS_free(bag); return NULL; } @@ -100,7 +97,7 @@ PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8) PKCS12_SAFEBAG *bag; if (!(bag = PKCS12_SAFEBAG_new())) { - PKCS12err(PKCS12_F_PKCS12_MAKE_KEYBAG, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return NULL; } bag->type = OBJ_nid2obj(NID_keyBag); @@ -119,7 +116,7 @@ PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, int passlen, /* Set up the safe bag */ if (!(bag = PKCS12_SAFEBAG_new())) { - PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return NULL; } @@ -132,7 +129,7 @@ PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, int passlen, if (!(bag->value.shkeybag = PKCS8_encrypt(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter, p8))) { - PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); PKCS12_SAFEBAG_free(bag); return NULL; } @@ -147,18 +144,17 @@ PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk) PKCS7 *p7; if (!(p7 = PKCS7_new())) { - PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return NULL; } p7->type = OBJ_nid2obj(NID_pkcs7_data); if (!(p7->d.data = ASN1_OCTET_STRING_new())) { - PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); goto err; } if (!ASN1_item_pack(sk, &PKCS12_SAFEBAGS_it, &p7->d.data)) { - PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, - PKCS12_R_CANT_PACK_STRUCTURE); + PKCS12error(PKCS12_R_CANT_PACK_STRUCTURE); goto err; } return p7; @@ -173,8 +169,7 @@ STACK_OF(PKCS12_SAFEBAG) * PKCS12_unpack_p7data(PKCS7 *p7) { if (!PKCS7_type_is_data(p7)) { - PKCS12err(PKCS12_F_PKCS12_UNPACK_P7DATA, - PKCS12_R_CONTENT_TYPE_NOT_DATA); + PKCS12error(PKCS12_R_CONTENT_TYPE_NOT_DATA); return NULL; } return ASN1_item_unpack(p7->d.data, &PKCS12_SAFEBAGS_it); @@ -191,12 +186,11 @@ PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, const EVP_CIPHER *pbe_ciph; if (!(p7 = PKCS7_new())) { - PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return NULL; } if (!PKCS7_set_type(p7, NID_pkcs7_encrypted)) { - PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, - PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE); + PKCS12error(PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE); goto err; } @@ -208,7 +202,7 @@ PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen); if (!pbe) { - PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); goto err; } X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm); @@ -216,8 +210,7 @@ PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data); if (!(p7->d.encrypted->enc_data->enc_data = PKCS12_item_i2d_encrypt( pbe, &PKCS12_SAFEBAGS_it, pass, passlen, bags, 1))) { - PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, - PKCS12_R_ENCRYPT_ERROR); + PKCS12error(PKCS12_R_ENCRYPT_ERROR); goto err; } @@ -257,8 +250,7 @@ STACK_OF(PKCS7) * PKCS12_unpack_authsafes(PKCS12 *p12) { if (!PKCS7_type_is_data(p12->authsafes)) { - PKCS12err(PKCS12_F_PKCS12_UNPACK_AUTHSAFES, - PKCS12_R_CONTENT_TYPE_NOT_DATA); + PKCS12error(PKCS12_R_CONTENT_TYPE_NOT_DATA); return NULL; } return ASN1_item_unpack(p12->authsafes->d.data, diff --git a/lib/libcrypto/pkcs12/p12_crpt.c b/lib/libcrypto/pkcs12/p12_crpt.c index f2d635fc623..d1f7d71fd3a 100644 --- a/lib/libcrypto/pkcs12/p12_crpt.c +++ b/lib/libcrypto/pkcs12/p12_crpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_crpt.c,v 1.13 2016/11/08 20:01:06 miod Exp $ */ +/* $OpenBSD: p12_crpt.c,v 1.14 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -82,20 +82,20 @@ PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, /* Extract useful info from parameter */ if (param == NULL || param->type != V_ASN1_SEQUENCE || param->value.sequence == NULL) { - PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR); + PKCS12error(PKCS12_R_DECODE_ERROR); return 0; } pbuf = param->value.sequence->data; if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) { - PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR); + PKCS12error(PKCS12_R_DECODE_ERROR); return 0; } if (!pbe->iter) iter = 1; else if ((iter = ASN1_INTEGER_get(pbe->iter)) <= 0) { - PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR); + PKCS12error(PKCS12_R_DECODE_ERROR); PBEPARAM_free(pbe); return 0; } @@ -103,13 +103,13 @@ PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, saltlen = pbe->salt->length; if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_KEY_ID, iter, EVP_CIPHER_key_length(cipher), key, md)) { - PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_KEY_GEN_ERROR); + PKCS12error(PKCS12_R_KEY_GEN_ERROR); PBEPARAM_free(pbe); return 0; } if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_IV_ID, iter, EVP_CIPHER_iv_length(cipher), iv, md)) { - PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_IV_GEN_ERROR); + PKCS12error(PKCS12_R_IV_GEN_ERROR); PBEPARAM_free(pbe); return 0; } diff --git a/lib/libcrypto/pkcs12/p12_crt.c b/lib/libcrypto/pkcs12/p12_crt.c index bef4d54cd9f..af2c6afc37e 100644 --- a/lib/libcrypto/pkcs12/p12_crt.c +++ b/lib/libcrypto/pkcs12/p12_crt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_crt.c,v 1.16 2015/02/14 12:43:07 miod Exp $ */ +/* $OpenBSD: p12_crt.c,v 1.17 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -104,8 +104,7 @@ PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, mac_iter = 1; if (!pkey && !cert && !ca) { - PKCS12err(PKCS12_F_PKCS12_CREATE, - PKCS12_R_INVALID_NULL_ARGUMENT); + PKCS12error(PKCS12_R_INVALID_NULL_ARGUMENT); return NULL; } diff --git a/lib/libcrypto/pkcs12/p12_decr.c b/lib/libcrypto/pkcs12/p12_decr.c index ad4e0bc6605..ca08ee55d54 100644 --- a/lib/libcrypto/pkcs12/p12_decr.c +++ b/lib/libcrypto/pkcs12/p12_decr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_decr.c,v 1.17 2015/09/30 18:41:06 jsing Exp $ */ +/* $OpenBSD: p12_decr.c,v 1.18 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -79,20 +79,19 @@ PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, int passlen, if (!EVP_PBE_CipherInit(algor->algorithm, pass, passlen, algor->parameter, &ctx, en_de)) { out = NULL; - PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, - PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR); + PKCS12error(PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR); goto err; } if (!(out = malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))) { - PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_CipherUpdate(&ctx, out, &i, in, inlen)) { free(out); out = NULL; - PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_EVP_LIB); + PKCS12error(ERR_R_EVP_LIB); goto err; } @@ -100,8 +99,7 @@ PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, int passlen, if (!EVP_CipherFinal_ex(&ctx, out + i, &i)) { free(out); out = NULL; - PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, - PKCS12_R_PKCS12_CIPHERFINAL_ERROR); + PKCS12error(PKCS12_R_PKCS12_CIPHERFINAL_ERROR); goto err; } outlen += i; @@ -131,8 +129,7 @@ PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, if (!PKCS12_pbe_crypt(algor, pass, passlen, oct->data, oct->length, &out, &outlen, 0)) { - PKCS12err(PKCS12_F_PKCS12_ITEM_DECRYPT_D2I, - PKCS12_R_PKCS12_PBE_CRYPT_ERROR); + PKCS12error(PKCS12_R_PKCS12_PBE_CRYPT_ERROR); return NULL; } p = out; @@ -140,8 +137,7 @@ PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, if (zbuf) explicit_bzero(out, outlen); if (!ret) - PKCS12err(PKCS12_F_PKCS12_ITEM_DECRYPT_D2I, - PKCS12_R_DECODE_ERROR); + PKCS12error(PKCS12_R_DECODE_ERROR); free(out); return ret; } @@ -160,20 +156,17 @@ PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, int inlen; if (!(oct = ASN1_OCTET_STRING_new ())) { - PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, - ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return NULL; } inlen = ASN1_item_i2d(obj, &in, it); if (!in) { - PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, - PKCS12_R_ENCODE_ERROR); + PKCS12error(PKCS12_R_ENCODE_ERROR); goto err; } if (!PKCS12_pbe_crypt(algor, pass, passlen, in, inlen, &oct->data, &oct->length, 1)) { - PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, - PKCS12_R_ENCRYPT_ERROR); + PKCS12error(PKCS12_R_ENCRYPT_ERROR); goto err; } if (zbuf) diff --git a/lib/libcrypto/pkcs12/p12_init.c b/lib/libcrypto/pkcs12/p12_init.c index cd01196b6fc..637c430bf47 100644 --- a/lib/libcrypto/pkcs12/p12_init.c +++ b/lib/libcrypto/pkcs12/p12_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_init.c,v 1.10 2015/09/30 18:41:06 jsing Exp $ */ +/* $OpenBSD: p12_init.c,v 1.11 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -69,7 +69,7 @@ PKCS12_init(int mode) PKCS12 *pkcs12; if (!(pkcs12 = PKCS12_new())) { - PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return NULL; } ASN1_INTEGER_set(pkcs12->version, 3); @@ -78,13 +78,12 @@ PKCS12_init(int mode) case NID_pkcs7_data: if (!(pkcs12->authsafes->d.data = ASN1_OCTET_STRING_new())) { - PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); goto err; } break; default: - PKCS12err(PKCS12_F_PKCS12_INIT, - PKCS12_R_UNSUPPORTED_PKCS12_MODE); + PKCS12error(PKCS12_R_UNSUPPORTED_PKCS12_MODE); goto err; } diff --git a/lib/libcrypto/pkcs12/p12_key.c b/lib/libcrypto/pkcs12/p12_key.c index 891f764c232..fd710771a54 100644 --- a/lib/libcrypto/pkcs12/p12_key.c +++ b/lib/libcrypto/pkcs12/p12_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_key.c,v 1.24 2016/11/05 13:02:34 miod Exp $ */ +/* $OpenBSD: p12_key.c,v 1.25 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -81,7 +81,7 @@ PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, unipass = NULL; uniplen = 0; } else if (!OPENSSL_asc2uni(pass, passlen, &unipass, &uniplen)) { - PKCS12err(PKCS12_F_PKCS12_KEY_GEN_ASC, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return 0; } ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, @@ -186,7 +186,7 @@ PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, } err: - PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); end: free(Ai); diff --git a/lib/libcrypto/pkcs12/p12_kiss.c b/lib/libcrypto/pkcs12/p12_kiss.c index eb2c3a76d52..102ca3563bd 100644 --- a/lib/libcrypto/pkcs12/p12_kiss.c +++ b/lib/libcrypto/pkcs12/p12_kiss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_kiss.c,v 1.18 2016/12/30 15:08:22 jsing Exp $ */ +/* $OpenBSD: p12_kiss.c,v 1.19 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -87,8 +87,7 @@ PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, /* Check for NULL PKCS12 structure */ if (!p12) { - PKCS12err(PKCS12_F_PKCS12_PARSE, - PKCS12_R_INVALID_NULL_PKCS12_POINTER); + PKCS12error(PKCS12_R_INVALID_NULL_PKCS12_POINTER); return 0; } @@ -111,24 +110,23 @@ PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, else if (PKCS12_verify_mac(p12, "", 0)) pass = ""; else { - PKCS12err(PKCS12_F_PKCS12_PARSE, - PKCS12_R_MAC_VERIFY_FAILURE); + PKCS12error(PKCS12_R_MAC_VERIFY_FAILURE); goto err; } } else if (!PKCS12_verify_mac(p12, pass, -1)) { - PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_MAC_VERIFY_FAILURE); + PKCS12error(PKCS12_R_MAC_VERIFY_FAILURE); goto err; } /* Allocate stack for other certificates */ ocerts = sk_X509_new_null(); if (!ocerts) { - PKCS12err(PKCS12_F_PKCS12_PARSE, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return 0; } if (!parse_pk12 (p12, pass, -1, pkey, ocerts)) { - PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_PARSE_ERROR); + PKCS12error(PKCS12_R_PARSE_ERROR); goto err; } diff --git a/lib/libcrypto/pkcs12/p12_mutl.c b/lib/libcrypto/pkcs12/p12_mutl.c index 56a4964a343..f3132ec75f6 100644 --- a/lib/libcrypto/pkcs12/p12_mutl.c +++ b/lib/libcrypto/pkcs12/p12_mutl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_mutl.c,v 1.22 2016/11/08 20:01:06 miod Exp $ */ +/* $OpenBSD: p12_mutl.c,v 1.23 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -80,8 +80,7 @@ PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, int md_size; if (!PKCS7_type_is_data(p12->authsafes)) { - PKCS12err(PKCS12_F_PKCS12_GEN_MAC, - PKCS12_R_CONTENT_TYPE_NOT_DATA); + PKCS12error(PKCS12_R_CONTENT_TYPE_NOT_DATA); return 0; } @@ -90,13 +89,12 @@ PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, if (!p12->mac->iter) iter = 1; else if ((iter = ASN1_INTEGER_get(p12->mac->iter)) <= 0) { - PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_DECODE_ERROR); + PKCS12error(PKCS12_R_DECODE_ERROR); return 0; } if (!(md_type = EVP_get_digestbyobj( p12->mac->dinfo->algor->algorithm))) { - PKCS12err(PKCS12_F_PKCS12_GEN_MAC, - PKCS12_R_UNKNOWN_DIGEST_ALGORITHM); + PKCS12error(PKCS12_R_UNKNOWN_DIGEST_ALGORITHM); return 0; } md_size = EVP_MD_size(md_type); @@ -104,7 +102,7 @@ PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, return 0; if (!PKCS12_key_gen(pass, passlen, salt, saltlen, PKCS12_MAC_ID, iter, md_size, key, md_type)) { - PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_KEY_GEN_ERROR); + PKCS12error(PKCS12_R_KEY_GEN_ERROR); return 0; } HMAC_CTX_init(&hmac); @@ -127,12 +125,11 @@ PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen) unsigned int maclen; if (p12->mac == NULL) { - PKCS12err(PKCS12_F_PKCS12_VERIFY_MAC, PKCS12_R_MAC_ABSENT); + PKCS12error(PKCS12_R_MAC_ABSENT); return 0; } if (!PKCS12_gen_mac(p12, pass, passlen, mac, &maclen)) { - PKCS12err(PKCS12_F_PKCS12_VERIFY_MAC, - PKCS12_R_MAC_GENERATION_ERROR); + PKCS12error(PKCS12_R_MAC_GENERATION_ERROR); return 0; } if ((maclen != (unsigned int)p12->mac->dinfo->digest->length) || @@ -154,17 +151,15 @@ PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, unsigned char *salt, md_type = EVP_sha1(); if (PKCS12_setup_mac(p12, iter, salt, saltlen, md_type) == PKCS12_ERROR) { - PKCS12err(PKCS12_F_PKCS12_SET_MAC, PKCS12_R_MAC_SETUP_ERROR); + PKCS12error(PKCS12_R_MAC_SETUP_ERROR); return 0; } if (!PKCS12_gen_mac(p12, pass, passlen, mac, &maclen)) { - PKCS12err(PKCS12_F_PKCS12_SET_MAC, - PKCS12_R_MAC_GENERATION_ERROR); + PKCS12error(PKCS12_R_MAC_GENERATION_ERROR); return 0; } if (!(ASN1_STRING_set(p12->mac->dinfo->digest, mac, maclen))) { - PKCS12err(PKCS12_F_PKCS12_SET_MAC, - PKCS12_R_MAC_STRING_SET_ERROR); + PKCS12error(PKCS12_R_MAC_STRING_SET_ERROR); return 0; } return 1; @@ -179,20 +174,18 @@ PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, return PKCS12_ERROR; if (iter > 1) { if (!(p12->mac->iter = ASN1_INTEGER_new())) { - PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, - ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return 0; } if (!ASN1_INTEGER_set(p12->mac->iter, iter)) { - PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, - ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return 0; } } if (!saltlen) saltlen = PKCS12_SALT_LEN; if (!(p12->mac->salt->data = malloc(saltlen))) { - PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return 0; } p12->mac->salt->length = saltlen; @@ -202,7 +195,7 @@ PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, memcpy (p12->mac->salt->data, salt, saltlen); p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type)); if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) { - PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); return 0; } p12->mac->dinfo->algor->parameter->type = V_ASN1_NULL; diff --git a/lib/libcrypto/pkcs12/p12_npas.c b/lib/libcrypto/pkcs12/p12_npas.c index 7803721a268..63b3df17ada 100644 --- a/lib/libcrypto/pkcs12/p12_npas.c +++ b/lib/libcrypto/pkcs12/p12_npas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_npas.c,v 1.11 2016/12/30 15:08:22 jsing Exp $ */ +/* $OpenBSD: p12_npas.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -81,20 +81,19 @@ PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass) /* Check for NULL PKCS12 structure */ if (!p12) { - PKCS12err(PKCS12_F_PKCS12_NEWPASS, - PKCS12_R_INVALID_NULL_PKCS12_POINTER); + PKCS12error(PKCS12_R_INVALID_NULL_PKCS12_POINTER); return 0; } /* Check the mac */ if (!PKCS12_verify_mac(p12, oldpass, -1)) { - PKCS12err(PKCS12_F_PKCS12_NEWPASS, PKCS12_R_MAC_VERIFY_FAILURE); + PKCS12error(PKCS12_R_MAC_VERIFY_FAILURE); return 0; } if (!newpass_p12(p12, oldpass, newpass)) { - PKCS12err(PKCS12_F_PKCS12_NEWPASS, PKCS12_R_PARSE_ERROR); + PKCS12error(PKCS12_R_PARSE_ERROR); return 0; } diff --git a/lib/libcrypto/pkcs12/p12_p8e.c b/lib/libcrypto/pkcs12/p12_p8e.c index e39d5975d50..5e3fc6486a8 100644 --- a/lib/libcrypto/pkcs12/p12_p8e.c +++ b/lib/libcrypto/pkcs12/p12_p8e.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_p8e.c,v 1.7 2016/12/30 15:34:35 jsing Exp $ */ +/* $OpenBSD: p12_p8e.c,v 1.8 2017/01/29 17:49:23 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -70,7 +70,7 @@ PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, X509_ALGOR *pbe; if (!(p8 = X509_SIG_new())) { - PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE); + PKCS12error(ERR_R_MALLOC_FAILURE); goto err; } @@ -79,7 +79,7 @@ PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen); if (!pbe) { - PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB); + PKCS12error(ERR_R_ASN1_LIB); goto err; } X509_ALGOR_free(p8->algor); @@ -88,7 +88,7 @@ PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, p8->digest = PKCS12_item_i2d_encrypt(pbe, &PKCS8_PRIV_KEY_INFO_it, pass, passlen, p8inf, 1); if (!p8->digest) { - PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR); + PKCS12error(PKCS12_R_ENCRYPT_ERROR); goto err; } |