diff --git a/library/pk_wrap.c b/library/pk_wrap.c index a75ab3248..7776f0114 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -436,6 +436,7 @@ static int rsa_alt_decrypt_wrap( void *ctx, RSA_PRIVATE, olen, input, output, osize ) ); } +#if defined(POLARSSL_RSA_C) static int rsa_alt_check_pair( const void *pub, const void *prv ) { unsigned char sig[POLARSSL_MPI_MAX_SIZE]; @@ -463,6 +464,7 @@ static int rsa_alt_check_pair( const void *pub, const void *prv ) return( 0 ); } +#endif /* POLARSSL_RSA_C */ static void *rsa_alt_alloc_wrap( void ) { @@ -489,7 +491,11 @@ const pk_info_t rsa_alt_info = { rsa_alt_sign_wrap, rsa_alt_decrypt_wrap, NULL, +#if defined(POLARSSL_RSA_C) rsa_alt_check_pair, +#else + NULL, +#endif rsa_alt_alloc_wrap, rsa_alt_free_wrap, NULL, diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function index c88d36588..fb86c99f7 100644 --- a/tests/suites/test_suite_pk.function +++ b/tests/suites/test_suite_pk.function @@ -1,6 +1,10 @@ /* BEGIN_HEADER */ #include +/* For error codes */ +#include +#include + static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len ); #define RSA_KEY_SIZE 512 @@ -80,7 +84,7 @@ exit: } /* END_CASE */ -/* BEGIN_CASE depends_on:POLARSSL_PK_PARSE_C */ +/* BEGIN_CASE depends_on:POLARSSL_PK_PARSE_C:POLARSSL_FS_IO */ void pk_check_pair( char *pub_file, char *prv_file, int ret ) { pk_context pub, prv, alt; @@ -94,12 +98,14 @@ void pk_check_pair( char *pub_file, char *prv_file, int ret ) TEST_ASSERT( pk_check_pair( &pub, &prv ) == ret ); +#if defined(POLARSSL_RSA_C) if( pk_get_type( &prv ) == POLARSSL_PK_RSA ) { TEST_ASSERT( pk_init_ctx_rsa_alt( &alt, pk_rsa( prv ), rsa_decrypt_func, rsa_sign_func, rsa_key_len_func ) == 0 ); TEST_ASSERT( pk_check_pair( &pub, &alt ) == ret ); } +#endif pk_free( &pub ); pk_free( &prv );