mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +03:00
Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@@ -41,67 +41,68 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define CHECK_DLERROR( function, argument ) \
|
||||
#define CHECK_DLERROR(function, argument) \
|
||||
do \
|
||||
{ \
|
||||
char *CHECK_DLERROR_error = dlerror ( ); \
|
||||
if( CHECK_DLERROR_error != NULL ) \
|
||||
char *CHECK_DLERROR_error = dlerror(); \
|
||||
if (CHECK_DLERROR_error != NULL) \
|
||||
{ \
|
||||
fprintf( stderr, "Dynamic loading error for %s(%s): %s\n", \
|
||||
function, argument, CHECK_DLERROR_error ); \
|
||||
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); \
|
||||
fprintf(stderr, "Dynamic loading error for %s(%s): %s\n", \
|
||||
function, argument, CHECK_DLERROR_error); \
|
||||
mbedtls_exit(MBEDTLS_EXIT_FAILURE); \
|
||||
} \
|
||||
} \
|
||||
while( 0 )
|
||||
while (0)
|
||||
|
||||
int main( void )
|
||||
int main(void)
|
||||
{
|
||||
#if defined(MBEDTLS_MD_C) || defined(MBEDTLS_SSL_TLS_C)
|
||||
unsigned n;
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_TLS_C)
|
||||
void *tls_so = dlopen( TLS_SO_FILENAME, RTLD_NOW );
|
||||
CHECK_DLERROR( "dlopen", TLS_SO_FILENAME );
|
||||
const int *( *ssl_list_ciphersuites )( void ) =
|
||||
dlsym( tls_so, "mbedtls_ssl_list_ciphersuites" );
|
||||
CHECK_DLERROR( "dlsym", "mbedtls_ssl_list_ciphersuites" );
|
||||
const int *ciphersuites = ssl_list_ciphersuites( );
|
||||
for( n = 0; ciphersuites[n] != 0; n++ )
|
||||
/* nothing to do, we're just counting */;
|
||||
mbedtls_printf( "dlopen(%s): %u ciphersuites\n",
|
||||
TLS_SO_FILENAME, n );
|
||||
dlclose( tls_so );
|
||||
CHECK_DLERROR( "dlclose", TLS_SO_FILENAME );
|
||||
void *tls_so = dlopen(TLS_SO_FILENAME, RTLD_NOW);
|
||||
CHECK_DLERROR("dlopen", TLS_SO_FILENAME);
|
||||
const int *(*ssl_list_ciphersuites)(void) =
|
||||
dlsym(tls_so, "mbedtls_ssl_list_ciphersuites");
|
||||
CHECK_DLERROR("dlsym", "mbedtls_ssl_list_ciphersuites");
|
||||
const int *ciphersuites = ssl_list_ciphersuites();
|
||||
for (n = 0; ciphersuites[n] != 0; n++) {/* nothing to do, we're just counting */
|
||||
;
|
||||
}
|
||||
mbedtls_printf("dlopen(%s): %u ciphersuites\n",
|
||||
TLS_SO_FILENAME, n);
|
||||
dlclose(tls_so);
|
||||
CHECK_DLERROR("dlclose", TLS_SO_FILENAME);
|
||||
#endif /* MBEDTLS_SSL_TLS_C */
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
void *x509_so = dlopen( X509_SO_FILENAME, RTLD_NOW );
|
||||
CHECK_DLERROR( "dlopen", X509_SO_FILENAME );
|
||||
void *x509_so = dlopen(X509_SO_FILENAME, RTLD_NOW);
|
||||
CHECK_DLERROR("dlopen", X509_SO_FILENAME);
|
||||
const mbedtls_x509_crt_profile *profile =
|
||||
dlsym( x509_so, "mbedtls_x509_crt_profile_default" );
|
||||
CHECK_DLERROR( "dlsym", "mbedtls_x509_crt_profile_default" );
|
||||
mbedtls_printf( "dlopen(%s): Allowed md mask: %08x\n",
|
||||
X509_SO_FILENAME, (unsigned) profile->allowed_mds );
|
||||
dlclose( x509_so );
|
||||
CHECK_DLERROR( "dlclose", X509_SO_FILENAME );
|
||||
dlsym(x509_so, "mbedtls_x509_crt_profile_default");
|
||||
CHECK_DLERROR("dlsym", "mbedtls_x509_crt_profile_default");
|
||||
mbedtls_printf("dlopen(%s): Allowed md mask: %08x\n",
|
||||
X509_SO_FILENAME, (unsigned) profile->allowed_mds);
|
||||
dlclose(x509_so);
|
||||
CHECK_DLERROR("dlclose", X509_SO_FILENAME);
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_MD_C)
|
||||
void *crypto_so = dlopen( CRYPTO_SO_FILENAME, RTLD_NOW );
|
||||
CHECK_DLERROR( "dlopen", CRYPTO_SO_FILENAME );
|
||||
const int *( *md_list )( void ) =
|
||||
dlsym( crypto_so, "mbedtls_md_list" );
|
||||
CHECK_DLERROR( "dlsym", "mbedtls_md_list" );
|
||||
const int *mds = md_list( );
|
||||
for( n = 0; mds[n] != 0; n++ )
|
||||
/* nothing to do, we're just counting */;
|
||||
mbedtls_printf( "dlopen(%s): %u hashes\n",
|
||||
CRYPTO_SO_FILENAME, n );
|
||||
dlclose( crypto_so );
|
||||
CHECK_DLERROR( "dlclose", CRYPTO_SO_FILENAME );
|
||||
void *crypto_so = dlopen(CRYPTO_SO_FILENAME, RTLD_NOW);
|
||||
CHECK_DLERROR("dlopen", CRYPTO_SO_FILENAME);
|
||||
const int *(*md_list)(void) =
|
||||
dlsym(crypto_so, "mbedtls_md_list");
|
||||
CHECK_DLERROR("dlsym", "mbedtls_md_list");
|
||||
const int *mds = md_list();
|
||||
for (n = 0; mds[n] != 0; n++) {/* nothing to do, we're just counting */
|
||||
;
|
||||
}
|
||||
mbedtls_printf("dlopen(%s): %u hashes\n",
|
||||
CRYPTO_SO_FILENAME, n);
|
||||
dlclose(crypto_so);
|
||||
CHECK_DLERROR("dlclose", CRYPTO_SO_FILENAME);
|
||||
#endif /* MBEDTLS_MD_C */
|
||||
|
||||
return( 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user