diff --git a/include/mbedtls/asn1.h b/include/mbedtls/asn1.h index 3242699e72..825020fe33 100644 --- a/include/mbedtls/asn1.h +++ b/include/mbedtls/asn1.h @@ -209,6 +209,7 @@ typedef struct mbedtls_asn1_named_data { } mbedtls_asn1_named_data; +#if defined(MBEDTLS_ASN1_PARSE_C) || defined(MBEDTLS_X509_CREATE_C) /** * \brief Get the length of an ASN.1 element. * Updates the pointer to immediately behind the length. @@ -271,6 +272,9 @@ int mbedtls_asn1_get_tag(unsigned char **p, * \return An ASN.1 error code if the input does not start with * a valid ASN.1 BOOLEAN. */ +#endif /* MBEDTLS_ASN1_PARSE_C || MBEDTLS_X509_CREATE_C */ + +#if defined(MBEDTLS_ASN1_PARSE_C) int mbedtls_asn1_get_bool(unsigned char **p, const unsigned char *end, int *val); @@ -645,4 +649,6 @@ void mbedtls_asn1_free_named_data_list_shallow(mbedtls_asn1_named_data *name); } #endif +#endif /* MBEDTLS_ASN1_PARSE_C */ + #endif /* asn1.h */ diff --git a/library/asn1parse.c b/library/asn1parse.c index d257ef4383..edc4c698ff 100644 --- a/library/asn1parse.c +++ b/library/asn1parse.c @@ -19,7 +19,7 @@ #include "common.h" -#if defined(MBEDTLS_ASN1_PARSE_C) +#if defined(MBEDTLS_ASN1_PARSE_C) || defined(MBEDTLS_X509_CREATE_C) #include "mbedtls/asn1.h" #include "mbedtls/platform_util.h" @@ -114,7 +114,9 @@ int mbedtls_asn1_get_tag(unsigned char **p, return mbedtls_asn1_get_len(p, end, len); } +#endif /* MBEDTLS_ASN1_PARSE_C || MBEDTLS_X509_CREATE_C */ +#if defined(MBEDTLS_ASN1_PARSE_C) int mbedtls_asn1_get_bool(unsigned char **p, const unsigned char *end, int *val) diff --git a/library/x509_create.c b/library/x509_create.c index 1da1587878..6ef33b0336 100644 --- a/library/x509_create.c +++ b/library/x509_create.c @@ -30,9 +30,7 @@ #include "mbedtls/platform.h" -#if defined(MBEDTLS_ASN1_PARSE_C) #include "mbedtls/asn1.h" -#endif /* Structure linking OIDs for X.509 DN AttributeTypes to their * string representations and default string encodings used by Mbed TLS. */ @@ -186,7 +184,6 @@ static int parse_attribute_value_string(const char *s, return 0; } -#if defined(MBEDTLS_ASN1_PARSE_C) static int parse_attribute_value_der_encoded(const char *s, int len, unsigned char *data, @@ -233,7 +230,6 @@ static int parse_attribute_value_der_encoded(const char *s, return 0; } -#endif int mbedtls_x509_string_to_names(mbedtls_asn1_named_data **head, const char *name) { @@ -276,16 +272,12 @@ int mbedtls_x509_string_to_names(mbedtls_asn1_named_data **head, const char *nam mbedtls_free(oid.p); return MBEDTLS_ERR_X509_INVALID_NAME; } else if (*s == '#') { -#if defined(MBEDTLS_ASN1_PARSE_C) if ((parse_ret = parse_attribute_value_der_encoded(s, (int) (c - s), data, &data_len, &tag)) != 0) { mbedtls_free(oid.p); return MBEDTLS_ERR_X509_INVALID_NAME; } -#else - return MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE -#endif } else { if (numericoid) { mbedtls_free(oid.p);