Added POLARSSL_PK_PARSE_C and POLARSSL_PK_WRITE_C

This commit is contained in:
Paul Bakker 2013-09-15 17:04:23 +02:00
parent 428b9ba3b7
commit 4606c7317b
6 changed files with 54 additions and 10 deletions

View File

@ -1184,6 +1184,34 @@
*/
#define POLARSSL_PK_C
/**
* \def POLARSSL_PK_PARSE_C
*
* Enable the generic public (asymetric) key parser.
*
* Module: library/pkparse.c
* Caller: library/x509parse.c
*
* Requires: POLARSSL_PK_C
*
* Uncomment to enable generic public key parse functions.
*/
#define POLARSSL_PK_PARSE_C
/**
* \def POLARSSL_PK_WRITE_C
*
* Enable the generic public (asymetric) key write.
*
* Module: library/pkwrite.c
* Caller: library/x509write.c
*
* Requires: POLARSSL_PK_C
*
* Uncomment to enable generic public key write functions.
*/
#define POLARSSL_PK_WRITE_C
/**
* \def POLARSSL_PKCS5_C
*
@ -1379,7 +1407,7 @@
* library/ssl_tls.c
*
* Requires: POLARSSL_ASN1_PARSE_C, POLARSSL_BIGNUM_C, POLARSSL_OID_C,
* POLARSSL_PK_C
* POLARSSL_PK_PARSE_C
*
* This module is required for X.509 certificate parsing.
*/
@ -1392,7 +1420,7 @@
*
* Module: library/x509write.c
*
* Requires: POLARSSL_BIGNUM_C, POLARSSL_OID_C, POLARSSL_PK_C
* Requires: POLARSSL_BIGNUM_C, POLARSSL_OID_C, POLARSSL_PK_WRITE_C
*
* This module is required for X.509 certificate request writing.
*/
@ -1562,6 +1590,14 @@
#error "POLARSSL_PEM_C defined, but not all prerequisites"
#endif
#if defined(POLARSSL_PK_PARSE_C) && !defined(POLARSSL_PK_C)
#error "POLARSSL_PK_PARSE_C defined, but not all prerequisites"
#endif
#if defined(POLARSSL_PK_WRITE_C) && !defined(POLARSSL_PK_C)
#error "POLARSSL_PK_WRITE_C defined, but not all prerequisites"
#endif
#if defined(POLARSSL_PKCS11_C) && !defined(POLARSSL_PK_C)
#error "POLARSSL_PKCS11_C defined, but not all prerequisites"
#endif
@ -1614,13 +1650,13 @@
#if defined(POLARSSL_X509_PARSE_C) && ( !defined(POLARSSL_BIGNUM_C) || \
!defined(POLARSSL_OID_C) || !defined(POLARSSL_ASN1_PARSE_C) || \
!defined(POLARSSL_PK_C) )
!defined(POLARSSL_PK_PARSE_C) )
#error "POLARSSL_X509_PARSE_C defined, but not all prerequisites"
#endif
#if defined(POLARSSL_X509_WRITE_C) && ( !defined(POLARSSL_BIGNUM_C) || \
!defined(POLARSSL_OID_C) || !defined(POLARSSL_ASN1_WRITE_C) || \
!defined(POLARSSL_RSA_C) )
!defined(POLARSSL_RSA_C) || !defined(POLARSSL_PK_WRITE_C) )
#error "POLARSSL_X509_WRITE_C defined, but not all prerequisites"
#endif

View File

@ -389,6 +389,7 @@ const char * pk_get_name( const pk_context *ctx );
*/
pk_type_t pk_get_type( const pk_context *ctx );
#if defined(POLARSSL_PK_PARSE_C)
/** \ingroup x509_module */
/**
* \brief Parse a private key
@ -443,7 +444,9 @@ int pk_parse_keyfile( pk_context *ctx,
*/
int pk_parse_public_keyfile( pk_context *ctx, const char *path );
#endif /* POLARSSL_FS_IO */
#endif /* POLARSSL_PK_PARSE_C */
#if defined(POLARSSL_PK_WRITE_C)
/**
* \brief Write a private key to a PKCS#1 or SEC1 DER structure
* Note: data is written at the end of the buffer! Use the
@ -497,12 +500,14 @@ int pk_write_pubkey_pem( pk_context *key, unsigned char *buf, size_t size );
*/
int pk_write_key_pem( pk_context *key, unsigned char *buf, size_t size );
#endif /* POLARSSL_BASE64_C */
#endif /* POLARSSL_PK_WRITE_C */
/*
* WARNING: Low-level functions. You probably do not want to use these unless
* you are certain you do ;)
*/
#if defined(POLARSSL_PK_PARSE_C)
/**
* \brief Parse a SubjectPublicKeyInfo DER structure
*
@ -514,7 +519,9 @@ int pk_write_key_pem( pk_context *key, unsigned char *buf, size_t size );
*/
int pk_parse_get_pubkey( unsigned char **p, const unsigned char *end,
pk_context *pk );
#endif /* POLARSSL_PK_PARSE_C */
#if defined(POLARSSL_PK_WRITE_C)
/**
* \brief Write a subjectPublicKey to ASN.1 data
* Note: function works backwards in data buffer
@ -527,6 +534,7 @@ int pk_parse_get_pubkey( unsigned char **p, const unsigned char *end,
*/
int pk_write_pubkey( unsigned char **p, unsigned char *start,
const pk_context *key );
#endif /* POLARSSL_PK_WRITE_C */
#ifdef __cplusplus
}

View File

@ -25,7 +25,7 @@
#include "polarssl/config.h"
#if defined(POLARSSL_PK_C)
#if defined(POLARSSL_PK_PARSE_C)
#include "polarssl/pk.h"
#include "polarssl/asn1.h"
@ -954,4 +954,4 @@ int pk_parse_public_key( pk_context *ctx,
return( ret );
}
#endif /* POLARSSL_PK_C */
#endif /* POLARSSL_PK_PARSE_C */

View File

@ -25,7 +25,7 @@
#include "polarssl/config.h"
#if defined(POLARSSL_PK_C)
#if defined(POLARSSL_PK_WRITE_C)
#include "polarssl/pk.h"
#include "polarssl/asn1write.h"
@ -386,4 +386,4 @@ int pk_write_key_pem( pk_context *key, unsigned char *buf, size_t size )
}
#endif /* POLARSSL_BASE64_C */
#endif /* POLARSSL_PK_C */
#endif /* POLARSSL_PK_WRITE_C */

View File

@ -5,7 +5,7 @@
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:POLARSSL_PK_C:POLARSSL_BIGNUM_C
* depends_on:POLARSSL_PK_PARSE_C:POLARSSL_BIGNUM_C
* END_DEPENDENCIES
*/

View File

@ -5,7 +5,7 @@
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:POLARSSL_PK_C:POLARSSL_BIGNUM_C:POLARSSL_FS_IO
* depends_on:POLARSSL_PK_WRITE_C:POLARSSL_BIGNUM_C:POLARSSL_FS_IO
* END_DEPENDENCIES
*/