From adf7e6d1d63890f037625031789ed042187c3947 Mon Sep 17 00:00:00 2001 From: Shane Lontis Date: Tue, 9 Mar 2021 09:48:16 +1000 Subject: [PATCH] Add ossl_asn1 symbols Partial fix for #12964 Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/14473) --- crypto/asn1/a_bitstr.c | 6 +-- crypto/asn1/a_digest.c | 8 ++-- crypto/asn1/a_gentm.c | 9 +++-- crypto/asn1/a_int.c | 11 +++--- crypto/asn1/a_object.c | 6 +-- crypto/asn1/a_time.c | 34 ++++++++--------- crypto/asn1/a_type.c | 2 +- crypto/asn1/a_utctm.c | 12 +++--- crypto/asn1/asn1_lib.c | 9 +++-- crypto/asn1/asn1_local.h | 70 +++++++++++++++++----------------- crypto/asn1/evp_asn1.c | 8 ++-- crypto/asn1/standard_methods.h | 32 ++++++++-------- crypto/asn1/tasn_dec.c | 40 +++++++++---------- crypto/asn1/tasn_enc.c | 20 +++++----- crypto/asn1/tasn_fre.c | 40 +++++++++---------- crypto/asn1/tasn_new.c | 12 +++--- crypto/asn1/tasn_prn.c | 8 ++-- crypto/asn1/tasn_utl.c | 35 ++++++++--------- crypto/asn1/x_algor.c | 10 ++--- crypto/asn1/x_int64.c | 14 +++---- crypto/cmp/cmp_client.c | 8 ++-- crypto/cms/cms_ess.c | 8 ++-- crypto/cms/cms_rsa.c | 10 ++--- crypto/ctype.c | 2 +- crypto/dh/dh_ameth.c | 12 +++--- crypto/dsa/dsa_ameth.c | 2 +- crypto/ec/ec_ameth.c | 4 +- crypto/ec/ecx_meth.c | 8 ++-- crypto/evp/evp_lib.c | 9 +++-- crypto/rsa/rsa_ameth.c | 18 ++++----- crypto/ts/ts_rsp_verify.c | 2 +- crypto/x509/t_x509.c | 4 +- crypto/x509/x509_vfy.c | 2 +- crypto/x509/x_all.c | 4 +- include/crypto/asn1.h | 42 ++++++++++---------- include/crypto/ctype.h | 2 +- include/crypto/x509.h | 6 +-- include/internal/cryptlib.h | 4 +- 38 files changed, 270 insertions(+), 263 deletions(-) diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c index 7d179e6f89..a9da7eab3b 100644 --- a/crypto/asn1/a_bitstr.c +++ b/crypto/asn1/a_bitstr.c @@ -18,7 +18,7 @@ int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len) return ASN1_STRING_set(x, d, len); } -int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) +int ossl_i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) { int ret, j, bits, len; unsigned char *p, *d; @@ -76,8 +76,8 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) return ret; } -ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, - const unsigned char **pp, long len) +ASN1_BIT_STRING *ossl_c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, + const unsigned char **pp, long len) { ASN1_BIT_STRING *ret = NULL; const unsigned char *p; diff --git a/crypto/asn1/a_digest.c b/crypto/asn1/a_digest.c index 0fd1e6e0b8..3976cfbd16 100644 --- a/crypto/asn1/a_digest.c +++ b/crypto/asn1/a_digest.c @@ -53,9 +53,9 @@ int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, #endif -int asn1_item_digest_ex(const ASN1_ITEM *it, const EVP_MD *md, void *asn, - unsigned char *data, unsigned int *len, - OSSL_LIB_CTX *libctx, const char *propq) +int ossl_asn1_item_digest_ex(const ASN1_ITEM *it, const EVP_MD *md, void *asn, + unsigned char *data, unsigned int *len, + OSSL_LIB_CTX *libctx, const char *propq) { int i, ret = 0; unsigned char *str = NULL; @@ -89,6 +89,6 @@ err: int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *md, void *asn, unsigned char *data, unsigned int *len) { - return asn1_item_digest_ex(it, md, asn, data, len, NULL, NULL); + return ossl_asn1_item_digest_ex(it, md, asn, data, len, NULL, NULL); } diff --git a/crypto/asn1/a_gentm.c b/crypto/asn1/a_gentm.c index 1d89e23b8f..aed5ae7499 100644 --- a/crypto/asn1/a_gentm.c +++ b/crypto/asn1/a_gentm.c @@ -21,12 +21,13 @@ IMPLEMENT_ASN1_DUP_FUNCTION(ASN1_GENERALIZEDTIME) /* This is the primary function used to parse ASN1_GENERALIZEDTIME */ -int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d) +static int asn1_generalizedtime_to_tm(struct tm *tm, + const ASN1_GENERALIZEDTIME *d) { - /* wrapper around asn1_time_to_tm */ + /* wrapper around ossl_asn1_time_to_tm */ if (d->type != V_ASN1_GENERALIZEDTIME) return 0; - return asn1_time_to_tm(tm, d); + return ossl_asn1_time_to_tm(tm, d); } int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d) @@ -74,7 +75,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, return NULL; } - return asn1_time_from_tm(s, ts, V_ASN1_GENERALIZEDTIME); + return ossl_asn1_time_from_tm(s, ts, V_ASN1_GENERALIZEDTIME); } int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c index 98c759cc93..92c58b3418 100644 --- a/crypto/asn1/a_int.c +++ b/crypto/asn1/a_int.c @@ -204,7 +204,7 @@ static size_t c2i_ibuf(unsigned char *b, int *pneg, return plen; } -int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp) +int ossl_i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp) { return i2c_ibuf(a->data, a->length, a->type & V_ASN1_NEG, pp); } @@ -283,8 +283,8 @@ static int asn1_get_int64(int64_t *pr, const unsigned char *b, size_t blen, } /* Convert ASN1 INTEGER content octets to ASN1_INTEGER structure */ -ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, - long len) +ASN1_INTEGER *ossl_c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, + long len) { ASN1_INTEGER *ret = NULL; size_t r; @@ -609,7 +609,8 @@ BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn) } /* Internal functions used by x_int64.c */ -int c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, long len) +int ossl_c2i_uint64_int(uint64_t *ret, int *neg, + const unsigned char **pp, long len) { unsigned char buf[sizeof(uint64_t)]; size_t buflen; @@ -625,7 +626,7 @@ int c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, long len) return asn1_get_uint64(ret, buf, buflen); } -int i2c_uint64_int(unsigned char *p, uint64_t r, int neg) +int ossl_i2c_uint64_int(unsigned char *p, uint64_t r, int neg) { unsigned char buf[sizeof(uint64_t)]; size_t off; diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index 15726e7f03..6967ab44e8 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c @@ -226,7 +226,7 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, i = ASN1_R_EXPECTING_AN_OBJECT; goto err; } - ret = c2i_ASN1_OBJECT(a, &p, len); + ret = ossl_c2i_ASN1_OBJECT(a, &p, len); if (ret) *pp = p; return ret; @@ -235,8 +235,8 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, return NULL; } -ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, - long len) +ASN1_OBJECT *ossl_c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, + long len) { ASN1_OBJECT *ret = NULL, tobj; const unsigned char *p; diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index b9950cc5cb..1a0c91ef9f 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -73,7 +73,7 @@ static void determine_days(struct tm *tm) tm->tm_wday = (d + (13 * m) / 5 + y + y / 4 + c / 4 + 5 * c + 6) % 7; } -int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d) +int ossl_asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d) { static const int min[9] = { 0, 0, 1, 1, 0, 0, 0, 0, 0 }; static const int max[9] = { 99, 99, 12, 31, 23, 59, 59, 12, 59 }; @@ -130,14 +130,14 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d) i++; break; } - if (!ascii_isdigit(a[o])) + if (!ossl_ascii_isdigit(a[o])) goto err; n = a[o] - num_zero; /* incomplete 2-digital number */ if (++o == l) goto err; - if (!ascii_isdigit(a[o])) + if (!ossl_ascii_isdigit(a[o])) goto err; n = (n * 10) + a[o] - num_zero; /* no more bytes to read, but we haven't seen time-zone yet */ @@ -198,7 +198,7 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d) if (++o == l) goto err; i = o; - while ((o < l) && ascii_isdigit(a[o])) + while ((o < l) && ossl_ascii_isdigit(a[o])) o++; /* Must have at least one digit after decimal point */ if (i == o) @@ -229,11 +229,11 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d) if (o + 4 != l) goto err; for (i = end; i < end + 2; i++) { - if (!ascii_isdigit(a[o])) + if (!ossl_ascii_isdigit(a[o])) goto err; n = a[o] - num_zero; o++; - if (!ascii_isdigit(a[o])) + if (!ossl_ascii_isdigit(a[o])) goto err; n = (n * 10) + a[o] - num_zero; i2 = (d->type == V_ASN1_UTCTIME) ? i + 1 : i; @@ -264,7 +264,7 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d) return 0; } -ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type) +ASN1_TIME *ossl_asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type) { char* p; ASN1_TIME *tmps = NULL; @@ -336,7 +336,7 @@ ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec)) return NULL; } - return asn1_time_from_tm(s, ts, V_ASN1_UNDEF); + return ossl_asn1_time_from_tm(s, ts, V_ASN1_UNDEF); } int ASN1_TIME_check(const ASN1_TIME *t) @@ -361,7 +361,7 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, if (out != NULL) ret = *out; - ret = asn1_time_from_tm(ret, &tm, V_ASN1_GENERALIZEDTIME); + ret = ossl_asn1_time_from_tm(ret, &tm, V_ASN1_GENERALIZEDTIME); if (out != NULL && ret != NULL) *out = ret; @@ -410,7 +410,7 @@ int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str) */ if (s != NULL && t.type == V_ASN1_GENERALIZEDTIME) { - if (!asn1_time_to_tm(&tm, &t)) + if (!ossl_asn1_time_to_tm(&tm, &t)) goto out; if (is_utc(tm.tm_year)) { t.length -= 2; @@ -448,7 +448,7 @@ int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm) return 0; } - return asn1_time_to_tm(tm, s); + return ossl_asn1_time_to_tm(tm, s); } int ASN1_TIME_diff(int *pday, int *psec, @@ -471,19 +471,19 @@ static const char _asn1_mon[12][4] = { /* returns 1 on success, 0 on BIO write error or parse failure */ int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) { - return asn1_time_print_ex(bp, tm) > 0; + return ossl_asn1_time_print_ex(bp, tm) > 0; } /* returns 0 on BIO write error, else -1 in case of parse failure, else 1 */ -int asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm) +int ossl_asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm) { char *v; int gmt = 0, l; struct tm stm; const char upper_z = 0x5A, period = 0x2E; - /* asn1_time_to_tm will check the time type */ - if (!asn1_time_to_tm(&stm, tm)) + /* ossl_asn1_time_to_tm will check the time type */ + if (!ossl_asn1_time_to_tm(&stm, tm)) return BIO_write(bp, "Bad time value", 14) ? -1 : 0; l = tm->length; @@ -502,7 +502,7 @@ int asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm) if (tm->length > 15 && v[14] == period) { f = &v[14]; f_len = 1; - while (14 + f_len < l && ascii_isdigit(f[f_len])) + while (14 + f_len < l && ossl_ascii_isdigit(f[f_len])) ++f_len; } @@ -546,7 +546,7 @@ int ASN1_TIME_normalize(ASN1_TIME *t) if (!ASN1_TIME_to_tm(t, &tm)) return 0; - return asn1_time_from_tm(t, &tm, V_ASN1_UNDEF) != NULL; + return ossl_asn1_time_from_tm(t, &tm, V_ASN1_UNDEF) != NULL; } int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b) diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c index 3a75385a25..c0eee53ff0 100644 --- a/crypto/asn1/a_type.c +++ b/crypto/asn1/a_type.c @@ -29,7 +29,7 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value) && a->type != V_ASN1_NULL && a->value.ptr != NULL) { ASN1_TYPE **tmp_a = &a; - asn1_primitive_free((ASN1_VALUE **)tmp_a, NULL, 0); + ossl_asn1_primitive_free((ASN1_VALUE **)tmp_a, NULL, 0); } a->type = type; if (type == V_ASN1_BOOLEAN) diff --git a/crypto/asn1/a_utctm.c b/crypto/asn1/a_utctm.c index c5b49730ff..5ae878a8e6 100644 --- a/crypto/asn1/a_utctm.c +++ b/crypto/asn1/a_utctm.c @@ -17,17 +17,17 @@ IMPLEMENT_ASN1_DUP_FUNCTION(ASN1_UTCTIME) /* This is the primary function used to parse ASN1_UTCTIME */ -int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d) +int ossl_asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d) { - /* wrapper around asn1_time_to_tm */ + /* wrapper around ossl_asn1_time_to_tm */ if (d->type != V_ASN1_UTCTIME) return 0; - return asn1_time_to_tm(tm, d); + return ossl_asn1_time_to_tm(tm, d); } int ASN1_UTCTIME_check(const ASN1_UTCTIME *d) { - return asn1_utctime_to_tm(NULL, d); + return ossl_asn1_utctime_to_tm(NULL, d); } /* Sets the string via simple copy without cleaning it up */ @@ -69,7 +69,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, return NULL; } - return asn1_time_from_tm(s, ts, V_ASN1_UTCTIME); + return ossl_asn1_time_from_tm(s, ts, V_ASN1_UTCTIME); } int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) @@ -77,7 +77,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) struct tm stm, ttm; int day, sec; - if (!asn1_utctime_to_tm(&stm, s)) + if (!ossl_asn1_utctime_to_tm(&stm, s)) return -2; if (OPENSSL_gmtime(&t, &ttm) == NULL) diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c index 97b016ae18..1fd46913af 100644 --- a/crypto/asn1/asn1_lib.c +++ b/crypto/asn1/asn1_lib.c @@ -340,7 +340,7 @@ ASN1_STRING *ASN1_STRING_type_new(int type) return ret; } -void asn1_string_embed_free(ASN1_STRING *a, int embed) +void ossl_asn1_string_embed_free(ASN1_STRING *a, int embed) { if (a == NULL) return; @@ -354,7 +354,7 @@ void ASN1_STRING_free(ASN1_STRING *a) { if (a == NULL) return; - asn1_string_embed_free(a, a->flags & ASN1_STRING_FLAG_EMBED); + ossl_asn1_string_embed_free(a, a->flags & ASN1_STRING_FLAG_EMBED); } void ASN1_STRING_clear_free(ASN1_STRING *a) @@ -411,8 +411,9 @@ unsigned char *ASN1_STRING_data(ASN1_STRING *x) } #endif -char *sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text, const char *sep, - size_t max_len /* excluding NUL terminator */) +char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text, + const char *sep, + size_t max_len /* excluding NUL terminator */) { int i; ASN1_UTF8STRING *current; diff --git a/crypto/asn1/asn1_local.h b/crypto/asn1/asn1_local.h index 5720c9096a..f7717c09f8 100644 --- a/crypto/asn1/asn1_local.h +++ b/crypto/asn1/asn1_local.h @@ -12,9 +12,8 @@ typedef const ASN1_VALUE const_ASN1_VALUE; SKM_DEFINE_STACK_OF(const_ASN1_VALUE, const ASN1_VALUE, ASN1_VALUE) -int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d); -int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d); -int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d); +int ossl_asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d); +int ossl_asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d); /* ASN1 scan context structure */ @@ -46,44 +45,47 @@ DEFINE_STACK_OF(MIME_PARAM) typedef struct mime_header_st MIME_HEADER; DEFINE_STACK_OF(MIME_HEADER) -void asn1_string_embed_free(ASN1_STRING *a, int embed); +void ossl_asn1_string_embed_free(ASN1_STRING *a, int embed); -int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_set_choice_selector(ASN1_VALUE **pval, int value, - const ASN1_ITEM *it); +int ossl_asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); +int ossl_asn1_get_choice_selector_const(const ASN1_VALUE **pval, + const ASN1_ITEM *it); +int ossl_asn1_set_choice_selector(ASN1_VALUE **pval, int value, + const ASN1_ITEM *it); -ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); -const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval, - const ASN1_TEMPLATE *tt); +ASN1_VALUE **ossl_asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +const ASN1_VALUE **ossl_asn1_get_const_field_ptr(const ASN1_VALUE **pval, + const ASN1_TEMPLATE *tt); -const ASN1_TEMPLATE *asn1_do_adb(const ASN1_VALUE *val, const ASN1_TEMPLATE *tt, - int nullerr); +const ASN1_TEMPLATE *ossl_asn1_do_adb(const ASN1_VALUE *val, + const ASN1_TEMPLATE *tt, + int nullerr); -int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); +int ossl_asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); -void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); -void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval, - const ASN1_ITEM *it); -int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, - const ASN1_ITEM *it); +void ossl_asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); +void ossl_asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int ossl_asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval, + const ASN1_ITEM *it); +int ossl_asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, + const ASN1_ITEM *it); -void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); -void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); -void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +void ossl_asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); +void ossl_asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); +void ossl_asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); -ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, - long length); -int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); -ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, - const unsigned char **pp, long length); -int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); -ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, - long length); +ASN1_OBJECT *ossl_c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, + long length); +int ossl_i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); +ASN1_BIT_STRING *ossl_c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, + const unsigned char **pp, long length); +int ossl_i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); +ASN1_INTEGER *ossl_c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, + long length); /* Internal functions used by x_int64.c */ -int c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, long len); -int i2c_uint64_int(unsigned char *p, uint64_t r, int neg); +int ossl_c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, + long len); +int ossl_i2c_uint64_int(unsigned char *p, uint64_t r, int neg); -ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type); +ASN1_TIME *ossl_asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type); diff --git a/crypto/asn1/evp_asn1.c b/crypto/asn1/evp_asn1.c index 3129fdf2df..d3db5f75cb 100644 --- a/crypto/asn1/evp_asn1.c +++ b/crypto/asn1/evp_asn1.c @@ -143,8 +143,8 @@ ASN1_SEQUENCE(asn1_oct_int) = { DECLARE_ASN1_ITEM(asn1_oct_int) -int asn1_type_set_octetstring_int(ASN1_TYPE *a, long num, unsigned char *data, - int len) +int ossl_asn1_type_set_octetstring_int(ASN1_TYPE *a, long num, + unsigned char *data, int len) { asn1_oct_int atmp; ASN1_OCTET_STRING oct; @@ -158,8 +158,8 @@ int asn1_type_set_octetstring_int(ASN1_TYPE *a, long num, unsigned char *data, return 0; } -int asn1_type_get_octetstring_int(const ASN1_TYPE *a, long *num, - unsigned char *data, int max_len) +int ossl_asn1_type_get_octetstring_int(const ASN1_TYPE *a, long *num, + unsigned char *data, int max_len) { asn1_oct_int *atmp = NULL; int ret = -1; diff --git a/crypto/asn1/standard_methods.h b/crypto/asn1/standard_methods.h index 7d225b308a..664d657178 100644 --- a/crypto/asn1/standard_methods.h +++ b/crypto/asn1/standard_methods.h @@ -13,35 +13,35 @@ * is used to search it. */ static const EVP_PKEY_ASN1_METHOD *standard_methods[] = { - &rsa_asn1_meths[0], - &rsa_asn1_meths[1], + &ossl_rsa_asn1_meths[0], + &ossl_rsa_asn1_meths[1], #ifndef OPENSSL_NO_DH - &dh_asn1_meth, + &ossl_dh_asn1_meth, #endif #ifndef OPENSSL_NO_DSA - &dsa_asn1_meths[0], - &dsa_asn1_meths[1], - &dsa_asn1_meths[2], - &dsa_asn1_meths[3], - &dsa_asn1_meths[4], + &ossl_dsa_asn1_meths[0], + &ossl_dsa_asn1_meths[1], + &ossl_dsa_asn1_meths[2], + &ossl_dsa_asn1_meths[3], + &ossl_dsa_asn1_meths[4], #endif #ifndef OPENSSL_NO_EC - &eckey_asn1_meth, + &ossl_eckey_asn1_meth, #endif - &rsa_pss_asn1_meth, + &ossl_rsa_pss_asn1_meth, #ifndef OPENSSL_NO_DH - &dhx_asn1_meth, + &ossl_dhx_asn1_meth, #endif #ifndef OPENSSL_NO_EC - &ecx25519_asn1_meth, - &ecx448_asn1_meth, + &ossl_ecx25519_asn1_meth, + &ossl_ecx448_asn1_meth, #endif #ifndef OPENSSL_NO_EC - &ed25519_asn1_meth, - &ed448_asn1_meth, + &ossl_ed25519_asn1_meth, + &ossl_ed448_asn1_meth, #endif #ifndef OPENSSL_NO_SM2 - &sm2_asn1_meth, + &ossl_sm2_asn1_meth, #endif }; diff --git a/crypto/asn1/tasn_dec.c b/crypto/asn1/tasn_dec.c index 9a210e221f..0987c2ece3 100644 --- a/crypto/asn1/tasn_dec.c +++ b/crypto/asn1/tasn_dec.c @@ -239,12 +239,12 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, goto auxerr; if (*pval) { /* Free up and zero CHOICE value if initialised */ - i = asn1_get_choice_selector(pval, it); + i = ossl_asn1_get_choice_selector(pval, it); if ((i >= 0) && (i < it->tcount)) { tt = it->templates + i; - pchptr = asn1_get_field_ptr(pval, tt); - asn1_template_free(pchptr, tt); - asn1_set_choice_selector(pval, -1, it); + pchptr = ossl_asn1_get_field_ptr(pval, tt); + ossl_asn1_template_free(pchptr, tt); + ossl_asn1_set_choice_selector(pval, -1, it); } } else if (!ASN1_item_ex_new(pval, it)) { ERR_raise(ERR_LIB_ASN1, ERR_R_NESTED_ASN1_ERROR); @@ -253,7 +253,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, /* CHOICE type, try each possibility in turn */ p = *in; for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { - pchptr = asn1_get_field_ptr(pval, tt); + pchptr = ossl_asn1_get_field_ptr(pval, tt); /* * We mark field as OPTIONAL so its absence can be recognised. */ @@ -268,7 +268,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, * Must be an ASN1 parsing error. * Free up any partial choice value */ - asn1_template_free(pchptr, tt); + ossl_asn1_template_free(pchptr, tt); errtt = tt; ERR_raise(ERR_LIB_ASN1, ERR_R_NESTED_ASN1_ERROR); goto err; @@ -286,7 +286,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, goto err; } - asn1_set_choice_selector(pval, i, it); + ossl_asn1_set_choice_selector(pval, i, it); if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL)) goto auxerr; @@ -336,11 +336,11 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, if (tt->flags & ASN1_TFLG_ADB_MASK) { const ASN1_TEMPLATE *seqtt; ASN1_VALUE **pseqval; - seqtt = asn1_do_adb(*pval, tt, 0); + seqtt = ossl_asn1_do_adb(*pval, tt, 0); if (seqtt == NULL) continue; - pseqval = asn1_get_field_ptr(pval, seqtt); - asn1_template_free(pseqval, seqtt); + pseqval = ossl_asn1_get_field_ptr(pval, seqtt); + ossl_asn1_template_free(pseqval, seqtt); } } @@ -348,10 +348,10 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { const ASN1_TEMPLATE *seqtt; ASN1_VALUE **pseqval; - seqtt = asn1_do_adb(*pval, tt, 1); + seqtt = ossl_asn1_do_adb(*pval, tt, 1); if (seqtt == NULL) goto err; - pseqval = asn1_get_field_ptr(pval, seqtt); + pseqval = ossl_asn1_get_field_ptr(pval, seqtt); /* Have we ran out of data? */ if (!len) break; @@ -388,7 +388,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, /* * OPTIONAL component absent. Free and zero the field. */ - asn1_template_free(pseqval, seqtt); + ossl_asn1_template_free(pseqval, seqtt); continue; } /* Update length */ @@ -413,13 +413,13 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, */ for (; i < it->tcount; tt++, i++) { const ASN1_TEMPLATE *seqtt; - seqtt = asn1_do_adb(*pval, tt, 1); + seqtt = ossl_asn1_do_adb(*pval, tt, 1); if (seqtt == NULL) goto err; if (seqtt->flags & ASN1_TFLG_OPTIONAL) { ASN1_VALUE **pseqval; - pseqval = asn1_get_field_ptr(pval, seqtt); - asn1_template_free(pseqval, seqtt); + pseqval = ossl_asn1_get_field_ptr(pval, seqtt); + ossl_asn1_template_free(pseqval, seqtt); } else { errtt = seqtt; ERR_raise(ERR_LIB_ASN1, ASN1_R_FIELD_MISSING); @@ -427,7 +427,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, } } /* Save encoding */ - if (!asn1_enc_save(pval, *in, p - *in, it)) + if (!ossl_asn1_enc_save(pval, *in, p - *in, it)) goto auxerr; if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL)) goto auxerr; @@ -814,7 +814,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, } switch (utype) { case V_ASN1_OBJECT: - if (!c2i_ASN1_OBJECT((ASN1_OBJECT **)pval, &cont, len)) + if (!ossl_c2i_ASN1_OBJECT((ASN1_OBJECT **)pval, &cont, len)) goto err; break; @@ -838,14 +838,14 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, break; case V_ASN1_BIT_STRING: - if (!c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &cont, len)) + if (!ossl_c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &cont, len)) goto err; break; case V_ASN1_INTEGER: case V_ASN1_ENUMERATED: tint = (ASN1_INTEGER **)pval; - if (!c2i_ASN1_INTEGER(tint, &cont, len)) + if (!ossl_c2i_ASN1_INTEGER(tint, &cont, len)) goto err; /* Fixup type to match the expected form */ (*tint)->type = utype | ((*tint)->type & V_ASN1_NEG); diff --git a/crypto/asn1/tasn_enc.c b/crypto/asn1/tasn_enc.c index 9d65f294db..c066bc5837 100644 --- a/crypto/asn1/tasn_enc.c +++ b/crypto/asn1/tasn_enc.c @@ -127,12 +127,12 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, } if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) return 0; - i = asn1_get_choice_selector_const(pval, it); + i = ossl_asn1_get_choice_selector_const(pval, it); if ((i >= 0) && (i < it->tcount)) { const ASN1_VALUE **pchval; const ASN1_TEMPLATE *chtt; chtt = it->templates + i; - pchval = asn1_get_const_field_ptr(pval, chtt); + pchval = ossl_asn1_get_const_field_ptr(pval, chtt); return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass); } /* Fixme: error condition if selector out of range */ @@ -152,7 +152,7 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, /* fall through */ case ASN1_ITYPE_SEQUENCE: - i = asn1_enc_restore(&seqcontlen, out, pval, it); + i = ossl_asn1_enc_restore(&seqcontlen, out, pval, it); /* An error occurred */ if (i < 0) return 0; @@ -175,10 +175,10 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *seqtt; const ASN1_VALUE **pseqval; int tmplen; - seqtt = asn1_do_adb(*pval, tt, 1); + seqtt = ossl_asn1_do_adb(*pval, tt, 1); if (!seqtt) return 0; - pseqval = asn1_get_const_field_ptr(pval, seqtt); + pseqval = ossl_asn1_get_const_field_ptr(pval, seqtt); tmplen = asn1_template_ex_i2d(pseqval, NULL, seqtt, -1, aclass); if (tmplen == -1 || (tmplen > INT_MAX - seqcontlen)) return -1; @@ -193,10 +193,10 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) { const ASN1_TEMPLATE *seqtt; const ASN1_VALUE **pseqval; - seqtt = asn1_do_adb(*pval, tt, 1); + seqtt = ossl_asn1_do_adb(*pval, tt, 1); if (!seqtt) return 0; - pseqval = asn1_get_const_field_ptr(pval, seqtt); + pseqval = ossl_asn1_get_const_field_ptr(pval, seqtt); /* FIXME: check for errors in enhanced version */ asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass); } @@ -578,15 +578,15 @@ static int asn1_ex_i2c(const ASN1_VALUE **pval, unsigned char *cout, int *putype break; case V_ASN1_BIT_STRING: - return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, - cout ? &cout : NULL); + return ossl_i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, + cout ? &cout : NULL); case V_ASN1_INTEGER: case V_ASN1_ENUMERATED: /* * These are all have the same content format as ASN1_INTEGER */ - return i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : NULL); + return ossl_i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : NULL); case V_ASN1_OCTET_STRING: case V_ASN1_NUMERICSTRING: diff --git a/crypto/asn1/tasn_fre.c b/crypto/asn1/tasn_fre.c index 3a5b29f37d..c6cf62c441 100644 --- a/crypto/asn1/tasn_fre.c +++ b/crypto/asn1/tasn_fre.c @@ -17,15 +17,15 @@ void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it) { - asn1_item_embed_free(&val, it, 0); + ossl_asn1_item_embed_free(&val, it, 0); } void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { - asn1_item_embed_free(pval, it, 0); + ossl_asn1_item_embed_free(pval, it, 0); } -void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) +void ossl_asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) { const ASN1_TEMPLATE *tt = NULL, *seqtt; const ASN1_EXTERN_FUNCS *ef; @@ -46,13 +46,13 @@ void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) case ASN1_ITYPE_PRIMITIVE: if (it->templates) - asn1_template_free(pval, it->templates); + ossl_asn1_template_free(pval, it->templates); else - asn1_primitive_free(pval, it, embed); + ossl_asn1_primitive_free(pval, it, embed); break; case ASN1_ITYPE_MSTRING: - asn1_primitive_free(pval, it, embed); + ossl_asn1_primitive_free(pval, it, embed); break; case ASN1_ITYPE_CHOICE: @@ -61,13 +61,13 @@ void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) if (i == 2) return; } - i = asn1_get_choice_selector(pval, it); + i = ossl_asn1_get_choice_selector(pval, it); if ((i >= 0) && (i < it->tcount)) { ASN1_VALUE **pchval; tt = it->templates + i; - pchval = asn1_get_field_ptr(pval, tt); - asn1_template_free(pchval, tt); + pchval = ossl_asn1_get_field_ptr(pval, tt); + ossl_asn1_template_free(pchval, tt); } if (asn1_cb) asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); @@ -85,14 +85,14 @@ void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) case ASN1_ITYPE_NDEF_SEQUENCE: case ASN1_ITYPE_SEQUENCE: - if (asn1_do_lock(pval, -1, it) != 0) /* if error or ref-counter > 0 */ + if (ossl_asn1_do_lock(pval, -1, it) != 0) /* if error or ref-counter > 0 */ return; if (asn1_cb) { i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); if (i == 2) return; } - asn1_enc_free(pval, it); + ossl_asn1_enc_free(pval, it); /* * If we free up as normal we will invalidate any ANY DEFINED BY * field and we won't be able to determine the type of the field it @@ -103,11 +103,11 @@ void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) ASN1_VALUE **pseqval; tt--; - seqtt = asn1_do_adb(*pval, tt, 0); + seqtt = ossl_asn1_do_adb(*pval, tt, 0); if (!seqtt) continue; - pseqval = asn1_get_field_ptr(pval, seqtt); - asn1_template_free(pseqval, seqtt); + pseqval = ossl_asn1_get_field_ptr(pval, seqtt); + ossl_asn1_template_free(pseqval, seqtt); } if (asn1_cb) asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); @@ -119,7 +119,7 @@ void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) } } -void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) +void ossl_asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) { int embed = tt->flags & ASN1_TFLG_EMBED; ASN1_VALUE *tval; @@ -134,16 +134,16 @@ void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) { ASN1_VALUE *vtmp = sk_ASN1_VALUE_value(sk, i); - asn1_item_embed_free(&vtmp, ASN1_ITEM_ptr(tt->item), embed); + ossl_asn1_item_embed_free(&vtmp, ASN1_ITEM_ptr(tt->item), embed); } sk_ASN1_VALUE_free(sk); *pval = NULL; } else { - asn1_item_embed_free(pval, ASN1_ITEM_ptr(tt->item), embed); + ossl_asn1_item_embed_free(pval, ASN1_ITEM_ptr(tt->item), embed); } } -void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) +void ossl_asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) { int utype; @@ -196,12 +196,12 @@ void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) break; case V_ASN1_ANY: - asn1_primitive_free(pval, NULL, 0); + ossl_asn1_primitive_free(pval, NULL, 0); OPENSSL_free(*pval); break; default: - asn1_string_embed_free((ASN1_STRING *)*pval, embed); + ossl_asn1_string_embed_free((ASN1_STRING *)*pval, embed); break; } *pval = NULL; diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c index 06fc558457..826636f027 100644 --- a/crypto/asn1/tasn_new.c +++ b/crypto/asn1/tasn_new.c @@ -91,7 +91,7 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) if (*pval == NULL) goto memerr; } - asn1_set_choice_selector(pval, -1, it); + ossl_asn1_set_choice_selector(pval, -1, it); if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) goto auxerr2; break; @@ -114,16 +114,16 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) goto memerr; } /* 0 : init. lock */ - if (asn1_do_lock(pval, 0, it) < 0) { + if (ossl_asn1_do_lock(pval, 0, it) < 0) { if (!embed) { OPENSSL_free(*pval); *pval = NULL; } goto memerr; } - asn1_enc_init(pval, it); + ossl_asn1_enc_init(pval, it); for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) { - pseqval = asn1_get_field_ptr(pval, tt); + pseqval = ossl_asn1_get_field_ptr(pval, tt); if (!asn1_template_new(pseqval, tt)) goto memerr2; } @@ -134,13 +134,13 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) return 1; memerr2: - asn1_item_embed_free(pval, it, embed); + ossl_asn1_item_embed_free(pval, it, embed); memerr: ERR_raise(ERR_LIB_ASN1, ERR_R_MALLOC_FAILURE); return 0; auxerr2: - asn1_item_embed_free(pval, it, embed); + ossl_asn1_item_embed_free(pval, it, embed); auxerr: ERR_raise(ERR_LIB_ASN1, ASN1_R_AUX_ERROR); return 0; diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c index e4926616f3..0d1a82a1c5 100644 --- a/crypto/asn1/tasn_prn.c +++ b/crypto/asn1/tasn_prn.c @@ -195,7 +195,7 @@ static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent, case ASN1_ITYPE_CHOICE: /* CHOICE type, get selector */ - i = asn1_get_choice_selector_const(fld, it); + i = ossl_asn1_get_choice_selector_const(fld, it); /* This should never happen... */ if ((i < 0) || (i >= it->tcount)) { if (BIO_printf(out, "ERROR: selector [%d] invalid\n", i) <= 0) @@ -203,7 +203,7 @@ static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent, return 1; } tt = it->templates + i; - tmpfld = asn1_get_const_field_ptr(fld, tt); + tmpfld = ossl_asn1_get_const_field_ptr(fld, tt); if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx)) return 0; break; @@ -233,10 +233,10 @@ static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent, /* Print each field entry */ for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { const ASN1_TEMPLATE *seqtt; - seqtt = asn1_do_adb(*fld, tt, 1); + seqtt = ossl_asn1_do_adb(*fld, tt, 1); if (!seqtt) return 0; - tmpfld = asn1_get_const_field_ptr(fld, seqtt); + tmpfld = ossl_asn1_get_const_field_ptr(fld, seqtt); if (!asn1_template_print_ctx(out, tmpfld, indent + 2, seqtt, pctx)) return 0; diff --git a/crypto/asn1/tasn_utl.c b/crypto/asn1/tasn_utl.c index 0fcfedc845..889c6a2b7b 100644 --- a/crypto/asn1/tasn_utl.c +++ b/crypto/asn1/tasn_utl.c @@ -26,14 +26,15 @@ * Given an ASN1_ITEM CHOICE type return the selector value */ -int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) +int ossl_asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) { int *sel = offset2ptr(*pval, it->utype); return *sel; } -int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it) +int ossl_asn1_get_choice_selector_const(const ASN1_VALUE **pval, + const ASN1_ITEM *it) { int *sel = offset2ptr(*pval, it->utype); @@ -44,8 +45,8 @@ int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it) * Given an ASN1_ITEM CHOICE type set the selector value, return old value. */ -int asn1_set_choice_selector(ASN1_VALUE **pval, int value, - const ASN1_ITEM *it) +int ossl_asn1_set_choice_selector(ASN1_VALUE **pval, int value, + const ASN1_ITEM *it) { int *sel, ret; @@ -64,7 +65,7 @@ int asn1_set_choice_selector(ASN1_VALUE **pval, int value, * It returns -1 on initialisation error. * Used by ASN1_SEQUENCE construct of X509, X509_REQ, X509_CRL objects */ -int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it) +int ossl_asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it) { const ASN1_AUX *aux; CRYPTO_REF_COUNT *lck; @@ -135,7 +136,7 @@ static const ASN1_ENCODING *asn1_get_const_enc_ptr(const ASN1_VALUE **pval, return offset2ptr(*pval, aux->enc_offset); } -void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) +void ossl_asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) { ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it); @@ -146,7 +147,7 @@ void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) } } -void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) +void ossl_asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it); @@ -158,8 +159,8 @@ void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) } } -int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, - const ASN1_ITEM *it) +int ossl_asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, + const ASN1_ITEM *it) { ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it); @@ -178,8 +179,8 @@ int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, return 1; } -int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval, - const ASN1_ITEM *it) +int ossl_asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval, + const ASN1_ITEM *it) { const ASN1_ENCODING *enc = asn1_get_const_enc_ptr(pval, it); @@ -195,7 +196,7 @@ int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval, } /* Given an ASN1_TEMPLATE get a pointer to a field */ -ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) +ASN1_VALUE **ossl_asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) { ASN1_VALUE **pvaltmp = offset2ptr(*pval, tt->offset); @@ -207,8 +208,8 @@ ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) } /* Given an ASN1_TEMPLATE get a const pointer to a field */ -const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval, - const ASN1_TEMPLATE *tt) +const ASN1_VALUE **ossl_asn1_get_const_field_ptr(const ASN1_VALUE **pval, + const ASN1_TEMPLATE *tt) { return offset2ptr(*pval, tt->offset); } @@ -218,9 +219,9 @@ const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval, * ASN1_TEMPLATE in the table and return it. */ -const ASN1_TEMPLATE *asn1_do_adb(const ASN1_VALUE *val, - const ASN1_TEMPLATE *tt, - int nullerr) +const ASN1_TEMPLATE *ossl_asn1_do_adb(const ASN1_VALUE *val, + const ASN1_TEMPLATE *tt, + int nullerr) { const ASN1_ADB *adb; const ASN1_ADB_TABLE *atbl; diff --git a/crypto/asn1/x_algor.c b/crypto/asn1/x_algor.c index 9a313170f0..aab1e3a6dc 100644 --- a/crypto/asn1/x_algor.c +++ b/crypto/asn1/x_algor.c @@ -129,7 +129,7 @@ int X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src) } /* allocate and set algorithm ID from EVP_MD, default SHA1 */ -int x509_algor_new_from_md(X509_ALGOR **palg, const EVP_MD *md) +int ossl_x509_algor_new_from_md(X509_ALGOR **palg, const EVP_MD *md) { /* Default is SHA1 so no need to create it - still success */ if (md == NULL || EVP_MD_is_a(md, "SHA1")) @@ -142,7 +142,7 @@ int x509_algor_new_from_md(X509_ALGOR **palg, const EVP_MD *md) } /* convert algorithm ID to EVP_MD, default SHA1 */ -const EVP_MD *x509_algor_get_md(X509_ALGOR *alg) +const EVP_MD *ossl_x509_algor_get_md(X509_ALGOR *alg) { const EVP_MD *md; @@ -154,7 +154,7 @@ const EVP_MD *x509_algor_get_md(X509_ALGOR *alg) return md; } -X509_ALGOR *x509_algor_mgf1_decode(X509_ALGOR *alg) +X509_ALGOR *ossl_x509_algor_mgf1_decode(X509_ALGOR *alg) { if (OBJ_obj2nid(alg->algorithm) != NID_mgf1) return NULL; @@ -163,7 +163,7 @@ X509_ALGOR *x509_algor_mgf1_decode(X509_ALGOR *alg) } /* Allocate and set MGF1 algorithm ID from EVP_MD */ -int x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md) +int ossl_x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md) { X509_ALGOR *algtmp = NULL; ASN1_STRING *stmp = NULL; @@ -172,7 +172,7 @@ int x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md) if (mgf1md == NULL || EVP_MD_is_a(mgf1md, "SHA1")) return 1; /* need to embed algorithm ID inside another */ - if (!x509_algor_new_from_md(&algtmp, mgf1md)) + if (!ossl_x509_algor_new_from_md(&algtmp, mgf1md)) goto err; if (ASN1_item_pack(algtmp, ASN1_ITEM_rptr(X509_ALGOR), &stmp) == NULL) goto err; diff --git a/crypto/asn1/x_int64.c b/crypto/asn1/x_int64.c index 50157a2bb2..e01ca4ef2f 100644 --- a/crypto/asn1/x_int64.c +++ b/crypto/asn1/x_int64.c @@ -62,12 +62,12 @@ static int uint64_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype, return -1; if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED && (int64_t)utmp < 0) { - /* i2c_uint64_int() assumes positive values */ + /* ossl_i2c_uint64_int() assumes positive values */ utmp = 0 - utmp; neg = 1; } - return i2c_uint64_int(cont, utmp, neg); + return ossl_i2c_uint64_int(cont, utmp, neg); } static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, @@ -91,7 +91,7 @@ static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, if (len == 0) goto long_compat; - if (!c2i_uint64_int(&utmp, &neg, &cont, len)) + if (!ossl_c2i_uint64_int(&utmp, &neg, &cont, len)) return 0; if ((it->size & INTxx_FLAG_SIGNED) == 0 && neg) { ERR_raise(ERR_LIB_ASN1, ASN1_R_ILLEGAL_NEGATIVE_VALUE); @@ -103,7 +103,7 @@ static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, return 0; } if (neg) - /* c2i_uint64_int() returns positive values */ + /* ossl_c2i_uint64_int() returns positive values */ utmp = 0 - utmp; long_compat: @@ -157,12 +157,12 @@ static int uint32_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype, return -1; if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED && (int32_t)utmp < 0) { - /* i2c_uint64_int() assumes positive values */ + /* ossl_i2c_uint64_int() assumes positive values */ utmp = 0 - utmp; neg = 1; } - return i2c_uint64_int(cont, (uint64_t)utmp, neg); + return ossl_i2c_uint64_int(cont, (uint64_t)utmp, neg); } /* @@ -194,7 +194,7 @@ static int uint32_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, if (len == 0) goto long_compat; - if (!c2i_uint64_int(&utmp, &neg, &cont, len)) + if (!ossl_c2i_uint64_int(&utmp, &neg, &cont, len)) return 0; if ((it->size & INTxx_FLAG_SIGNED) == 0 && neg) { ERR_raise(ERR_LIB_ASN1, ASN1_R_ILLEGAL_NEGATIVE_VALUE); diff --git a/crypto/cmp/cmp_client.c b/crypto/cmp/cmp_client.c index 00c5256013..728ec21968 100644 --- a/crypto/cmp/cmp_client.c +++ b/crypto/cmp/cmp_client.c @@ -221,8 +221,8 @@ static int send_receive_check(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *req, ASN1_INTEGER_get(emc->errorCode)) > 0) ERR_add_error_data(1, buf); if (emc->errorDetails != NULL) { - char *text = sk_ASN1_UTF8STRING2text(emc->errorDetails, ", ", - OSSL_CMP_PKISI_BUFLEN - 1); + char *text = ossl_sk_ASN1_UTF8STRING2text(emc->errorDetails, ", ", + OSSL_CMP_PKISI_BUFLEN - 1); if (text != NULL) ERR_add_error_data(2, "; errorDetails: ", text); @@ -316,8 +316,8 @@ static int poll_for_response(OSSL_CMP_CTX *ctx, int sleep, int rid, " with reason = '")) < 0) { *str = '\0'; } else { - char *text = sk_ASN1_UTF8STRING2text(pollRep->reason, ", ", - sizeof(str) - len - 2); + char *text = ossl_sk_ASN1_UTF8STRING2text(pollRep->reason, ", ", + sizeof(str) - len - 2); if (text == NULL || BIO_snprintf(str + len, sizeof(str) - len, diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c index 5982035c45..b713581c05 100644 --- a/crypto/cms/cms_ess.c +++ b/crypto/cms/cms_ess.c @@ -166,10 +166,10 @@ static int cms_msgSigDigest(CMS_SignerInfo *si, if (md == NULL) return 0; - if (!asn1_item_digest_ex(ASN1_ITEM_rptr(CMS_Attributes_Verify), md, - si->signedAttrs, dig, diglen, - ossl_cms_ctx_get0_libctx(si->cms_ctx), - ossl_cms_ctx_get0_propq(si->cms_ctx))) + if (!ossl_asn1_item_digest_ex(ASN1_ITEM_rptr(CMS_Attributes_Verify), md, + si->signedAttrs, dig, diglen, + ossl_cms_ctx_get0_libctx(si->cms_ctx), + ossl_cms_ctx_get0_propq(si->cms_ctx))) return 0; return 1; } diff --git a/crypto/cms/cms_rsa.c b/crypto/cms/cms_rsa.c index f577d462f1..b9e895aed4 100644 --- a/crypto/cms/cms_rsa.c +++ b/crypto/cms/cms_rsa.c @@ -25,7 +25,7 @@ static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg) return NULL; if (oaep->maskGenFunc != NULL) { - oaep->maskHash = x509_algor_mgf1_decode(oaep->maskGenFunc); + oaep->maskHash = ossl_x509_algor_mgf1_decode(oaep->maskGenFunc); if (oaep->maskHash == NULL) { RSA_OAEP_PARAMS_free(oaep); return NULL; @@ -65,10 +65,10 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri) goto err; } - mgf1md = x509_algor_get_md(oaep->maskHash); + mgf1md = ossl_x509_algor_get_md(oaep->maskHash); if (mgf1md == NULL) goto err; - md = x509_algor_get_md(oaep->hashFunc); + md = ossl_x509_algor_get_md(oaep->hashFunc); if (md == NULL) goto err; @@ -140,9 +140,9 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri) oaep = RSA_OAEP_PARAMS_new(); if (oaep == NULL) goto err; - if (!x509_algor_new_from_md(&oaep->hashFunc, md)) + if (!ossl_x509_algor_new_from_md(&oaep->hashFunc, md)) goto err; - if (!x509_algor_md_to_mgf1(&oaep->maskGenFunc, mgf1md)) + if (!ossl_x509_algor_md_to_mgf1(&oaep->maskGenFunc, mgf1md)) goto err; if (labellen > 0) { ASN1_OCTET_STRING *los; diff --git a/crypto/ctype.c b/crypto/ctype.c index dbd7891399..8612415b9b 100644 --- a/crypto/ctype.c +++ b/crypto/ctype.c @@ -273,7 +273,7 @@ int ossl_toupper(int c) return ossl_islower(c) ? c ^ case_change : c; } -int ascii_isdigit(const char inchar) { +int ossl_ascii_isdigit(const char inchar) { if (inchar > 0x2F && inchar < 0x3A) return 1; return 0; diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c index cccd880c20..08656877f3 100644 --- a/crypto/dh/dh_ameth.c +++ b/crypto/dh/dh_ameth.c @@ -35,7 +35,7 @@ static DH *d2i_dhp(const EVP_PKEY *pkey, const unsigned char **pp, long length) { DH *dh = NULL; - int is_dhx = (pkey->ameth == &dhx_asn1_meth); + int is_dhx = (pkey->ameth == &ossl_dhx_asn1_meth); if (is_dhx) dh = d2i_DHxparams(NULL, pp, length); @@ -47,7 +47,7 @@ static DH *d2i_dhp(const EVP_PKEY *pkey, const unsigned char **pp, static int i2d_dhp(const EVP_PKEY *pkey, const DH *a, unsigned char **pp) { - if (pkey->ameth == &dhx_asn1_meth) + if (pkey->ameth == &ossl_dhx_asn1_meth) return i2d_DHxparams(a, pp); return i2d_DHparams(a, pp); } @@ -350,7 +350,7 @@ static int dh_security_bits(const EVP_PKEY *pkey) static int dh_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) { return ossl_ffc_params_cmp(&a->pkey.dh->params, &a->pkey.dh->params, - a->ameth != &dhx_asn1_meth); + a->ameth != &ossl_dhx_asn1_meth); } static int int_dh_param_copy(DH *to, const DH *from, int is_x942) @@ -386,7 +386,7 @@ static int dh_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) return 0; } return int_dh_param_copy(to->pkey.dh, from->pkey.dh, - from->ameth == &dhx_asn1_meth); + from->ameth == &ossl_dhx_asn1_meth); } static int dh_missing_parameters(const EVP_PKEY *a) @@ -574,7 +574,7 @@ static int dhx_pkey_import_from(const OSSL_PARAM params[], void *vpctx) return dh_pkey_import_from_type(params, vpctx, EVP_PKEY_DHX); } -const EVP_PKEY_ASN1_METHOD dh_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_dh_asn1_meth = { EVP_PKEY_DH, EVP_PKEY_DH, 0, @@ -619,7 +619,7 @@ const EVP_PKEY_ASN1_METHOD dh_asn1_meth = { dh_pkey_import_from, }; -const EVP_PKEY_ASN1_METHOD dhx_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_dhx_asn1_meth = { EVP_PKEY_DHX, EVP_PKEY_DHX, 0, diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index c073f6b799..50ecd3ed3b 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -557,7 +557,7 @@ static int dsa_pkey_import_from(const OSSL_PARAM params[], void *vpctx) /* NB these are sorted in pkey_id order, lowest first */ -const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[5] = { +const EVP_PKEY_ASN1_METHOD ossl_dsa_asn1_meths[5] = { { EVP_PKEY_DSA2, diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index 694fcb3789..2c86af22f0 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -708,7 +708,7 @@ static int ec_pkey_import_from(const OSSL_PARAM params[], void *vpctx) return 1; } -const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_eckey_asn1_meth = { EVP_PKEY_EC, EVP_PKEY_EC, 0, @@ -759,7 +759,7 @@ const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = { }; #if !defined(OPENSSL_NO_SM2) -const EVP_PKEY_ASN1_METHOD sm2_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_sm2_asn1_meth = { EVP_PKEY_SM2, EVP_PKEY_EC, ASN1_PKEY_ALIAS diff --git a/crypto/ec/ecx_meth.c b/crypto/ec/ecx_meth.c index 9a812c875b..789610cac5 100644 --- a/crypto/ec/ecx_meth.c +++ b/crypto/ec/ecx_meth.c @@ -469,7 +469,7 @@ static int x25519_import_from(const OSSL_PARAM params[], void *vpctx) return ecx_generic_import_from(params, vpctx, EVP_PKEY_X25519); } -const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_ecx25519_asn1_meth = { EVP_PKEY_X25519, EVP_PKEY_X25519, 0, @@ -522,7 +522,7 @@ static int x448_import_from(const OSSL_PARAM params[], void *vpctx) return ecx_generic_import_from(params, vpctx, EVP_PKEY_X448); } -const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_ecx448_asn1_meth = { EVP_PKEY_X448, EVP_PKEY_X448, 0, @@ -649,7 +649,7 @@ static int ed25519_import_from(const OSSL_PARAM params[], void *vpctx) return ecx_generic_import_from(params, vpctx, EVP_PKEY_ED25519); } -const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_ed25519_asn1_meth = { EVP_PKEY_ED25519, EVP_PKEY_ED25519, 0, @@ -701,7 +701,7 @@ static int ed448_import_from(const OSSL_PARAM params[], void *vpctx) return ecx_generic_import_from(params, vpctx, EVP_PKEY_ED448); } -const EVP_PKEY_ASN1_METHOD ed448_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_ed448_asn1_meth = { EVP_PKEY_ED448, EVP_PKEY_ED448, 0, diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index dd3173ddd5..48bf99d1f5 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -243,10 +243,10 @@ int evp_cipher_get_asn1_aead_params(EVP_CIPHER_CTX *c, ASN1_TYPE *type, if (type == NULL || asn1_params == NULL) return 0; - i = asn1_type_get_octetstring_int(type, &tl, NULL, EVP_MAX_IV_LENGTH); + i = ossl_asn1_type_get_octetstring_int(type, &tl, NULL, EVP_MAX_IV_LENGTH); if (i <= 0) return -1; - asn1_type_get_octetstring_int(type, &tl, iv, i); + ossl_asn1_type_get_octetstring_int(type, &tl, iv, i); memcpy(asn1_params->iv, iv, i); asn1_params->iv_len = i; @@ -260,8 +260,9 @@ int evp_cipher_set_asn1_aead_params(EVP_CIPHER_CTX *c, ASN1_TYPE *type, if (type == NULL || asn1_params == NULL) return 0; - return asn1_type_set_octetstring_int(type, asn1_params->tag_len, - asn1_params->iv, asn1_params->iv_len); + return ossl_asn1_type_set_octetstring_int(type, asn1_params->tag_len, + asn1_params->iv, + asn1_params->iv_len); } #endif /* !defined(FIPS_MODULE) */ diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c index e9e442606d..6be5a908af 100644 --- a/crypto/rsa/rsa_ameth.c +++ b/crypto/rsa/rsa_ameth.c @@ -299,7 +299,7 @@ static int rsa_pss_param_print(BIO *bp, int pss_key, RSA_PSS_PARAMS *pss, goto err; if (BIO_puts(bp, " with ") <= 0) goto err; - maskHash = x509_algor_mgf1_decode(pss->maskGenAlgorithm); + maskHash = ossl_x509_algor_mgf1_decode(pss->maskGenAlgorithm); if (maskHash != NULL) { if (i2a_ASN1_OBJECT(bp, maskHash->algorithm) <= 0) goto err; @@ -455,7 +455,7 @@ static RSA_PSS_PARAMS *rsa_pss_decode(const X509_ALGOR *alg) return NULL; if (pss->maskGenAlgorithm != NULL) { - pss->maskHash = x509_algor_mgf1_decode(pss->maskGenAlgorithm); + pss->maskHash = ossl_x509_algor_mgf1_decode(pss->maskGenAlgorithm); if (pss->maskHash == NULL) { RSA_PSS_PARAMS_free(pss); return NULL; @@ -554,13 +554,13 @@ RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd, if (!ASN1_INTEGER_set(pss->saltLength, saltlen)) goto err; } - if (!x509_algor_new_from_md(&pss->hashAlgorithm, sigmd)) + if (!ossl_x509_algor_new_from_md(&pss->hashAlgorithm, sigmd)) goto err; if (mgf1md == NULL) mgf1md = sigmd; - if (!x509_algor_md_to_mgf1(&pss->maskGenAlgorithm, mgf1md)) + if (!ossl_x509_algor_md_to_mgf1(&pss->maskGenAlgorithm, mgf1md)) goto err; - if (!x509_algor_new_from_md(&pss->maskHash, mgf1md)) + if (!ossl_x509_algor_new_from_md(&pss->maskHash, mgf1md)) goto err; return pss; err: @@ -668,10 +668,10 @@ static int rsa_pss_get_param_unverified(const RSA_PSS_PARAMS *pss, if (pss == NULL) return 0; - *pmd = x509_algor_get_md(pss->hashAlgorithm); + *pmd = ossl_x509_algor_get_md(pss->hashAlgorithm); if (*pmd == NULL) return 0; - *pmgf1md = x509_algor_get_md(pss->maskHash); + *pmgf1md = ossl_x509_algor_get_md(pss->maskHash); if (*pmgf1md == NULL) return 0; if (pss->saltLength) @@ -1018,7 +1018,7 @@ static int rsa_pss_pkey_import_from(const OSSL_PARAM params[], void *vpctx) return rsa_int_import_from(params, vpctx, RSA_FLAG_TYPE_RSASSAPSS); } -const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2] = { +const EVP_PKEY_ASN1_METHOD ossl_rsa_asn1_meths[2] = { { EVP_PKEY_RSA, EVP_PKEY_RSA, @@ -1066,7 +1066,7 @@ const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2] = { ASN1_PKEY_ALIAS} }; -const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth = { +const EVP_PKEY_ASN1_METHOD ossl_rsa_pss_asn1_meth = { EVP_PKEY_RSA_PSS, EVP_PKEY_RSA_PSS, ASN1_PKEY_SIGPARAM_NULL, diff --git a/crypto/ts/ts_rsp_verify.c b/crypto/ts/ts_rsp_verify.c index 4660647ffc..89428cdf54 100644 --- a/crypto/ts/ts_rsp_verify.c +++ b/crypto/ts/ts_rsp_verify.c @@ -373,7 +373,7 @@ static int ts_check_status_info(TS_RESP *response) static char *ts_get_status_text(STACK_OF(ASN1_UTF8STRING) *text) { - return sk_ASN1_UTF8STRING2text(text, "/", TS_MAX_STATUS_LENGTH); + return ossl_sk_ASN1_UTF8STRING2text(text, "/", TS_MAX_STATUS_LENGTH); } static int ts_check_policy(const ASN1_OBJECT *req_oid, diff --git a/crypto/x509/t_x509.c b/crypto/x509/t_x509.c index 48be16eae8..e4a204fb1a 100644 --- a/crypto/x509/t_x509.c +++ b/crypto/x509/t_x509.c @@ -140,11 +140,11 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, goto err; if (BIO_write(bp, " Not Before: ", 24) <= 0) goto err; - if (asn1_time_print_ex(bp, X509_get0_notBefore(x)) == 0) + if (ossl_asn1_time_print_ex(bp, X509_get0_notBefore(x)) == 0) goto err; if (BIO_write(bp, "\n Not After : ", 25) <= 0) goto err; - if (asn1_time_print_ex(bp, X509_get0_notAfter(x)) == 0) + if (ossl_asn1_time_print_ex(bp, X509_get0_notAfter(x)) == 0) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index 5174a67bed..46ea798756 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -1886,7 +1886,7 @@ int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time) * Digit and date ranges will be verified in the conversion methods. */ for (i = 0; i < ctm->length - 1; i++) { - if (!ascii_isdigit(ctm->data[i])) + if (!ossl_ascii_isdigit(ctm->data[i])) return 0; } if (ctm->data[ctm->length - 1] != upper_z) diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index d80e50219e..d21b0799f6 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -399,8 +399,8 @@ int X509_digest(const X509 *cert, const EVP_MD *md, unsigned char *data, memcpy(data, cert->sha1_hash, sizeof(cert->sha1_hash)); return 1; } - return (asn1_item_digest_ex(ASN1_ITEM_rptr(X509), md, (char *)cert, data, - len, cert->libctx, cert->propq)); + return (ossl_asn1_item_digest_ex(ASN1_ITEM_rptr(X509), md, (char *)cert, + data, len, cert->libctx, cert->propq)); } /* calculate cert digest using the same hash algorithm as in its signature */ diff --git a/include/crypto/asn1.h b/include/crypto/asn1.h index 7d9dec10db..b812bdd614 100644 --- a/include/crypto/asn1.h +++ b/include/crypto/asn1.h @@ -92,18 +92,18 @@ struct evp_pkey_asn1_method_st { DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD) -extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[5]; -extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD ed448_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD sm2_asn1_meth; - -extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2]; -extern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ossl_dh_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ossl_dhx_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ossl_dsa_asn1_meths[5]; +extern const EVP_PKEY_ASN1_METHOD ossl_eckey_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ossl_ecx25519_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ossl_ecx448_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ossl_ed25519_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ossl_ed448_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ossl_sm2_asn1_meth; + +extern const EVP_PKEY_ASN1_METHOD ossl_rsa_asn1_meths[2]; +extern const EVP_PKEY_ASN1_METHOD ossl_rsa_pss_asn1_meth; /* * These are used internally in the ASN1_OBJECT to keep track of whether the @@ -133,15 +133,15 @@ struct asn1_pctx_st { /* ASN1 type functions */ -int asn1_type_set_octetstring_int(ASN1_TYPE *a, long num, - unsigned char *data, int len); -int asn1_type_get_octetstring_int(const ASN1_TYPE *a, long *num, - unsigned char *data, int max_len); +int ossl_asn1_type_set_octetstring_int(ASN1_TYPE *a, long num, + unsigned char *data, int len); +int ossl_asn1_type_get_octetstring_int(const ASN1_TYPE *a, long *num, + unsigned char *data, int max_len); -int x509_algor_new_from_md(X509_ALGOR **palg, const EVP_MD *md); -const EVP_MD *x509_algor_get_md(X509_ALGOR *alg); -X509_ALGOR *x509_algor_mgf1_decode(X509_ALGOR *alg); -int x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md); -int asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm); +int ossl_x509_algor_new_from_md(X509_ALGOR **palg, const EVP_MD *md); +const EVP_MD *ossl_x509_algor_get_md(X509_ALGOR *alg); +X509_ALGOR *ossl_x509_algor_mgf1_decode(X509_ALGOR *alg); +int ossl_x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md); +int ossl_asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm); #endif /* ndef OSSL_CRYPTO_ASN1_H */ diff --git a/include/crypto/ctype.h b/include/crypto/ctype.h index cb6e81b56e..a35c137e84 100644 --- a/include/crypto/ctype.h +++ b/include/crypto/ctype.h @@ -58,7 +58,7 @@ int ossl_ctype_check(int c, unsigned int mask); int ossl_tolower(int c); int ossl_toupper(int c); -int ascii_isdigit(const char inchar); +int ossl_ascii_isdigit(const char inchar); # define ossl_isalnum(c) (ossl_ctype_check((c), CTYPE_MASK_alnum)) # define ossl_isalpha(c) (ossl_ctype_check((c), CTYPE_MASK_alpha)) diff --git a/include/crypto/x509.h b/include/crypto/x509.h index 67fd88dbc4..c031dc56b1 100644 --- a/include/crypto/x509.h +++ b/include/crypto/x509.h @@ -315,9 +315,9 @@ int x509_check_issued_int(X509 *issuer, X509 *subject, OSSL_LIB_CTX *libctx, int x509_set0_libctx(X509 *x, OSSL_LIB_CTX *libctx, const char *propq); int x509_crl_set0_libctx(X509_CRL *x, OSSL_LIB_CTX *libctx, const char *propq); int x509_init_sig_info(X509 *x); -int asn1_item_digest_ex(const ASN1_ITEM *it, const EVP_MD *type, void *data, - unsigned char *md, unsigned int *len, - OSSL_LIB_CTX *libctx, const char *propq); +int ossl_asn1_item_digest_ex(const ASN1_ITEM *it, const EVP_MD *type, void *data, + unsigned char *md, unsigned int *len, + OSSL_LIB_CTX *libctx, const char *propq); int ossl_x509_add_cert_new(STACK_OF(X509) **sk, X509 *cert, int flags); int ossl_x509_add_certs_new(STACK_OF(X509) **p_sk, STACK_OF(X509) *certs, int flags); diff --git a/include/internal/cryptlib.h b/include/internal/cryptlib.h index 26862310d8..fb46657dba 100644 --- a/include/internal/cryptlib.h +++ b/include/internal/cryptlib.h @@ -247,8 +247,8 @@ static ossl_inline void ossl_sleep(unsigned long millis) } #endif /* defined OPENSSL_SYS_UNIX */ -char *sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text, const char *sep, - size_t max_len); +char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text, + const char *sep, size_t max_len); char *ossl_ipaddr_to_asc(unsigned char *p, int len); char *ossl_buf2hexstr_sep(const unsigned char *buf, long buflen, char sep); -- 2.34.1