mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Reduce code size when mbedtls_x509_*_info() unused
Introduce MBEDTLS_X509_INFO to indicate the availability of the mbedtls_x509_*_info() function and closely related APIs. When this is not defined, also omit name and description from mbedtls_oid_descriptor_t, and omit OID arrays, macros, and types that are entirely unused. This saves several KB of code space. Signed-off-by: Hanno Becker <hanno.becker@arm.com> Signed-off-by: Chris Jones <christopher.jones@arm.com>
This commit is contained in:
committed by
Chris Jones
parent
12f93f4fc2
commit
9a969b66c1
@ -529,9 +529,12 @@ static unsigned char peer_crt_info[1024];
|
||||
static int my_verify( void *data, mbedtls_x509_crt *crt,
|
||||
int depth, uint32_t *flags )
|
||||
{
|
||||
#if defined(MBEDTLS_X509_INFO)
|
||||
char buf[1024];
|
||||
#endif
|
||||
((void) data);
|
||||
|
||||
#if defined(MBEDTLS_X509_INFO)
|
||||
mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, "", crt );
|
||||
if( depth == 0 )
|
||||
memcpy( peer_crt_info, buf, sizeof( buf ) );
|
||||
@ -541,13 +544,19 @@ static int my_verify( void *data, mbedtls_x509_crt *crt,
|
||||
|
||||
mbedtls_printf( "\nVerify requested for (Depth %d):\n", depth );
|
||||
mbedtls_printf( "%s", buf );
|
||||
#else
|
||||
((void) crt);
|
||||
((void) depth);
|
||||
#endif
|
||||
|
||||
if ( ( *flags ) == 0 )
|
||||
mbedtls_printf( " This certificate has no flags\n" );
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_X509_INFO)
|
||||
mbedtls_x509_crt_verify_info( buf, sizeof( buf ), " ! ", *flags );
|
||||
mbedtls_printf( "%s\n", buf );
|
||||
#endif
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
@ -2275,14 +2284,18 @@ int main( int argc, char *argv[] )
|
||||
|
||||
if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 )
|
||||
{
|
||||
#if defined(MBEDTLS_X509_INFO)
|
||||
char vrfy_buf[512];
|
||||
#endif
|
||||
|
||||
mbedtls_printf( " failed\n" );
|
||||
|
||||
#if defined(MBEDTLS_X509_INFO)
|
||||
mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ),
|
||||
" ! ", flags );
|
||||
|
||||
mbedtls_printf( "%s\n", vrfy_buf );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
Reference in New Issue
Block a user