Add support for alternative RSA implementations

Alternative RSA implementations can be provided by defining MBEDTLS_RSA_ALT in
config.h, defining an mbedtls_rsa_context struct in a new file rsa_alt.h and
re-implementing the RSA interface specified in rsa.h.

Through the previous reworkings, the adherence to the interface is the only
implementation obligation - in particular, implementors are free to use a
different layout for the RSA context structure.
This commit is contained in:
Hanno Becker 2017-08-23 16:24:51 +01:00
parent bf37b10370
commit ab3773123c
4 changed files with 15 additions and 0 deletions

View file

@ -267,6 +267,7 @@
//#define MBEDTLS_BLOWFISH_ALT
//#define MBEDTLS_CAMELLIA_ALT
//#define MBEDTLS_DES_ALT
//#define MBEDTLS_RSA_ALT
//#define MBEDTLS_XTEA_ALT
//#define MBEDTLS_MD2_ALT
//#define MBEDTLS_MD4_ALT

View file

@ -209,6 +209,8 @@ int mbedtls_rsa_check_params( mbedtls_mpi *N, mbedtls_mpi *P, mbedtls_mpi *Q,
* Implementation of RSA interface
*/
#if !defined(MBEDTLS_RSA_ALT)
/**
* \brief RSA context structure
*/
@ -252,6 +254,12 @@ typedef struct
}
mbedtls_rsa_context;
#else
#include "rsa_alt.h"
#endif /* MBEDTLS_RSA_ALT */
/**
* \brief Initialize an RSA context
*