Support for STM32L5 PKA ECC sign/verify acceleration.

This commit is contained in:
David Garske 2020-06-03 11:38:56 -07:00
parent 16c0160e63
commit 5837c70e99
3 changed files with 25 additions and 11 deletions

View File

@ -64,6 +64,7 @@ extern "C" {
//#define NO_STM32_HASH
//#define NO_STM32_RNG
//#define NO_STM32_CRYPTO
//#define WOLFSSL_STM32_PKA /* WB55 and L5 only */
/* ------------------------------------------------------------------------- */

View File

@ -363,9 +363,14 @@ int wc_Stm32_Aes_Init(Aes* aes, CRYP_InitTypeDef* cryptInit,
#ifdef WOLFSSL_STM32_PKA
#include <stdint.h>
#if defined(WOLFSSL_STM32L5)
#include <stm32l5xx_hal_conf.h>
#include <stm32l5xx_hal_pka.h>
#else
#include <stm32wbxx_hal_conf.h>
#include <stm32wbxx_hal_pka.h>
#endif
extern PKA_HandleTypeDef hpka;
/* Reverse array in memory (in place) */

View File

@ -28,11 +28,6 @@
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/types.h>
#if defined(WOLFSSL_STM32_PKA) && defined(HAVE_ECC)
#include <wolfssl/wolfcrypt/integer.h>
#include <wolfssl/wolfcrypt/ecc.h>
#endif
#ifdef STM32_HASH
#define WOLFSSL_NO_HASH_RAW
@ -139,12 +134,25 @@ int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo,
#endif /* STM32_CRYPTO */
#if defined(WOLFSSL_STM32_PKA) && defined(HAVE_ECC)
int stm32_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
word32 hashlen, int* res, ecc_key* key);
int stm32_ecc_sign_hash_ex(const byte* hash, word32 hashlen, WC_RNG* rng,
ecc_key* key, mp_int *r, mp_int *s);
#ifdef WOLFSSL_SP_MATH
struct sp_int;
#define MATH_INT_T struct sp_int
#elif defined(USE_FAST_MATH)
struct fp_int;
#define MATH_INT_T struct fp_int
#else
struct mp_int;
#define MATH_INT_T struct mp_int
#endif
struct ecc_key;
struct WC_RNG;
int stm32_ecc_verify_hash_ex(MATH_INT_T *r, MATH_INT_T *s, const byte* hash,
word32 hashlen, int* res, struct ecc_key* key);
int stm32_ecc_sign_hash_ex(const byte* hash, word32 hashlen, struct WC_RNG* rng,
struct ecc_key* key, MATH_INT_T *r, MATH_INT_T *s);
#endif /* WOLFSSL_STM32_PKA && HAVE_ECC */
#endif /* _WOLFPORT_STM32_H_ */