add support for Kinetis K70 HW RNGA

This commit is contained in:
Chris Conlon
2012-11-02 17:49:30 -06:00
parent 917bc83c60
commit 11c8e5afb8
3 changed files with 50 additions and 8 deletions

6
README
View File

@@ -32,6 +32,12 @@ SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
before calling SSL_new(); Though it's not recommended.
Note 3)
The Freescale Kinetis K70 RNGA documentation can be found in Chapter 37 of the
K70 Sub-Family Reference Manual:
http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K70P256M150SF3RM.pdf
*** end Note ***
CyaSSL Release 2.4.0 (10/10/2012)

View File

@@ -161,16 +161,51 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
#elif defined(FREESCALE_MQX)
#warning "write a real random seed!!!!, just for testing now"
#ifdef FREESCALE_K70_RNGA
/*
* Generates a RNG seed using the Random Number Generator Accelerator
* on the Kinetis K70. Documentation located in Chapter 37 of
* K70 Sub-Family Reference Manual (see Note 3 in the README for link).
*/
int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
for (i = 0; i < sz; i++ )
output[i] = i;
/* turn on RNGA module */
SIM_SCGC3 |= SIM_SCGC3_RNGA_MASK;
return 0;
}
/* set SLP bit to 0 - "RNGA is not in sleep mode" */
RNG_CR &= ~RNG_CR_SLP_MASK;
/* set HA bit to 1 - "security violations masked" */
RNG_CR |= RNG_CR_HA_MASK;
/* set GO bit to 1 - "output register loaded with data" */
RNG_CR |= RNG_CR_GO_MASK;
for (i = 0; i < sz; i++) {
/* wait for RNG FIFO to be full */
while((RNG_SR & RNG_SR_OREG_LVL(0xF)) == 0) {}
/* get value */
output[i] = RNG_OR;
}
return 0;
}
#else
#warning "write a real random seed!!!!, just for testing now"
int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
for (i = 0; i < sz; i++ )
output[i] = i;
return 0;
}
#endif /* FREESCALE_K70_RNGA */
#elif defined(NO_DEV_RANDOM)

View File

@@ -203,6 +203,7 @@
#define NO_CYASSL_DIR
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define FREESCALE_K70_RNGA
#ifndef NO_FILESYSTEM
#include "mfs.h"
#include "fio.h"