mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 20:54:41 +02:00
spelling mistakes, formatting, and change error name
This commit is contained in:
@@ -434,11 +434,11 @@ const char* wc_GetErrorString(int error)
|
|||||||
case ECC_PRIVATEONLY_E:
|
case ECC_PRIVATEONLY_E:
|
||||||
return "Invalid use of private only ECC key";
|
return "Invalid use of private only ECC key";
|
||||||
|
|
||||||
case WC_CAAM_E:
|
case WC_HW_E:
|
||||||
return "Error with CAAM use";
|
return "Error with hardware crypto use";
|
||||||
|
|
||||||
case WC_CAAM_WAIT:
|
case WC_HW_WAIT_E:
|
||||||
return "CAAM Driver waiting on resource";
|
return "Hardware waiting on resource";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "unknown error number";
|
return "unknown error number";
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* caam_aes.c
|
/* caam_aes.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
* Copyright (C) 2006-2017 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL.
|
* This file is part of wolfSSL.
|
||||||
*
|
*
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* caam_driver.c
|
/* caam_driver.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
* Copyright (C) 2006-2017 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL.
|
* This file is part of wolfSSL.
|
||||||
*
|
*
|
||||||
@@ -105,13 +105,13 @@ static Error caamReset()
|
|||||||
{
|
{
|
||||||
int t = 100000; /* time out counter for flushing job ring */
|
int t = 100000; /* time out counter for flushing job ring */
|
||||||
|
|
||||||
/* make sure interupts are masked in JRCFGR0_LS register */
|
/* make sure interrupts are masked in JRCFGR0_LS register */
|
||||||
CAAM_WRITE(CAAM_BASE | 0x1054, CAAM_READ(CAAM_BASE | 0x1054) | 1);
|
CAAM_WRITE(CAAM_BASE | 0x1054, CAAM_READ(CAAM_BASE | 0x1054) | 1);
|
||||||
|
|
||||||
/* flush and reset job rings using JRCR0 register */
|
/* flush and reset job rings using JRCR0 register */
|
||||||
CAAM_WRITE(CAAM_BASE | 0x106C, 1);
|
CAAM_WRITE(CAAM_BASE | 0x106C, 1);
|
||||||
|
|
||||||
/* check register JRINTR for if halt is in prgress */
|
/* check register JRINTR for if halt is in progress */
|
||||||
while (t > 0 && ((CAAM_READ(CAAM_BASE | 0x104C) & 0x4) == 0x4)) t--;
|
while (t > 0 && ((CAAM_READ(CAAM_BASE | 0x104C) & 0x4) == 0x4)) t--;
|
||||||
if (t == 0) {
|
if (t == 0) {
|
||||||
/*unrecoverable failure, the job ring is locked, up hard reset needed*/
|
/*unrecoverable failure, the job ring is locked, up hard reset needed*/
|
||||||
@@ -145,14 +145,14 @@ static Error caamCreatePartition(unsigned char page, unsigned char par)
|
|||||||
return MemoryMapMayNotBeEmpty;
|
return MemoryMapMayNotBeEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set generic all access permisions, gets reset later */
|
/* set generic all access permissions, gets reset later */
|
||||||
CAAM_WRITE(CAAM_BASE | (0x1108 + (par * 16)), 0xF);
|
CAAM_WRITE(CAAM_BASE | (0x1108 + (par * 16)), 0xF);
|
||||||
CAAM_WRITE(CAAM_BASE | (0x110C + (par * 16)), 0xF);
|
CAAM_WRITE(CAAM_BASE | (0x110C + (par * 16)), 0xF);
|
||||||
CAAM_WRITE(CAAM_BASE | (0x1104 + (par * 16)), 0xFF);
|
CAAM_WRITE(CAAM_BASE | (0x1104 + (par * 16)), 0xFF);
|
||||||
|
|
||||||
/* check ownership of page */
|
/* check ownership of page */
|
||||||
CAAM_WRITE(CAAM_BASE | 0x10F4, (page << 16) | 0x5);
|
CAAM_WRITE(CAAM_BASE | 0x10F4, (page << 16) | 0x5);
|
||||||
/* wait for inquery cmd to complete */
|
/* wait for inquiry cmd to complete */
|
||||||
while ((CAAM_READ(CAAM_BASE | 0x10FC) & 0x0000C000) > 0 &&
|
while ((CAAM_READ(CAAM_BASE | 0x10FC) & 0x0000C000) > 0 &&
|
||||||
(CAAM_READ(CAAM_BASE | 0x10FC) & 0x00003000) == 0) {
|
(CAAM_READ(CAAM_BASE | 0x10FC) & 0x00003000) == 0) {
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ static Error caamCreatePartition(unsigned char page, unsigned char par)
|
|||||||
(CAAM_READ(CAAM_BASE | 0x10FC) & 0x00003000) == 0) {}
|
(CAAM_READ(CAAM_BASE | 0x10FC) & 0x00003000) == 0) {}
|
||||||
if ((CAAM_READ(CAAM_BASE | 0x10FC) & 0x00003000) > 0) {
|
if ((CAAM_READ(CAAM_BASE | 0x10FC) & 0x00003000) > 0) {
|
||||||
/* error while deallocating page */
|
/* error while deallocating page */
|
||||||
return MemoryMapMayNotBeEmpty; /* PSP set on page or is unavialbale */
|
return MemoryMapMayNotBeEmpty; /* PSP set on page or is unavailable */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -186,7 +186,7 @@ static Error caamCreatePartition(unsigned char page, unsigned char par)
|
|||||||
|
|
||||||
/* double check ownership now of page */
|
/* double check ownership now of page */
|
||||||
CAAM_WRITE(CAAM_BASE | 0x10F4, (page << 16) | 0x5);
|
CAAM_WRITE(CAAM_BASE | 0x10F4, (page << 16) | 0x5);
|
||||||
/* wait for inquery cmd to complete */
|
/* wait for inquiry cmd to complete */
|
||||||
while ((CAAM_READ(CAAM_BASE | 0x10FC) & 0x0000C000) > 0 &&
|
while ((CAAM_READ(CAAM_BASE | 0x10FC) & 0x0000C000) > 0 &&
|
||||||
(CAAM_READ(CAAM_BASE | 0x10FC) & 0x00003000) == 0) {
|
(CAAM_READ(CAAM_BASE | 0x10FC) & 0x00003000) == 0) {
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ static int caamInitRng(struct CAAM_DEVICE* dev)
|
|||||||
reg |= CAAM_CTLERR;
|
reg |= CAAM_CTLERR;
|
||||||
CAAM_WRITE(CAAM_RTMCTL, reg);
|
CAAM_WRITE(CAAM_RTMCTL, reg);
|
||||||
|
|
||||||
/* check input slot is avialable and then add */
|
/* check input slot is available and then add */
|
||||||
if (CAAM_READ(CAAM_BASE | 0x1014) > 0) {
|
if (CAAM_READ(CAAM_BASE | 0x1014) > 0) {
|
||||||
UINT4* in = (UINT4*)dev->ring.JobIn;
|
UINT4* in = (UINT4*)dev->ring.JobIn;
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ static Error caamDoJob(struct DescStruct* desc)
|
|||||||
desc->desc[0] &= 0xFFFFFF80;
|
desc->desc[0] &= 0xFFFFFF80;
|
||||||
desc->desc[0] += desc->idx;
|
desc->desc[0] += desc->idx;
|
||||||
|
|
||||||
/* check input slot is avialable and then add */
|
/* check input slot is available and then add */
|
||||||
if (CAAM_READ(CAAM_BASE | 0x1014) > 0) {
|
if (CAAM_READ(CAAM_BASE | 0x1014) > 0) {
|
||||||
UINT4* in = (UINT4*)desc->caam->ring.JobIn;
|
UINT4* in = (UINT4*)desc->caam->ring.JobIn;
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ static int caamAddIO(struct DescStruct* desc, UINT4 options, UINT4 sz,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dataSz % align > 0) {
|
if (dataSz % align > 0) {
|
||||||
/* store potental overlap */
|
/* store potential overlap */
|
||||||
int tmpSz = dataSz % align;
|
int tmpSz = dataSz % align;
|
||||||
int add = (tmpSz < (align - desc->alignIdx)) ? tmpSz :
|
int add = (tmpSz < (align - desc->alignIdx)) ? tmpSz :
|
||||||
align - desc->alignIdx;
|
align - desc->alignIdx;
|
||||||
@@ -557,7 +557,7 @@ static Error caamBlob(struct DescStruct* desc)
|
|||||||
CAAM AES Operations
|
CAAM AES Operations
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* returns amount writin on success and negative value in error case.
|
/* returns amount written on success and negative value in error case.
|
||||||
* Is different from caamAddIO in that it only adds a single input buffer
|
* Is different from caamAddIO in that it only adds a single input buffer
|
||||||
* rather than multiple ones.
|
* rather than multiple ones.
|
||||||
*/
|
*/
|
||||||
@@ -786,7 +786,7 @@ static Error caamAes(struct DescStruct* desc)
|
|||||||
|
|
||||||
case CAAM_AESCTR:
|
case CAAM_AESCTR:
|
||||||
ofst = 0x00001000;
|
ofst = 0x00001000;
|
||||||
/* fall through because states are the same only the offest changes */
|
/* fall through because states are the same only the offset changes */
|
||||||
|
|
||||||
case CAAM_AESCBC:
|
case CAAM_AESCBC:
|
||||||
{
|
{
|
||||||
@@ -851,7 +851,7 @@ static Error caamAes(struct DescStruct* desc)
|
|||||||
align = 16;
|
align = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* indefinit loop for input/output buffers */
|
/* indefinite loop for input/output buffers */
|
||||||
desc->headIdx = desc->idx;
|
desc->headIdx = desc->idx;
|
||||||
desc->output = 0;
|
desc->output = 0;
|
||||||
offset = 0; /* store left over amount for output buffer */
|
offset = 0; /* store left over amount for output buffer */
|
||||||
@@ -1047,7 +1047,7 @@ static Error caamAead(struct DescStruct* desc)
|
|||||||
FIFOL_TYPE_AAD + desc->aadSz;
|
FIFOL_TYPE_AAD + desc->aadSz;
|
||||||
desc->desc[desc->idx++] = BSP_VirtualToPhysical(desc->aadSzBuf);
|
desc->desc[desc->idx++] = BSP_VirtualToPhysical(desc->aadSzBuf);
|
||||||
|
|
||||||
/* now set aadSz to unformated version for getting buffers */
|
/* now set aadSz to unformatted version for getting buffers */
|
||||||
if (desc->aadSz == 2) {
|
if (desc->aadSz == 2) {
|
||||||
unsigned char* pt = (unsigned char*)desc->aadSzBuf;
|
unsigned char* pt = (unsigned char*)desc->aadSzBuf;
|
||||||
desc->aadSz = (((UINT4)pt[0] & 0xFF) << 8) |
|
desc->aadSz = (((UINT4)pt[0] & 0xFF) << 8) |
|
||||||
@@ -1230,7 +1230,7 @@ static Error caamSha(struct DescStruct* desc, int start)
|
|||||||
ASP_FlushCaches((Address)desc->iv, ctxSz);
|
ASP_FlushCaches((Address)desc->iv, ctxSz);
|
||||||
/*Manage Context (current digest + 8 byte running message length)*/
|
/*Manage Context (current digest + 8 byte running message length)*/
|
||||||
if ((desc->state & CAAM_ALG_INIT) != CAAM_ALG_INIT) {
|
if ((desc->state & CAAM_ALG_INIT) != CAAM_ALG_INIT) {
|
||||||
/* dont load into the class 2 context register on inti.
|
/* don't load into the class 2 context register on inti.
|
||||||
Found that loading in caused context to not get set. */
|
Found that loading in caused context to not get set. */
|
||||||
if (desc->idx + 2 > MAX_DESC_SZ) {
|
if (desc->idx + 2 > MAX_DESC_SZ) {
|
||||||
return TransferFailed;
|
return TransferFailed;
|
||||||
@@ -1588,7 +1588,7 @@ static void HandleInterrupt(Address id)
|
|||||||
Value InterruptStatus = INTERRUPT_AtomicWrite(&local->InterruptStatus, 0);
|
Value InterruptStatus = INTERRUPT_AtomicWrite(&local->InterruptStatus, 0);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Loop through decriptors and try to dismiss them */
|
/* Loop through descriptors and try to dismiss them */
|
||||||
for (i = 0; i < DESC_COUNT; i++) {
|
for (i = 0; i < DESC_COUNT; i++) {
|
||||||
struct DescStruct* desc = &local->DescArray[i];
|
struct DescStruct* desc = &local->DescArray[i];
|
||||||
if (InterruptStatus & (1 << i)) {
|
if (InterruptStatus & (1 << i)) {
|
||||||
@@ -1650,7 +1650,7 @@ void InitCAAM(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* call interupt to make IORequests available */
|
/* call interrupt to make IORequests available */
|
||||||
caam.InterruptStatus = 0;
|
caam.InterruptStatus = 0;
|
||||||
INTERRUPT_InitCall(&caam.HandleInterruptCall,
|
INTERRUPT_InitCall(&caam.HandleInterruptCall,
|
||||||
&HandleInterrupt, "Start up CAAM IORequest");
|
&HandleInterrupt, "Start up CAAM IORequest");
|
||||||
@@ -1667,7 +1667,7 @@ void InitCAAM(void)
|
|||||||
|
|
||||||
/* set up job ring */
|
/* set up job ring */
|
||||||
|
|
||||||
/* @TODO create partion in physical memory for job rings
|
/* @TODO create partition in physical memory for job rings
|
||||||
current partion security is set to the default */
|
current partion security is set to the default */
|
||||||
for (i = 1; i < CAAM_PAGE_MAX; i++) {
|
for (i = 1; i < CAAM_PAGE_MAX; i++) {
|
||||||
ret = caamCreatePartition(i, i);
|
ret = caamCreatePartition(i, i);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* caam_init.c
|
/* caam_init.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
* Copyright (C) 2006-2017 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL.
|
* This file is part of wolfSSL.
|
||||||
*
|
*
|
||||||
@@ -124,7 +124,7 @@ int wc_caamInit()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WOLFSSL_MSG("Hashing not supported by CAAM");
|
WOLFSSL_MSG("Hashing not supported by CAAM");
|
||||||
return WC_CAAM_E;
|
return WC_HW_E;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ int wc_caamInit()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WOLFSSL_MSG("AES not supported by CAAM");
|
WOLFSSL_MSG("AES not supported by CAAM");
|
||||||
return WC_CAAM_E;
|
return WC_HW_E;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -178,14 +178,14 @@ void wc_caamWriteRegister(word32 reg, word32 value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* return 0 on success and WC_CAAM_E on failure. Can also return WC_CAAM_WAIT
|
/* return 0 on success and WC_HW_E on failure. Can also return WC_HW_WAIT_E
|
||||||
* in the case that the driver is waiting for a resource. */
|
* in the case that the driver is waiting for a resource. */
|
||||||
int wc_caamAddAndWait(Buffer* buf, word32 arg[4], word32 type)
|
int wc_caamAddAndWait(Buffer* buf, word32 arg[4], word32 type)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
if (caam == NULLIODevice) {
|
if (caam == NULLIODevice) {
|
||||||
WOLFSSL_MSG("Error CAAM IODevice not found! Bad password?");
|
WOLFSSL_MSG("Error CAAM IODevice not found! Bad password?");
|
||||||
return WC_CAAM_E;
|
return WC_HW_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = SynchronousSendIORequest(caam, type, (const Value*)arg, buf))
|
if ((ret = SynchronousSendIORequest(caam, type, (const Value*)arg, buf))
|
||||||
@@ -197,10 +197,10 @@ int wc_caamAddAndWait(Buffer* buf, word32 arg[4], word32 type)
|
|||||||
/* if waiting for resource or RNG return waiting */
|
/* if waiting for resource or RNG return waiting */
|
||||||
if (ret == Waiting) {
|
if (ret == Waiting) {
|
||||||
WOLFSSL_MSG("Waiting on CAAM driver");
|
WOLFSSL_MSG("Waiting on CAAM driver");
|
||||||
return WC_CAAM_WAIT;
|
return WC_HW_WAIT_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
return WC_CAAM_E;
|
return WC_HW_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)ret;
|
(void)ret;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* caam_sha.c
|
/* caam_sha.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
* Copyright (C) 2006-2017 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL.
|
* This file is part of wolfSSL.
|
||||||
*
|
*
|
||||||
|
@@ -1657,7 +1657,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* driver could be waiting for entropy */
|
/* driver could be waiting for entropy */
|
||||||
if (ret != WC_CAAM_WAIT) {
|
if (ret != WC_HW_WAIT_E) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
@@ -191,8 +191,8 @@ enum {
|
|||||||
|
|
||||||
ECC_PRIVATEONLY_E = -246, /* Invalid use of private only ECC key*/
|
ECC_PRIVATEONLY_E = -246, /* Invalid use of private only ECC key*/
|
||||||
EXTKEYUSAGE_E = -247, /* Bad Extended Key Usage value */
|
EXTKEYUSAGE_E = -247, /* Bad Extended Key Usage value */
|
||||||
WC_CAAM_E = -248, /* Error with CAAM use */
|
WC_HW_E = -248, /* Error with hardware crypto use */
|
||||||
WC_CAAM_WAIT = -249, /* CAAM Driver waiting on resource */
|
WC_HW_WAIT_E = -249, /* Hardware waiting on resource */
|
||||||
|
|
||||||
WC_LAST_E = -249, /* Update this to indicate last error */
|
WC_LAST_E = -249, /* Update this to indicate last error */
|
||||||
MIN_CODE_E = -300 /* errors -101 - -299 */
|
MIN_CODE_E = -300 /* errors -101 - -299 */
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* caam_driver.h
|
/* caam_driver.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
* Copyright (C) 2006-2017 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL.
|
* This file is part of wolfSSL.
|
||||||
*
|
*
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* wolfcaam.h
|
/* wolfcaam.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
* Copyright (C) 2006-2017 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL.
|
* This file is part of wolfSSL.
|
||||||
*
|
*
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* wolfcaam_sha.h
|
/* wolfcaam_sha.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
* Copyright (C) 2006-2017 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL.
|
* This file is part of wolfSSL.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user