Merge code for RSA and ECDSA in SSL

This commit is contained in:
Manuel Pégourié-Gonnard 2013-08-21 16:14:26 +02:00
parent 070cc7fd21
commit 0d42049440
5 changed files with 71 additions and 126 deletions

View file

@ -244,6 +244,17 @@ int pk_init_ctx_rsa_alt( pk_context *ctx, void * key,
*/
size_t pk_get_size( const pk_context *ctx );
/**
* \brief Get the length in bytes of the underlying key
* \param ctx Context to use
*
* \return Key lenght in bytes, or 0 on error
*/
static size_t pk_get_len( const pk_context *ctx )
{
return( ( pk_get_size( ctx ) + 7 ) / 8 );
}
/**
* \brief Tell if a context can do the operation given by type
*

View file

@ -202,6 +202,7 @@
#define SSL_HASH_SHA384 5
#define SSL_HASH_SHA512 6
#define SSL_SIG_ANON 0
#define SSL_SIG_RSA 1
#define SSL_SIG_ECDSA 3
@ -580,13 +581,6 @@ struct _ssl_context
*/
pk_context *pk_key; /*!< own private key */
int pk_key_own_alloc; /*!< did we allocate pk_key? */
#if defined(POLARSSL_RSA_C)
int rsa_use_alt; /*<! flag for alt (temporary) */
void *rsa_key; /*!< own RSA private key */
rsa_decrypt_func rsa_decrypt; /*!< function for RSA decrypt*/
rsa_sign_func rsa_sign; /*!< function for RSA sign */
rsa_key_len_func rsa_key_len; /*!< function for RSA key len*/
#endif /* POLARSSL_RSA_C */
#if defined(POLARSSL_X509_PARSE_C)
x509_cert *own_cert; /*!< own X.509 certificate */
@ -909,7 +903,7 @@ void ssl_set_ca_chain( ssl_context *ssl, x509_cert *ca_chain,
* \param pk_key own private key
*/
void ssl_set_own_cert( ssl_context *ssl, x509_cert *own_cert,
pk_context *rsa_key );
pk_context *pk_key );
#if defined(POLARSSL_RSA_C)
/**
@ -922,9 +916,11 @@ void ssl_set_own_cert( ssl_context *ssl, x509_cert *own_cert,
* \param ssl SSL context
* \param own_cert own public certificate chain
* \param rsa_key own private RSA key
*
* \return 0 on success, or a specific error code.
*/
void ssl_set_own_cert_rsa( ssl_context *ssl, x509_cert *own_cert,
rsa_context *rsa_key );
int ssl_set_own_cert_rsa( ssl_context *ssl, x509_cert *own_cert,
rsa_context *rsa_key );
#endif /* POLARSSL_RSA_C */
/**
@ -1388,6 +1384,8 @@ int ssl_write_finished( ssl_context *ssl );
void ssl_optimize_checksum( ssl_context *ssl, const ssl_ciphersuite_t *ciphersuite_info );
unsigned char ssl_sig_from_pk( pk_context *pk );
#ifdef __cplusplus
}
#endif