mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-11 00:40:05 +00:00
Tidy up style in x509_info_subject_alt_name
This commit is contained in:
parent
22f605fbab
commit
2f0ec1e3bf
@ -1661,7 +1661,8 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int x509_info_subject_alt_name( char **buf, size_t *size,
|
static int x509_info_subject_alt_name( char **buf, size_t *size,
|
||||||
const mbedtls_x509_sequence *subject_alt_name,
|
const mbedtls_x509_sequence
|
||||||
|
*subject_alt_name,
|
||||||
const char *prefix )
|
const char *prefix )
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -1679,77 +1680,94 @@ static int x509_info_subject_alt_name( char **buf, size_t *size,
|
|||||||
* otherName
|
* otherName
|
||||||
*/
|
*/
|
||||||
case( MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_X509_SAN_OTHER_NAME ):
|
case( MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_X509_SAN_OTHER_NAME ):
|
||||||
{
|
|
||||||
mbedtls_x509_san_other_name other_name;
|
|
||||||
|
|
||||||
int parse_ret = x509_get_other_name( &cur->buf, &other_name );
|
|
||||||
|
|
||||||
ret = mbedtls_snprintf( p, n, "\n%s otherName :", prefix );
|
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
|
||||||
|
|
||||||
if( parse_ret != 0 )
|
|
||||||
{
|
{
|
||||||
if( ret == MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE )
|
mbedtls_x509_san_other_name other_name;
|
||||||
|
|
||||||
|
int parse_ret = x509_get_other_name( &cur->buf,
|
||||||
|
&other_name );
|
||||||
|
|
||||||
|
ret = mbedtls_snprintf( p, n, "\n%s otherName :",
|
||||||
|
prefix );
|
||||||
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
|
||||||
|
if( parse_ret != 0 )
|
||||||
{
|
{
|
||||||
ret = mbedtls_snprintf( p, n, " <unsupported>" );
|
if( ret == MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE )
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
{
|
||||||
}
|
ret = mbedtls_snprintf( p, n, " <unsupported>" );
|
||||||
else
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
{
|
}
|
||||||
ret = mbedtls_snprintf( p, n, " <malformed>" );
|
else
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
{
|
||||||
|
ret = mbedtls_snprintf( p, n, " <malformed>" );
|
||||||
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
if( MBEDTLS_OID_CMP( MBEDTLS_OID_ON_HW_MODULE_NAME,
|
||||||
|
&other_name.value.hardware_module_name.oid )
|
||||||
|
!= 0 )
|
||||||
|
{
|
||||||
|
ret = mbedtls_snprintf( p, n, "\n%s "
|
||||||
|
"hardware module name :",
|
||||||
|
prefix );
|
||||||
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
ret = mbedtls_snprintf( p, n,
|
||||||
|
"\n%s "
|
||||||
|
"hardware type : ",
|
||||||
|
prefix );
|
||||||
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
|
||||||
|
ret = mbedtls_oid_get_numeric_string( p, n,
|
||||||
|
&other_name.value.hardware_module_name.oid );
|
||||||
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
|
||||||
|
ret = mbedtls_snprintf( p, n,
|
||||||
|
"\n%s "
|
||||||
|
"hardware serial number : ",
|
||||||
|
prefix );
|
||||||
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
|
||||||
|
if( other_name.value.hardware_module_name.val.len >= n )
|
||||||
|
{
|
||||||
|
*p = '\0';
|
||||||
|
return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( i = 0;
|
||||||
|
i < other_name.value.hardware_module_name.val.len;
|
||||||
|
i++ )
|
||||||
|
{
|
||||||
|
*p++ =
|
||||||
|
other_name.value.hardware_module_name.val.p[i];
|
||||||
|
}
|
||||||
|
n -= other_name.value.hardware_module_name.val.len;
|
||||||
|
|
||||||
|
}/* MBEDTLS_OID_ON_HW_MODULE_NAME */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
if( MBEDTLS_OID_CMP( MBEDTLS_OID_ON_HW_MODULE_NAME,
|
|
||||||
&other_name.value.hardware_module_name.oid ) != 0 )
|
|
||||||
{
|
|
||||||
ret = mbedtls_snprintf( p, n, "\n%s hardware module name :", prefix );
|
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
|
||||||
ret = mbedtls_snprintf( p, n, "\n%s hardware type : ", prefix );
|
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
|
||||||
|
|
||||||
ret = mbedtls_oid_get_numeric_string( p, n, &other_name.value.hardware_module_name.oid );
|
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
|
||||||
|
|
||||||
ret = mbedtls_snprintf( p, n, "\n%s hardware serial number : ", prefix );
|
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
|
||||||
|
|
||||||
if( other_name.value.hardware_module_name.val.len >= n )
|
|
||||||
{
|
|
||||||
*p = '\0';
|
|
||||||
return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( i = 0; i < other_name.value.hardware_module_name.val.len; i++ )
|
|
||||||
{
|
|
||||||
*p++ = other_name.value.hardware_module_name.val.p[i];
|
|
||||||
}
|
|
||||||
n -= other_name.value.hardware_module_name.val.len;
|
|
||||||
|
|
||||||
}/* MBEDTLS_OID_ON_HW_MODULE_NAME */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dNSName
|
* dNSName
|
||||||
*/
|
*/
|
||||||
case( MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_X509_SAN_DNS_NAME ):
|
case( MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_X509_SAN_DNS_NAME ):
|
||||||
{
|
|
||||||
ret = mbedtls_snprintf( p, n, "\n%s dNSName : ", prefix );
|
ret = mbedtls_snprintf( p, n, "\n%s dNSName : ", prefix );
|
||||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||||
|
|
||||||
if( cur->buf.len >= n )
|
if( cur->buf.len >= n )
|
||||||
{
|
{
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL );
|
return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL );
|
||||||
}
|
}
|
||||||
|
|
||||||
n -= cur->buf.len;
|
n -= cur->buf.len;
|
||||||
for( i = 0; i < cur->buf.len; i++ )
|
for( i = 0; i < cur->buf.len; i++ )
|
||||||
*p++ = cur->buf.p[i];
|
*p++ = cur->buf.p[i];
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Type not supported.
|
* Type not supported.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user