Tidy up style in x509_info_subject_alt_name

This commit is contained in:
Janos Follath 2019-05-10 11:06:31 +01:00
parent 22f605fbab
commit 2f0ec1e3bf

View file

@ -1661,7 +1661,8 @@ cleanup:
}
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 )
{
size_t i;
@ -1682,9 +1683,11 @@ static int x509_info_subject_alt_name( char **buf, size_t *size,
{
mbedtls_x509_san_other_name other_name;
int parse_ret = x509_get_other_name( &cur->buf, &other_name );
int parse_ret = x509_get_other_name( &cur->buf,
&other_name );
ret = mbedtls_snprintf( p, n, "\n%s otherName :", prefix );
ret = mbedtls_snprintf( p, n, "\n%s otherName :",
prefix );
MBEDTLS_X509_SAFE_SNPRINTF;
if( parse_ret != 0 )
@ -1704,17 +1707,27 @@ static int x509_info_subject_alt_name( char **buf, size_t *size,
}
if( MBEDTLS_OID_CMP( MBEDTLS_OID_ON_HW_MODULE_NAME,
&other_name.value.hardware_module_name.oid ) != 0 )
&other_name.value.hardware_module_name.oid )
!= 0 )
{
ret = mbedtls_snprintf( p, n, "\n%s hardware module name :", prefix );
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 );
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 );
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 );
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 )
@ -1723,13 +1736,17 @@ static int x509_info_subject_alt_name( char **buf, size_t *size,
return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL );
}
for( i = 0; i < other_name.value.hardware_module_name.val.len; i++ )
for( i = 0;
i < other_name.value.hardware_module_name.val.len;
i++ )
{
*p++ = other_name.value.hardware_module_name.val.p[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;
@ -1737,18 +1754,19 @@ static int x509_info_subject_alt_name( char **buf, size_t *size,
* dNSName
*/
case( MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_X509_SAN_DNS_NAME ):
{
ret = mbedtls_snprintf( p, n, "\n%s dNSName : ", prefix );
MBEDTLS_X509_SAFE_SNPRINTF;
if( cur->buf.len >= n )
{
*p = '\0';
return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL );
}
n -= cur->buf.len;
for( i = 0; i < cur->buf.len; i++ )
*p++ = cur->buf.p[i];
}
break;
/*