mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 11:17:29 +02:00
additional comments, code readability, and error check
This commit is contained in:
@ -436,6 +436,7 @@ static void print_jdkek()
|
|||||||
|
|
||||||
|
|
||||||
/* instantiate RNG and create JDKEK, TDKEK, and TDSK key */
|
/* instantiate RNG and create JDKEK, TDKEK, and TDSK key */
|
||||||
|
#define WC_RNG_START_SIZE 6
|
||||||
static unsigned int wc_rng_start[] = {
|
static unsigned int wc_rng_start[] = {
|
||||||
CAAM_HEAD | 0x00000006,
|
CAAM_HEAD | 0x00000006,
|
||||||
CAAM_OP | CAAM_CLASS1 | CAAM_RNG | 0x00000004, /* Instantiate RNG handle 0
|
CAAM_OP | CAAM_CLASS1 | CAAM_RNG | 0x00000004, /* Instantiate RNG handle 0
|
||||||
@ -459,7 +460,7 @@ int caamInitRng(struct CAAM_DEVICE* dev)
|
|||||||
/* set up the job description for RNG initialization */
|
/* set up the job description for RNG initialization */
|
||||||
memset(&desc, 0, sizeof(DESCSTRUCT));
|
memset(&desc, 0, sizeof(DESCSTRUCT));
|
||||||
desc.desc[desc.idx++] = CAAM_HEAD; /* later will put size to header*/
|
desc.desc[desc.idx++] = CAAM_HEAD; /* later will put size to header*/
|
||||||
for (i = 1; i < 6; i = i + 1) {
|
for (i = 1; i < WC_RNG_START_SIZE; i = i + 1) {
|
||||||
desc.desc[desc.idx++] = wc_rng_start[i];
|
desc.desc[desc.idx++] = wc_rng_start[i];
|
||||||
}
|
}
|
||||||
desc.caam = dev;
|
desc.caam = dev;
|
||||||
@ -474,7 +475,7 @@ int caamInitRng(struct CAAM_DEVICE* dev)
|
|||||||
/* Set up use of the TRNG for seeding wolfSSL HASH-DRBG */
|
/* Set up use of the TRNG for seeding wolfSSL HASH-DRBG */
|
||||||
/* check out the status and see if already setup */
|
/* check out the status and see if already setup */
|
||||||
CAAM_WRITE(CAAM_RTMCTL, CAAM_PRGM);
|
CAAM_WRITE(CAAM_RTMCTL, CAAM_PRGM);
|
||||||
CAAM_WRITE(CAAM_RTMCTL, CAAM_READ(CAAM_RTMCTL) | 0x40); /* reset */
|
CAAM_WRITE(CAAM_RTMCTL, CAAM_READ(CAAM_RTMCTL) | CAAM_RTMCTL_RESET);
|
||||||
|
|
||||||
/* Set up reading from TRNG */
|
/* Set up reading from TRNG */
|
||||||
CAAM_WRITE(CAAM_RTMCTL, CAAM_READ(CAAM_RTMCTL) | CAAM_TRNG);
|
CAAM_WRITE(CAAM_RTMCTL, CAAM_READ(CAAM_RTMCTL) | CAAM_TRNG);
|
||||||
@ -494,7 +495,7 @@ int caamInitRng(struct CAAM_DEVICE* dev)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set back to run mode and clear RTMCL error bit */
|
/* Set back to run mode and clear RTMCL error bit */
|
||||||
reg = CAAM_READ(CAAM_RTMCTL) ^ CAAM_PRGM;
|
reg = CAAM_READ(CAAM_RTMCTL) & (~CAAM_PRGM);
|
||||||
CAAM_WRITE(CAAM_RTMCTL, reg);
|
CAAM_WRITE(CAAM_RTMCTL, reg);
|
||||||
reg = CAAM_READ(CAAM_RTMCTL);
|
reg = CAAM_READ(CAAM_RTMCTL);
|
||||||
reg |= CAAM_CTLERR;
|
reg |= CAAM_CTLERR;
|
||||||
@ -1440,6 +1441,8 @@ int InitCAAM(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret != Success) {
|
if (ret != Success) {
|
||||||
|
WOLFSSL_MSG("Failed to find a partition on startup");
|
||||||
|
INTERRUPT_Panic();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,8 @@
|
|||||||
|
|
||||||
/* RNG Masks/Values */
|
/* RNG Masks/Values */
|
||||||
#ifndef CAAM_ENT_DLY
|
#ifndef CAAM_ENT_DLY
|
||||||
/*less than half the default value to try and increase entropy collection */
|
/* Less than half the default value to try and increase entropy collection.
|
||||||
|
* Value is system clock cycles. */
|
||||||
#define CAAM_ENT_DLY 1200
|
#define CAAM_ENT_DLY 1200
|
||||||
#endif
|
#endif
|
||||||
#ifndef CAAM_ENT_DLY_INCREMENT
|
#ifndef CAAM_ENT_DLY_INCREMENT
|
||||||
@ -206,6 +207,7 @@
|
|||||||
|
|
||||||
#define CAAM_PRGM 0x00010000 /* Set RTMCTL to program state */
|
#define CAAM_PRGM 0x00010000 /* Set RTMCTL to program state */
|
||||||
#define CAAM_TRNG 0x00000020 /* Set TRNG access */
|
#define CAAM_TRNG 0x00000020 /* Set TRNG access */
|
||||||
|
#define CAAM_RTMCTL_RESET 0x40 /* TRNG reset to defaults */
|
||||||
#define CAAM_CTLERR 0x00001000
|
#define CAAM_CTLERR 0x00001000
|
||||||
#define CAAM_ENTVAL 0x00000400 /* checking RTMCTL for entropy ready */
|
#define CAAM_ENTVAL 0x00000400 /* checking RTMCTL for entropy ready */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user