mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 15:14:17 +01:00
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:
parent
bf37b10370
commit
ab3773123c
@ -267,6 +267,7 @@
|
|||||||
//#define MBEDTLS_BLOWFISH_ALT
|
//#define MBEDTLS_BLOWFISH_ALT
|
||||||
//#define MBEDTLS_CAMELLIA_ALT
|
//#define MBEDTLS_CAMELLIA_ALT
|
||||||
//#define MBEDTLS_DES_ALT
|
//#define MBEDTLS_DES_ALT
|
||||||
|
//#define MBEDTLS_RSA_ALT
|
||||||
//#define MBEDTLS_XTEA_ALT
|
//#define MBEDTLS_XTEA_ALT
|
||||||
//#define MBEDTLS_MD2_ALT
|
//#define MBEDTLS_MD2_ALT
|
||||||
//#define MBEDTLS_MD4_ALT
|
//#define MBEDTLS_MD4_ALT
|
||||||
|
@ -209,6 +209,8 @@ int mbedtls_rsa_check_params( mbedtls_mpi *N, mbedtls_mpi *P, mbedtls_mpi *Q,
|
|||||||
* Implementation of RSA interface
|
* Implementation of RSA interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_RSA_ALT)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief RSA context structure
|
* \brief RSA context structure
|
||||||
*/
|
*/
|
||||||
@ -252,6 +254,12 @@ typedef struct
|
|||||||
}
|
}
|
||||||
mbedtls_rsa_context;
|
mbedtls_rsa_context;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include "rsa_alt.h"
|
||||||
|
|
||||||
|
#endif /* MBEDTLS_RSA_ALT */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialize an RSA context
|
* \brief Initialize an RSA context
|
||||||
*
|
*
|
||||||
|
@ -464,6 +464,7 @@ cleanup:
|
|||||||
* Default RSA interface implementation
|
* Default RSA interface implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_RSA_ALT)
|
||||||
|
|
||||||
int mbedtls_rsa_import( mbedtls_rsa_context *ctx,
|
int mbedtls_rsa_import( mbedtls_rsa_context *ctx,
|
||||||
const mbedtls_mpi *N,
|
const mbedtls_mpi *N,
|
||||||
@ -2493,6 +2494,8 @@ void mbedtls_rsa_free( mbedtls_rsa_context *ctx )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* !MBEDTLS_RSA_ALT */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SELF_TEST)
|
#if defined(MBEDTLS_SELF_TEST)
|
||||||
|
|
||||||
#include "mbedtls/sha1.h"
|
#include "mbedtls/sha1.h"
|
||||||
|
@ -99,6 +99,9 @@ static const char *features[] = {
|
|||||||
#if defined(MBEDTLS_DES_ALT)
|
#if defined(MBEDTLS_DES_ALT)
|
||||||
"MBEDTLS_DES_ALT",
|
"MBEDTLS_DES_ALT",
|
||||||
#endif /* MBEDTLS_DES_ALT */
|
#endif /* MBEDTLS_DES_ALT */
|
||||||
|
#if defined(MBEDTLS_RSA_ALT)
|
||||||
|
"MBEDTLS_RSA_ALT",
|
||||||
|
#endif /* MBEDTLS_RSA_ALT */
|
||||||
#if defined(MBEDTLS_XTEA_ALT)
|
#if defined(MBEDTLS_XTEA_ALT)
|
||||||
"MBEDTLS_XTEA_ALT",
|
"MBEDTLS_XTEA_ALT",
|
||||||
#endif /* MBEDTLS_XTEA_ALT */
|
#endif /* MBEDTLS_XTEA_ALT */
|
||||||
|
Loading…
Reference in New Issue
Block a user