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
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index 6841f7b..f2e00f7 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -488,19 +488,28 @@
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 @@
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" );