forked from wolfSSL/wolfssl
Merge pull request #1703 from cconlon/truestudio
Fix Atollic TrueSTUDIO warning, add WOLFSSL_STM32F427_RNG
This commit is contained in:
@ -4764,6 +4764,8 @@ exit_ed_verify:
|
|||||||
|
|
||||||
#elif defined FREERTOS
|
#elif defined FREERTOS
|
||||||
|
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
double current_time(int reset)
|
double current_time(int reset)
|
||||||
{
|
{
|
||||||
portTickType tickCount;
|
portTickType tickCount;
|
||||||
|
@ -1308,6 +1308,7 @@ static int wc_PKCS12_create_key_bag(WC_PKCS12* pkcs12, WC_RNG* rng,
|
|||||||
tmpSz = SetSequence(totalSz, out);
|
tmpSz = SetSequence(totalSz, out);
|
||||||
XMEMMOVE(out + tmpSz, out + MAX_SEQ_SZ, totalSz);
|
XMEMMOVE(out + tmpSz, out + MAX_SEQ_SZ, totalSz);
|
||||||
|
|
||||||
|
(void)heap;
|
||||||
return totalSz + tmpSz;
|
return totalSz + tmpSz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1580,9 +1580,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
#endif /* FREESCALE_K70_RNGA */
|
#endif /* FREESCALE_K70_RNGA */
|
||||||
|
|
||||||
#elif defined(STM32_RNG)
|
#elif defined(STM32_RNG)
|
||||||
/*
|
/* Generate a RNG seed using the hardware random number generator
|
||||||
* wc_Generate a RNG seed using the hardware random number generator
|
* on the STM32F2/F4/F7. */
|
||||||
* on the STM32F2/F4/F7. */
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_STM32_CUBEMX
|
#ifdef WOLFSSL_STM32_CUBEMX
|
||||||
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||||
@ -1605,7 +1604,42 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#elif defined(WOLFSSL_STM32F427_RNG)
|
||||||
|
|
||||||
|
/* Generate a RNG seed using the hardware RNG on the STM32F427
|
||||||
|
* directly, following steps outlined in STM32F4 Reference
|
||||||
|
* Manual (Chapter 24) for STM32F4xx family. */
|
||||||
|
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
(void)os;
|
||||||
|
|
||||||
|
/* enable RNG interrupt, set IE bit in RNG->CR register */
|
||||||
|
RNG->CR |= RNG_CR_IE;
|
||||||
|
|
||||||
|
/* enable RNG, set RNGEN bit in RNG->CR. Activates RNG,
|
||||||
|
* RNG_LFSR, and error detector */
|
||||||
|
RNG->CR |= RNG_CR_RNGEN;
|
||||||
|
|
||||||
|
/* verify no errors, make sure SEIS and CEIS bits are 0
|
||||||
|
* in RNG->SR register */
|
||||||
|
if (RNG->SR & (RNG_SR_SECS | RNG_SR_CECS))
|
||||||
|
return RNG_FAILURE_E;
|
||||||
|
|
||||||
|
for (i = 0; i < (int)sz; i++) {
|
||||||
|
/* wait until RNG number is ready */
|
||||||
|
while ((RNG->SR & RNG_SR_DRDY) == 0) { }
|
||||||
|
|
||||||
|
/* get value */
|
||||||
|
output[i] = RNG->DR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
/* Generate a RNG seed using the STM32 Standard Peripheral Library */
|
||||||
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -1008,6 +1008,9 @@ extern void uITRON4_free(void *p) ;
|
|||||||
#ifndef NO_STM32_RNG
|
#ifndef NO_STM32_RNG
|
||||||
#undef STM32_RNG
|
#undef STM32_RNG
|
||||||
#define STM32_RNG
|
#define STM32_RNG
|
||||||
|
#ifdef WOLFSSL_STM32F427_RNG
|
||||||
|
#include "stm32f427xx.h"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_STM32_CRYPTO
|
#ifndef NO_STM32_CRYPTO
|
||||||
#undef STM32_CRYPTO
|
#undef STM32_CRYPTO
|
||||||
|
Reference in New Issue
Block a user