Fix issues when MBEDTLS_PEM_PARSE_C not defined

1) Fix compilatoin issues when `MBEDTLS_PEM_PARSE_C` not defined
2) remove dependency for `MBEDTLS_PEM_PARSE_C` in DER tests
This commit is contained in:
Ron Eldor 2017-10-17 09:49:00 +03:00
parent 40b14a894b
commit 5472d43ffb
2 changed files with 6 additions and 4 deletions

View file

@ -1250,10 +1250,12 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
{ {
int ret; int ret;
unsigned char *p; unsigned char *p;
#if defined(MBEDTLS_RSA_C)
const mbedtls_pk_info_t *pk_info;
#endif
#if defined(MBEDTLS_PEM_PARSE_C) #if defined(MBEDTLS_PEM_PARSE_C)
size_t len; size_t len;
mbedtls_pem_context pem; mbedtls_pem_context pem;
const mbedtls_pk_info_t *pk_info;
mbedtls_pem_init( &pem ); mbedtls_pem_init( &pem );
#if defined(MBEDTLS_RSA_C) #if defined(MBEDTLS_RSA_C)
/* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */
@ -1311,6 +1313,7 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
mbedtls_pem_free( &pem ); mbedtls_pem_free( &pem );
return( ret ); return( ret );
} }
mbedtls_pem_free( &pem );
#endif /* MBEDTLS_PEM_PARSE_C */ #endif /* MBEDTLS_PEM_PARSE_C */
#if defined(MBEDTLS_RSA_C) #if defined(MBEDTLS_RSA_C)
@ -1324,7 +1327,6 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
ret = pk_get_rsapubkey( &p, p + keylen, mbedtls_pk_rsa( *ctx ) ); ret = pk_get_rsapubkey( &p, p + keylen, mbedtls_pk_rsa( *ctx ) );
if ( ret == 0 ) if ( ret == 0 )
{ {
mbedtls_pem_free( &pem );
return( ret ); return( ret );
} }
mbedtls_pk_free( ctx ); mbedtls_pk_free( ctx );

View file

@ -107,7 +107,7 @@ depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C
pk_parse_public_keyfile_rsa:"data_files/format_gen.pub":0 pk_parse_public_keyfile_rsa:"data_files/format_gen.pub":0
Parse Public RSA Key #1 (PKCS#8 wrapped, DER) Parse Public RSA Key #1 (PKCS#8 wrapped, DER)
depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C depends_on:MBEDTLS_MD5_C
pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs8_1024_public.der":0 pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs8_1024_public.der":0
Parse Public RSA Key #3 (PKCS#1 wrapped) Parse Public RSA Key #3 (PKCS#1 wrapped)
@ -115,7 +115,7 @@ depends_on:MBEDTLS_RSA_C:MBEDTLS_PEM_PARSE_C
pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs1_2048_public.pem":0 pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs1_2048_public.pem":0
Parse Public RSA Key #4 (PKCS#1 wrapped, DER) Parse Public RSA Key #4 (PKCS#1 wrapped, DER)
depends_on:MBEDTLS_RSA_C:MBEDTLS_PEM_PARSE_C depends_on:MBEDTLS_RSA_C
pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs1_2048_public.der":0 pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs1_2048_public.der":0
Parse Public EC Key #1 (RFC 5480, DER) Parse Public EC Key #1 (RFC 5480, DER)