mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-01 03:32:43 +00:00
Merge pull request #8025 from AgathiyanB/accept-numericoid-hexstring-x509
Accept numericoid hexstring x509
This commit is contained in:
commit
3cea3efc25
3
ChangeLog.d/extend-distinguished-names.txt
Normal file
3
ChangeLog.d/extend-distinguished-names.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Features
|
||||||
|
* Accept arbitrary AttributeType and AttributeValue in certificate
|
||||||
|
Distinguished Names using RFC 4514 syntax.
|
@ -96,15 +96,14 @@
|
|||||||
|
|
||||||
/* Slightly smaller way to check if tag is a string tag
|
/* Slightly smaller way to check if tag is a string tag
|
||||||
* compared to canonical implementation. */
|
* compared to canonical implementation. */
|
||||||
#define MBEDTLS_ASN1_IS_STRING_TAG(tag) \
|
#define MBEDTLS_ASN1_IS_STRING_TAG(tag) \
|
||||||
((tag) < 32u && ( \
|
((unsigned int) (tag) < 32u && ( \
|
||||||
((1u << (tag)) & ((1u << MBEDTLS_ASN1_BMP_STRING) | \
|
((1u << (tag)) & ((1u << MBEDTLS_ASN1_BMP_STRING) | \
|
||||||
(1u << MBEDTLS_ASN1_UTF8_STRING) | \
|
(1u << MBEDTLS_ASN1_UTF8_STRING) | \
|
||||||
(1u << MBEDTLS_ASN1_T61_STRING) | \
|
(1u << MBEDTLS_ASN1_T61_STRING) | \
|
||||||
(1u << MBEDTLS_ASN1_IA5_STRING) | \
|
(1u << MBEDTLS_ASN1_IA5_STRING) | \
|
||||||
(1u << MBEDTLS_ASN1_UNIVERSAL_STRING) | \
|
(1u << MBEDTLS_ASN1_UNIVERSAL_STRING) | \
|
||||||
(1u << MBEDTLS_ASN1_PRINTABLE_STRING) | \
|
(1u << MBEDTLS_ASN1_PRINTABLE_STRING))) != 0))
|
||||||
(1u << MBEDTLS_ASN1_BIT_STRING))) != 0))
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bit masks for each of the components of an ASN.1 tag as specified in
|
* Bit masks for each of the components of an ASN.1 tag as specified in
|
||||||
@ -210,6 +209,7 @@ typedef struct mbedtls_asn1_named_data {
|
|||||||
}
|
}
|
||||||
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.
|
* \brief Get the length of an ASN.1 element.
|
||||||
* Updates the pointer to immediately behind the length.
|
* Updates the pointer to immediately behind the length.
|
||||||
@ -256,7 +256,9 @@ int mbedtls_asn1_get_len(unsigned char **p,
|
|||||||
int mbedtls_asn1_get_tag(unsigned char **p,
|
int mbedtls_asn1_get_tag(unsigned char **p,
|
||||||
const unsigned char *end,
|
const unsigned char *end,
|
||||||
size_t *len, int tag);
|
size_t *len, int tag);
|
||||||
|
#endif /* MBEDTLS_ASN1_PARSE_C || MBEDTLS_X509_CREATE_C */
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||||
/**
|
/**
|
||||||
* \brief Retrieve a boolean ASN.1 tag and its value.
|
* \brief Retrieve a boolean ASN.1 tag and its value.
|
||||||
* Updates the pointer to immediately behind the full tag.
|
* Updates the pointer to immediately behind the full tag.
|
||||||
@ -646,4 +648,6 @@ void mbedtls_asn1_free_named_data_list_shallow(mbedtls_asn1_named_data *name);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* MBEDTLS_ASN1_PARSE_C */
|
||||||
|
|
||||||
#endif /* asn1.h */
|
#endif /* asn1.h */
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ASN1_WRITE_C) || defined(MBEDTLS_X509_USE_C)
|
||||||
/**
|
/**
|
||||||
* \brief Write a length field in ASN.1 format.
|
* \brief Write a length field in ASN.1 format.
|
||||||
*
|
*
|
||||||
@ -76,7 +77,9 @@ int mbedtls_asn1_write_len(unsigned char **p, const unsigned char *start,
|
|||||||
*/
|
*/
|
||||||
int mbedtls_asn1_write_tag(unsigned char **p, const unsigned char *start,
|
int mbedtls_asn1_write_tag(unsigned char **p, const unsigned char *start,
|
||||||
unsigned char tag);
|
unsigned char tag);
|
||||||
|
#endif /* MBEDTLS_ASN1_WRITE_C || MBEDTLS_X509_USE_C */
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ASN1_WRITE_C)
|
||||||
/**
|
/**
|
||||||
* \brief Write raw buffer data.
|
* \brief Write raw buffer data.
|
||||||
*
|
*
|
||||||
@ -393,4 +396,6 @@ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data(mbedtls_asn1_named_data *
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* MBEDTLS_ASN1_WRITE_C */
|
||||||
|
|
||||||
#endif /* MBEDTLS_ASN1_WRITE_H */
|
#endif /* MBEDTLS_ASN1_WRITE_H */
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#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/asn1.h"
|
||||||
#include "mbedtls/platform_util.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);
|
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,
|
int mbedtls_asn1_get_bool(unsigned char **p,
|
||||||
const unsigned char *end,
|
const unsigned char *end,
|
||||||
int *val)
|
int *val)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_ASN1_WRITE_C)
|
#if defined(MBEDTLS_ASN1_WRITE_C) || defined(MBEDTLS_X509_USE_C)
|
||||||
|
|
||||||
#include "mbedtls/asn1write.h"
|
#include "mbedtls/asn1write.h"
|
||||||
#include "mbedtls/error.h"
|
#include "mbedtls/error.h"
|
||||||
@ -102,7 +102,9 @@ int mbedtls_asn1_write_tag(unsigned char **p, const unsigned char *start, unsign
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif /* MBEDTLS_ASN1_WRITE_C || MBEDTLS_X509_USE_C */
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ASN1_WRITE_C)
|
||||||
int mbedtls_asn1_write_raw_buffer(unsigned char **p, const unsigned char *start,
|
int mbedtls_asn1_write_raw_buffer(unsigned char **p, const unsigned char *start,
|
||||||
const unsigned char *buf, size_t size)
|
const unsigned char *buf, size_t size)
|
||||||
{
|
{
|
||||||
|
103
library/x509.c
103
library/x509.c
@ -43,6 +43,8 @@
|
|||||||
#include "mbedtls/pem.h"
|
#include "mbedtls/pem.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "mbedtls/asn1write.h"
|
||||||
|
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_HAVE_TIME)
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
@ -810,6 +812,11 @@ int mbedtls_x509_get_ext(unsigned char **p, const unsigned char *end,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char nibble_to_hex_digit(int i)
|
||||||
|
{
|
||||||
|
return (i < 10) ? (i + '0') : (i - 10 + 'A');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Store the name in printable form into buf; no more
|
* Store the name in printable form into buf; no more
|
||||||
* than size characters will be written
|
* than size characters will be written
|
||||||
@ -817,11 +824,16 @@ int mbedtls_x509_get_ext(unsigned char **p, const unsigned char *end,
|
|||||||
int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
|
int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
size_t i, j, n;
|
size_t i, j, n, asn1_len_size, asn1_tag_size, asn1_tag_len_buf_start;
|
||||||
|
/* 6 is enough as our asn1 write functions only write one byte for the tag and at most five bytes for the length*/
|
||||||
|
unsigned char asn1_tag_len_buf[6];
|
||||||
|
unsigned char *asn1_len_p;
|
||||||
unsigned char c, merge = 0;
|
unsigned char c, merge = 0;
|
||||||
const mbedtls_x509_name *name;
|
const mbedtls_x509_name *name;
|
||||||
const char *short_name = NULL;
|
const char *short_name = NULL;
|
||||||
|
char lowbits, highbits;
|
||||||
char s[MBEDTLS_X509_MAX_DN_NAME_SIZE], *p;
|
char s[MBEDTLS_X509_MAX_DN_NAME_SIZE], *p;
|
||||||
|
int print_hexstring;
|
||||||
|
|
||||||
memset(s, 0, sizeof(s));
|
memset(s, 0, sizeof(s));
|
||||||
|
|
||||||
@ -840,32 +852,91 @@ int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
|
|||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mbedtls_oid_get_attr_short_name(&name->oid, &short_name);
|
print_hexstring = (name->val.tag != MBEDTLS_ASN1_UTF8_STRING) &&
|
||||||
|
(name->val.tag != MBEDTLS_ASN1_PRINTABLE_STRING) &&
|
||||||
|
(name->val.tag != MBEDTLS_ASN1_IA5_STRING);
|
||||||
|
|
||||||
if (ret == 0) {
|
if ((ret = mbedtls_oid_get_attr_short_name(&name->oid, &short_name)) == 0) {
|
||||||
ret = mbedtls_snprintf(p, n, "%s=", short_name);
|
ret = mbedtls_snprintf(p, n, "%s=", short_name);
|
||||||
} else {
|
} else {
|
||||||
ret = mbedtls_snprintf(p, n, "\?\?=");
|
if ((ret = mbedtls_oid_get_numeric_string(p, n, &name->oid)) > 0) {
|
||||||
|
n -= ret;
|
||||||
|
p += ret;
|
||||||
|
ret = mbedtls_snprintf(p, n, "=");
|
||||||
|
print_hexstring = 1;
|
||||||
|
} else if (ret == MBEDTLS_ERR_OID_BUF_TOO_SMALL) {
|
||||||
|
return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
||||||
|
} else {
|
||||||
|
ret = mbedtls_snprintf(p, n, "\?\?=");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
|
||||||
for (i = 0, j = 0; i < name->val.len; i++, j++) {
|
if (print_hexstring) {
|
||||||
if (j >= sizeof(s) - 1) {
|
s[0] = '#';
|
||||||
return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
c = name->val.p[i];
|
asn1_len_p = asn1_tag_len_buf + sizeof(asn1_tag_len_buf);
|
||||||
// Special characters requiring escaping, RFC 1779
|
if ((ret = mbedtls_asn1_write_len(&asn1_len_p, asn1_tag_len_buf, name->val.len)) < 0) {
|
||||||
if (c && strchr(",=+<>#;\"\\", c)) {
|
return MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
|
}
|
||||||
|
asn1_len_size = ret;
|
||||||
|
if ((ret = mbedtls_asn1_write_tag(&asn1_len_p, asn1_tag_len_buf, name->val.tag)) < 0) {
|
||||||
|
return MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
|
}
|
||||||
|
asn1_tag_size = ret;
|
||||||
|
asn1_tag_len_buf_start = sizeof(asn1_tag_len_buf) - asn1_len_size - asn1_tag_size;
|
||||||
|
for (i = 0, j = 1; i < asn1_len_size + asn1_tag_size; i++) {
|
||||||
if (j + 1 >= sizeof(s) - 1) {
|
if (j + 1 >= sizeof(s) - 1) {
|
||||||
return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
s[j++] = '\\';
|
c = asn1_tag_len_buf[asn1_tag_len_buf_start+i];
|
||||||
|
lowbits = (c & 0x0F);
|
||||||
|
highbits = c >> 4;
|
||||||
|
s[j++] = nibble_to_hex_digit(highbits);
|
||||||
|
s[j++] = nibble_to_hex_digit(lowbits);
|
||||||
}
|
}
|
||||||
if (c < 32 || c >= 127) {
|
for (i = 0; i < name->val.len; i++) {
|
||||||
s[j] = '?';
|
if (j + 1 >= sizeof(s) - 1) {
|
||||||
} else {
|
return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
||||||
s[j] = c;
|
}
|
||||||
|
c = name->val.p[i];
|
||||||
|
lowbits = (c & 0x0F);
|
||||||
|
highbits = c >> 4;
|
||||||
|
s[j++] = nibble_to_hex_digit(highbits);
|
||||||
|
s[j++] = nibble_to_hex_digit(lowbits);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0, j = 0; i < name->val.len; i++, j++) {
|
||||||
|
if (j >= sizeof(s) - 1) {
|
||||||
|
return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
c = name->val.p[i];
|
||||||
|
// Special characters requiring escaping, RFC 4514 Section 2.4
|
||||||
|
if (c == '\0') {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
} else {
|
||||||
|
if (strchr(",=+<>;\"\\", c) ||
|
||||||
|
((i == 0) && strchr("# ", c)) ||
|
||||||
|
((i == name->val.len-1) && (c == ' '))) {
|
||||||
|
if (j + 1 >= sizeof(s) - 1) {
|
||||||
|
return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
s[j++] = '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c < 32 || c >= 127) {
|
||||||
|
if (j + 3 >= sizeof(s) - 1) {
|
||||||
|
return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
s[j++] = '\\';
|
||||||
|
lowbits = (c & 0x0F);
|
||||||
|
highbits = c >> 4;
|
||||||
|
s[j++] = nibble_to_hex_digit(highbits);
|
||||||
|
s[j] = nibble_to_hex_digit(lowbits);
|
||||||
|
} else {
|
||||||
|
s[j] = c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s[j] = '\0';
|
s[j] = '\0';
|
||||||
|
@ -28,6 +28,10 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "mbedtls/platform.h"
|
||||||
|
|
||||||
|
#include "mbedtls/asn1.h"
|
||||||
|
|
||||||
/* Structure linking OIDs for X.509 DN AttributeTypes to their
|
/* Structure linking OIDs for X.509 DN AttributeTypes to their
|
||||||
* string representations and default string encodings used by Mbed TLS. */
|
* string representations and default string encodings used by Mbed TLS. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -35,7 +39,8 @@ typedef struct {
|
|||||||
* "CN" or "emailAddress". */
|
* "CN" or "emailAddress". */
|
||||||
size_t name_len; /* Length of 'name', without trailing 0 byte. */
|
size_t name_len; /* Length of 'name', without trailing 0 byte. */
|
||||||
const char *oid; /* String representation of OID of AttributeType,
|
const char *oid; /* String representation of OID of AttributeType,
|
||||||
* as per RFC 5280, Appendix A.1. */
|
* as per RFC 5280, Appendix A.1. encoded as per
|
||||||
|
* X.690 */
|
||||||
int default_tag; /* The default character encoding used for the
|
int default_tag; /* The default character encoding used for the
|
||||||
* given attribute type, e.g.
|
* given attribute type, e.g.
|
||||||
* MBEDTLS_ASN1_UTF8_STRING for UTF-8. */
|
* MBEDTLS_ASN1_UTF8_STRING for UTF-8. */
|
||||||
@ -123,79 +128,200 @@ static const x509_attr_descriptor_t *x509_attr_descr_from_name(const char *name,
|
|||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int hex_to_int(char c)
|
||||||
|
{
|
||||||
|
return ('0' <= c && c <= '9') ? (c - '0') :
|
||||||
|
('a' <= c && c <= 'f') ? (c - 'a' + 10) :
|
||||||
|
('A' <= c && c <= 'F') ? (c - 'A' + 10) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int hexpair_to_int(const char *hexpair)
|
||||||
|
{
|
||||||
|
int n1 = hex_to_int(*hexpair);
|
||||||
|
int n2 = hex_to_int(*(hexpair + 1));
|
||||||
|
|
||||||
|
if (n1 != -1 && n2 != -1) {
|
||||||
|
return (n1 << 4) | n2;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_attribute_value_string(const char *s,
|
||||||
|
int len,
|
||||||
|
unsigned char *data,
|
||||||
|
size_t *data_len)
|
||||||
|
{
|
||||||
|
const char *c;
|
||||||
|
const char *end = s + len;
|
||||||
|
unsigned char *d = data;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
for (c = s; c < end; c++) {
|
||||||
|
if (*c == '\\') {
|
||||||
|
c++;
|
||||||
|
|
||||||
|
/* Check for valid escaped characters as per RFC 4514 Section 3 */
|
||||||
|
if (c + 1 < end && (n = hexpair_to_int(c)) != -1) {
|
||||||
|
if (n == 0) {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
}
|
||||||
|
*(d++) = n;
|
||||||
|
c++;
|
||||||
|
} else if (c < end && strchr(" ,=+<>#;\"\\", *c)) {
|
||||||
|
*(d++) = *c;
|
||||||
|
} else {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*(d++) = *c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d - data == MBEDTLS_X509_MAX_DN_NAME_SIZE) {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*data_len = d - data;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_attribute_value_der_encoded(const char *s,
|
||||||
|
int len,
|
||||||
|
unsigned char *data,
|
||||||
|
size_t *data_len,
|
||||||
|
int *tag)
|
||||||
|
{
|
||||||
|
const char *c = s;
|
||||||
|
const char *end = c + len;
|
||||||
|
unsigned char asn1_der_buf[MBEDTLS_X509_MAX_DN_NAME_SIZE];
|
||||||
|
unsigned char *asn1_der_end;
|
||||||
|
unsigned char *p;
|
||||||
|
unsigned char *d = data;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* Converting from hexstring to raw binary so we can use asn1parse.c */
|
||||||
|
if ((len < 5) || (*c != '#')) {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
}
|
||||||
|
c++;
|
||||||
|
if ((*tag = hexpair_to_int(c)) == -1) {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
}
|
||||||
|
c += 2;
|
||||||
|
p = asn1_der_buf;
|
||||||
|
for (p = asn1_der_buf; c < end; c += 2) {
|
||||||
|
if ((c + 1 >= end) || (n = hexpair_to_int(c)) == -1) {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
}
|
||||||
|
if (MBEDTLS_ASN1_IS_STRING_TAG(*tag) && n == 0) {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
}
|
||||||
|
*(p++) = n;
|
||||||
|
}
|
||||||
|
asn1_der_end = p;
|
||||||
|
|
||||||
|
p = asn1_der_buf;
|
||||||
|
if (mbedtls_asn1_get_len(&p, asn1_der_end, data_len) != 0) {
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (p < asn1_der_end) {
|
||||||
|
*(d++) = *(p++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int mbedtls_x509_string_to_names(mbedtls_asn1_named_data **head, const char *name)
|
int mbedtls_x509_string_to_names(mbedtls_asn1_named_data **head, const char *name)
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_X509_INVALID_NAME;
|
int ret = MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
int parse_ret = 0;
|
||||||
const char *s = name, *c = s;
|
const char *s = name, *c = s;
|
||||||
const char *end = s + strlen(s);
|
const char *end = s + strlen(s);
|
||||||
const char *oid = NULL;
|
mbedtls_asn1_buf oid = { .p = NULL, .len = 0, .tag = MBEDTLS_ASN1_NULL };
|
||||||
const x509_attr_descriptor_t *attr_descr = NULL;
|
const x509_attr_descriptor_t *attr_descr = NULL;
|
||||||
int in_tag = 1;
|
int in_attr_type = 1;
|
||||||
char data[MBEDTLS_X509_MAX_DN_NAME_SIZE];
|
int tag;
|
||||||
char *d = data;
|
int numericoid = 0;
|
||||||
|
unsigned char data[MBEDTLS_X509_MAX_DN_NAME_SIZE];
|
||||||
|
size_t data_len = 0;
|
||||||
|
|
||||||
/* Clear existing chain if present */
|
/* Clear existing chain if present */
|
||||||
mbedtls_asn1_free_named_data_list(head);
|
mbedtls_asn1_free_named_data_list(head);
|
||||||
|
|
||||||
while (c <= end) {
|
while (c <= end) {
|
||||||
if (in_tag && *c == '=') {
|
if (in_attr_type && *c == '=') {
|
||||||
if ((attr_descr = x509_attr_descr_from_name(s, c - s)) == NULL) {
|
if ((attr_descr = x509_attr_descr_from_name(s, c - s)) == NULL) {
|
||||||
ret = MBEDTLS_ERR_X509_UNKNOWN_OID;
|
if ((mbedtls_oid_from_numeric_string(&oid, s, c - s)) != 0) {
|
||||||
goto exit;
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
} else {
|
||||||
|
numericoid = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oid.len = strlen(attr_descr->oid);
|
||||||
|
oid.p = mbedtls_calloc(1, oid.len);
|
||||||
|
memcpy(oid.p, attr_descr->oid, oid.len);
|
||||||
|
numericoid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
oid = attr_descr->oid;
|
|
||||||
s = c + 1;
|
s = c + 1;
|
||||||
in_tag = 0;
|
in_attr_type = 0;
|
||||||
d = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_tag && *c == '\\' && c != end) {
|
if (!in_attr_type && ((*c == ',' && *(c-1) != '\\') || c == end)) {
|
||||||
c++;
|
if (s == c) {
|
||||||
|
mbedtls_free(oid.p);
|
||||||
/* Check for valid escaped characters */
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
if (c == end || *c != ',') {
|
} else if (*s == '#') {
|
||||||
ret = MBEDTLS_ERR_X509_INVALID_NAME;
|
if ((parse_ret =
|
||||||
goto exit;
|
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 {
|
||||||
|
if (numericoid) {
|
||||||
|
mbedtls_free(oid.p);
|
||||||
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
|
} else {
|
||||||
|
if ((parse_ret =
|
||||||
|
parse_attribute_value_string(s, (int) (c - s), data,
|
||||||
|
&data_len)) != 0) {
|
||||||
|
mbedtls_free(oid.p);
|
||||||
|
return parse_ret;
|
||||||
|
}
|
||||||
|
tag = attr_descr->default_tag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (!in_tag && (*c == ',' || c == end)) {
|
|
||||||
mbedtls_asn1_named_data *cur =
|
|
||||||
mbedtls_asn1_store_named_data(head, oid, strlen(oid),
|
|
||||||
(unsigned char *) data,
|
|
||||||
d - data);
|
|
||||||
|
|
||||||
|
mbedtls_asn1_named_data *cur =
|
||||||
|
mbedtls_asn1_store_named_data(head, (char *) oid.p, oid.len,
|
||||||
|
(unsigned char *) data,
|
||||||
|
data_len);
|
||||||
|
mbedtls_free(oid.p);
|
||||||
|
oid.p = NULL;
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
return MBEDTLS_ERR_X509_ALLOC_FAILED;
|
return MBEDTLS_ERR_X509_ALLOC_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set tagType
|
// set tagType
|
||||||
cur->val.tag = attr_descr->default_tag;
|
cur->val.tag = tag;
|
||||||
|
|
||||||
while (c < end && *(c + 1) == ' ') {
|
while (c < end && *(c + 1) == ' ') {
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = c + 1;
|
s = c + 1;
|
||||||
in_tag = 1;
|
in_attr_type = 1;
|
||||||
|
|
||||||
/* Successfully parsed one name, update ret to success */
|
/* Successfully parsed one name, update ret to success */
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_tag && s != c + 1) {
|
|
||||||
*(d++) = *c;
|
|
||||||
|
|
||||||
if (d - data == MBEDTLS_X509_MAX_DN_NAME_SIZE) {
|
|
||||||
ret = MBEDTLS_ERR_X509_INVALID_NAME;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
if (oid.p != NULL) {
|
||||||
exit:
|
mbedtls_free(oid.p);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1441,6 +1441,14 @@ all_final += server1.req.cert_type_empty
|
|||||||
parse_input/server1.req.commas.sha256: server1.key
|
parse_input/server1.req.commas.sha256: server1.key
|
||||||
$(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL\, Commas,CN=PolarSSL Server 1" md=SHA256
|
$(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL\, Commas,CN=PolarSSL Server 1" md=SHA256
|
||||||
|
|
||||||
|
parse_input/server1.req.hashsymbol.sha256: server1.key
|
||||||
|
$(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=\#PolarSSL,CN=PolarSSL Server 1" md=SHA256
|
||||||
|
|
||||||
|
parse_input/server1.req.spaces.sha256: server1.key
|
||||||
|
$(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O= PolarSSL ,CN=PolarSSL Server 1" md=SHA256
|
||||||
|
|
||||||
|
parse_input/server1.req.asciichars.sha256: server1.key
|
||||||
|
$(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=极地SSL,CN=PolarSSL Server 1" md=SHA256
|
||||||
# server2*
|
# server2*
|
||||||
|
|
||||||
server2_pwd_ec = PolarSSLTest
|
server2_pwd_ec = PolarSSLTest
|
||||||
@ -1590,7 +1598,13 @@ server1.der: server1.crt
|
|||||||
$(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
|
$(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
|
||||||
server1.commas.crt: server1.key parse_input/server1.req.commas.sha256 $(test_ca_crt) $(test_ca_key_file_rsa)
|
server1.commas.crt: server1.key parse_input/server1.req.commas.sha256 $(test_ca_crt) $(test_ca_key_file_rsa)
|
||||||
$(MBEDTLS_CERT_WRITE) request_file=parse_input/server1.req.commas.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20190210144406 not_after=20290210144406 md=SHA1 version=3 output_file=$@
|
$(MBEDTLS_CERT_WRITE) request_file=parse_input/server1.req.commas.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20190210144406 not_after=20290210144406 md=SHA1 version=3 output_file=$@
|
||||||
all_final += server1.crt server1.noauthid.crt parse_input/server1.crt.der server1.commas.crt
|
server1.hashsymbol.crt: server1.key parse_input/server1.req.hashsymbol.sha256 $(test_ca_crt) $(test_ca_key_file_rsa)
|
||||||
|
$(MBEDTLS_CERT_WRITE) request_file=parse_input/server1.req.hashsymbol.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20190210144406 not_after=20290210144406 md=SHA1 version=3 output_file=$@
|
||||||
|
server1.spaces.crt: server1.key parse_input/server1.req.spaces.sha256 $(test_ca_crt) $(test_ca_key_file_rsa)
|
||||||
|
$(MBEDTLS_CERT_WRITE) request_file=parse_input/server1.req.spaces.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20190210144406 not_after=20290210144406 md=SHA1 version=3 output_file=$@
|
||||||
|
server1.asciichars.crt: server1.key parse_input/server1.req.asciichars.sha256 $(test_ca_crt) $(test_ca_key_file_rsa)
|
||||||
|
$(MBEDTLS_CERT_WRITE) request_file=parse_input/server1.req.asciichars.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20190210144406 not_after=20290210144406 md=SHA1 version=3 output_file=$@
|
||||||
|
all_final += server1.crt server1.noauthid.crt parse_input/server1.crt.der server1.commas.crt server1.hashsymbol.crt server1.spaces.crt server1.asciichars.crt
|
||||||
|
|
||||||
parse_input/server1.key_usage.crt: parse_input/server1.req.sha256
|
parse_input/server1.key_usage.crt: parse_input/server1.req.sha256
|
||||||
server1.key_usage.crt: server1.req.sha256
|
server1.key_usage.crt: server1.req.sha256
|
||||||
|
20
tests/data_files/server1.asciichars.crt
Normal file
20
tests/data_files/server1.asciichars.crt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDQDCCAiigAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER
|
||||||
|
MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN
|
||||||
|
MTkwMjEwMTQ0NDA2WhcNMjkwMjEwMTQ0NDA2WjA9MQswCQYDVQQGEwJOTDESMBAG
|
||||||
|
A1UECgwJ5p6B5ZywU1NMMRowGAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIw
|
||||||
|
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6J
|
||||||
|
v7joRZDb7ogWUtPxQ1BHlhJZZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVB
|
||||||
|
Q3dfOXwJBEeCsFc5cO2j7BUZHqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYEl
|
||||||
|
XwqxU8YwfhU5rPla7n+SnqYFW+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk
|
||||||
|
65Wb3P5BXhem2mxbacwCuhQsFiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZP
|
||||||
|
cG6ezr1YieJTWZ5uWpJl4og/DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEA
|
||||||
|
AaNNMEswCQYDVR0TBAIwADAdBgNVHQ4EFgQUH3TWPynBdHRFOwUSLD2ovUNZAqYw
|
||||||
|
HwYDVR0jBBgwFoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQEFBQAD
|
||||||
|
ggEBAHqJLYmgkQ6yqml3PZM6iwbmo+lZLyDEPFpl/thHZm5LI8TTYOeU+wMAZ6KI
|
||||||
|
VumyjZxypmLF2MiiJ2f3zQooU7H1waAcTpsafTuD6RRYdthYYxs1L9gCm1ZT2Ga8
|
||||||
|
fgn3wrugPLUrtSM/TkTj6F4XkSlluzZpEKsSYLSoyde+uQgdbtR+3Tc+3oU8xBMM
|
||||||
|
N6uq4VQC49avIQkI+598E3vKrjGGt3l2a1Ts1qvXWjo9mpJW5GM4e1zfogKnc8XQ
|
||||||
|
K1hYQ39wL42l9Hijwre85O0PSBfbNOv1BPSDm8das3VNzGsUIz8InkAKAKCKwxG6
|
||||||
|
BCw3D/CE8s6DCnpb+eK1sVJwZ4E=
|
||||||
|
-----END CERTIFICATE-----
|
20
tests/data_files/server1.hashsymbol.crt
Normal file
20
tests/data_files/server1.hashsymbol.crt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDQDCCAiigAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER
|
||||||
|
MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN
|
||||||
|
MTkwMjEwMTQ0NDA2WhcNMjkwMjEwMTQ0NDA2WjA9MQswCQYDVQQGEwJOTDESMBAG
|
||||||
|
A1UECgwJI1BvbGFyU1NMMRowGAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIw
|
||||||
|
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6J
|
||||||
|
v7joRZDb7ogWUtPxQ1BHlhJZZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVB
|
||||||
|
Q3dfOXwJBEeCsFc5cO2j7BUZHqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYEl
|
||||||
|
XwqxU8YwfhU5rPla7n+SnqYFW+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk
|
||||||
|
65Wb3P5BXhem2mxbacwCuhQsFiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZP
|
||||||
|
cG6ezr1YieJTWZ5uWpJl4og/DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEA
|
||||||
|
AaNNMEswCQYDVR0TBAIwADAdBgNVHQ4EFgQUH3TWPynBdHRFOwUSLD2ovUNZAqYw
|
||||||
|
HwYDVR0jBBgwFoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQEFBQAD
|
||||||
|
ggEBAJcKcv/Xro61Sxm0GH42pYu7AvtD2b8nynvA8BW9gCHmiIHvHQWNO9NTMuno
|
||||||
|
1+HdzQVF1JxHC/A/hvXsczxGEc3jVnVeg1fwi8mZ/Fy1XtAVCTA0yJu7JTaaYbg+
|
||||||
|
IU2y7Nu36FSOztLpOfHGmwVDoJ1+wCzG/id64hXwJRrHvUfGK4EvIsV97swhk2Do
|
||||||
|
zSAfDA9N+QNV4zeiF9mLMOpUhCUBq8r41EDqm9lM0wSd3HNen8jwO20F4F1b1dYm
|
||||||
|
L+bMarvUgHq91f128m2fF3sWNnz4RGoagSI/aOU/AP6Ksq8SUruGHpqrVWLClA6n
|
||||||
|
EyyTPlNTwYIRCydZt7zlsw1/4h4=
|
||||||
|
-----END CERTIFICATE-----
|
20
tests/data_files/server1.spaces.crt
Normal file
20
tests/data_files/server1.spaces.crt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDQTCCAimgAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER
|
||||||
|
MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN
|
||||||
|
MTkwMjEwMTQ0NDA2WhcNMjkwMjEwMTQ0NDA2WjA+MQswCQYDVQQGEwJOTDETMBEG
|
||||||
|
A1UECgwKIFBvbGFyU1NMIDEaMBgGA1UEAwwRUG9sYXJTU0wgU2VydmVyIDEwggEi
|
||||||
|
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpAh89QGrVVVOL/TbugmUuFWFe
|
||||||
|
ib+46EWQ2+6IFlLT8UNQR5YSWWSHa/0r4Eb5c77dz5LhkVvtZqBviSl5RYDQg2rV
|
||||||
|
QUN3Xzl8CQRHgrBXOXDto+wVGR6oMwhHwQVCqf1Mw7Tf3QYfTRBRQGdzEw9A+G2B
|
||||||
|
JV8KsVPGMH4VOaz5Wu5/kp6mBVvnE5eFtSOS2dQkBtUJJYl1B92mGo8/CRm+rWUs
|
||||||
|
ZOuVm9z+QV4XptpsW2nMAroULBYknErczdD3Umdz8S2gI/1+9DHKLXDKiQsE2y6m
|
||||||
|
T3Buns69WIniU1meblqSZeKIPwyUGaPd5eidlRPtKdurcBLcWsprF6tSglSxAgMB
|
||||||
|
AAGjTTBLMAkGA1UdEwQCMAAwHQYDVR0OBBYEFB901j8pwXR0RTsFEiw9qL1DWQKm
|
||||||
|
MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBBQUA
|
||||||
|
A4IBAQBsR3jOFh7uGF5MCvEK8DrSmmvcFJzMmTRp0hCMeb0wEULhrMKeRDIa2yvr
|
||||||
|
FrHHCUNAk2HjsjJevpCM8f3ibDqecckfbxE2vT9IUCmPrtOWmhQR/Il5TR9FvYns
|
||||||
|
4BF1KUPRqGUFAXoIN+xKcYdp+myIluGHumM4Bop7tAZ5gg68IV/UJh5RqShxiLgV
|
||||||
|
rxHzrp6oM1kn199m2wc1Twy2YwcNmfJDSOLV6K4xWjwcc8Eq+rLhuWUs5GNdrSEY
|
||||||
|
ZjWmF1AlbVVChU3Dl5XOAY8T6+wJst5RIwkf1Fl1TPCZX8FWzGM9HYiYW0cC7cno
|
||||||
|
IdSS7mVGxNrNe+6/Cu+zfqeiLdN2
|
||||||
|
-----END CERTIFICATE-----
|
@ -184,11 +184,11 @@ x509_cert_info:"data_files/parse_input/server3.crt":"cert. version \: 3\nser
|
|||||||
|
|
||||||
X509 CRT information Bitstring in subject name
|
X509 CRT information Bitstring in subject name
|
||||||
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
||||||
x509_cert_info:"data_files/parse_input/bitstring-in-dn.pem":"cert. version \: 3\nserial number \: 02\nissuer name \: CN=Test CA 01, ST=Ecnivorp, C=XX, emailAddress=tca@example.com, O=Test CA Authority\nsubject name \: C=XX, O=tca, ST=Ecnivorp, OU=TCA, CN=Client, emailAddress=client@example.com, serialNumber=7101012255, uniqueIdentifier=?7101012255\nissued on \: 2015-03-11 12\:06\:51\nexpires on \: 2025-03-08 12\:06\:51\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\nsubject alt name \:\n rfc822Name \: client@example.com\next key usage \: TLS Web Client Authentication\n"
|
x509_cert_info:"data_files/parse_input/bitstring-in-dn.pem":"cert. version \: 3\nserial number \: 02\nissuer name \: CN=Test CA 01, ST=Ecnivorp, C=XX, emailAddress=tca@example.com, O=Test CA Authority\nsubject name \: C=XX, O=tca, ST=Ecnivorp, OU=TCA, CN=Client, emailAddress=client@example.com, serialNumber=7101012255, uniqueIdentifier=#030B0037313031303132323535\nissued on \: 2015-03-11 12\:06\:51\nexpires on \: 2025-03-08 12\:06\:51\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\nsubject alt name \:\n rfc822Name \: client@example.com\next key usage \: TLS Web Client Authentication\n"
|
||||||
|
|
||||||
X509 CRT information Non-ASCII string in issuer name and subject name
|
X509 CRT information Non-ASCII string in issuer name and subject name
|
||||||
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA256
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA256
|
||||||
x509_cert_info:"data_files/parse_input/non-ascii-string-in-issuer.crt":"cert. version \: 3\nserial number \: 05\:E6\:53\:E7\:1B\:74\:F0\:B5\:D3\:84\:6D\:0C\:6D\:DC\:FA\:3F\:A4\:5A\:2B\:E0\nissuer name \: C=JP, ST=Tokyo, O=?????????????????? Ltd, CN=?????????????????? CA\nsubject name \: C=JP, ST=Tokyo, O=?????????????????? Ltd, CN=?????????????????? CA\nissued on \: 2020-05-20 16\:17\:23\nexpires on \: 2020-06-19 16\:17\:23\nsigned using \: RSA with SHA-256\nRSA key size \: 2048 bits\nbasic constraints \: CA=true\n"
|
x509_cert_info:"data_files/parse_input/non-ascii-string-in-issuer.crt":"cert. version \: 3\nserial number \: 05\:E6\:53\:E7\:1B\:74\:F0\:B5\:D3\:84\:6D\:0C\:6D\:DC\:FA\:3F\:A4\:5A\:2B\:E0\nissuer name \: C=JP, ST=Tokyo, O=\\C3\\A3\\C2\\83\\C2\\86\\C3\\A3\\C2\\82\\C2\\B9\\C3\\A3\\C2\\83\\C2\\88 Ltd, CN=\\C3\\A3\\C2\\83\\C2\\86\\C3\\A3\\C2\\82\\C2\\B9\\C3\\A3\\C2\\83\\C2\\88 CA\nsubject name \: C=JP, ST=Tokyo, O=\\C3\\A3\\C2\\83\\C2\\86\\C3\\A3\\C2\\82\\C2\\B9\\C3\\A3\\C2\\83\\C2\\88 Ltd, CN=\\C3\\A3\\C2\\83\\C2\\86\\C3\\A3\\C2\\82\\C2\\B9\\C3\\A3\\C2\\83\\C2\\88 CA\nissued on \: 2020-05-20 16\:17\:23\nexpires on \: 2020-06-19 16\:17\:23\nsigned using \: RSA with SHA-256\nRSA key size \: 2048 bits\nbasic constraints \: CA=true\n"
|
||||||
|
|
||||||
X509 CRT information Parsing IPv4 and IPv6 IP names
|
X509 CRT information Parsing IPv4 and IPv6 IP names
|
||||||
depends_on:MBEDTLS_PK_CAN_ECDSA_VERIFY:MBEDTLS_MD_CAN_SHA256:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_RSA_C
|
depends_on:MBEDTLS_PK_CAN_ECDSA_VERIFY:MBEDTLS_MD_CAN_SHA256:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_RSA_C
|
||||||
@ -447,6 +447,18 @@ X509 Get Distinguished Name #5
|
|||||||
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
||||||
mbedtls_x509_dn_gets:"data_files/server1.commas.crt":"subject":"C=NL, O=PolarSSL\\, Commas, CN=PolarSSL Server 1"
|
mbedtls_x509_dn_gets:"data_files/server1.commas.crt":"subject":"C=NL, O=PolarSSL\\, Commas, CN=PolarSSL Server 1"
|
||||||
|
|
||||||
|
X509 Get Distinguished Name #6
|
||||||
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
||||||
|
mbedtls_x509_dn_gets:"data_files/server1.hashsymbol.crt":"subject":"C=NL, O=\\#PolarSSL, CN=PolarSSL Server 1"
|
||||||
|
|
||||||
|
X509 Get Distinguished Name #7
|
||||||
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
||||||
|
mbedtls_x509_dn_gets:"data_files/server1.spaces.crt":"subject":"C=NL, O=\\ PolarSSL\\ , CN=PolarSSL Server 1"
|
||||||
|
|
||||||
|
X509 Get Distinguished Name #8
|
||||||
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
||||||
|
mbedtls_x509_dn_gets:"data_files/server1.asciichars.crt":"subject":"C=NL, O=\\E6\\9E\\81\\E5\\9C\\B0SSL, CN=PolarSSL Server 1"
|
||||||
|
|
||||||
X509 Get Modified DN #1
|
X509 Get Modified DN #1
|
||||||
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
||||||
mbedtls_x509_dn_gets_subject_replace:"data_files/server1.crt":"Modified":"C=NL, O=Modified, CN=PolarSSL Server 1":0
|
mbedtls_x509_dn_gets_subject_replace:"data_files/server1.crt":"Modified":"C=NL, O=Modified, CN=PolarSSL Server 1":0
|
||||||
@ -2373,7 +2385,7 @@ x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d01010b05003
|
|||||||
|
|
||||||
X509 CRT ASN1 (Name with composite RDN)
|
X509 CRT ASN1 (Name with composite RDN)
|
||||||
depends_on:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
depends_on:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA1
|
||||||
x509parse_crt:"3082029f30820208a00302010202044c20e3bd300d06092a864886f70d01010505003056310b3009060355040613025553310b300906035504080c0243413121301f060355040a0c18496e7465726e6574205769646769747320507479204c74643117301506035504030c0e4672616e6b656e63657274204341301e170d3133303830323135313433375a170d3135303831373035353433315a3081d1310b3009060355040613025553311330110603550408130a57617368696e67746f6e31133011060b2b0601040182373c0201031302555331193017060b2b0601040182373c020102130844656c6177617265311a3018060355040a1311417574686f72697a652e4e6574204c4c43311d301b060355040f131450726976617465204f7267616e697a6174696f6e312a300e06035504051307343336393139313018060355040313117777772e617574686f72697a652e6e6574311630140603550407130d53616e204672616e636973636f30819f300d06092a864886f70d010101050003818d0030818902818100d885c62e209b6ac005c64f0bcfdaac1f2b67a18802f75b08851ff933deed888b7b68a62fcabdb21d4a8914becfeaaa1b7e08a09ffaf9916563586dc95e2877262b0b5f5ec27eb4d754aa6facd1d39d25b38a2372891bacdd3e919f791ed25704e8920e380e5623a38e6a23935978a3aec7a8e761e211d42effa2713e44e7de0b0203010001300d06092a864886f70d010105050003818100092f7424d3f6da4b8553829d958ed1980b9270b42c0d3d5833509a28c66bb207df9f3c51d122065e00b87c08c2730d2745fe1c279d16fae4d53b4bf5bdfa3631fceeb2e772b6b08a3eca5a2e2c687aefd23b4b73bf77ac6099711342cf070b35c6f61333a7cbf613d8dd4bd73e9df34bcd4284b0b4df57c36c450613f11e5dac":"cert. version \: 3\nserial number \: 4C\:20\:E3\:BD\nissuer name \: C=US, ST=CA, O=Internet Widgits Pty Ltd, CN=Frankencert CA\nsubject name \: C=US, ST=Washington, ??=US, ??=Delaware, O=Authorize.Net LLC, ??=Private Organization, serialNumber=4369191 + CN=www.authorize.net, L=San Francisco\nissued on \: 2013-08-02 15\:14\:37\nexpires on \: 2015-08-17 05\:54\:31\nsigned using \: RSA with SHA1\nRSA key size \: 1024 bits\n":0
|
x509parse_crt:"3082029f30820208a00302010202044c20e3bd300d06092a864886f70d01010505003056310b3009060355040613025553310b300906035504080c0243413121301f060355040a0c18496e7465726e6574205769646769747320507479204c74643117301506035504030c0e4672616e6b656e63657274204341301e170d3133303830323135313433375a170d3135303831373035353433315a3081d1310b3009060355040613025553311330110603550408130a57617368696e67746f6e31133011060b2b0601040182373c0201031302555331193017060b2b0601040182373c020102130844656c6177617265311a3018060355040a1311417574686f72697a652e4e6574204c4c43311d301b060355040f131450726976617465204f7267616e697a6174696f6e312a300e06035504051307343336393139313018060355040313117777772e617574686f72697a652e6e6574311630140603550407130d53616e204672616e636973636f30819f300d06092a864886f70d010101050003818d0030818902818100d885c62e209b6ac005c64f0bcfdaac1f2b67a18802f75b08851ff933deed888b7b68a62fcabdb21d4a8914becfeaaa1b7e08a09ffaf9916563586dc95e2877262b0b5f5ec27eb4d754aa6facd1d39d25b38a2372891bacdd3e919f791ed25704e8920e380e5623a38e6a23935978a3aec7a8e761e211d42effa2713e44e7de0b0203010001300d06092a864886f70d010105050003818100092f7424d3f6da4b8553829d958ed1980b9270b42c0d3d5833509a28c66bb207df9f3c51d122065e00b87c08c2730d2745fe1c279d16fae4d53b4bf5bdfa3631fceeb2e772b6b08a3eca5a2e2c687aefd23b4b73bf77ac6099711342cf070b35c6f61333a7cbf613d8dd4bd73e9df34bcd4284b0b4df57c36c450613f11e5dac":"cert. version \: 3\nserial number \: 4C\:20\:E3\:BD\nissuer name \: C=US, ST=CA, O=Internet Widgits Pty Ltd, CN=Frankencert CA\nsubject name \: C=US, ST=Washington, 1.3.6.1.4.1.311.60.2.1.3=#13025553, 1.3.6.1.4.1.311.60.2.1.2=#130844656C6177617265, O=Authorize.Net LLC, 2.5.4.15=#131450726976617465204F7267616E697A6174696F6E, serialNumber=4369191 + CN=www.authorize.net, L=San Francisco\nissued on \: 2013-08-02 15\:14\:37\nexpires on \: 2015-08-17 05\:54\:31\nsigned using \: RSA with SHA1\nRSA key size \: 1024 bits\n":0
|
||||||
|
|
||||||
X509 CRT ASN1 (Name with PKCS9 email)
|
X509 CRT ASN1 (Name with PKCS9 email)
|
||||||
depends_on:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA256
|
depends_on:MBEDTLS_RSA_C:MBEDTLS_MD_CAN_SHA256
|
||||||
|
@ -170,7 +170,7 @@ X509 String to Names #1
|
|||||||
mbedtls_x509_string_to_names:"C=NL,O=Offspark\\, Inc., OU=PolarSSL":"C=NL, O=Offspark\\, Inc., OU=PolarSSL":0
|
mbedtls_x509_string_to_names:"C=NL,O=Offspark\\, Inc., OU=PolarSSL":"C=NL, O=Offspark\\, Inc., OU=PolarSSL":0
|
||||||
|
|
||||||
X509 String to Names #2
|
X509 String to Names #2
|
||||||
mbedtls_x509_string_to_names:"C=NL, O=Offspark, Inc., OU=PolarSSL":"":MBEDTLS_ERR_X509_UNKNOWN_OID
|
mbedtls_x509_string_to_names:"C=NL, O=Offspark, Inc., OU=PolarSSL":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
X509 String to Names #3 (Name precisely 255 bytes)
|
X509 String to Names #3 (Name precisely 255 bytes)
|
||||||
mbedtls_x509_string_to_names:"C=NL, O=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345,OU=PolarSSL":"C=NL, O=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345, OU=PolarSSL":0
|
mbedtls_x509_string_to_names:"C=NL, O=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345,OU=PolarSSL":"C=NL, O=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345, OU=PolarSSL":0
|
||||||
@ -184,8 +184,56 @@ mbedtls_x509_string_to_names:"C=NL, O=Offspark\\a Inc., OU=PolarSSL":"":MBEDTLS_
|
|||||||
X509 String to Names #6 (Escape at end)
|
X509 String to Names #6 (Escape at end)
|
||||||
mbedtls_x509_string_to_names:"C=NL, O=Offspark\\":"":MBEDTLS_ERR_X509_INVALID_NAME
|
mbedtls_x509_string_to_names:"C=NL, O=Offspark\\":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
X509 String to Names #6 (Invalid, no '=' or ',')
|
X509 String to Names #7 (Invalid, no '=' or ',')
|
||||||
mbedtls_x509_string_to_names:"ABC123":"":MBEDTLS_ERR_X509_INVALID_NAME
|
mbedtls_x509_string_to_names:"ABC123":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
|
X509 String to Names #8 (Escaped valid characters)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=Offspark\\+ \\> \\=, OU=PolarSSL":"C=NL, O=Offspark\\+ \\> \\=, OU=PolarSSL":0
|
||||||
|
|
||||||
|
X509 String to Names #9 (Escaped ascii hexpairs uppercase encoded)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=\\4F\\66\\66\\73\\70\\61\\72\\6B, OU=PolarSSL":"C=NL, O=Offspark, OU=PolarSSL":0
|
||||||
|
|
||||||
|
X509 String to Names #10 (Escaped ascii hexpairs lowercase encoded)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=\\4f\\66\\66\\73\\70\\61\\72\\6b, OU=PolarSSL":"C=NL, O=Offspark, OU=PolarSSL":0
|
||||||
|
|
||||||
|
X509 String to Names #11 (Invalid hexpair escape at end of string)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=\\4f\\66\\66\\73\\70\\61\\72\\6, OU=PolarSSL":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
|
X509 String to Names #12 (Reject escaped null hexpair)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=Of\\00spark, OU=PolarSSL":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
|
X509 String to Names #13 (Invalid hexpairs)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=Of\\flspark, OU=PolarSSL":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
|
X509 String to Names #14 (Accept numercoid/hexstring)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, 2.5.4.10=#0C084F6666737061726B, OU=PolarSSL":"C=NL, O=Offspark, OU=PolarSSL":0
|
||||||
|
|
||||||
|
X509 String to Names #15 (Odd length DER hexstring)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, 2.5.4.10=#0C084F6666737061726, OU=PolarSSL":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
|
X509 String to Names #16 (Length mismatch DER hexstring)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, 2.5.4.10=#0C0B4F6666737061726B, OU=PolarSSL":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
|
X509 String to Names #17 (Invalid OID)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, 10.5.4.10=#0C084F6666737061726B, OU=PolarSSL":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
|
X509 String to Names #18 (short name and hexstring)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=#0C084F6666737061726B, OU=PolarSSL":"C=NL, O=Offspark, OU=PolarSSL":0
|
||||||
|
|
||||||
|
X509 String to Names #19 (Accept non-ascii hexpairs)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=Of\\CCspark, OU=PolarSSL":"C=NL, O=Of\\CCspark, OU=PolarSSL":0
|
||||||
|
|
||||||
|
X509 String to Names #20 (Reject empty AttributeValue)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, O=, OU=PolarSSL":"":MBEDTLS_ERR_X509_INVALID_NAME
|
||||||
|
|
||||||
|
X509 Round trip test (Escaped characters)
|
||||||
|
mbedtls_x509_string_to_names:"CN=Lu\\C4\\8Di\\C4\\87, O=Offspark, OU=PolarSSL":"CN=Lu\\C4\\8Di\\C4\\87, O=Offspark, OU=PolarSSL":0
|
||||||
|
|
||||||
|
X509 Round trip test (hexstring output for non string input)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, 2.5.4.10=#03084F6666737061726B, OU=PolarSSL":"C=NL, O=#03084F6666737061726B, OU=PolarSSL":0
|
||||||
|
|
||||||
|
X509 Round trip test (numercoid hexstring output for unknown OID)
|
||||||
|
mbedtls_x509_string_to_names:"C=NL, 2.5.4.10.234.532=#0C084F6666737061726B, OU=PolarSSL":"C=NL, 2.5.4.10.234.532=#0C084F6666737061726B, OU=PolarSSL":0
|
||||||
|
|
||||||
Check max serial length
|
Check max serial length
|
||||||
x509_set_serial_check:
|
x509_set_serial_check:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user