Add asn1 get tag and len to x509 create config
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
diff --git a/library/asn1parse.c b/library/asn1parse.c
index d257ef4..edc4c69 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 @@
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 1da1587..6ef33b0 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 @@
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 @@
return 0;
}
-#endif
int mbedtls_x509_string_to_names(mbedtls_asn1_named_data **head, const char *name)
{
@@ -276,16 +272,12 @@
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);