mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2026-04-04 22:19:05 +00: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. Change-Id: I056312613379890e0d70e1d08c34171287c0aa17
This commit is contained in:
parent
1abb159e90
commit
dc470ae8af
27 changed files with 273 additions and 150 deletions
|
|
@ -488,19 +488,28 @@ static int my_send( void *ctx, const unsigned char *buf, size_t len )
|
|||
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_printf( "\nVerify requested for (Depth %d):\n", depth );
|
||||
mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, "", crt );
|
||||
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 );
|
||||
|
|
@ -1976,14 +1985,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" );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue