mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Fix code style on x509.c and x509_create.c
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
This commit is contained in:
@ -854,12 +854,13 @@ int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
|
|||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_hexstring = (name->val.tag == MBEDTLS_ASN1_BIT_STRING) || (name->val.tag == MBEDTLS_ASN1_OCTET_STRING);
|
print_hexstring = (name->val.tag == MBEDTLS_ASN1_BIT_STRING) ||
|
||||||
|
(name->val.tag == MBEDTLS_ASN1_OCTET_STRING);
|
||||||
|
|
||||||
if ((ret = mbedtls_oid_get_attr_short_name(&name->oid, &short_name)) == 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 {
|
||||||
if ((ret = mbedtls_oid_get_numeric_string(numericoid,256,&name->oid)) > 0) {
|
if ((ret = mbedtls_oid_get_numeric_string(numericoid, 256, &name->oid)) > 0) {
|
||||||
ret = mbedtls_snprintf(p, n, "%s=", numericoid);
|
ret = mbedtls_snprintf(p, n, "%s=", numericoid);
|
||||||
print_hexstring = 1;
|
print_hexstring = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -868,7 +869,7 @@ int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
|
|||||||
}
|
}
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
|
||||||
if(print_hexstring) {
|
if (print_hexstring) {
|
||||||
#if defined(MBEDTLS_ASN1_WRITE_C)
|
#if defined(MBEDTLS_ASN1_WRITE_C)
|
||||||
s[0] = '#';
|
s[0] = '#';
|
||||||
|
|
||||||
@ -879,16 +880,15 @@ int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
|
|||||||
s[2] = nibble_to_hex_digit(lowbits);
|
s[2] = nibble_to_hex_digit(lowbits);
|
||||||
|
|
||||||
asn1_len_p = asn1_len_buf+5;
|
asn1_len_p = asn1_len_buf+5;
|
||||||
asn1_len_size = mbedtls_asn1_write_len(&asn1_len_p,asn1_len_buf,name->val.len);
|
asn1_len_size = mbedtls_asn1_write_len(&asn1_len_p, asn1_len_buf, name->val.len);
|
||||||
asn1_len_start = 5 - asn1_len_size;
|
asn1_len_start = 5 - asn1_len_size;
|
||||||
for (i = 0, j = 3; i < asn1_len_size + name->val.len; i++, j++) {
|
for (i = 0, j = 3; i < asn1_len_size + name->val.len; i++, j++) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
if(i < asn1_len_size) {
|
if (i < asn1_len_size) {
|
||||||
c = asn1_len_buf[asn1_len_start+i];
|
c = asn1_len_buf[asn1_len_start+i];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
c = name->val.p[i-asn1_len_size];
|
c = name->val.p[i-asn1_len_size];
|
||||||
}
|
}
|
||||||
char lowbits = (c & 0x0F);
|
char lowbits = (c & 0x0F);
|
||||||
|
@ -175,7 +175,10 @@ static int hexpair_to_int(char c1, char c2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_attribute_value_string(const char *s, int len, unsigned char *data, size_t *data_len)
|
static int parse_attribute_value_string(const char *s,
|
||||||
|
int len,
|
||||||
|
unsigned char *data,
|
||||||
|
size_t *data_len)
|
||||||
{
|
{
|
||||||
const char *c = s;
|
const char *c = s;
|
||||||
const char *end = c + len;
|
const char *end = c + len;
|
||||||
@ -210,7 +213,11 @@ static int parse_attribute_value_string(const char *s, int len, unsigned char *d
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||||
static int parse_attribute_value_ber_encoded(const char *s, int len, unsigned char *data, size_t *data_len, int *tag)
|
static int parse_attribute_value_ber_encoded(const char *s,
|
||||||
|
int len,
|
||||||
|
unsigned char *data,
|
||||||
|
size_t *data_len,
|
||||||
|
int *tag)
|
||||||
{
|
{
|
||||||
const char *c = s;
|
const char *c = s;
|
||||||
const char *end = c + len;
|
const char *end = c + len;
|
||||||
@ -224,7 +231,7 @@ static int parse_attribute_value_ber_encoded(const char *s, int len, unsigned ch
|
|||||||
return MBEDTLS_ERR_X509_INVALID_NAME;
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
if((*tag = hexpair_to_int(*c, *(c+1))) == -1) {
|
if ((*tag = hexpair_to_int(*c, *(c+1))) == -1) {
|
||||||
return MBEDTLS_ERR_X509_INVALID_NAME;
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
}
|
}
|
||||||
c += 2;
|
c += 2;
|
||||||
@ -238,7 +245,7 @@ static int parse_attribute_value_ber_encoded(const char *s, int len, unsigned ch
|
|||||||
asn1_der_end = p;
|
asn1_der_end = p;
|
||||||
|
|
||||||
p = asn1_der_buf;
|
p = asn1_der_buf;
|
||||||
if(mbedtls_asn1_get_len(&p, asn1_der_end, data_len) != 0) {
|
if (mbedtls_asn1_get_len(&p, asn1_der_end, data_len) != 0) {
|
||||||
return MBEDTLS_ERR_X509_INVALID_NAME;
|
return MBEDTLS_ERR_X509_INVALID_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user