Add extra compilation conditions to X.509 samples

The sample applications programs/pkey/cert_req.c and
programs/pkey/cert_write.c use the library functions mbedtls_pk_write_csr_pem()
and mbedtls_pk_write_crt_pem() respectively and programs/pkey/gen_key.c uses
the library function mbedtls_pk_write_key_pem().

These are dependent on the configuration option POLARSSL_PEM_WRITE_C. If the
option isn't defined the build breaks.

This change adds the compilation condition POLARSSL_PEM_WRITE_C to these
sample applications.
This commit is contained in:
Simon Butcher 2016-10-10 23:23:41 +01:00
parent 372bf79d67
commit 8c9ab6ce6f
3 changed files with 26 additions and 17 deletions

View file

@ -33,8 +33,9 @@
#define polarssl_printf printf #define polarssl_printf printf
#endif #endif
#if defined(POLARSSL_PK_WRITE_C) && defined(POLARSSL_FS_IO) && \ #if defined(POLARSSL_PK_WRITE_C) && defined(POLARSSL_PEM_WRITE_C) && \
defined(POLARSSL_ENTROPY_C) && defined(POLARSSL_CTR_DRBG_C) defined(POLARSSL_FS_IO) && defined(POLARSSL_ENTROPY_C) && \
defined(POLARSSL_CTR_DRBG_C)
#include "polarssl/error.h" #include "polarssl/error.h"
#include "polarssl/pk.h" #include "polarssl/pk.h"
#include "polarssl/ecdsa.h" #include "polarssl/ecdsa.h"
@ -121,12 +122,14 @@ int dev_random_entropy_poll( void *data, unsigned char *output,
USAGE_DEV_RANDOM \ USAGE_DEV_RANDOM \
"\n" "\n"
#if !defined(POLARSSL_PK_WRITE_C) || !defined(POLARSSL_FS_IO) || \ #if !defined(POLARSSL_PK_WRITE_C) || !defined(POLARSSL_PEM_WRITE_C) || \
!defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C) !defined(POLARSSL_FS_IO) || !defined(POLARSSL_ENTROPY_C) || \
!defined(POLARSSL_CTR_DRBG_C)
int main( void ) int main( void )
{ {
polarssl_printf( "POLARSSL_PK_WRITE_C and/or POLARSSL_FS_IO and/or " polarssl_printf( "POLARSSL_PK_WRITE_C and/or POLARSSL_FS_IO and/or "
"POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C " "POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C and/or "
"POLARSSL_PEM_WRITE_C "
"not defined.\n" ); "not defined.\n" );
return( 0 ); return( 0 );
} }
@ -417,4 +420,5 @@ exit:
return( ret ); return( ret );
} }
#endif /* POLARSSL_PK_WRITE_C && POLARSSL_FS_IO */ #endif /* POLARSSL_PK_WRITE_C && POLARSSL_PEM_WRITE_C && POLARSSL_FS_IO &&
* POLARSSL_ENTROPY_C && POLARSSL_CTR_DRBG_C */

View file

@ -35,12 +35,14 @@
#if !defined(POLARSSL_X509_CSR_WRITE_C) || !defined(POLARSSL_FS_IO) || \ #if !defined(POLARSSL_X509_CSR_WRITE_C) || !defined(POLARSSL_FS_IO) || \
!defined(POLARSSL_PK_PARSE_C) || !defined(POLARSSL_SHA256_C) || \ !defined(POLARSSL_PK_PARSE_C) || !defined(POLARSSL_SHA256_C) || \
!defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C) !defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C) || \
!defined(POLARSSL_PEM_WRITE_C)
int main( void ) int main( void )
{ {
polarssl_printf( "POLARSSL_X509_CSR_WRITE_C and/or POLARSSL_FS_IO and/or " polarssl_printf( "POLARSSL_X509_CSR_WRITE_C and/or POLARSSL_FS_IO and/or "
"POLARSSL_PK_PARSE_C and/or POLARSSL_SHA256_c and/or " "POLARSSL_PK_PARSE_C and/or POLARSSL_SHA256_c and/or "
"POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C " "POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C and/or "
"POLARSSL_PEM_WRITE_C "
"not defined.\n"); "not defined.\n");
return( 0 ); return( 0 );
} }
@ -341,4 +343,4 @@ exit:
return( ret ); return( ret );
} }
#endif /* POLARSSL_X509_CSR_WRITE_C && POLARSSL_PK_PARSE_C && POLARSSL_FS_IO && #endif /* POLARSSL_X509_CSR_WRITE_C && POLARSSL_PK_PARSE_C && POLARSSL_FS_IO &&
POLARSSL_ENTROPY_C && POLARSSL_CTR_DRBG_C */ POLARSSL_ENTROPY_C && POLARSSL_CTR_DRBG_C && POLARSSL_PEM_WRITE_C */

View file

@ -36,12 +36,15 @@
#if !defined(POLARSSL_X509_CRT_WRITE_C) || \ #if !defined(POLARSSL_X509_CRT_WRITE_C) || \
!defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_FS_IO) || \ !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_FS_IO) || \
!defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C) || \ !defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C) || \
!defined(POLARSSL_ERROR_C) || !defined(POLARSSL_SHA256_C) !defined(POLARSSL_ERROR_C) || !defined(POLARSSL_SHA256_C) || \
!defined(POLARSSL_PEM_WRITE_C)
int main( void ) int main( void )
{ {
polarssl_printf( "POLARSSL_X509_CRT_WRITE_C and/or POLARSSL_X509_CRT_PARSE_C and/or " polarssl_printf( "POLARSSL_X509_CRT_WRITE_C and/or "
"POLARSSL_X509_CRT_PARSE_C and/or "
"POLARSSL_FS_IO and/or POLARSSL_SHA256_C and_or " "POLARSSL_FS_IO and/or POLARSSL_SHA256_C and_or "
"POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C and/or " "POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C and/or "
"POLARSSL_PEM_WRITE_C and/or "
"POLARSSL_ERROR_C not defined.\n"); "POLARSSL_ERROR_C not defined.\n");
return( 0 ); return( 0 );
} }
@ -665,4 +668,4 @@ exit:
} }
#endif /* POLARSSL_X509_CRT_WRITE_C && POLARSSL_X509_CRT_PARSE_C && #endif /* POLARSSL_X509_CRT_WRITE_C && POLARSSL_X509_CRT_PARSE_C &&
POLARSSL_FS_IO && POLARSSL_ENTROPY_C && POLARSSL_CTR_DRBG_C && POLARSSL_FS_IO && POLARSSL_ENTROPY_C && POLARSSL_CTR_DRBG_C &&
POLARSSL_ERROR_C */ POLARSSL_ERROR_C && MBEDTLS_PEM_WRITE_C */