From 957b11334a7afb14537322f0e4795b2e368b3f59 Mon Sep 17 00:00:00 2001 From: beck <> Date: Sun, 29 Jan 2017 17:49:23 +0000 Subject: 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@ --- src/lib/libcrypto/asn1/a_bitstr.c | 6 +- src/lib/libcrypto/asn1/a_bool.c | 4 +- src/lib/libcrypto/asn1/a_bytes.c | 8 +- src/lib/libcrypto/asn1/a_d2i_fp.c | 33 ++++----- src/lib/libcrypto/asn1/a_dup.c | 6 +- src/lib/libcrypto/asn1/a_enum.c | 10 +-- src/lib/libcrypto/asn1/a_i2d_fp.c | 10 +-- src/lib/libcrypto/asn1/a_int.c | 14 ++-- src/lib/libcrypto/asn1/a_mbstr.c | 30 +++----- src/lib/libcrypto/asn1/a_object.c | 29 +++----- src/lib/libcrypto/asn1/a_set.c | 17 ++--- src/lib/libcrypto/asn1/a_sign.c | 14 ++-- src/lib/libcrypto/asn1/a_strnid.c | 10 +-- src/lib/libcrypto/asn1/a_time_tm.c | 5 +- src/lib/libcrypto/asn1/a_verify.c | 27 +++---- src/lib/libcrypto/asn1/asn1_err.c | 124 +------------------------------ src/lib/libcrypto/asn1/asn1_gen.c | 76 +++++++++---------- src/lib/libcrypto/asn1/asn1_lib.c | 10 +-- src/lib/libcrypto/asn1/asn_mime.c | 46 +++++------- src/lib/libcrypto/asn1/asn_moid.c | 6 +- src/lib/libcrypto/asn1/asn_pack.c | 24 +++--- src/lib/libcrypto/asn1/bio_ndef.c | 4 +- src/lib/libcrypto/asn1/d2i_pr.c | 11 ++- src/lib/libcrypto/asn1/d2i_pu.c | 14 ++-- src/lib/libcrypto/asn1/evp_asn1.c | 7 +- src/lib/libcrypto/asn1/f_enum.c | 13 ++-- src/lib/libcrypto/asn1/f_int.c | 13 ++-- src/lib/libcrypto/asn1/f_string.c | 13 ++-- src/lib/libcrypto/asn1/i2d_pr.c | 4 +- src/lib/libcrypto/asn1/i2d_pu.c | 4 +- src/lib/libcrypto/asn1/n_pkey.c | 24 +++--- src/lib/libcrypto/asn1/p5_pbe.c | 12 +-- src/lib/libcrypto/asn1/p5_pbev2.c | 12 ++- src/lib/libcrypto/asn1/t_crl.c | 4 +- src/lib/libcrypto/asn1/t_req.c | 6 +- src/lib/libcrypto/asn1/t_x509.c | 6 +- src/lib/libcrypto/asn1/tasn_dec.c | 146 ++++++++++++++----------------------- src/lib/libcrypto/asn1/tasn_new.c | 8 +- src/lib/libcrypto/asn1/tasn_prn.c | 4 +- src/lib/libcrypto/asn1/tasn_utl.c | 5 +- src/lib/libcrypto/asn1/x_crl.c | 4 +- src/lib/libcrypto/asn1/x_info.c | 4 +- src/lib/libcrypto/asn1/x_long.c | 6 +- src/lib/libcrypto/asn1/x_name.c | 8 +- src/lib/libcrypto/asn1/x_pkey.c | 8 +- src/lib/libcrypto/asn1/x_pubkey.c | 25 +++---- 46 files changed, 324 insertions(+), 550 deletions(-) (limited to 'src/lib/libcrypto/asn1') diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c index c847b471d6..9ba77d6958 100644 --- a/src/lib/libcrypto/asn1/a_bitstr.c +++ b/src/lib/libcrypto/asn1/a_bitstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_bitstr.c,v 1.23 2015/09/29 13:54:40 jsing Exp $ */ +/* $OpenBSD: a_bitstr.c,v 1.24 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -176,7 +176,7 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) return (ret); err: - ASN1err(ASN1_F_C2I_ASN1_BIT_STRING, i); + ASN1error(i); if ((ret != NULL) && ((a == NULL) || (*a != ret))) ASN1_BIT_STRING_free(ret); return (NULL); @@ -206,7 +206,7 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) return(1); /* Don't need to set */ c = OPENSSL_realloc_clean(a->data, a->length, w + 1); if (c == NULL) { - ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } if (w + 1 - a->length > 0) diff --git a/src/lib/libcrypto/asn1/a_bool.c b/src/lib/libcrypto/asn1/a_bool.c index d5a0c0c8a4..e8469bec65 100644 --- a/src/lib/libcrypto/asn1/a_bool.c +++ b/src/lib/libcrypto/asn1/a_bool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_bool.c,v 1.7 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_bool.c,v 1.8 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -110,6 +110,6 @@ d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length) return (ret); err: - ASN1err(ASN1_F_D2I_ASN1_BOOLEAN, i); + ASN1error(i); return (ret); } diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c index 727ad3ed9b..f3fe234851 100644 --- a/src/lib/libcrypto/asn1/a_bytes.c +++ b/src/lib/libcrypto/asn1/a_bytes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_bytes.c,v 1.18 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_bytes.c,v 1.19 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -123,7 +123,7 @@ d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, return (ret); err: - ASN1err(ASN1_F_D2I_ASN1_TYPE_BYTES, i); + ASN1error(i); if (a == NULL || *a != ret) ASN1_STRING_free(ret); return (NULL); @@ -235,7 +235,7 @@ d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, err: if (a == NULL || *a != ret) ASN1_STRING_free(ret); - ASN1err(ASN1_F_D2I_ASN1_BYTES, i); + ASN1error(i); return (NULL); } @@ -299,7 +299,7 @@ asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c) return (1); err: - ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE, c->error); + ASN1error(c->error); ASN1_STRING_free(os); free(b.data); return (0); diff --git a/src/lib/libcrypto/asn1/a_d2i_fp.c b/src/lib/libcrypto/asn1/a_d2i_fp.c index c00b304c61..390a1072d5 100644 --- a/src/lib/libcrypto/asn1/a_d2i_fp.c +++ b/src/lib/libcrypto/asn1/a_d2i_fp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_d2i_fp.c,v 1.15 2016/05/20 15:46:21 bcook Exp $ */ +/* $OpenBSD: a_d2i_fp.c,v 1.16 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -74,7 +74,7 @@ ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x) void *ret; if ((b = BIO_new(BIO_s_file())) == NULL) { - ASN1err(ASN1_F_ASN1_D2I_FP, ERR_R_BUF_LIB); + ASN1error(ERR_R_BUF_LIB); return (NULL); } BIO_set_fp(b, in, BIO_NOCLOSE); @@ -134,7 +134,7 @@ ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x) char *ret; if ((b = BIO_new(BIO_s_file())) == NULL) { - ASN1err(ASN1_F_ASN1_ITEM_D2I_FP, ERR_R_BUF_LIB); + ASN1error(ERR_R_BUF_LIB); return (NULL); } BIO_set_fp(b, in, BIO_NOCLOSE); @@ -159,7 +159,7 @@ asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) b = BUF_MEM_new(); if (b == NULL) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return -1; } @@ -170,20 +170,17 @@ asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) if (len + want < len || !BUF_MEM_grow_clean(b, len + want)) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } i = BIO_read(in, &(b->data[len]), want); if ((i < 0) && ((len - off) == 0)) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, - ASN1_R_NOT_ENOUGH_DATA); + ASN1error(ASN1_R_NOT_ENOUGH_DATA); goto err; } if (i > 0) { if (len + i < len) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, - ASN1_R_TOO_LONG); + ASN1error(ASN1_R_TOO_LONG); goto err; } len += i; @@ -211,8 +208,7 @@ asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) /* no data body so go round again */ eos++; if (eos < 0) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, - ASN1_R_HEADER_TOO_LONG); + ASN1error(ASN1_R_HEADER_TOO_LONG); goto err; } want = HEADER_SIZE; @@ -232,8 +228,7 @@ asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) want -= (len - off); if (want > INT_MAX /* BIO_read takes an int length */ || len+want < len) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, - ASN1_R_TOO_LONG); + ASN1error(ASN1_R_TOO_LONG); goto err; } while (want > 0) { @@ -246,16 +241,14 @@ asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) size_t chunk = want > chunk_max ? chunk_max : want; if (!BUF_MEM_grow_clean(b, len + chunk)) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } want -= chunk; while (chunk > 0) { i = BIO_read(in, &(b->data[len]), chunk); if (i <= 0) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, - ASN1_R_NOT_ENOUGH_DATA); + ASN1error(ASN1_R_NOT_ENOUGH_DATA); goto err; } /* @@ -270,7 +263,7 @@ asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) } } if (off + c.slen < off) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); + ASN1error(ASN1_R_TOO_LONG); goto err; } off += c.slen; @@ -282,7 +275,7 @@ asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) } if (off > INT_MAX) { - ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); + ASN1error(ASN1_R_TOO_LONG); goto err; } diff --git a/src/lib/libcrypto/asn1/a_dup.c b/src/lib/libcrypto/asn1/a_dup.c index 79cd1d4586..2e17a1e219 100644 --- a/src/lib/libcrypto/asn1/a_dup.c +++ b/src/lib/libcrypto/asn1/a_dup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_dup.c,v 1.13 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_dup.c,v 1.14 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -77,7 +77,7 @@ ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x) i = i2d(x, NULL); b = malloc(i + 10); if (b == NULL) { - ASN1err(ASN1_F_ASN1_DUP, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (NULL); } p = b; @@ -108,7 +108,7 @@ ASN1_item_dup(const ASN1_ITEM *it, void *x) i = ASN1_item_i2d(x, &b, it); if (b == NULL) { - ASN1err(ASN1_F_ASN1_ITEM_DUP, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (NULL); } p = b; diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c index 142f6ed575..23875958bf 100644 --- a/src/lib/libcrypto/asn1/a_enum.c +++ b/src/lib/libcrypto/asn1/a_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_enum.c,v 1.17 2015/09/30 18:45:56 jsing Exp $ */ +/* $OpenBSD: a_enum.c,v 1.18 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -81,7 +81,7 @@ ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) a->data = calloc(1, sizeof(long) + 1); } if (a->data == NULL) { - ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (0); } d = v; @@ -144,7 +144,7 @@ BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai) else ret = ai; if (ret == NULL) { - ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED, ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } if (BN_is_negative(bn)) @@ -156,7 +156,7 @@ BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai) if (ret->length < len + 4) { unsigned char *new_data = realloc(ret->data, len + 4); if (!new_data) { - ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } ret->data = new_data; @@ -182,7 +182,7 @@ ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn) BIGNUM *ret; if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL) - ASN1err(ASN1_F_ASN1_ENUMERATED_TO_BN, ASN1_R_BN_LIB); + ASN1error(ASN1_R_BN_LIB); else if (ai->type == V_ASN1_NEG_ENUMERATED) BN_set_negative(ret, 1); return (ret); diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c index 424068d784..6398978aac 100644 --- a/src/lib/libcrypto/asn1/a_i2d_fp.c +++ b/src/lib/libcrypto/asn1/a_i2d_fp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_i2d_fp.c,v 1.14 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_i2d_fp.c,v 1.15 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,7 +71,7 @@ ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x) int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { - ASN1err(ASN1_F_ASN1_I2D_FP, ERR_R_BUF_LIB); + ASN1error(ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, out, BIO_NOCLOSE); @@ -90,7 +90,7 @@ ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) n = i2d(x, NULL); b = malloc(n); if (b == NULL) { - ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (0); } @@ -121,7 +121,7 @@ ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { - ASN1err(ASN1_F_ASN1_ITEM_I2D_FP, ERR_R_BUF_LIB); + ASN1error(ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, out, BIO_NOCLOSE); @@ -138,7 +138,7 @@ ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) n = ASN1_item_i2d(x, &b, it); if (b == NULL) { - ASN1err(ASN1_F_ASN1_ITEM_I2D_BIO, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (0); } diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c index 5c0103ba36..95d0f6dbb2 100644 --- a/src/lib/libcrypto/asn1/a_int.c +++ b/src/lib/libcrypto/asn1/a_int.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_int.c,v 1.30 2015/09/30 17:30:15 jsing Exp $ */ +/* $OpenBSD: a_int.c,v 1.31 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -266,7 +266,7 @@ c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) return (ret); err: - ASN1err(ASN1_F_C2I_ASN1_INTEGER, i); + ASN1error(i); if (a == NULL || *a != ret) ASN1_INTEGER_free(ret); return (NULL); @@ -332,7 +332,7 @@ d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, long length) return (ret); err: - ASN1err(ASN1_F_D2I_ASN1_UINTEGER, i); + ASN1error(i); if (a == NULL || *a != ret) ASN1_INTEGER_free(ret); return (NULL); @@ -353,7 +353,7 @@ ASN1_INTEGER_set(ASN1_INTEGER *a, long v) a->data = calloc(1, sizeof(long) + 1); } if (a->data == NULL) { - ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (0); } d = v; @@ -416,7 +416,7 @@ BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai) else ret = ai; if (ret == NULL) { - ASN1err(ASN1_F_BN_TO_ASN1_INTEGER, ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } if (BN_is_negative(bn)) @@ -428,7 +428,7 @@ BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai) if (ret->length < len + 4) { unsigned char *new_data = realloc(ret->data, len + 4); if (!new_data) { - ASN1err(ASN1_F_BN_TO_ASN1_INTEGER, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } ret->data = new_data; @@ -454,7 +454,7 @@ ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn) BIGNUM *ret; if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL) - ASN1err(ASN1_F_ASN1_INTEGER_TO_BN, ASN1_R_BN_LIB); + ASN1error(ASN1_R_BN_LIB); else if (ai->type == V_ASN1_NEG_INTEGER) BN_set_negative(ret, 1); return (ret); diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c index e715fe7348..b7cfba379a 100644 --- a/src/lib/libcrypto/asn1/a_mbstr.c +++ b/src/lib/libcrypto/asn1/a_mbstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_mbstr.c,v 1.22 2015/07/16 02:18:58 miod Exp $ */ +/* $OpenBSD: a_mbstr.c,v 1.23 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -113,8 +113,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, switch (inform) { case MBSTRING_BMP: if (len & 1) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, - ASN1_R_INVALID_BMPSTRING_LENGTH); + ASN1error(ASN1_R_INVALID_BMPSTRING_LENGTH); return -1; } nchar = len >> 1; @@ -122,8 +121,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, case MBSTRING_UNIV: if (len & 3) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, - ASN1_R_INVALID_UNIVERSALSTRING_LENGTH); + ASN1error(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH); return -1; } nchar = len >> 2; @@ -134,8 +132,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, /* This counts the characters and does utf8 syntax checking */ ret = traverse_string(in, len, MBSTRING_UTF8, in_utf8, &nchar); if (ret < 0) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, - ASN1_R_INVALID_UTF8STRING); + ASN1error(ASN1_R_INVALID_UTF8STRING); return -1; } break; @@ -145,25 +142,25 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, break; default: - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_UNKNOWN_FORMAT); + ASN1error(ASN1_R_UNKNOWN_FORMAT); return -1; } if ((minsize > 0) && (nchar < minsize)) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_SHORT); + ASN1error(ASN1_R_STRING_TOO_SHORT); ERR_asprintf_error_data("minsize=%ld", minsize); return -1; } if ((maxsize > 0) && (nchar > maxsize)) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_LONG); + ASN1error(ASN1_R_STRING_TOO_LONG); ERR_asprintf_error_data("maxsize=%ld", maxsize); return -1; } /* Now work out minimal type (if any) */ if (traverse_string(in, len, inform, type_str, &mask) < 0) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_ILLEGAL_CHARACTERS); + ASN1error(ASN1_R_ILLEGAL_CHARACTERS); return -1; } @@ -201,8 +198,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, free_out = 1; dest = ASN1_STRING_type_new(str_type); if (!dest) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return -1; } *out = dest; @@ -210,8 +206,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, /* If both the same type just copy across */ if (inform == outform) { if (!ASN1_STRING_set(dest, in, len)) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } return str_type; @@ -237,15 +232,14 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, case MBSTRING_UTF8: outlen = 0; if (traverse_string(in, len, inform, out_utf8, &outlen) < 0) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, - ASN1_R_ILLEGAL_CHARACTERS); + ASN1error(ASN1_R_ILLEGAL_CHARACTERS); goto err; } cpyfunc = cpy_utf8; break; } if (!(p = malloc(outlen + 1))) { - ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } dest->length = outlen; diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c index 44694d2ba7..711b01f149 100644 --- a/src/lib/libcrypto/asn1/a_object.c +++ b/src/lib/libcrypto/asn1/a_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_object.c,v 1.28 2016/11/06 17:04:48 bcook Exp $ */ +/* $OpenBSD: a_object.c,v 1.29 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -109,12 +109,12 @@ a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) if ((c >= '0') && (c <= '2')) { first= c-'0'; } else { - ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_FIRST_NUM_TOO_LARGE); + ASN1error(ASN1_R_FIRST_NUM_TOO_LARGE); goto err; } if (num <= 0) { - ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_MISSING_SECOND_NUMBER); + ASN1error(ASN1_R_MISSING_SECOND_NUMBER); goto err; } c = *(p++); @@ -123,8 +123,7 @@ a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) if (num <= 0) break; if ((c != '.') && (c != ' ')) { - ASN1err(ASN1_F_A2D_ASN1_OBJECT, - ASN1_R_INVALID_SEPARATOR); + ASN1error(ASN1_R_INVALID_SEPARATOR); goto err; } l = 0; @@ -137,8 +136,7 @@ a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) if ((c == ' ') || (c == '.')) break; if ((c < '0') || (c > '9')) { - ASN1err(ASN1_F_A2D_ASN1_OBJECT, - ASN1_R_INVALID_DIGIT); + ASN1error(ASN1_R_INVALID_DIGIT); goto err; } if (!use_bn && l >= ((ULONG_MAX - 80) / 10L)) { @@ -157,8 +155,7 @@ a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) } if (len == 0) { if ((first < 2) && (l >= 40)) { - ASN1err(ASN1_F_A2D_ASN1_OBJECT, - ASN1_R_SECOND_NUMBER_TOO_LARGE); + ASN1error(ASN1_R_SECOND_NUMBER_TOO_LARGE); goto err; } if (use_bn) { @@ -194,8 +191,7 @@ a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) } if (out != NULL) { if (len + i > olen) { - ASN1err(ASN1_F_A2D_ASN1_OBJECT, - ASN1_R_BUFFER_TOO_SMALL); + ASN1error(ASN1_R_BUFFER_TOO_SMALL); goto err; } while (--i > 0) @@ -277,7 +273,7 @@ d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long length) return ret; err: - ASN1err(ASN1_F_D2I_ASN1_OBJECT, i); + ASN1error(i); return (NULL); } @@ -297,7 +293,7 @@ c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long len) */ if (len <= 0 || len > INT_MAX || pp == NULL || (p = *pp) == NULL || p[len - 1] & 0x80) { - ASN1err(ASN1_F_C2I_ASN1_OBJECT, ASN1_R_INVALID_OBJECT_ENCODING); + ASN1error(ASN1_R_INVALID_OBJECT_ENCODING); return (NULL); } @@ -305,8 +301,7 @@ c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long len) length = (int)len; for (i = 0; i < length; i++, p++) { if (*p == 0x80 && (!i || !(p[-1] & 0x80))) { - ASN1err(ASN1_F_C2I_ASN1_OBJECT, - ASN1_R_INVALID_OBJECT_ENCODING); + ASN1error(ASN1_R_INVALID_OBJECT_ENCODING); return (NULL); } } @@ -330,7 +325,7 @@ c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long len) data = malloc(length); if (data == NULL) { - ASN1err(ASN1_F_C2I_ASN1_OBJECT, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } @@ -362,7 +357,7 @@ ASN1_OBJECT_new(void) ret = malloc(sizeof(ASN1_OBJECT)); if (ret == NULL) { - ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (NULL); } ret->length = 0; diff --git a/src/lib/libcrypto/asn1/a_set.c b/src/lib/libcrypto/asn1/a_set.c index 63d55c3714..4d5cae337b 100644 --- a/src/lib/libcrypto/asn1/a_set.c +++ b/src/lib/libcrypto/asn1/a_set.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_set.c,v 1.17 2015/03/19 14:00:22 tedu Exp $ */ +/* $OpenBSD: a_set.c,v 1.18 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -125,7 +125,7 @@ i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp, i2d_of_void *i2d, /* In this array we will store the SET blobs */ rgSetBlob = reallocarray(NULL, sk_OPENSSL_BLOCK_num(a), sizeof(MYBLOB)); if (rgSetBlob == NULL) { - ASN1err(ASN1_F_I2D_ASN1_SET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } @@ -146,7 +146,7 @@ i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp, i2d_of_void *i2d, qsort(rgSetBlob, sk_OPENSSL_BLOCK_num(a), sizeof(MYBLOB), SetBlobCmp); if ((pTempMem = malloc(totSize)) == NULL) { free(rgSetBlob); - ASN1err(ASN1_F_I2D_ASN1_SET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } @@ -175,7 +175,7 @@ d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, const unsigned char **pp, long length, if (a == NULL || (*a) == NULL) { if ((ret = sk_OPENSSL_BLOCK_new_null()) == NULL) { - ASN1err(ASN1_F_D2I_ASN1_SET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } } else @@ -188,15 +188,15 @@ d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, const unsigned char **pp, long length, if (c.inf & 0x80) goto err; if (ex_class != c.xclass) { - ASN1err(ASN1_F_D2I_ASN1_SET, ASN1_R_BAD_CLASS); + ASN1error(ASN1_R_BAD_CLASS); goto err; } if (ex_tag != c.tag) { - ASN1err(ASN1_F_D2I_ASN1_SET, ASN1_R_BAD_TAG); + ASN1error(ASN1_R_BAD_TAG); goto err; } if (c.slen + c.p > c.max) { - ASN1err(ASN1_F_D2I_ASN1_SET, ASN1_R_LENGTH_ERROR); + ASN1error(ASN1_R_LENGTH_ERROR); goto err; } /* check for infinite constructed - it can be as long @@ -211,8 +211,7 @@ d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, const unsigned char **pp, long length, if (M_ASN1_D2I_end_sequence()) break; if ((s = d2i(NULL, &c.p, c.slen)) == NULL) { - ASN1err(ASN1_F_D2I_ASN1_SET, - ASN1_R_ERROR_PARSING_SET_ELEMENT); + ASN1error(ASN1_R_ERROR_PARSING_SET_ELEMENT); asn1_add_error(*pp, (int)(c.p - *pp)); goto err; } diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c index 195daa3b9f..4e545eb719 100644 --- a/src/lib/libcrypto/asn1/a_sign.c +++ b/src/lib/libcrypto/asn1/a_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_sign.c,v 1.21 2015/09/10 15:56:24 jsing Exp $ */ +/* $OpenBSD: a_sign.c,v 1.22 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -153,8 +153,7 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, pkey = EVP_PKEY_CTX_get0_pkey(ctx->pctx); if (!type || !pkey) { - ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, - ASN1_R_CONTEXT_NOT_INITIALISED); + ASN1error(ASN1_R_CONTEXT_NOT_INITIALISED); return 0; } @@ -170,7 +169,7 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, * 3: ASN1 method sets algorithm identifiers: just sign. */ if (rv <= 0) - ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB); + ASN1error(ERR_R_EVP_LIB); if (rv <= 1) goto err; } else @@ -181,8 +180,7 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, if (!pkey->ameth || !OBJ_find_sigid_by_algs(&signid, EVP_MD_nid(type), pkey->ameth->pkey_id)) { - ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, - ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); + ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); return 0; } } else @@ -207,14 +205,14 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, buf_out = malloc(outl); if ((buf_in == NULL) || (buf_out == NULL)) { outl = 0; - ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_DigestSignUpdate(ctx, buf_in, inl) || !EVP_DigestSignFinal(ctx, buf_out, &outl)) { outl = 0; - ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB); + ASN1error(ERR_R_EVP_LIB); goto err; } free(signature->data); diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c index f325d91924..0585f7050b 100644 --- a/src/lib/libcrypto/asn1/a_strnid.c +++ b/src/lib/libcrypto/asn1/a_strnid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_strnid.c,v 1.20 2017/01/21 04:31:25 jsing Exp $ */ +/* $OpenBSD: a_strnid.c,v 1.21 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -258,14 +258,13 @@ ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, unsigned long mask, if (!stable) stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp); if (!stable) { - ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } if (!(tmp = ASN1_STRING_TABLE_get(nid))) { tmp = malloc(sizeof(ASN1_STRING_TABLE)); if (!tmp) { - ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } tmp->flags = flags | STABLE_FLAGS_MALLOC; @@ -280,8 +279,7 @@ ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, unsigned long mask, if (new_nid) { if (sk_ASN1_STRING_TABLE_push(stable, tmp) == 0) { free(tmp); - ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } } diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c index fcd3acf9c8..b2f65045b5 100644 --- a/src/lib/libcrypto/asn1/a_time_tm.c +++ b/src/lib/libcrypto/asn1/a_time_tm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_time_tm.c,v 1.10 2016/11/04 18:07:23 beck Exp $ */ +/* $OpenBSD: a_time_tm.c,v 1.11 2017/01/29 17:49:22 beck Exp $ */ /* * Copyright (c) 2015 Bob Beck * @@ -267,8 +267,7 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec, return (NULL); } if (p == NULL) { - ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, - ASN1_R_ILLEGAL_TIME_VALUE); + ASN1error(ASN1_R_ILLEGAL_TIME_VALUE); return (NULL); } diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c index 12b76501e0..8f8e58c095 100644 --- a/src/lib/libcrypto/asn1/a_verify.c +++ b/src/lib/libcrypto/asn1/a_verify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_verify.c,v 1.22 2015/09/10 15:56:24 jsing Exp $ */ +/* $OpenBSD: a_verify.c,v 1.23 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -82,14 +82,13 @@ ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, int mdnid, pknid; if (!pkey) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_PASSED_NULL_PARAMETER); + ASN1error(ERR_R_PASSED_NULL_PARAMETER); return -1; } if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7) { - ASN1err(ASN1_F_ASN1_VERIFY, - ASN1_R_INVALID_BIT_STRING_BITS_LEFT); + ASN1error(ASN1_R_INVALID_BIT_STRING_BITS_LEFT); return -1; } @@ -97,14 +96,12 @@ ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, /* Convert signature OID into digest and public key OIDs */ if (!OBJ_find_sigid_algs(OBJ_obj2nid(a->algorithm), &mdnid, &pknid)) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, - ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); + ASN1error(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); goto err; } if (mdnid == NID_undef) { if (!pkey->ameth || !pkey->ameth->item_verify) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, - ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); + ASN1error(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); goto err; } ret = pkey->ameth->item_verify(&ctx, it, asn, a, @@ -120,20 +117,18 @@ ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, const EVP_MD *type; type = EVP_get_digestbynid(mdnid); if (type == NULL) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, - ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM); + ASN1error(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM); goto err; } /* Check public key OID matches public key type */ if (EVP_PKEY_type(pknid) != pkey->ameth->pkey_id) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, - ASN1_R_WRONG_PUBLIC_KEY_TYPE); + ASN1error(ASN1_R_WRONG_PUBLIC_KEY_TYPE); goto err; } if (!EVP_DigestVerifyInit(&ctx, NULL, type, NULL, pkey)) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_EVP_LIB); + ASN1error(ERR_R_EVP_LIB); ret = 0; goto err; } @@ -143,12 +138,12 @@ ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, inl = ASN1_item_i2d(asn, &buf_in, it); if (buf_in == NULL) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_DigestVerifyUpdate(&ctx, buf_in, inl)) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_EVP_LIB); + ASN1error(ERR_R_EVP_LIB); ret = 0; goto err; } @@ -158,7 +153,7 @@ ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, if (EVP_DigestVerifyFinal(&ctx, signature->data, (size_t)signature->length) <= 0) { - ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_EVP_LIB); + ASN1error(ERR_R_EVP_LIB); ret = 0; goto err; } diff --git a/src/lib/libcrypto/asn1/asn1_err.c b/src/lib/libcrypto/asn1/asn1_err.c index 8fd5cf6765..0c827a9236 100644 --- a/src/lib/libcrypto/asn1/asn1_err.c +++ b/src/lib/libcrypto/asn1/asn1_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_err.c,v 1.19 2015/02/15 14:35:30 miod Exp $ */ +/* $OpenBSD: asn1_err.c,v 1.20 2017/01/29 17:49:22 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -72,127 +72,7 @@ #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ASN1,0,reason) static ERR_STRING_DATA ASN1_str_functs[] = { - {ERR_FUNC(ASN1_F_A2D_ASN1_OBJECT), "a2d_ASN1_OBJECT"}, - {ERR_FUNC(ASN1_F_A2I_ASN1_ENUMERATED), "a2i_ASN1_ENUMERATED"}, - {ERR_FUNC(ASN1_F_A2I_ASN1_INTEGER), "a2i_ASN1_INTEGER"}, - {ERR_FUNC(ASN1_F_A2I_ASN1_STRING), "a2i_ASN1_STRING"}, - {ERR_FUNC(ASN1_F_APPEND_EXP), "APPEND_EXP"}, - {ERR_FUNC(ASN1_F_ASN1_BIT_STRING_SET_BIT), "ASN1_BIT_STRING_set_bit"}, - {ERR_FUNC(ASN1_F_ASN1_CB), "ASN1_CB"}, - {ERR_FUNC(ASN1_F_ASN1_CHECK_TLEN), "ASN1_CHECK_TLEN"}, - {ERR_FUNC(ASN1_F_ASN1_COLLATE_PRIMITIVE), "ASN1_COLLATE_PRIMITIVE"}, - {ERR_FUNC(ASN1_F_ASN1_COLLECT), "ASN1_COLLECT"}, - {ERR_FUNC(ASN1_F_ASN1_D2I_EX_PRIMITIVE), "ASN1_D2I_EX_PRIMITIVE"}, - {ERR_FUNC(ASN1_F_ASN1_D2I_FP), "ASN1_d2i_fp"}, - {ERR_FUNC(ASN1_F_ASN1_D2I_READ_BIO), "ASN1_D2I_READ_BIO"}, - {ERR_FUNC(ASN1_F_ASN1_DIGEST), "ASN1_digest"}, - {ERR_FUNC(ASN1_F_ASN1_DO_ADB), "ASN1_DO_ADB"}, - {ERR_FUNC(ASN1_F_ASN1_DUP), "ASN1_dup"}, - {ERR_FUNC(ASN1_F_ASN1_ENUMERATED_SET), "ASN1_ENUMERATED_set"}, - {ERR_FUNC(ASN1_F_ASN1_ENUMERATED_TO_BN), "ASN1_ENUMERATED_to_BN"}, - {ERR_FUNC(ASN1_F_ASN1_EX_C2I), "ASN1_EX_C2I"}, - {ERR_FUNC(ASN1_F_ASN1_FIND_END), "ASN1_FIND_END"}, - {ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_ADJ), "ASN1_GENERALIZEDTIME_adj"}, - {ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_SET), "ASN1_GENERALIZEDTIME_set"}, - {ERR_FUNC(ASN1_F_ASN1_GENERATE_V3), "ASN1_generate_v3"}, - {ERR_FUNC(ASN1_F_ASN1_GET_OBJECT), "ASN1_get_object"}, - {ERR_FUNC(ASN1_F_ASN1_HEADER_NEW), "ASN1_HEADER_NEW"}, - {ERR_FUNC(ASN1_F_ASN1_I2D_BIO), "ASN1_i2d_bio"}, - {ERR_FUNC(ASN1_F_ASN1_I2D_FP), "ASN1_i2d_fp"}, - {ERR_FUNC(ASN1_F_ASN1_INTEGER_SET), "ASN1_INTEGER_set"}, - {ERR_FUNC(ASN1_F_ASN1_INTEGER_TO_BN), "ASN1_INTEGER_to_BN"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_D2I_FP), "ASN1_item_d2i_fp"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_DUP), "ASN1_item_dup"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW), "ASN1_ITEM_EX_COMBINE_NEW"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_EX_D2I), "ASN1_ITEM_EX_D2I"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_BIO), "ASN1_item_i2d_bio"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_FP), "ASN1_item_i2d_fp"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_PACK), "ASN1_item_pack"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN), "ASN1_item_sign"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN_CTX), "ASN1_item_sign_ctx"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_UNPACK), "ASN1_item_unpack"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_VERIFY), "ASN1_item_verify"}, - {ERR_FUNC(ASN1_F_ASN1_MBSTRING_NCOPY), "ASN1_mbstring_ncopy"}, - {ERR_FUNC(ASN1_F_ASN1_OBJECT_NEW), "ASN1_OBJECT_new"}, - {ERR_FUNC(ASN1_F_ASN1_OUTPUT_DATA), "ASN1_OUTPUT_DATA"}, - {ERR_FUNC(ASN1_F_ASN1_PACK_STRING), "ASN1_pack_string"}, - {ERR_FUNC(ASN1_F_ASN1_PCTX_NEW), "ASN1_PCTX_new"}, - {ERR_FUNC(ASN1_F_ASN1_PKCS5_PBE_SET), "ASN1_PKCS5_PBE_SET"}, - {ERR_FUNC(ASN1_F_ASN1_SEQ_PACK), "ASN1_seq_pack"}, - {ERR_FUNC(ASN1_F_ASN1_SEQ_UNPACK), "ASN1_seq_unpack"}, - {ERR_FUNC(ASN1_F_ASN1_SIGN), "ASN1_sign"}, - {ERR_FUNC(ASN1_F_ASN1_STR2TYPE), "ASN1_STR2TYPE"}, - {ERR_FUNC(ASN1_F_ASN1_STRING_SET), "ASN1_STRING_set"}, - {ERR_FUNC(ASN1_F_ASN1_STRING_TABLE_ADD), "ASN1_STRING_TABLE_add"}, - {ERR_FUNC(ASN1_F_ASN1_STRING_TYPE_NEW), "ASN1_STRING_type_new"}, - {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_EX_D2I), "ASN1_TEMPLATE_EX_D2I"}, - {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NEW), "ASN1_TEMPLATE_NEW"}, - {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I), "ASN1_TEMPLATE_NOEXP_D2I"}, - {ERR_FUNC(ASN1_F_ASN1_TIME_ADJ), "ASN1_TIME_adj"}, - {ERR_FUNC(ASN1_F_ASN1_TIME_SET), "ASN1_TIME_set"}, - {ERR_FUNC(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING), "ASN1_TYPE_get_int_octetstring"}, - {ERR_FUNC(ASN1_F_ASN1_TYPE_GET_OCTETSTRING), "ASN1_TYPE_get_octetstring"}, - {ERR_FUNC(ASN1_F_ASN1_UNPACK_STRING), "ASN1_unpack_string"}, - {ERR_FUNC(ASN1_F_ASN1_UTCTIME_ADJ), "ASN1_UTCTIME_adj"}, - {ERR_FUNC(ASN1_F_ASN1_UTCTIME_SET), "ASN1_UTCTIME_set"}, - {ERR_FUNC(ASN1_F_ASN1_VERIFY), "ASN1_verify"}, - {ERR_FUNC(ASN1_F_B64_READ_ASN1), "B64_READ_ASN1"}, - {ERR_FUNC(ASN1_F_B64_WRITE_ASN1), "B64_WRITE_ASN1"}, - {ERR_FUNC(ASN1_F_BIO_NEW_NDEF), "BIO_new_NDEF"}, - {ERR_FUNC(ASN1_F_BITSTR_CB), "BITSTR_CB"}, - {ERR_FUNC(ASN1_F_BN_TO_ASN1_ENUMERATED), "BN_to_ASN1_ENUMERATED"}, - {ERR_FUNC(ASN1_F_BN_TO_ASN1_INTEGER), "BN_to_ASN1_INTEGER"}, - {ERR_FUNC(ASN1_F_C2I_ASN1_BIT_STRING), "c2i_ASN1_BIT_STRING"}, - {ERR_FUNC(ASN1_F_C2I_ASN1_INTEGER), "c2i_ASN1_INTEGER"}, - {ERR_FUNC(ASN1_F_C2I_ASN1_OBJECT), "c2i_ASN1_OBJECT"}, - {ERR_FUNC(ASN1_F_COLLECT_DATA), "COLLECT_DATA"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_BIT_STRING), "D2I_ASN1_BIT_STRING"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_BOOLEAN), "d2i_ASN1_BOOLEAN"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_BYTES), "d2i_ASN1_bytes"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_GENERALIZEDTIME), "D2I_ASN1_GENERALIZEDTIME"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_HEADER), "D2I_ASN1_HEADER"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_INTEGER), "D2I_ASN1_INTEGER"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_OBJECT), "d2i_ASN1_OBJECT"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_SET), "d2i_ASN1_SET"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_TYPE_BYTES), "d2i_ASN1_type_bytes"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_UINTEGER), "d2i_ASN1_UINTEGER"}, - {ERR_FUNC(ASN1_F_D2I_ASN1_UTCTIME), "D2I_ASN1_UTCTIME"}, - {ERR_FUNC(ASN1_F_D2I_AUTOPRIVATEKEY), "d2i_AutoPrivateKey"}, - {ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA), "d2i_Netscape_RSA"}, - {ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA_2), "D2I_NETSCAPE_RSA_2"}, - {ERR_FUNC(ASN1_F_D2I_PRIVATEKEY), "d2i_PrivateKey"}, - {ERR_FUNC(ASN1_F_D2I_PUBLICKEY), "d2i_PublicKey"}, - {ERR_FUNC(ASN1_F_D2I_RSA_NET), "d2i_RSA_NET"}, - {ERR_FUNC(ASN1_F_D2I_RSA_NET_2), "D2I_RSA_NET_2"}, - {ERR_FUNC(ASN1_F_D2I_X509), "D2I_X509"}, - {ERR_FUNC(ASN1_F_D2I_X509_CINF), "D2I_X509_CINF"}, - {ERR_FUNC(ASN1_F_D2I_X509_PKEY), "d2i_X509_PKEY"}, - {ERR_FUNC(ASN1_F_I2D_ASN1_BIO_STREAM), "i2d_ASN1_bio_stream"}, - {ERR_FUNC(ASN1_F_I2D_ASN1_SET), "i2d_ASN1_SET"}, - {ERR_FUNC(ASN1_F_I2D_ASN1_TIME), "I2D_ASN1_TIME"}, - {ERR_FUNC(ASN1_F_I2D_DSA_PUBKEY), "i2d_DSA_PUBKEY"}, - {ERR_FUNC(ASN1_F_I2D_EC_PUBKEY), "i2d_EC_PUBKEY"}, - {ERR_FUNC(ASN1_F_I2D_PRIVATEKEY), "i2d_PrivateKey"}, - {ERR_FUNC(ASN1_F_I2D_PUBLICKEY), "i2d_PublicKey"}, - {ERR_FUNC(ASN1_F_I2D_RSA_NET), "i2d_RSA_NET"}, - {ERR_FUNC(ASN1_F_I2D_RSA_PUBKEY), "i2d_RSA_PUBKEY"}, - {ERR_FUNC(ASN1_F_LONG_C2I), "LONG_C2I"}, - {ERR_FUNC(ASN1_F_OID_MODULE_INIT), "OID_MODULE_INIT"}, - {ERR_FUNC(ASN1_F_PARSE_TAGGING), "PARSE_TAGGING"}, - {ERR_FUNC(ASN1_F_PKCS5_PBE2_SET_IV), "PKCS5_pbe2_set_iv"}, - {ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_pbe_set"}, - {ERR_FUNC(ASN1_F_PKCS5_PBE_SET0_ALGOR), "PKCS5_pbe_set0_algor"}, - {ERR_FUNC(ASN1_F_PKCS5_PBKDF2_SET), "PKCS5_pbkdf2_set"}, - {ERR_FUNC(ASN1_F_SMIME_READ_ASN1), "SMIME_read_ASN1"}, - {ERR_FUNC(ASN1_F_SMIME_TEXT), "SMIME_text"}, - {ERR_FUNC(ASN1_F_X509_CINF_NEW), "X509_CINF_NEW"}, - {ERR_FUNC(ASN1_F_X509_CRL_ADD0_REVOKED), "X509_CRL_add0_revoked"}, - {ERR_FUNC(ASN1_F_X509_INFO_NEW), "X509_INFO_new"}, - {ERR_FUNC(ASN1_F_X509_NAME_ENCODE), "X509_NAME_ENCODE"}, - {ERR_FUNC(ASN1_F_X509_NAME_EX_D2I), "X509_NAME_EX_D2I"}, - {ERR_FUNC(ASN1_F_X509_NAME_EX_NEW), "X509_NAME_EX_NEW"}, - {ERR_FUNC(ASN1_F_X509_NEW), "X509_NEW"}, - {ERR_FUNC(ASN1_F_X509_PKEY_NEW), "X509_PKEY_new"}, + {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; diff --git a/src/lib/libcrypto/asn1/asn1_gen.c b/src/lib/libcrypto/asn1/asn1_gen.c index e899337b6f..f84cc6136b 100644 --- a/src/lib/libcrypto/asn1/asn1_gen.c +++ b/src/lib/libcrypto/asn1/asn1_gen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_gen.c,v 1.15 2015/12/12 21:03:52 beck Exp $ */ +/* $OpenBSD: asn1_gen.c,v 1.16 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2002. */ @@ -160,8 +160,7 @@ ASN1_generate_v3(char *str, X509V3_CTX *cnf) if ((asn1_tags.utype == V_ASN1_SEQUENCE) || (asn1_tags.utype == V_ASN1_SET)) { if (!cnf) { - ASN1err(ASN1_F_ASN1_GENERATE_V3, - ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG); + ASN1error(ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG); return NULL; } ret = asn1_multi(asn1_tags.utype, asn1_tags.str, cnf); @@ -290,7 +289,7 @@ asn1_cb(const char *elem, int len, void *bitstr) utype = asn1_str2tag(elem, len); if (utype == -1) { - ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKNOWN_TAG); + ASN1error(ASN1_R_UNKNOWN_TAG); ERR_asprintf_error_data("tag=%s", elem); return -1; } @@ -301,7 +300,7 @@ asn1_cb(const char *elem, int len, void *bitstr) arg->str = vstart; /* If no value and not end of string, error */ if (!vstart && elem[len]) { - ASN1err(ASN1_F_ASN1_CB, ASN1_R_MISSING_VALUE); + ASN1error(ASN1_R_MISSING_VALUE); return -1; } return 0; @@ -312,7 +311,7 @@ asn1_cb(const char *elem, int len, void *bitstr) case ASN1_GEN_FLAG_IMP: /* Check for illegal multiple IMPLICIT tagging */ if (arg->imp_tag != -1) { - ASN1err(ASN1_F_ASN1_CB, ASN1_R_ILLEGAL_NESTED_TAGGING); + ASN1error(ASN1_R_ILLEGAL_NESTED_TAGGING); return -1; } if (!parse_tagging(vstart, vlen, &arg->imp_tag, @@ -349,7 +348,7 @@ asn1_cb(const char *elem, int len, void *bitstr) case ASN1_GEN_FLAG_FORMAT: if (vstart == NULL) { - ASN1err(ASN1_F_ASN1_CB, ASN1_R_ILLEGAL_FORMAT); + ASN1error(ASN1_R_ILLEGAL_FORMAT); return -1; } if (!strncmp(vstart, "ASCII", 5)) @@ -361,7 +360,7 @@ asn1_cb(const char *elem, int len, void *bitstr) else if (!strncmp(vstart, "BITLIST", 7)) arg->format = ASN1_GEN_FORMAT_BITLIST; else { - ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKOWN_FORMAT); + ASN1error(ASN1_R_UNKOWN_FORMAT); return -1; } break; @@ -384,7 +383,7 @@ parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) if (eptr && *eptr && (eptr > vstart + vlen)) return 0; if (tag_num < 0) { - ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_NUMBER); + ASN1error(ASN1_R_INVALID_NUMBER); return 0; } *ptag = tag_num; @@ -413,7 +412,7 @@ parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) break; default: - ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_MODIFIER); + ASN1error(ASN1_R_INVALID_MODIFIER); ERR_asprintf_error_data("Char=%c", *eptr); return 0; break; @@ -497,12 +496,12 @@ append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, /* Can only have IMPLICIT if permitted */ if ((arg->imp_tag != -1) && !imp_ok) { - ASN1err(ASN1_F_APPEND_EXP, ASN1_R_ILLEGAL_IMPLICIT_TAG); + ASN1error(ASN1_R_ILLEGAL_IMPLICIT_TAG); return 0; } if (arg->exp_count == ASN1_FLAG_EXP_MAX) { - ASN1err(ASN1_F_APPEND_EXP, ASN1_R_DEPTH_EXCEEDED); + ASN1error(ASN1_R_DEPTH_EXCEEDED); return 0; } @@ -614,7 +613,7 @@ asn1_str2type(const char *str, int format, int utype) int no_unused = 1; if (!(atmp = ASN1_TYPE_new())) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return NULL; } @@ -625,22 +624,21 @@ asn1_str2type(const char *str, int format, int utype) case V_ASN1_NULL: if (str && *str) { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ASN1_R_ILLEGAL_NULL_VALUE); + ASN1error(ASN1_R_ILLEGAL_NULL_VALUE); goto bad_form; } break; case V_ASN1_BOOLEAN: if (format != ASN1_GEN_FORMAT_ASCII) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_NOT_ASCII_FORMAT); + ASN1error(ASN1_R_NOT_ASCII_FORMAT); goto bad_form; } vtmp.name = NULL; vtmp.section = NULL; vtmp.value = (char *)str; if (!X509V3_get_value_bool(&vtmp, &atmp->value.boolean)) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_BOOLEAN); + ASN1error(ASN1_R_ILLEGAL_BOOLEAN); goto bad_str; } break; @@ -648,25 +646,23 @@ asn1_str2type(const char *str, int format, int utype) case V_ASN1_INTEGER: case V_ASN1_ENUMERATED: if (format != ASN1_GEN_FORMAT_ASCII) { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ASN1_R_INTEGER_NOT_ASCII_FORMAT); + ASN1error(ASN1_R_INTEGER_NOT_ASCII_FORMAT); goto bad_form; } if (!(atmp->value.integer = s2i_ASN1_INTEGER(NULL, (char *)str))) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_INTEGER); + ASN1error(ASN1_R_ILLEGAL_INTEGER); goto bad_str; } break; case V_ASN1_OBJECT: if (format != ASN1_GEN_FORMAT_ASCII) { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ASN1_R_OBJECT_NOT_ASCII_FORMAT); + ASN1error(ASN1_R_OBJECT_NOT_ASCII_FORMAT); goto bad_form; } if (!(atmp->value.object = OBJ_txt2obj(str, 0))) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_OBJECT); + ASN1error(ASN1_R_ILLEGAL_OBJECT); goto bad_str; } break; @@ -674,22 +670,20 @@ asn1_str2type(const char *str, int format, int utype) case V_ASN1_UTCTIME: case V_ASN1_GENERALIZEDTIME: if (format != ASN1_GEN_FORMAT_ASCII) { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ASN1_R_TIME_NOT_ASCII_FORMAT); + ASN1error(ASN1_R_TIME_NOT_ASCII_FORMAT); goto bad_form; } if (!(atmp->value.asn1_string = ASN1_STRING_new())) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto bad_str; } if (!ASN1_STRING_set(atmp->value.asn1_string, str, -1)) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto bad_str; } atmp->value.asn1_string->type = utype; if (!ASN1_TIME_check(atmp->value.asn1_string)) { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ASN1_R_ILLEGAL_TIME_VALUE); + ASN1error(ASN1_R_ILLEGAL_TIME_VALUE); goto bad_str; } break; @@ -709,14 +703,14 @@ asn1_str2type(const char *str, int format, int utype) else if (format == ASN1_GEN_FORMAT_UTF8) format = MBSTRING_UTF8; else { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_FORMAT); + ASN1error(ASN1_R_ILLEGAL_FORMAT); goto bad_form; } if (ASN1_mbstring_copy(&atmp->value.asn1_string, (unsigned char *)str, -1, format, ASN1_tag2bit(utype)) <= 0) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto bad_str; } break; @@ -724,15 +718,14 @@ asn1_str2type(const char *str, int format, int utype) case V_ASN1_BIT_STRING: case V_ASN1_OCTET_STRING: if (!(atmp->value.asn1_string = ASN1_STRING_new())) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto bad_form; } if (format == ASN1_GEN_FORMAT_HEX) { if (!(rdata = string_to_hex((char *)str, &rdlen))) { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ASN1_R_ILLEGAL_HEX); + ASN1error(ASN1_R_ILLEGAL_HEX); goto bad_str; } @@ -743,23 +736,20 @@ asn1_str2type(const char *str, int format, int utype) } else if (format == ASN1_GEN_FORMAT_ASCII) { if (ASN1_STRING_set(atmp->value.asn1_string, str, -1) == 0) { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto bad_str; } } else if ((format == ASN1_GEN_FORMAT_BITLIST) && (utype == V_ASN1_BIT_STRING)) { if (!CONF_parse_list(str, ',', 1, bitstr_cb, atmp->value.bit_string)) { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ASN1_R_LIST_ERROR); + ASN1error(ASN1_R_LIST_ERROR); goto bad_str; } no_unused = 0; } else { - ASN1err(ASN1_F_ASN1_STR2TYPE, - ASN1_R_ILLEGAL_BITSTRING_FORMAT); + ASN1error(ASN1_R_ILLEGAL_BITSTRING_FORMAT); goto bad_form; } @@ -773,7 +763,7 @@ asn1_str2type(const char *str, int format, int utype) break; default: - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_UNSUPPORTED_TYPE); + ASN1error(ASN1_R_UNSUPPORTED_TYPE); goto bad_str; break; } @@ -800,11 +790,11 @@ bitstr_cb(const char *elem, int len, void *bitstr) if (eptr && *eptr && (eptr != elem + len)) return 0; if (bitnum < 0) { - ASN1err(ASN1_F_BITSTR_CB, ASN1_R_INVALID_NUMBER); + ASN1error(ASN1_R_INVALID_NUMBER); return 0; } if (!ASN1_BIT_STRING_set_bit(bitstr, bitnum, 1)) { - ASN1err(ASN1_F_BITSTR_CB, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } return 1; diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c index 444a34c072..a90873d54a 100644 --- a/src/lib/libcrypto/asn1/asn1_lib.c +++ b/src/lib/libcrypto/asn1/asn1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_lib.c,v 1.37 2016/03/06 18:05:00 beck Exp $ */ +/* $OpenBSD: asn1_lib.c,v 1.38 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -140,7 +140,7 @@ ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, goto err; if (*plength > (omax - (p - *pp))) { - ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_TOO_LONG); + ASN1error(ASN1_R_TOO_LONG); /* Set this so that even if things are not long enough * the values are set correctly */ ret |= 0x80; @@ -149,7 +149,7 @@ ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, return (ret | inf); err: - ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG); + ASN1error(ASN1_R_HEADER_TOO_LONG); return (0x80); } @@ -385,7 +385,7 @@ ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) unsigned char *tmp; tmp = realloc(str->data, len + 1); if (tmp == NULL) { - ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (0); } str->data = tmp; @@ -421,7 +421,7 @@ ASN1_STRING_type_new(int type) ret = malloc(sizeof(ASN1_STRING)); if (ret == NULL) { - ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (NULL); } ret->length = 0; diff --git a/src/lib/libcrypto/asn1/asn_mime.c b/src/lib/libcrypto/asn1/asn_mime.c index 1d82f1a76f..6bad111775 100644 --- a/src/lib/libcrypto/asn1/asn_mime.c +++ b/src/lib/libcrypto/asn1/asn_mime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn_mime.c,v 1.26 2015/02/22 15:19:56 jsing Exp $ */ +/* $OpenBSD: asn_mime.c,v 1.27 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -122,8 +122,7 @@ i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, BIO *bio, *tbio; bio = BIO_new_NDEF(out, val, it); if (!bio) { - ASN1err(ASN1_F_I2D_ASN1_BIO_STREAM, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } SMIME_crlf_copy(in, bio, flags); @@ -154,7 +153,7 @@ B64_write_ASN1(BIO *out, ASN1_VALUE *val, BIO *in, int flags, b64 = BIO_new(BIO_f_base64()); if (!b64) { - ASN1err(ASN1_F_B64_WRITE_ASN1, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } /* prepend the b64 BIO so all data is base64 encoded. @@ -187,13 +186,13 @@ b64_read_asn1(BIO *bio, const ASN1_ITEM *it) BIO *b64; ASN1_VALUE *val; if (!(b64 = BIO_new(BIO_f_base64()))) { - ASN1err(ASN1_F_B64_READ_ASN1, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } bio = BIO_push(b64, bio); val = ASN1_item_d2i_bio(it, bio, NULL); if (!val) - ASN1err(ASN1_F_B64_READ_ASN1, ASN1_R_DECODE_ERROR); + ASN1error(ASN1_R_DECODE_ERROR); (void)BIO_flush(bio); bio = BIO_pop(bio); BIO_free(b64); @@ -388,8 +387,7 @@ asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags, } if (!aux || !aux->asn1_cb) { - ASN1err(ASN1_F_ASN1_OUTPUT_DATA, - ASN1_R_STREAMING_NOT_SUPPORTED); + ASN1error(ASN1_R_STREAMING_NOT_SUPPORTED); return 0; } @@ -440,13 +438,13 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) *bcont = NULL; if (!(headers = mime_parse_hdr(bio))) { - ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_PARSE_ERROR); + ASN1error(ASN1_R_MIME_PARSE_ERROR); return NULL; } if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { sk_MIME_HEADER_pop_free(headers, mime_hdr_free); - ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_CONTENT_TYPE); + ASN1error(ASN1_R_NO_CONTENT_TYPE); return NULL; } @@ -457,15 +455,13 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) prm = mime_param_find(hdr, "boundary"); if (!prm || !prm->param_value) { sk_MIME_HEADER_pop_free(headers, mime_hdr_free); - ASN1err(ASN1_F_SMIME_READ_ASN1, - ASN1_R_NO_MULTIPART_BOUNDARY); + ASN1error(ASN1_R_NO_MULTIPART_BOUNDARY); return NULL; } ret = multi_split(bio, prm->param_value, &parts); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); if (!ret || (sk_BIO_num(parts) != 2) ) { - ASN1err(ASN1_F_SMIME_READ_ASN1, - ASN1_R_NO_MULTIPART_BODY_FAILURE); + ASN1error(ASN1_R_NO_MULTIPART_BODY_FAILURE); sk_BIO_pop_free(parts, BIO_vfree); return NULL; } @@ -474,8 +470,7 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) asnin = sk_BIO_value(parts, 1); if (!(headers = mime_parse_hdr(asnin))) { - ASN1err(ASN1_F_SMIME_READ_ASN1, - ASN1_R_MIME_SIG_PARSE_ERROR); + ASN1error(ASN1_R_MIME_SIG_PARSE_ERROR); sk_BIO_pop_free(parts, BIO_vfree); return NULL; } @@ -486,15 +481,13 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) !hdr->value) { sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_BIO_pop_free(parts, BIO_vfree); - ASN1err(ASN1_F_SMIME_READ_ASN1, - ASN1_R_NO_SIG_CONTENT_TYPE); + ASN1error(ASN1_R_NO_SIG_CONTENT_TYPE); return NULL; } if (strcmp(hdr->value, "application/x-pkcs7-signature") && strcmp(hdr->value, "application/pkcs7-signature")) { - ASN1err(ASN1_F_SMIME_READ_ASN1, - ASN1_R_SIG_INVALID_MIME_TYPE); + ASN1error(ASN1_R_SIG_INVALID_MIME_TYPE); ERR_asprintf_error_data("type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_BIO_pop_free(parts, BIO_vfree); @@ -503,8 +496,7 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) sk_MIME_HEADER_pop_free(headers, mime_hdr_free); /* Read in ASN1 */ if (!(val = b64_read_asn1(asnin, it))) { - ASN1err(ASN1_F_SMIME_READ_ASN1, - ASN1_R_ASN1_SIG_PARSE_ERROR); + ASN1error(ASN1_R_ASN1_SIG_PARSE_ERROR); sk_BIO_pop_free(parts, BIO_vfree); return NULL; } @@ -521,7 +513,7 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) if (strcmp (hdr->value, "application/x-pkcs7-mime") && strcmp (hdr->value, "application/pkcs7-mime")) { - ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_INVALID_MIME_TYPE); + ASN1error(ASN1_R_INVALID_MIME_TYPE); ERR_asprintf_error_data("type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return NULL; @@ -530,7 +522,7 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) sk_MIME_HEADER_pop_free(headers, mime_hdr_free); if (!(val = b64_read_asn1(bio, it))) { - ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_PARSE_ERROR); + ASN1error(ASN1_R_ASN1_PARSE_ERROR); return NULL; } return val; @@ -583,16 +575,16 @@ SMIME_text(BIO *in, BIO *out) MIME_HEADER *hdr; if (!(headers = mime_parse_hdr(in))) { - ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_PARSE_ERROR); + ASN1error(ASN1_R_MIME_PARSE_ERROR); return 0; } if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { - ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_NO_CONTENT_TYPE); + ASN1error(ASN1_R_MIME_NO_CONTENT_TYPE); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return 0; } if (strcmp (hdr->value, "text/plain")) { - ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_INVALID_MIME_TYPE); + ASN1error(ASN1_R_INVALID_MIME_TYPE); ERR_asprintf_error_data("type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return 0; diff --git a/src/lib/libcrypto/asn1/asn_moid.c b/src/lib/libcrypto/asn1/asn_moid.c index 76b6405212..7bf493e288 100644 --- a/src/lib/libcrypto/asn1/asn_moid.c +++ b/src/lib/libcrypto/asn1/asn_moid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn_moid.c,v 1.12 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: asn_moid.c,v 1.13 2017/01/29 17:49:22 beck Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -79,13 +79,13 @@ oid_module_init(CONF_IMODULE *md, const CONF *cnf) oid_section = CONF_imodule_get_value(md); if (!(sktmp = NCONF_get_section(cnf, oid_section))) { - ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION); + ASN1error(ASN1_R_ERROR_LOADING_SECTION); return 0; } for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { oval = sk_CONF_VALUE_value(sktmp, i); if (!do_create(oval->value, oval->name)) { - ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT); + ASN1error(ASN1_R_ADDING_OBJECT); return 0; } } diff --git a/src/lib/libcrypto/asn1/asn_pack.c b/src/lib/libcrypto/asn1/asn_pack.c index 65f4b9bf97..09d150583a 100644 --- a/src/lib/libcrypto/asn1/asn_pack.c +++ b/src/lib/libcrypto/asn1/asn_pack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn_pack.c,v 1.15 2015/12/23 20:37:23 mmcc Exp $ */ +/* $OpenBSD: asn_pack.c,v 1.16 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -77,7 +77,7 @@ ASN1_seq_unpack(const unsigned char *buf, int len, d2i_of_void *d2i, pbuf = buf; if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL))) - ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR); + ASN1error(ASN1_R_DECODE_ERROR); return sk; } @@ -94,11 +94,11 @@ ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d, if (!(safelen = i2d_ASN1_SET(safes, NULL, i2d, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE))) { - ASN1err(ASN1_F_ASN1_SEQ_PACK,ASN1_R_ENCODE_ERROR); + ASN1error(ASN1_R_ENCODE_ERROR); return NULL; } if (!(safe = malloc(safelen))) { - ASN1err(ASN1_F_ASN1_SEQ_PACK,ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return NULL; } p = safe; @@ -121,7 +121,7 @@ ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i) p = oct->data; if (!(ret = d2i(NULL, &p, oct->length))) - ASN1err(ASN1_F_ASN1_UNPACK_STRING,ASN1_R_DECODE_ERROR); + ASN1error(ASN1_R_DECODE_ERROR); return ret; } @@ -135,18 +135,18 @@ ASN1_pack_string(void *obj, i2d_of_void *i2d, ASN1_STRING **oct) if (!oct || !*oct) { if (!(octmp = ASN1_STRING_new())) { - ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return NULL; } } else octmp = *oct; if (!(octmp->length = i2d(obj, NULL))) { - ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR); + ASN1error(ASN1_R_ENCODE_ERROR); goto err; } if (!(p = malloc (octmp->length))) { - ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } octmp->data = p; @@ -174,7 +174,7 @@ ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) if (!oct || !*oct) { if (!(octmp = ASN1_STRING_new ())) { - ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return NULL; } } else @@ -184,11 +184,11 @@ ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) octmp->data = NULL; if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) { - ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR); + ASN1error(ASN1_R_ENCODE_ERROR); goto err; } if (!octmp->data) { - ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } if (oct) @@ -210,6 +210,6 @@ ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it) p = oct->data; if (!(ret = ASN1_item_d2i(NULL, &p, oct->length, it))) - ASN1err(ASN1_F_ASN1_ITEM_UNPACK, ASN1_R_DECODE_ERROR); + ASN1error(ASN1_R_DECODE_ERROR); return ret; } diff --git a/src/lib/libcrypto/asn1/bio_ndef.c b/src/lib/libcrypto/asn1/bio_ndef.c index 1a23c27d04..890b141304 100644 --- a/src/lib/libcrypto/asn1/bio_ndef.c +++ b/src/lib/libcrypto/asn1/bio_ndef.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_ndef.c,v 1.9 2014/07/25 06:05:32 doug Exp $ */ +/* $OpenBSD: bio_ndef.c,v 1.10 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -106,7 +106,7 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) ASN1_STREAM_ARG sarg; if (!aux || !aux->asn1_cb) { - ASN1err(ASN1_F_BIO_NEW_NDEF, ASN1_R_STREAMING_NOT_SUPPORTED); + ASN1error(ASN1_R_STREAMING_NOT_SUPPORTED); return NULL; } ndef_aux = malloc(sizeof(NDEF_SUPPORT)); diff --git a/src/lib/libcrypto/asn1/d2i_pr.c b/src/lib/libcrypto/asn1/d2i_pr.c index 68d02177c4..7a5880a8cd 100644 --- a/src/lib/libcrypto/asn1/d2i_pr.c +++ b/src/lib/libcrypto/asn1/d2i_pr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d2i_pr.c,v 1.14 2015/03/19 14:00:22 tedu Exp $ */ +/* $OpenBSD: d2i_pr.c,v 1.15 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -80,7 +80,7 @@ d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) if ((a == NULL) || (*a == NULL)) { if ((ret = EVP_PKEY_new()) == NULL) { - ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_EVP_LIB); + ASN1error(ERR_R_EVP_LIB); return (NULL); } } else { @@ -94,7 +94,7 @@ d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) } if (!EVP_PKEY_set_type(ret, type)) { - ASN1err(ASN1_F_D2I_PRIVATEKEY, ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE); + ASN1error(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE); goto err; } @@ -109,7 +109,7 @@ d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); } else { - ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB); + ASN1error(ERR_R_ASN1_LIB); goto err; } } @@ -153,8 +153,7 @@ d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, long length) sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free); if (!p8) { - ASN1err(ASN1_F_D2I_AUTOPRIVATEKEY, - ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); + ASN1error(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); return NULL; } ret = EVP_PKCS82PKEY(p8); diff --git a/src/lib/libcrypto/asn1/d2i_pu.c b/src/lib/libcrypto/asn1/d2i_pu.c index e917356254..3750265e7f 100644 --- a/src/lib/libcrypto/asn1/d2i_pu.c +++ b/src/lib/libcrypto/asn1/d2i_pu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d2i_pu.c,v 1.13 2015/03/19 14:00:22 tedu Exp $ */ +/* $OpenBSD: d2i_pu.c,v 1.14 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -83,14 +83,14 @@ d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) if ((a == NULL) || (*a == NULL)) { if ((ret = EVP_PKEY_new()) == NULL) { - ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_EVP_LIB); + ASN1error(ERR_R_EVP_LIB); return (NULL); } } else ret = *a; if (!EVP_PKEY_set_type(ret, type)) { - ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_EVP_LIB); + ASN1error(ERR_R_EVP_LIB); goto err; } @@ -99,7 +99,7 @@ d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) case EVP_PKEY_RSA: if ((ret->pkey.rsa = d2i_RSAPublicKey(NULL, pp, length)) == NULL) { - ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB); + ASN1error(ERR_R_ASN1_LIB); goto err; } break; @@ -107,7 +107,7 @@ d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) #ifndef OPENSSL_NO_DSA case EVP_PKEY_DSA: if (!d2i_DSAPublicKey(&(ret->pkey.dsa), pp, length)) { - ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB); + ASN1error(ERR_R_ASN1_LIB); goto err; } break; @@ -115,13 +115,13 @@ d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) #ifndef OPENSSL_NO_EC case EVP_PKEY_EC: if (!o2i_ECPublicKey(&(ret->pkey.ec), pp, length)) { - ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB); + ASN1error(ERR_R_ASN1_LIB); goto err; } break; #endif default: - ASN1err(ASN1_F_D2I_PUBLICKEY, ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE); + ASN1error(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE); goto err; /* break; */ } diff --git a/src/lib/libcrypto/asn1/evp_asn1.c b/src/lib/libcrypto/asn1/evp_asn1.c index 1f36cebad7..83228bb5d2 100644 --- a/src/lib/libcrypto/asn1/evp_asn1.c +++ b/src/lib/libcrypto/asn1/evp_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_asn1.c,v 1.18 2015/09/30 19:07:08 jsing Exp $ */ +/* $OpenBSD: evp_asn1.c,v 1.19 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -87,7 +87,7 @@ ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len) if ((a->type != V_ASN1_OCTET_STRING) || (a->value.octet_string == NULL)) { - ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING, ASN1_R_DATA_IS_WRONG); + ASN1error(ASN1_R_DATA_IS_WRONG); return (-1); } p = ASN1_STRING_data(a->value.octet_string); @@ -192,8 +192,7 @@ ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data, memcpy(data, ASN1_STRING_data(os), n); if (0) { err: - ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, - ASN1_R_DATA_IS_WRONG); + ASN1error(ASN1_R_DATA_IS_WRONG); } ASN1_OCTET_STRING_free(os); ASN1_INTEGER_free(ai); diff --git a/src/lib/libcrypto/asn1/f_enum.c b/src/lib/libcrypto/asn1/f_enum.c index 7f064edb04..64feb97dc4 100644 --- a/src/lib/libcrypto/asn1/f_enum.c +++ b/src/lib/libcrypto/asn1/f_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_enum.c,v 1.14 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: f_enum.c,v 1.15 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -150,16 +150,14 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) k = 0; i -= again; if (i % 2 != 0) { - ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, - ASN1_R_ODD_NUMBER_OF_CHARS); + ASN1error(ASN1_R_ODD_NUMBER_OF_CHARS); goto err; } i /= 2; if (num + i > slen) { sp = realloc(s, num + i); if (sp == NULL) { - ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } s = sp; @@ -175,8 +173,7 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) else if ((m >= 'A') && (m <= 'F')) m = m - 'A' + 10; else { - ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, - ASN1_R_NON_HEX_CHARACTERS); + ASN1error(ASN1_R_NON_HEX_CHARACTERS); goto err; } s[num + j] <<= 4; @@ -194,7 +191,7 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) return (1); err_sl: - ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE); + ASN1error(ASN1_R_SHORT_LINE); err: free(s); return (ret); diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c index 0ec29f5769..75168872b3 100644 --- a/src/lib/libcrypto/asn1/f_int.c +++ b/src/lib/libcrypto/asn1/f_int.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_int.c,v 1.17 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: f_int.c,v 1.18 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -153,16 +153,14 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) k = 0; i -= again; if (i % 2 != 0) { - ASN1err(ASN1_F_A2I_ASN1_INTEGER, - ASN1_R_ODD_NUMBER_OF_CHARS); + ASN1error(ASN1_R_ODD_NUMBER_OF_CHARS); goto err; } i /= 2; if (num + i > slen) { sp = OPENSSL_realloc_clean(s, slen, num + i); if (sp == NULL) { - ASN1err(ASN1_F_A2I_ASN1_INTEGER, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } s = sp; @@ -178,8 +176,7 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) else if ((m >= 'A') && (m <= 'F')) m = m - 'A' + 10; else { - ASN1err(ASN1_F_A2I_ASN1_INTEGER, - ASN1_R_NON_HEX_CHARACTERS); + ASN1error(ASN1_R_NON_HEX_CHARACTERS); goto err; } s[num + j] <<= 4; @@ -197,7 +194,7 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) return (1); err_sl: - ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE); + ASN1error(ASN1_R_SHORT_LINE); err: free(s); return (ret); diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c index 14cd1a906a..138044e063 100644 --- a/src/lib/libcrypto/asn1/f_string.c +++ b/src/lib/libcrypto/asn1/f_string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: f_string.c,v 1.16 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: f_string.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -146,16 +146,14 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) k = 0; i -= again; if (i % 2 != 0) { - ASN1err(ASN1_F_A2I_ASN1_STRING, - ASN1_R_ODD_NUMBER_OF_CHARS); + ASN1error(ASN1_R_ODD_NUMBER_OF_CHARS); goto err; } i /= 2; if (num + i > slen) { sp = realloc(s, num + i); if (sp == NULL) { - ASN1err(ASN1_F_A2I_ASN1_STRING, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } s = sp; @@ -171,8 +169,7 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) else if ((m >= 'A') && (m <= 'F')) m = m - 'A' + 10; else { - ASN1err(ASN1_F_A2I_ASN1_STRING, - ASN1_R_NON_HEX_CHARACTERS); + ASN1error(ASN1_R_NON_HEX_CHARACTERS); goto err; } s[num + j] <<= 4; @@ -190,7 +187,7 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) return (1); err_sl: - ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE); + ASN1error(ASN1_R_SHORT_LINE); err: free(s); return (ret); diff --git a/src/lib/libcrypto/asn1/i2d_pr.c b/src/lib/libcrypto/asn1/i2d_pr.c index 5fa34678b6..0b545aeb49 100644 --- a/src/lib/libcrypto/asn1/i2d_pr.c +++ b/src/lib/libcrypto/asn1/i2d_pr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i2d_pr.c,v 1.10 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: i2d_pr.c,v 1.11 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -76,6 +76,6 @@ i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp) PKCS8_PRIV_KEY_INFO_free(p8); return ret; } - ASN1err(ASN1_F_I2D_PRIVATEKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); + ASN1error(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); return (-1); } diff --git a/src/lib/libcrypto/asn1/i2d_pu.c b/src/lib/libcrypto/asn1/i2d_pu.c index 6e485ea325..9baa84967b 100644 --- a/src/lib/libcrypto/asn1/i2d_pu.c +++ b/src/lib/libcrypto/asn1/i2d_pu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i2d_pu.c,v 1.10 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: i2d_pu.c,v 1.11 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -92,7 +92,7 @@ i2d_PublicKey(EVP_PKEY *a, unsigned char **pp) return (i2o_ECPublicKey(a->pkey.ec, pp)); #endif default: - ASN1err(ASN1_F_I2D_PUBLICKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); + ASN1error(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); return (-1); } } diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c index 1e73c82d09..d2fabf6e87 100644 --- a/src/lib/libcrypto/asn1/n_pkey.c +++ b/src/lib/libcrypto/asn1/n_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: n_pkey.c,v 1.30 2015/10/16 15:15:39 jsing Exp $ */ +/* $OpenBSD: n_pkey.c,v 1.31 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -260,7 +260,7 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, /* Since its RC4 encrypted length is actual length */ if ((zz = malloc(rsalen)) == NULL) { - ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } @@ -269,12 +269,12 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, i2d_RSAPrivateKey(a, &zz); if ((zz = malloc(pkeylen)) == NULL) { - ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } if (!ASN1_STRING_set(enckey->os, "private-key", -1)) { - ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } enckey->enckey->digest->data = zz; @@ -287,7 +287,7 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, cb = EVP_read_pw_string; i = cb((char *)buf, sizeof(buf), "Enter Private Key password:", 1); if (i != 0) { - ASN1err(ASN1_F_I2D_RSA_NET, ASN1_R_BAD_PASSWORD_READ); + ASN1error(ASN1_R_BAD_PASSWORD_READ); goto err; } i = strlen((char *)buf); @@ -340,19 +340,18 @@ d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, enckey = d2i_NETSCAPE_ENCRYPTED_PKEY(NULL, &p, length); if (!enckey) { - ASN1err(ASN1_F_D2I_RSA_NET, ASN1_R_DECODING_ERROR); + ASN1error(ASN1_R_DECODING_ERROR); return NULL; } /* XXX 11 == strlen("private-key") */ if (enckey->os->length != 11 || memcmp("private-key", enckey->os->data, 11) != 0) { - ASN1err(ASN1_F_D2I_RSA_NET, ASN1_R_PRIVATE_KEY_HEADER_MISSING); + ASN1error(ASN1_R_PRIVATE_KEY_HEADER_MISSING); goto err; } if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4) { - ASN1err(ASN1_F_D2I_RSA_NET, - ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM); + ASN1error(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM); goto err; } if (cb == NULL) @@ -384,7 +383,7 @@ d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, i=cb((char *)buf, sizeof(buf), "Enter Private Key password:",0); if (i != 0) { - ASN1err(ASN1_F_D2I_RSA_NET_2, ASN1_R_BAD_PASSWORD_READ); + ASN1error(ASN1_R_BAD_PASSWORD_READ); goto err; } @@ -411,15 +410,14 @@ d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, zz = os->data; if ((pkey = d2i_NETSCAPE_PKEY(NULL, &zz, os->length)) == NULL) { - ASN1err(ASN1_F_D2I_RSA_NET_2, - ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY); + ASN1error(ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY); goto err; } zz = pkey->private_key->data; if ((ret = d2i_RSAPrivateKey(a, &zz, pkey->private_key->length)) == NULL) { - ASN1err(ASN1_F_D2I_RSA_NET_2, ASN1_R_UNABLE_TO_DECODE_RSA_KEY); + ASN1error(ASN1_R_UNABLE_TO_DECODE_RSA_KEY); goto err; } diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c index e0609e02e9..8fd416a3e5 100644 --- a/src/lib/libcrypto/asn1/p5_pbe.c +++ b/src/lib/libcrypto/asn1/p5_pbe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p5_pbe.c,v 1.21 2016/12/30 16:04:34 jsing Exp $ */ +/* $OpenBSD: p5_pbe.c,v 1.22 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -127,19 +127,19 @@ PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, pbe = PBEPARAM_new(); if (!pbe) { - ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } if (iter <= 0) iter = PKCS5_DEFAULT_ITER; if (!ASN1_INTEGER_set(pbe->iter, iter)) { - ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } if (!saltlen) saltlen = PKCS5_SALT_LEN; if (!ASN1_STRING_set(pbe->salt, NULL, saltlen)) { - ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } sstr = ASN1_STRING_data(pbe->salt); @@ -149,7 +149,7 @@ PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, arc4random_buf(sstr, saltlen); if (!ASN1_item_pack(pbe, &PBEPARAM_it, &pbe_str)) { - ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } @@ -174,7 +174,7 @@ PKCS5_pbe_set(int alg, int iter, const unsigned char *salt, int saltlen) X509_ALGOR *ret; ret = X509_ALGOR_new(); if (!ret) { - ASN1err(ASN1_F_PKCS5_PBE_SET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return NULL; } diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c index 155e2b0b3e..0105c59549 100644 --- a/src/lib/libcrypto/asn1/p5_pbev2.c +++ b/src/lib/libcrypto/asn1/p5_pbev2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p5_pbev2.c,v 1.24 2016/12/30 16:04:34 jsing Exp $ */ +/* $OpenBSD: p5_pbev2.c,v 1.25 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999-2004. */ @@ -193,8 +193,7 @@ PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, unsigned char *salt, alg_nid = EVP_CIPHER_type(cipher); if (alg_nid == NID_undef) { - ASN1err(ASN1_F_PKCS5_PBE2_SET_IV, - ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER); + ASN1error(ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER); goto err; } obj = OBJ_nid2obj(alg_nid); @@ -223,8 +222,7 @@ PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, unsigned char *salt, if (!EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0)) goto err; if (EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) { - ASN1err(ASN1_F_PKCS5_PBE2_SET_IV, - ASN1_R_ERROR_SETTING_CIPHER_PARAMS); + ASN1error(ASN1_R_ERROR_SETTING_CIPHER_PARAMS); EVP_CIPHER_CTX_cleanup(&ctx); goto err; } @@ -275,7 +273,7 @@ PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, unsigned char *salt, return ret; merr: - ASN1err(ASN1_F_PKCS5_PBE2_SET_IV, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); err: PBE2PARAM_free(pbe2); @@ -367,7 +365,7 @@ PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, int prf_nid, return keyfunc; merr: - ASN1err(ASN1_F_PKCS5_PBKDF2_SET, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); PBKDF2PARAM_free(kdf); X509_ALGOR_free(keyfunc); return NULL; diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c index 67116361a5..c8122442bb 100644 --- a/src/lib/libcrypto/asn1/t_crl.c +++ b/src/lib/libcrypto/asn1/t_crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_crl.c,v 1.16 2014/07/12 16:33:25 miod Exp $ */ +/* $OpenBSD: t_crl.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -72,7 +72,7 @@ X509_CRL_print_fp(FILE *fp, X509_CRL *x) int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { - X509err(X509_F_X509_CRL_PRINT_FP, ERR_R_BUF_LIB); + X509error(ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c index 8db456708a..a9b14fed73 100644 --- a/src/lib/libcrypto/asn1/t_req.c +++ b/src/lib/libcrypto/asn1/t_req.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_req.c,v 1.18 2015/07/29 14:58:34 jsing Exp $ */ +/* $OpenBSD: t_req.c,v 1.19 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -81,7 +81,7 @@ X509_REQ_print_fp(FILE *fp, X509_REQ *x) int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { - X509err(X509_F_X509_REQ_PRINT_FP, ERR_R_BUF_LIB); + X509error(ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); @@ -256,7 +256,7 @@ get_next: return (1); err: - X509err(X509_F_X509_REQ_PRINT_EX, ERR_R_BUF_LIB); + X509error(ERR_R_BUF_LIB); return (0); } diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c index 1c83fc5608..14cbabedc7 100644 --- a/src/lib/libcrypto/asn1/t_x509.c +++ b/src/lib/libcrypto/asn1/t_x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_x509.c,v 1.26 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: t_x509.c,v 1.27 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -92,7 +92,7 @@ X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag) int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { - X509err(X509_F_X509_PRINT_EX_FP, ERR_R_BUF_LIB); + X509error(ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); @@ -530,7 +530,7 @@ X509_NAME_print(BIO *bp, X509_NAME *name, int obase) ret = 1; if (0) { err: - X509err(X509_F_X509_NAME_PRINT, ERR_R_BUF_LIB); + X509error(ERR_R_BUF_LIB); } free(b); return (ret); diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index de78164995..3f680c60fd 100644 --- a/src/lib/libcrypto/asn1/tasn_dec.c +++ b/src/lib/libcrypto/asn1/tasn_dec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_dec.c,v 1.33 2016/12/30 16:04:34 jsing Exp $ */ +/* $OpenBSD: tasn_dec.c,v 1.34 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -189,8 +189,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, * template itself. */ if ((tag != -1) || opt) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE); + ASN1error(ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE); goto err; } return asn1_template_ex_d2i(pval, in, len, @@ -206,8 +205,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL, &p, len, -1, 0, 1, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } @@ -216,8 +214,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, /* If OPTIONAL, assume this is OK */ if (opt) return -1; - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ASN1_R_MSTRING_NOT_UNIVERSAL); + ASN1error(ASN1_R_MSTRING_NOT_UNIVERSAL); goto err; } /* Check tag matches bit map */ @@ -225,8 +222,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, /* If OPTIONAL, assume this is OK */ if (opt) return -1; - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ASN1_R_MSTRING_WRONG_TAG); + ASN1error(ASN1_R_MSTRING_WRONG_TAG); goto err; } return asn1_d2i_ex_primitive(pval, in, len, @@ -252,8 +248,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, asn1_set_choice_selector(pval, -1, it); } } else if (!ASN1_item_ex_new(pval, it)) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } /* CHOICE type, try each possibility in turn */ @@ -272,8 +267,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, break; /* Otherwise must be an ASN1 parsing error */ errtt = tt; - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } @@ -285,8 +279,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, ASN1_item_ex_free(pval, it); return -1; } - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ASN1_R_NO_MATCHING_CHOICE_TYPE); + ASN1error(ASN1_R_NO_MATCHING_CHOICE_TYPE); goto err; } @@ -310,8 +303,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst, &p, len, tag, aclass, opt, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } else if (ret == -1) return -1; @@ -323,14 +315,12 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, else seq_nolen = seq_eoc; if (!cst) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ASN1_R_SEQUENCE_NOT_CONSTRUCTED); + ASN1error(ASN1_R_SEQUENCE_NOT_CONSTRUCTED); goto err; } if (!*pval && !ASN1_item_ex_new(pval, it)) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } @@ -364,8 +354,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, q = p; if (asn1_check_eoc(&p, len)) { if (!seq_eoc) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ASN1_R_UNEXPECTED_EOC); + ASN1error(ASN1_R_UNEXPECTED_EOC); goto err; } len -= p - q; @@ -404,13 +393,12 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, /* Check for EOC if expecting one */ if (seq_eoc && !asn1_check_eoc(&p, len)) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MISSING_EOC); + ASN1error(ASN1_R_MISSING_EOC); goto err; } /* Check all data read */ if (!seq_nolen && len) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ASN1_R_SEQUENCE_LENGTH_MISMATCH); + ASN1error(ASN1_R_SEQUENCE_LENGTH_MISMATCH); goto err; } @@ -429,14 +417,13 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, ASN1_template_free(pseqval, seqtt); } else { errtt = seqtt; - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, - ASN1_R_FIELD_MISSING); + ASN1error(ASN1_R_FIELD_MISSING); goto err; } } /* Save encoding */ if (!asn1_enc_save(pval, *in, p - *in, it)) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto auxerr; } *in = p; @@ -449,7 +436,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, } auxerr: - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_AUX_ERROR); + ASN1error(ASN1_R_AUX_ERROR); err: if (combine == 0) ASN1_item_ex_free(pval, it); @@ -493,21 +480,18 @@ asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, &p, inlen, tt->tag, aclass, opt, ctx); q = p; if (!ret) { - ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; } else if (ret == -1) return -1; if (!cst) { - ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, - ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED); + ASN1error(ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED); return 0; } /* We've found the field so it can't be OPTIONAL now */ ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; } /* We read the field in OK so update length */ @@ -515,16 +499,14 @@ asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, if (exp_eoc) { /* If NDEF we must have an EOC here */ if (!asn1_check_eoc(&p, len)) { - ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, - ASN1_R_MISSING_EOC); + ASN1error(ASN1_R_MISSING_EOC); goto err; } } else { /* Otherwise we must hit the EXPLICIT tag end or its * an error */ if (len) { - ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, - ASN1_R_EXPLICIT_LENGTH_MISMATCH); + ASN1error(ASN1_R_EXPLICIT_LENGTH_MISMATCH); goto err; } } @@ -574,8 +556,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, ret = asn1_check_tlen(&len, NULL, NULL, &sk_eoc, NULL, &p, len, sktag, skaclass, opt, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; } else if (ret == -1) return -1; @@ -594,8 +575,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, } if (!*val) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } @@ -606,8 +586,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, /* See if EOC found */ if (asn1_check_eoc(&p, len)) { if (!sk_eoc) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, - ASN1_R_UNEXPECTED_EOC); + ASN1error(ASN1_R_UNEXPECTED_EOC); goto err; } len -= p - q; @@ -617,21 +596,18 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, skfield = NULL; if (!ASN1_item_ex_d2i(&skfield, &p, len, tt->item, -1, 0, 0, ctx)) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } len -= p - q; if (!sk_ASN1_VALUE_push((STACK_OF(ASN1_VALUE) *)*val, skfield)) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } } if (sk_eoc) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, - ASN1_R_MISSING_EOC); + ASN1error(ASN1_R_MISSING_EOC); goto err; } } else if (flags & ASN1_TFLG_IMPTAG) { @@ -639,8 +615,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, ret = ASN1_item_ex_d2i(val, &p, len, tt->item, tt->tag, aclass, opt, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } else if (ret == -1) return -1; @@ -649,8 +624,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, ret = ASN1_item_ex_d2i(val, &p, len, tt->item, -1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); goto err; } else if (ret == -1) return -1; @@ -681,7 +655,7 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, buf.data = NULL; if (!pval) { - ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL); + ASN1error(ASN1_R_ILLEGAL_NULL); return 0; /* Should never happen */ } @@ -695,21 +669,18 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, /* If type is ANY need to figure out type from tag */ unsigned char oclass; if (tag >= 0) { - ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, - ASN1_R_ILLEGAL_TAGGED_ANY); + ASN1error(ASN1_R_ILLEGAL_TAGGED_ANY); return 0; } if (opt) { - ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, - ASN1_R_ILLEGAL_OPTIONAL_ANY); + ASN1error(ASN1_R_ILLEGAL_OPTIONAL_ANY); return 0; } p = *in; ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL, &p, inlen, -1, 0, 0, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, - ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; } if (oclass != V_ASN1_UNIVERSAL) @@ -724,7 +695,7 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst, &p, inlen, tag, aclass, opt, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; } else if (ret == -1) return -1; @@ -740,8 +711,7 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, } /* SEQUENCE and SET must be constructed */ else if (!cst) { - ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, - ASN1_R_TYPE_NOT_CONSTRUCTED); + ASN1error(ASN1_R_TYPE_NOT_CONSTRUCTED); return 0; } @@ -770,8 +740,7 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, len = buf.length; /* Append a final null to string */ if (!BUF_MEM_grow_clean(&buf, len + 1)) { - ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } buf.data[len] = 0; @@ -836,8 +805,7 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, case V_ASN1_NULL: if (len) { - ASN1err(ASN1_F_ASN1_EX_C2I, - ASN1_R_NULL_IS_WRONG_LENGTH); + ASN1error(ASN1_R_NULL_IS_WRONG_LENGTH); goto err; } *pval = (ASN1_VALUE *)1; @@ -845,8 +813,7 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, case V_ASN1_BOOLEAN: if (len != 1) { - ASN1err(ASN1_F_ASN1_EX_C2I, - ASN1_R_BOOLEAN_IS_WRONG_LENGTH); + ASN1error(ASN1_R_BOOLEAN_IS_WRONG_LENGTH); goto err; } else { ASN1_BOOLEAN *tbool; @@ -888,21 +855,18 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, case V_ASN1_SEQUENCE: default: if (utype == V_ASN1_BMPSTRING && (len & 1)) { - ASN1err(ASN1_F_ASN1_EX_C2I, - ASN1_R_BMPSTRING_IS_WRONG_LENGTH); + ASN1error(ASN1_R_BMPSTRING_IS_WRONG_LENGTH); goto err; } if (utype == V_ASN1_UNIVERSALSTRING && (len & 3)) { - ASN1err(ASN1_F_ASN1_EX_C2I, - ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH); + ASN1error(ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH); goto err; } /* All based on ASN1_STRING and handled the same */ if (!*pval) { stmp = ASN1_STRING_type_new(utype); if (!stmp) { - ASN1err(ASN1_F_ASN1_EX_C2I, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } *pval = (ASN1_VALUE *)stmp; @@ -918,8 +882,7 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, *free_cont = 0; } else { if (!ASN1_STRING_set(stmp, cont, len)) { - ASN1err(ASN1_F_ASN1_EX_C2I, - ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); ASN1_STRING_free(stmp); *pval = NULL; goto err; @@ -979,7 +942,7 @@ asn1_find_end(const unsigned char **in, long len, char inf) /* Just read in a header: only care about the length */ if (!asn1_check_tlen(&plen, NULL, NULL, &inf, NULL, &p, len, -1, 0, 0, NULL)) { - ASN1err(ASN1_F_ASN1_FIND_END, ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; } if (inf) @@ -989,7 +952,7 @@ asn1_find_end(const unsigned char **in, long len, char inf) len -= p - q; } if (expected_eoc) { - ASN1err(ASN1_F_ASN1_FIND_END, ASN1_R_MISSING_EOC); + ASN1error(ASN1_R_MISSING_EOC); return 0; } *in = p; @@ -1033,8 +996,7 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, /* EOC is illegal outside indefinite length * constructed form */ if (!inf) { - ASN1err(ASN1_F_ASN1_COLLECT, - ASN1_R_UNEXPECTED_EOC); + ASN1error(ASN1_R_UNEXPECTED_EOC); return 0; } inf = 0; @@ -1043,15 +1005,14 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, if (!asn1_check_tlen(&plen, NULL, NULL, &ininf, &cst, &p, len, tag, aclass, 0, NULL)) { - ASN1err(ASN1_F_ASN1_COLLECT, ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; } /* If indefinite length constructed update max length */ if (cst) { if (depth >= ASN1_MAX_STRING_NEST) { - ASN1err(ASN1_F_ASN1_COLLECT, - ASN1_R_NESTED_ASN1_STRING); + ASN1error(ASN1_R_NESTED_ASN1_STRING); return 0; } if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, @@ -1062,7 +1023,7 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, len -= p - q; } if (inf) { - ASN1err(ASN1_F_ASN1_COLLECT, ASN1_R_MISSING_EOC); + ASN1error(ASN1_R_MISSING_EOC); return 0; } *in = p; @@ -1076,7 +1037,7 @@ collect_data(BUF_MEM *buf, const unsigned char **p, long plen) if (buf) { len = buf->length; if (!BUF_MEM_grow_clean(buf, len + plen)) { - ASN1err(ASN1_F_COLLECT_DATA, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } memcpy(buf->data + len, *p, plen); @@ -1141,8 +1102,7 @@ asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, * header can't exceed total amount of data available. */ if (!(i & 0x81) && ((plen + ctx->hdrlen) > len)) { - ASN1err(ASN1_F_ASN1_CHECK_TLEN, - ASN1_R_TOO_LONG); + ASN1error(ASN1_R_TOO_LONG); asn1_tlc_clear(ctx); return 0; } @@ -1150,7 +1110,7 @@ asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, } if (i & 0x80) { - ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_BAD_OBJECT_HEADER); + ASN1error(ASN1_R_BAD_OBJECT_HEADER); asn1_tlc_clear(ctx); return 0; } @@ -1162,7 +1122,7 @@ asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, if (opt) return -1; asn1_tlc_clear(ctx); - ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_WRONG_TAG); + ASN1error(ASN1_R_WRONG_TAG); return 0; } /* We have a tag and class match: diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c index 491de0131e..e9bbc05e08 100644 --- a/src/lib/libcrypto/asn1/tasn_new.c +++ b/src/lib/libcrypto/asn1/tasn_new.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_new.c,v 1.16 2016/12/30 16:04:34 jsing Exp $ */ +/* $OpenBSD: tasn_new.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -190,7 +190,7 @@ asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) return 1; memerr: - ASN1err(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); #ifdef CRYPTO_MDEBUG if (it->sname) CRYPTO_pop_info(); @@ -198,7 +198,7 @@ memerr: return 0; auxerr: - ASN1err(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW, ASN1_R_AUX_ERROR); + ASN1error(ASN1_R_AUX_ERROR); ASN1_item_ex_free(pval, it); #ifdef CRYPTO_MDEBUG if (it->sname) @@ -266,7 +266,7 @@ ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) STACK_OF(ASN1_VALUE) *skval; skval = sk_ASN1_VALUE_new_null(); if (!skval) { - ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); ret = 0; goto done; } diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c index 80e7fbb890..7cccd56a16 100644 --- a/src/lib/libcrypto/asn1/tasn_prn.c +++ b/src/lib/libcrypto/asn1/tasn_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_prn.c,v 1.15 2016/12/30 16:04:34 jsing Exp $ */ +/* $OpenBSD: tasn_prn.c,v 1.16 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -87,7 +87,7 @@ ASN1_PCTX_new(void) ASN1_PCTX *ret; ret = malloc(sizeof(ASN1_PCTX)); if (ret == NULL) { - ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return NULL; } ret->flags = 0; diff --git a/src/lib/libcrypto/asn1/tasn_utl.c b/src/lib/libcrypto/asn1/tasn_utl.c index 529aaf6116..391ef01a57 100644 --- a/src/lib/libcrypto/asn1/tasn_utl.c +++ b/src/lib/libcrypto/asn1/tasn_utl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_utl.c,v 1.11 2015/07/25 17:07:17 jsing Exp $ */ +/* $OpenBSD: tasn_utl.c,v 1.12 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -275,7 +275,6 @@ asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr) err: /* FIXME: should log the value or OID of unsupported type */ if (nullerr) - ASN1err(ASN1_F_ASN1_DO_ADB, - ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE); + ASN1error(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE); return NULL; } diff --git a/src/lib/libcrypto/asn1/x_crl.c b/src/lib/libcrypto/asn1/x_crl.c index eeff341d7d..d8f24ca10b 100644 --- a/src/lib/libcrypto/asn1/x_crl.c +++ b/src/lib/libcrypto/asn1/x_crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_crl.c,v 1.26 2016/12/30 16:04:34 jsing Exp $ */ +/* $OpenBSD: x_crl.c,v 1.27 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -535,7 +535,7 @@ X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev) if (!inf->revoked) inf->revoked = sk_X509_REVOKED_new(X509_REVOKED_cmp); if (!inf->revoked || !sk_X509_REVOKED_push(inf->revoked, rev)) { - ASN1err(ASN1_F_X509_CRL_ADD0_REVOKED, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } inf->enc.modified = 1; diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c index 05ac364fa7..c476923158 100644 --- a/src/lib/libcrypto/asn1/x_info.c +++ b/src/lib/libcrypto/asn1/x_info.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_info.c,v 1.16 2016/03/11 07:08:44 mmcc Exp $ */ +/* $OpenBSD: x_info.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -70,7 +70,7 @@ X509_INFO_new(void) ret = malloc(sizeof(X509_INFO)); if (ret == NULL) { - ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (NULL); } diff --git a/src/lib/libcrypto/asn1/x_long.c b/src/lib/libcrypto/asn1/x_long.c index 90a41129bc..9df3a3181a 100644 --- a/src/lib/libcrypto/asn1/x_long.c +++ b/src/lib/libcrypto/asn1/x_long.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_long.c,v 1.10 2015/07/25 17:07:17 jsing Exp $ */ +/* $OpenBSD: x_long.c,v 1.11 2017/01/29 17:49:22 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -173,7 +173,7 @@ long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, unsigned long utmp = 0; char *cp = (char *)pval; if (len > (int)sizeof(long)) { - ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); + ASN1error(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); return 0; } /* Is it negative? */ @@ -195,7 +195,7 @@ long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, ltmp = -ltmp; } if (ltmp == it->size) { - ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); + ASN1error(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); return 0; } memcpy(cp, <mp, sizeof(long)); diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c index 87bcc2c5ba..30fef39fb7 100644 --- a/src/lib/libcrypto/asn1/x_name.c +++ b/src/lib/libcrypto/asn1/x_name.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_name.c,v 1.32 2016/12/30 16:04:34 jsing Exp $ */ +/* $OpenBSD: x_name.c,v 1.33 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -257,7 +257,7 @@ x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it) return 1; memerr: - ASN1err(ASN1_F_X509_NAME_EX_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); if (ret) { if (ret->entries) sk_X509_NAME_ENTRY_free(ret->entries); @@ -339,7 +339,7 @@ x509_name_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long len, err: if (nm.x != NULL) X509_NAME_free(nm.x); - ASN1err(ASN1_F_X509_NAME_EX_D2I, ERR_R_NESTED_ASN1_ERROR); + ASN1error(ERR_R_NESTED_ASN1_ERROR); return 0; } @@ -424,7 +424,7 @@ x509_name_encode(X509_NAME *a) memerr: sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s, local_sk_X509_NAME_ENTRY_free); - ASN1err(ASN1_F_X509_NAME_ENCODE, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return -1; } diff --git a/src/lib/libcrypto/asn1/x_pkey.c b/src/lib/libcrypto/asn1/x_pkey.c index 701db0fc6d..c946281f4a 100644 --- a/src/lib/libcrypto/asn1/x_pkey.c +++ b/src/lib/libcrypto/asn1/x_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_pkey.c,v 1.19 2015/09/30 18:41:06 jsing Exp $ */ +/* $OpenBSD: x_pkey.c,v 1.20 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -70,16 +70,16 @@ X509_PKEY_new(void) X509_PKEY *ret = NULL; if ((ret = malloc(sizeof(X509_PKEY))) == NULL) { - ASN1err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } ret->version = 0; if ((ret->enc_algor = X509_ALGOR_new()) == NULL) { - ASN1err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } if ((ret->enc_pkey = ASN1_OCTET_STRING_new()) == NULL) { - ASN1err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); goto err; } ret->dec_pkey = NULL; diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c index 3bdbb5a536..738507bbb6 100644 --- a/src/lib/libcrypto/asn1/x_pubkey.c +++ b/src/lib/libcrypto/asn1/x_pubkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_pubkey.c,v 1.25 2015/02/11 04:00:39 jsing Exp $ */ +/* $OpenBSD: x_pubkey.c,v 1.26 2017/01/29 17:49:22 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -149,17 +149,15 @@ X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) if (pkey->ameth) { if (pkey->ameth->pub_encode) { if (!pkey->ameth->pub_encode(pk, pkey)) { - X509err(X509_F_X509_PUBKEY_SET, - X509_R_PUBLIC_KEY_ENCODE_ERROR); + X509error(X509_R_PUBLIC_KEY_ENCODE_ERROR); goto error; } } else { - X509err(X509_F_X509_PUBKEY_SET, - X509_R_METHOD_NOT_SUPPORTED); + X509error(X509_R_METHOD_NOT_SUPPORTED); goto error; } } else { - X509err(X509_F_X509_PUBKEY_SET, X509_R_UNSUPPORTED_ALGORITHM); + X509error(X509_R_UNSUPPORTED_ALGORITHM); goto error; } @@ -193,23 +191,22 @@ X509_PUBKEY_get(X509_PUBKEY *key) goto error; if ((ret = EVP_PKEY_new()) == NULL) { - X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE); + X509error(ERR_R_MALLOC_FAILURE); goto error; } if (!EVP_PKEY_set_type(ret, OBJ_obj2nid(key->algor->algorithm))) { - X509err(X509_F_X509_PUBKEY_GET, X509_R_UNSUPPORTED_ALGORITHM); + X509error(X509_R_UNSUPPORTED_ALGORITHM); goto error; } if (ret->ameth->pub_decode) { if (!ret->ameth->pub_decode(ret, key)) { - X509err(X509_F_X509_PUBKEY_GET, - X509_R_PUBLIC_KEY_DECODE_ERROR); + X509error(X509_R_PUBLIC_KEY_DECODE_ERROR); goto error; } } else { - X509err(X509_F_X509_PUBKEY_GET, X509_R_METHOD_NOT_SUPPORTED); + X509error(X509_R_METHOD_NOT_SUPPORTED); goto error; } @@ -304,7 +301,7 @@ i2d_RSA_PUBKEY(RSA *a, unsigned char **pp) return 0; pktmp = EVP_PKEY_new(); if (!pktmp) { - ASN1err(ASN1_F_I2D_RSA_PUBKEY, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } EVP_PKEY_set1_RSA(pktmp, a); @@ -346,7 +343,7 @@ i2d_DSA_PUBKEY(DSA *a, unsigned char **pp) return 0; pktmp = EVP_PKEY_new(); if (!pktmp) { - ASN1err(ASN1_F_I2D_DSA_PUBKEY, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return 0; } EVP_PKEY_set1_DSA(pktmp, a); @@ -387,7 +384,7 @@ i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp) if (!a) return (0); if ((pktmp = EVP_PKEY_new()) == NULL) { - ASN1err(ASN1_F_I2D_EC_PUBKEY, ERR_R_MALLOC_FAILURE); + ASN1error(ERR_R_MALLOC_FAILURE); return (0); } EVP_PKEY_set1_EC_KEY(pktmp, a); -- cgit v1.2.3-55-g6feb