mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 19:55:36 +01:00
Use mbedtls_x509_crt_get_subject() in test_suite_x509parse test
This commit is contained in:
parent
5226c53e13
commit
3f8f0dc3fd
@ -24,17 +24,6 @@ const mbedtls_x509_crt_profile profile_all =
|
||||
1024,
|
||||
};
|
||||
|
||||
static void x509_free_name( mbedtls_x509_name *name )
|
||||
{
|
||||
while( name != NULL )
|
||||
{
|
||||
mbedtls_x509_name *next = name->next;
|
||||
mbedtls_platform_zeroize( name, sizeof( *name ) );
|
||||
mbedtls_free( name );
|
||||
name = next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Profile for backward compatibility. Allows SHA-1, unlike the default
|
||||
profile. */
|
||||
const mbedtls_x509_crt_profile compat_profile =
|
||||
@ -154,24 +143,17 @@ int verify_print( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint
|
||||
char *p = ctx->p;
|
||||
size_t n = ctx->buf + sizeof( ctx->buf ) - ctx->p;
|
||||
mbedtls_x509_crt_frame *frame;
|
||||
mbedtls_x509_name subject;
|
||||
mbedtls_x509_name *subject;
|
||||
((void) flags);
|
||||
|
||||
ret = mbedtls_x509_crt_get_subject( crt, &subject );
|
||||
if( ret != 0 )
|
||||
return( ret );
|
||||
|
||||
ret = mbedtls_x509_crt_frame_acquire( crt, &frame );
|
||||
if( ret != 0 )
|
||||
return( ret );
|
||||
|
||||
/* Get linked list presentation of issuer which
|
||||
* `mbedtls_x509_dn_gets()` understands. */
|
||||
{
|
||||
unsigned char *subject_start = frame->subject_raw.p;
|
||||
unsigned char *subject_end = frame->subject_raw.p + frame->subject_raw.len;
|
||||
|
||||
ret = mbedtls_x509_get_name( &subject_start, subject_end, &subject );
|
||||
if( ret != 0 )
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = mbedtls_snprintf( p, n, "depth %d - serial ", certificate_depth );
|
||||
MBEDTLS_X509_SAFE_SNPRINTF_WITH_ERROR;
|
||||
|
||||
@ -186,7 +168,7 @@ int verify_print( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint
|
||||
ret = mbedtls_snprintf( p, n, " - subject " );
|
||||
MBEDTLS_X509_SAFE_SNPRINTF_WITH_ERROR;
|
||||
|
||||
ret = mbedtls_x509_dn_gets( p, n, &subject );
|
||||
ret = mbedtls_x509_dn_gets( p, n, subject );
|
||||
MBEDTLS_X509_SAFE_SNPRINTF_WITH_ERROR;
|
||||
|
||||
ret = mbedtls_snprintf( p, n, " - flags 0x%08x\n", *flags );
|
||||
@ -196,7 +178,7 @@ int verify_print( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint
|
||||
|
||||
cleanup:
|
||||
|
||||
x509_free_name( subject.next );
|
||||
mbedtls_x509_name_free( subject );
|
||||
mbedtls_x509_crt_frame_release( crt, frame );
|
||||
|
||||
if( ret < 0 )
|
||||
|
Loading…
Reference in New Issue
Block a user