mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Merge pull request #7469 from douzzer/20240424-fix-ports-whitespace
20240424-fix-ports-whitespace
This commit is contained in:
@@ -23,15 +23,15 @@
|
|||||||
* See ESP32 Technical Reference Manual - RSA Accelerator Chapter
|
* See ESP32 Technical Reference Manual - RSA Accelerator Chapter
|
||||||
*
|
*
|
||||||
* esp_mp_exptmod() Large Number Modular Exponentiation Z = X^Y mod M
|
* esp_mp_exptmod() Large Number Modular Exponentiation Z = X^Y mod M
|
||||||
* esp_mp_mulmod() Large Number Modular Multiplication Z = X × Y mod M
|
* esp_mp_mulmod() Large Number Modular Multiplication Z = X * Y mod M
|
||||||
* esp_mp_mul() Large Number Multiplication Z = X × Y
|
* esp_mp_mul() Large Number Multiplication Z = X * Y
|
||||||
*
|
*
|
||||||
* The ESP32 RSA Accelerator supports operand lengths of:
|
* The ESP32 RSA Accelerator supports operand lengths of:
|
||||||
* N ∈ {512, 1024, 1536, 2048, 2560, 3072, 3584, 4096} bits. The bit length
|
* N in {512, 1024, 1536, 2048, 2560, 3072, 3584, 4096} bits. The bit length
|
||||||
* of arguments Z, X, Y , M, and r can be any one from the N set, but all
|
* of arguments Z, X, Y , M, and r can be any one from the N set, but all
|
||||||
* numbers in a calculation must be of the same length.
|
* numbers in a calculation must be of the same length.
|
||||||
*
|
*
|
||||||
* The bit length of M′ is always 32.
|
* The bit length of M' is always 32.
|
||||||
*
|
*
|
||||||
* Also, beware: "we have uint32_t == unsigned long for both Xtensa and RISC-V"
|
* Also, beware: "we have uint32_t == unsigned long for both Xtensa and RISC-V"
|
||||||
* see https://github.com/espressif/esp-idf/issues/9511#issuecomment-1207342464
|
* see https://github.com/espressif/esp-idf/issues/9511#issuecomment-1207342464
|
||||||
@@ -1285,8 +1285,8 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z)
|
|||||||
Zs = Xs + Ys;
|
Zs = Xs + Ys;
|
||||||
|
|
||||||
/* RSA Accelerator only supports Large Number Multiplication
|
/* RSA Accelerator only supports Large Number Multiplication
|
||||||
* with operand length N = 32 × x,
|
* with operand length N = 32 * x,
|
||||||
* where x ∈ {1, 2, 3, . . . , 64} */
|
* where x in {1, 2, 3, . . . , 64} */
|
||||||
if (Xs > 64 || Ys > 64) {
|
if (Xs > 64 || Ys > 64) {
|
||||||
return MP_HW_FALLBACK; /* TODO add count metric on size fallback */
|
return MP_HW_FALLBACK; /* TODO add count metric on size fallback */
|
||||||
}
|
}
|
||||||
@@ -1334,7 +1334,7 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z)
|
|||||||
|
|
||||||
/* Y (left-extend)
|
/* Y (left-extend)
|
||||||
* Accelerator supports large-number multiplication with only
|
* Accelerator supports large-number multiplication with only
|
||||||
* four operand lengths of N ∈ {512, 1024, 1536, 2048} */
|
* four operand lengths of N in {512, 1024, 1536, 2048} */
|
||||||
left_pad_offset = maxWords_sz << 2;
|
left_pad_offset = maxWords_sz << 2;
|
||||||
if (left_pad_offset <= 512 >> 3) {
|
if (left_pad_offset <= 512 >> 3) {
|
||||||
left_pad_offset = 512 >> 3; /* 64 bytes (16 words) */
|
left_pad_offset = 512 >> 3; /* 64 bytes (16 words) */
|
||||||
@@ -1583,10 +1583,10 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z)
|
|||||||
* 0 => no interrupt; 1 => interrupt on completion. */
|
* 0 => no interrupt; 1 => interrupt on completion. */
|
||||||
DPORT_REG_WRITE(RSA_INT_ENA_REG, 0);
|
DPORT_REG_WRITE(RSA_INT_ENA_REG, 0);
|
||||||
/* 2. Write number of words required for result. */
|
/* 2. Write number of words required for result. */
|
||||||
/* see 21.3.3 Write (/N16 − 1) to the RSA_MODE_REG register */
|
/* see 21.3.3 Write (/N16 - 1) to the RSA_MODE_REG register */
|
||||||
DPORT_REG_WRITE(RSA_MODE_REG, (hwWords_sz * 2 - 1));
|
DPORT_REG_WRITE(RSA_MODE_REG, (hwWords_sz * 2 - 1));
|
||||||
|
|
||||||
/* 3. Write Xi and Yi for ∈ {0, 1, . . . , n − 1} to memory blocks
|
/* 3. Write Xi and Yi for {0, 1, . . . , n - 1} to memory blocks
|
||||||
* RSA_X_MEM and RSA_Z_MEM
|
* RSA_X_MEM and RSA_Z_MEM
|
||||||
* Maximum is 64 words (64*8*4 = 2048 bits) */
|
* Maximum is 64 words (64*8*4 = 2048 bits) */
|
||||||
esp_mpint_to_memblock(RSA_X_MEM,
|
esp_mpint_to_memblock(RSA_X_MEM,
|
||||||
@@ -1796,7 +1796,7 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z)
|
|||||||
*
|
*
|
||||||
* See 24.3.3 of the ESP32 Technical Reference Manual
|
* See 24.3.3 of the ESP32 Technical Reference Manual
|
||||||
*
|
*
|
||||||
* Z = X × Y mod M */
|
* Z = X * Y mod M */
|
||||||
int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z)
|
int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z)
|
||||||
{
|
{
|
||||||
struct esp_mp_helper mph[1]; /* we'll save some values in this mp helper */
|
struct esp_mp_helper mph[1]; /* we'll save some values in this mp helper */
|
||||||
@@ -1839,7 +1839,7 @@ int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z)
|
|||||||
/* do we have an even moduli? */
|
/* do we have an even moduli? */
|
||||||
if ((M->dp[0] & 1) == 0) {
|
if ((M->dp[0] & 1) == 0) {
|
||||||
#ifndef NO_ESP_MP_MUL_EVEN_ALT_CALC
|
#ifndef NO_ESP_MP_MUL_EVEN_ALT_CALC
|
||||||
/* Z = X × Y mod M in mixed HW & SW*/
|
/* Z = X * Y mod M in mixed HW & SW*/
|
||||||
ret = esp_mp_mul(X, Y, tmpZ); /* HW X * Y */
|
ret = esp_mp_mul(X, Y, tmpZ); /* HW X * Y */
|
||||||
if (ret == MP_OKAY) {
|
if (ret == MP_OKAY) {
|
||||||
/* z = tmpZ mod M, 0 <= Z < M */
|
/* z = tmpZ mod M, 0 <= Z < M */
|
||||||
@@ -1973,13 +1973,13 @@ int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z)
|
|||||||
* or until the RSA_INTR interrupt is generated.
|
* or until the RSA_INTR interrupt is generated.
|
||||||
* (Or until the INTER interrupt is generated.)
|
* (Or until the INTER interrupt is generated.)
|
||||||
* 6. Write 1 to RSA_INTERRUPT_REG to clear the interrupt.
|
* 6. Write 1 to RSA_INTERRUPT_REG to clear the interrupt.
|
||||||
* 7. Write Yi (i ∈ [0, n) ∩ N) to RSA_X_MEM
|
* 7. Write Yi (i in [0, n) intersect N) to RSA_X_MEM
|
||||||
* Users need to write to the memory block only according to the length
|
* Users need to write to the memory block only according to the length
|
||||||
* of the number. Data beyond this length is ignored.
|
* of the number. Data beyond this length is ignored.
|
||||||
* 8. Write 1 to RSA_MULT_START_REG
|
* 8. Write 1 to RSA_MULT_START_REG
|
||||||
* 9. Wait for the second operation to be completed.
|
* 9. Wait for the second operation to be completed.
|
||||||
* Poll INTERRUPT_REG until it reads 1.
|
* Poll INTERRUPT_REG until it reads 1.
|
||||||
* 10. Read the Zi (i ∈ [0, n) ∩ N) from RSA_Z_MEM
|
* 10. Read the Zi (i in [0, n) intersect N) from RSA_Z_MEM
|
||||||
* 11. Write 1 to RSA_INTERUPT_REG to clear the interrupt.
|
* 11. Write 1 to RSA_INTERUPT_REG to clear the interrupt.
|
||||||
*
|
*
|
||||||
* post: Release the HW engine
|
* post: Release the HW engine
|
||||||
@@ -2500,15 +2500,15 @@ int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z)
|
|||||||
* ESP32S3, Section 20.3.1, https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf
|
* ESP32S3, Section 20.3.1, https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf
|
||||||
*
|
*
|
||||||
* The operation is based on Montgomery multiplication. Aside from the
|
* The operation is based on Montgomery multiplication. Aside from the
|
||||||
* arguments X, Y , and M, two additional ones are needed —r and M′
|
* arguments X, Y , and M, two additional ones are needed -r and M'
|
||||||
.* These arguments are calculated in advance by software.
|
.* These arguments are calculated in advance by software.
|
||||||
.*
|
.*
|
||||||
.* The RSA Accelerator supports operand lengths of N ∈ {512, 1024, 1536, 2048,
|
.* The RSA Accelerator supports operand lengths of N in {512, 1024, 1536, 2048,
|
||||||
.* 2560, 3072, 3584, 4096} bits on the ESP32 and N ∈ [32, 4096] bits
|
.* 2560, 3072, 3584, 4096} bits on the ESP32 and N in [32, 4096] bits
|
||||||
* on the ESP32s3.
|
* on the ESP32s3.
|
||||||
.* The bit length of arguments Z, X, Y , M, and r can be any one from
|
.* The bit length of arguments Z, X, Y , M, and r can be any one from
|
||||||
* the N set, but all numbers in a calculation must be of the same length.
|
* the N set, but all numbers in a calculation must be of the same length.
|
||||||
.* The bit length of M′ is always 32.
|
.* The bit length of M' is always 32.
|
||||||
.*
|
.*
|
||||||
* Z = (X ^ Y) mod M : Espressif generic notation
|
* Z = (X ^ Y) mod M : Espressif generic notation
|
||||||
* Y = (G ^ X) mod P : wolfSSL DH reference notation */
|
* Y = (G ^ X) mod P : wolfSSL DH reference notation */
|
||||||
|
@@ -59,7 +59,7 @@ static int gdevId = 7890; /* initial dev Id for Crypt Callback */
|
|||||||
defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)
|
defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)
|
||||||
FSPSM_ST *gCbCtx[MAX_FSPSM_CBINDEX];
|
FSPSM_ST *gCbCtx[MAX_FSPSM_CBINDEX];
|
||||||
#elif defined(WOLFSSL_RENESAS_TSIP_TLS) || \
|
#elif defined(WOLFSSL_RENESAS_TSIP_TLS) || \
|
||||||
defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY)
|
defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY)
|
||||||
#define FSPSM_ST TsipUserCtx;
|
#define FSPSM_ST TsipUserCtx;
|
||||||
#define MAX_FSPSM_CBINDEX 5
|
#define MAX_FSPSM_CBINDEX 5
|
||||||
TsipUserCtx *gCbCtx[MAX_FSPSM_CBINDEX];
|
TsipUserCtx *gCbCtx[MAX_FSPSM_CBINDEX];
|
||||||
|
@@ -4047,20 +4047,22 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|||||||
|
|
||||||
#ifdef WOLFSSL_RENESAS_TSIP_CRYPT_DEBUG
|
#ifdef WOLFSSL_RENESAS_TSIP_CRYPT_DEBUG
|
||||||
|
|
||||||
/* err
|
#if 0
|
||||||
* e_tsip_err
|
/* this is here for documentation purposes. */
|
||||||
|
enum e_tsip_err {
|
||||||
TSIP_SUCCESS = 0,
|
TSIP_SUCCESS = 0,
|
||||||
TSIP_ERR_SELF_CHECK1, // Self-check 1 fail or TSIP function internal err.
|
TSIP_ERR_SELF_CHECK1, /* Self-check 1 fail or TSIP function internal err. */
|
||||||
TSIP_ERR_RESOURCE_CONFLICT, // A resource conflict occurred.
|
TSIP_ERR_RESOURCE_CONFLICT, /* A resource conflict occurred. */
|
||||||
TSIP_ERR_SELF_CHECK2, // Self-check 2 fail.
|
TSIP_ERR_SELF_CHECK2, /* Self-check 2 fail. */
|
||||||
TSIP_ERR_KEY_SET, // setting the invalid key.
|
TSIP_ERR_KEY_SET, /* setting the invalid key. */
|
||||||
TSIP_ERR_AUTHENTICATION, // Authentication failed.
|
TSIP_ERR_AUTHENTICATION, /* Authentication failed. */
|
||||||
TSIP_ERR_CALLBACK_UNREGIST, // Callback function is not registered.
|
TSIP_ERR_CALLBACK_UNREGIST, /* Callback function is not registered. */
|
||||||
TSIP_ERR_PARAMETER, // Illegal Input data.
|
TSIP_ERR_PARAMETER, /* Illegal Input data. */
|
||||||
TSIP_ERR_PROHIBIT_FUNCTION, // An invalid function call occurred.
|
TSIP_ERR_PROHIBIT_FUNCTION, /* An invalid function call occurred. */
|
||||||
* TSIP_RESUME_FIRMWARE_GENERATE_MAC,
|
TSIP_RESUME_FIRMWARE_GENERATE_MAC
|
||||||
// There is a continuation of R_TSIP_GenerateFirmwareMAC.
|
/* There is a continuation of R_TSIP_GenerateFirmwareMAC. */
|
||||||
*/
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static void hexdump(const uint8_t* in, uint32_t len)
|
static void hexdump(const uint8_t* in, uint32_t len)
|
||||||
{
|
{
|
||||||
|
@@ -40,7 +40,7 @@ void wc_Afalg_SockAddr(struct sockaddr_alg* in, const char* type, const char* na
|
|||||||
int nameSz = (int)XSTRLEN(name) + 1; /* +1 for null terminator */
|
int nameSz = (int)XSTRLEN(name) + 1; /* +1 for null terminator */
|
||||||
|
|
||||||
if (typeSz > (int)sizeof(in->salg_type) ||
|
if (typeSz > (int)sizeof(in->salg_type) ||
|
||||||
nameSz > (int)sizeof(in->salg_name)) {
|
nameSz > (int)sizeof(in->salg_name)) {
|
||||||
WOLFSSL_MSG("type or name was too large");
|
WOLFSSL_MSG("type or name was too large");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -136,7 +136,7 @@ int atmel_get_random_number(uint32_t count, uint8_t* rand_out)
|
|||||||
|
|
||||||
int atmel_get_random_block(unsigned char* output, unsigned int sz)
|
int atmel_get_random_block(unsigned char* output, unsigned int sz)
|
||||||
{
|
{
|
||||||
return atmel_get_random_number((uint32_t)sz, (uint8_t*)output);
|
return atmel_get_random_number((uint32_t)sz, (uint8_t*)output);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WOLFSSL_ATMEL) && defined(WOLFSSL_ATMEL_TIME)
|
#if defined(WOLFSSL_ATMEL) && defined(WOLFSSL_ATMEL_TIME)
|
||||||
@@ -148,12 +148,12 @@ long atmel_get_curr_time_and_date(long* tm)
|
|||||||
{
|
{
|
||||||
long rt = 0;
|
long rt = 0;
|
||||||
|
|
||||||
/* Get current time */
|
/* Get current time */
|
||||||
struct rtc_calendar_time rtcTime;
|
struct rtc_calendar_time rtcTime;
|
||||||
const int monthDay[] = {0,31,59,90,120,151,181,212,243,273,304,334};
|
const int monthDay[] = {0,31,59,90,120,151,181,212,243,273,304,334};
|
||||||
int month, year, yearLeap;
|
int month, year, yearLeap;
|
||||||
|
|
||||||
rtc_calendar_get_time(_rtc_instance[0], &rtcTime);
|
rtc_calendar_get_time(_rtc_instance[0], &rtcTime);
|
||||||
|
|
||||||
/* Convert rtc_calendar_time to seconds since UTC */
|
/* Convert rtc_calendar_time to seconds since UTC */
|
||||||
month = rtcTime.month % 12;
|
month = rtcTime.month % 12;
|
||||||
@@ -359,7 +359,7 @@ int atmel_get_enc_key_default(byte* enckey, word16 keysize)
|
|||||||
static int atmel_init_enc_key(void)
|
static int atmel_init_enc_key(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint8_t read_key[ATECC_KEY_SIZE];
|
uint8_t read_key[ATECC_KEY_SIZE];
|
||||||
uint8_t writeBlock = 0;
|
uint8_t writeBlock = 0;
|
||||||
uint8_t writeOffset = 0;
|
uint8_t writeOffset = 0;
|
||||||
int slotId;
|
int slotId;
|
||||||
@@ -388,7 +388,7 @@ static int atmel_init_enc_key(void)
|
|||||||
ForceZero(read_key, sizeof(read_key));
|
ForceZero(read_key, sizeof(read_key));
|
||||||
ret = atmel_ecc_translate_err(ret);
|
ret = atmel_ecc_translate_err(ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -129,7 +129,7 @@ static Error caamDebugDesc(struct DescStruct* desc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//D0JQCR_LS
|
/* D0JQCR_LS */
|
||||||
printf("Next command to be executed = 0x%08X\n", CAAM_READ(0x8804));
|
printf("Next command to be executed = 0x%08X\n", CAAM_READ(0x8804));
|
||||||
printf("Desc = 0x%08X\n", desc->caam->ring.Desc);
|
printf("Desc = 0x%08X\n", desc->caam->ring.Desc);
|
||||||
|
|
||||||
|
@@ -1641,8 +1641,9 @@ int io_close_ocb(resmgr_context_t *ctp, void *reserved, RESMGR_OCB_T *ocb)
|
|||||||
#if 0
|
#if 0
|
||||||
static int getSupported(char* in)
|
static int getSupported(char* in)
|
||||||
{
|
{
|
||||||
//printf("CAAM Status [0x%8.8x] = 0x%8.8x\n",
|
/* printf("CAAM Status [0x%8.8x] = 0x%8.8x\n",
|
||||||
// CAAM_STATUS, WC_CAAM_READ(CAAM_STATUS));
|
* CAAM_STATUS, WC_CAAM_READ(CAAM_STATUS));
|
||||||
|
*/
|
||||||
printf("CAAM Version MS Register [0x%8.8x] = 0x%8.8x\n",
|
printf("CAAM Version MS Register [0x%8.8x] = 0x%8.8x\n",
|
||||||
CAAM_VERSION_MS, CAAM_READ(CAAM_VERSION_MS));
|
CAAM_VERSION_MS, CAAM_READ(CAAM_VERSION_MS));
|
||||||
printf("CAAM Version LS Register [0x%8.8x] = 0x%8.8x\n",
|
printf("CAAM Version LS Register [0x%8.8x] = 0x%8.8x\n",
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include <wolfssl/wolfcrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
|
|
||||||
#if defined(WOLFSSL_CAAM) && defined(WOLFSSL_CAAM_HASH) \
|
#if defined(WOLFSSL_CAAM) && defined(WOLFSSL_CAAM_HASH) \
|
||||||
&& !defined(WOLFSSL_IMXRT1170_CAAM)
|
&& !defined(WOLFSSL_IMXRT1170_CAAM)
|
||||||
|
|
||||||
#include <wolfssl/wolfcrypt/logging.h>
|
#include <wolfssl/wolfcrypt/logging.h>
|
||||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||||
|
@@ -77,7 +77,7 @@ block cipher mechanism that uses n-bit binary string parameter key with 128-bits
|
|||||||
#define WOLFSSL_MISC_INCLUDED
|
#define WOLFSSL_MISC_INCLUDED
|
||||||
#define WOLFSSL_HAVE_MIN
|
#define WOLFSSL_HAVE_MIN
|
||||||
#define WOLFSSL_HAVE_MAX
|
#define WOLFSSL_HAVE_MAX
|
||||||
// #include <wolfcrypt/src/misc.c>
|
/* #include <wolfcrypt/src/misc.c> */
|
||||||
#endif
|
#endif
|
||||||
/* This routine performs a left circular arithmetic shift of <x> by <y> value. */
|
/* This routine performs a left circular arithmetic shift of <x> by <y> value. */
|
||||||
|
|
||||||
|
@@ -144,9 +144,9 @@ typedef void (*IntelQaFreeFunc)(struct IntelQaDev*);
|
|||||||
|
|
||||||
/* QuickAssist device */
|
/* QuickAssist device */
|
||||||
typedef struct IntelQaDev {
|
typedef struct IntelQaDev {
|
||||||
CpaInstanceHandle handle;
|
CpaInstanceHandle handle;
|
||||||
int devId;
|
int devId;
|
||||||
void* heap;
|
void* heap;
|
||||||
|
|
||||||
/* callback return info */
|
/* callback return info */
|
||||||
int ret;
|
int ret;
|
||||||
@@ -220,7 +220,7 @@ static int IntelQaGetCyInstanceCount(void);
|
|||||||
|
|
||||||
#ifdef WOLF_CRYPTO_CB
|
#ifdef WOLF_CRYPTO_CB
|
||||||
static int IntelQaSymSync_CryptoDevCb(int, struct wc_CryptoInfo*,
|
static int IntelQaSymSync_CryptoDevCb(int, struct wc_CryptoInfo*,
|
||||||
void*);
|
void*);
|
||||||
#endif /* WOLF_CRYPTO_CB */
|
#endif /* WOLF_CRYPTO_CB */
|
||||||
|
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ int IntelQaHardwareStart(const char* process_name, int limitDevAccess)
|
|||||||
|
|
||||||
#ifdef QAT_DEBUG
|
#ifdef QAT_DEBUG
|
||||||
/* optionally enable debugging */
|
/* optionally enable debugging */
|
||||||
//osalLogLevelSet(8);
|
/* osalLogLevelSet(8); */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status = cpaCyGetNumInstances(&g_numInstances);
|
status = cpaCyGetNumInstances(&g_numInstances);
|
||||||
|
@@ -1573,7 +1573,7 @@ int wolfSSL_CTX_iotsafe_enable(WOLFSSL_CTX *ctx)
|
|||||||
WOLFSSL_MSG("ECC callbacks set to IoT_safe interface");
|
WOLFSSL_MSG("ECC callbacks set to IoT_safe interface");
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_RSA
|
#ifndef NO_RSA
|
||||||
/* wolfSSL_CTX_SetRsaSignCb(wolfIoT_rsa_sign); // TODO: RSA callbacks */
|
/* wolfSSL_CTX_SetRsaSignCb(wolfIoT_rsa_sign); */ /* TODO: RSA callbacks */
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
|
@@ -56,7 +56,7 @@ void dbg_dumphex(const char *identifier, const uint8_t* pdata, uint32_t plen);
|
|||||||
#endif /* MAXQ_DEBUG */
|
#endif /* MAXQ_DEBUG */
|
||||||
|
|
||||||
#if defined(USE_WINDOWS_API)
|
#if defined(USE_WINDOWS_API)
|
||||||
# define maxq_CryptHwMutexTryLock() (0)
|
# define maxq_CryptHwMutexTryLock() 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AES_KEY_ID_START (0x2000)
|
#define AES_KEY_ID_START (0x2000)
|
||||||
|
@@ -266,7 +266,7 @@ int se050_hash_copy(SE050_HASH_Context* src, SE050_HASH_Context* dst)
|
|||||||
|
|
||||||
int se050_hash_update(SE050_HASH_Context* se050Ctx, const byte* data, word32 len)
|
int se050_hash_update(SE050_HASH_Context* se050Ctx, const byte* data, word32 len)
|
||||||
{
|
{
|
||||||
byte* tmp = NULL;
|
byte* tmp = NULL;
|
||||||
|
|
||||||
if (se050Ctx == NULL || (len > 0 && data == NULL)) {
|
if (se050Ctx == NULL || (len > 0 && data == NULL)) {
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
@@ -539,7 +539,7 @@ int wolfSSL_STSAFE_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
|
|||||||
&otherKeyY[0], (word32*)&otherKeyY_len);
|
&otherKeyY[0], (word32*)&otherKeyY_len);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
/* Compute shared secret */
|
/* Compute shared secret */
|
||||||
*info->pk.ecdh.outlen = 0;
|
*info->pk.ecdh.outlen = 0;
|
||||||
rc = stsafe_interface_shared_secret(
|
rc = stsafe_interface_shared_secret(
|
||||||
#ifdef WOLFSSL_STSAFE_TAKES_SLOT
|
#ifdef WOLFSSL_STSAFE_TAKES_SLOT
|
||||||
STSAFE_A_SLOT_0,
|
STSAFE_A_SLOT_0,
|
||||||
|
@@ -203,7 +203,7 @@ WOLFSSL_API int wc_Md5GetHash(Md5* md5, byte* hash)
|
|||||||
|
|
||||||
WOLFSSL_API int wc_Md5Copy(Md5* src, Md5* dst)
|
WOLFSSL_API int wc_Md5Copy(Md5* src, Md5* dst)
|
||||||
{
|
{
|
||||||
return hashCopy((wolfssl_TI_Hash *)src, (wolfssl_TI_Hash *)dst);
|
return hashCopy((wolfssl_TI_Hash *)src, (wolfssl_TI_Hash *)dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
WOLFSSL_API int wc_Md5Hash(const byte*data, word32 len, byte* hash)
|
WOLFSSL_API int wc_Md5Hash(const byte*data, word32 len, byte* hash)
|
||||||
@@ -249,7 +249,7 @@ WOLFSSL_API int wc_ShaGetHash(Sha* sha, byte* hash)
|
|||||||
|
|
||||||
WOLFSSL_API int wc_ShaCopy(Sha* src, Sha* dst)
|
WOLFSSL_API int wc_ShaCopy(Sha* src, Sha* dst)
|
||||||
{
|
{
|
||||||
return hashCopy((wolfssl_TI_Hash *)src, (wolfssl_TI_Hash *)dst);
|
return hashCopy((wolfssl_TI_Hash *)src, (wolfssl_TI_Hash *)dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
WOLFSSL_API int wc_ShaHash(const byte*data, word32 len, byte* hash)
|
WOLFSSL_API int wc_ShaHash(const byte*data, word32 len, byte* hash)
|
||||||
|
@@ -87,9 +87,9 @@ static WC_INLINE int aligned_xmalloc(byte** buf, byte** aligned, void* heap, wor
|
|||||||
|
|
||||||
static WC_INLINE void aligned_xfree(void* buf, void* heap)
|
static WC_INLINE void aligned_xfree(void* buf, void* heap)
|
||||||
{
|
{
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return;
|
return;
|
||||||
XFREE(buf, heap, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(buf, heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WC_INLINE int check_keysize(word32 len)
|
static WC_INLINE int check_keysize(word32 len)
|
||||||
|
@@ -78,7 +78,7 @@ int wc_InitXsecure(wc_Xsecure* xsec)
|
|||||||
/**
|
/**
|
||||||
Convert Xilinx specific error to string
|
Convert Xilinx specific error to string
|
||||||
|
|
||||||
err The error to convert
|
err The error to convert
|
||||||
|
|
||||||
Returns a pointer to a string (always, never returns NULL).
|
Returns a pointer to a string (always, never returns NULL).
|
||||||
*/
|
*/
|
||||||
|
@@ -200,7 +200,7 @@ enum {
|
|||||||
** Even if HW is enabled, do not run HW math tests. See HW_MATH_ENABLED.
|
** Even if HW is enabled, do not run HW math tests. See HW_MATH_ENABLED.
|
||||||
**
|
**
|
||||||
** NO_ESP_MP_MUL_EVEN_ALT_CALC
|
** NO_ESP_MP_MUL_EVEN_ALT_CALC
|
||||||
** Used during Z = X × Y mod M
|
** Used during Z = X * Y mod M
|
||||||
** By default, even moduli use a two step HW esp_mp_mul with SW mp_mod.
|
** By default, even moduli use a two step HW esp_mp_mul with SW mp_mod.
|
||||||
** Enable this to instead fall back to pure software mp_mulmod.
|
** Enable this to instead fall back to pure software mp_mulmod.
|
||||||
**
|
**
|
||||||
@@ -820,8 +820,8 @@ extern "C"
|
|||||||
/* Non-FIFO read may not be needed in chip revision v3.0. */
|
/* Non-FIFO read may not be needed in chip revision v3.0. */
|
||||||
#define ESP_EM__READ_NON_FIFO_REG {DPORT_SEQUENCE_REG_READ(0x3FF40078);}
|
#define ESP_EM__READ_NON_FIFO_REG {DPORT_SEQUENCE_REG_READ(0x3FF40078);}
|
||||||
|
|
||||||
/* When the CPU frequency is 160 MHz, add six <EFBFBD>nop<EFBFBD> between two consecutive
|
/* When the CPU frequency is 160 MHz, add six nops between two consecutive
|
||||||
** FIFO reads. When the CPU frequency is 240 MHz, add seven <EFBFBD>nop<EFBFBD> between
|
** FIFO reads. When the CPU frequency is 240 MHz, add seven nops between
|
||||||
** two consecutive FIFO reads. See 3.16 */
|
** two consecutive FIFO reads. See 3.16 */
|
||||||
#if defined(CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80)
|
#if defined(CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80)
|
||||||
#define ESP_EM__3_16 { \
|
#define ESP_EM__3_16 { \
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#if defined(WOLFSSL_IMX6_CAAM) || defined(WOLFSSL_IMX6_CAAM_RNG) || \
|
#if defined(WOLFSSL_IMX6_CAAM) || defined(WOLFSSL_IMX6_CAAM_RNG) || \
|
||||||
defined(WOLFSSL_QNX_CAAM) || defined(WOLFSSL_SECO_CAAM) || \
|
defined(WOLFSSL_QNX_CAAM) || defined(WOLFSSL_SECO_CAAM) || \
|
||||||
defined(WOLFSSL_IMXRT1170_CAAM)
|
defined(WOLFSSL_IMXRT1170_CAAM)
|
||||||
|
|
||||||
|
|
||||||
/* unique devId for CAAM use on crypto callbacks */
|
/* unique devId for CAAM use on crypto callbacks */
|
||||||
@@ -75,9 +75,9 @@ WOLFSSL_LOCAL int caamWriteToPartition(CAAM_ADDRESS addr, const unsigned char* i
|
|||||||
WOLFSSL_LOCAL int caamReadPartition(CAAM_ADDRESS addr, unsigned char* out, int outSz);
|
WOLFSSL_LOCAL int caamReadPartition(CAAM_ADDRESS addr, unsigned char* out, int outSz);
|
||||||
|
|
||||||
WOLFSSL_API int wc_caamOpenBlob(byte* data, word32 dataSz, byte* out,
|
WOLFSSL_API int wc_caamOpenBlob(byte* data, word32 dataSz, byte* out,
|
||||||
word32* outSz);
|
word32* outSz);
|
||||||
WOLFSSL_API int wc_caamCreateBlob(byte* data, word32 dataSz, byte* out,
|
WOLFSSL_API int wc_caamCreateBlob(byte* data, word32 dataSz, byte* out,
|
||||||
word32* outSz);
|
word32* outSz);
|
||||||
|
|
||||||
WOLFSSL_API int wc_caamOpenBlob_ex(byte* data, word32 dataSz, byte* out,
|
WOLFSSL_API int wc_caamOpenBlob_ex(byte* data, word32 dataSz, byte* out,
|
||||||
word32* outSz, int type, byte* mod, word32 modSz);
|
word32* outSz, int type, byte* mod, word32 modSz);
|
||||||
@@ -97,7 +97,7 @@ WOLFSSL_API int wc_caamCoverKey(byte* in, word32 inSz, byte* out, word32* outSz,
|
|||||||
#define WC_CAAM_MAX_ENTROPY 44
|
#define WC_CAAM_MAX_ENTROPY 44
|
||||||
|
|
||||||
#if !defined(WOLFSSL_QNX_CAAM) && !defined(WOLFSSL_SECO_CAAM) && \
|
#if !defined(WOLFSSL_QNX_CAAM) && !defined(WOLFSSL_SECO_CAAM) && \
|
||||||
!defined(WOLFSSL_IMXRT1170_CAAM)
|
!defined(WOLFSSL_IMXRT1170_CAAM)
|
||||||
WOLFSSL_API int wc_caamSetResource(IODevice ioDev);
|
WOLFSSL_API int wc_caamSetResource(IODevice ioDev);
|
||||||
#ifndef WC_CAAM_READ
|
#ifndef WC_CAAM_READ
|
||||||
#define WC_CAAM_READ(reg) wc_caamReadRegister((reg))
|
#define WC_CAAM_READ(reg) wc_caamReadRegister((reg))
|
||||||
|
@@ -34,13 +34,13 @@ int ksdk_port_init(void);
|
|||||||
|
|
||||||
/* software algorithm, by wolfcrypt */
|
/* software algorithm, by wolfcrypt */
|
||||||
#if defined(FREESCALE_LTC_TFM)
|
#if defined(FREESCALE_LTC_TFM)
|
||||||
int wolfcrypt_mp_mul(mp_int *A, mp_int *B, mp_int *C);
|
int wolfcrypt_mp_mul(mp_int *A, mp_int *B, mp_int *C);
|
||||||
int wolfcrypt_mp_mod(mp_int *a, mp_int *b, mp_int *c);
|
int wolfcrypt_mp_mod(mp_int *a, mp_int *b, mp_int *c);
|
||||||
int wolfcrypt_mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
int wolfcrypt_mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
||||||
int wolfcrypt_mp_mod(mp_int *a, mp_int *b, mp_int *c);
|
int wolfcrypt_mp_mod(mp_int *a, mp_int *b, mp_int *c);
|
||||||
int wolfcrypt_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
|
int wolfcrypt_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
|
||||||
int wolfcrypt_mp_exptmod(mp_int *G, mp_int *X, mp_int *P, mp_int *Y);
|
int wolfcrypt_mp_exptmod(mp_int *G, mp_int *X, mp_int *P, mp_int *Y);
|
||||||
int wolfcrypt_mp_prime_is_prime_ex(mp_int* a, int t, int* result, WC_RNG* rng);
|
int wolfcrypt_mp_prime_is_prime_ex(mp_int* a, int t, int* result, WC_RNG* rng);
|
||||||
|
|
||||||
/* Exported mp_mulmod function */
|
/* Exported mp_mulmod function */
|
||||||
int mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
int mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
||||||
@@ -48,40 +48,40 @@ int ksdk_port_init(void);
|
|||||||
#endif /* FREESCALE_LTC_TFM */
|
#endif /* FREESCALE_LTC_TFM */
|
||||||
|
|
||||||
#if defined(FREESCALE_LTC_ECC)
|
#if defined(FREESCALE_LTC_ECC)
|
||||||
#include "fsl_ltc.h"
|
#include "fsl_ltc.h"
|
||||||
|
|
||||||
typedef enum _fsl_ltc_ecc_coordinate_system
|
typedef enum _fsl_ltc_ecc_coordinate_system
|
||||||
{
|
{
|
||||||
kLTC_Weierstrass = 0U, /*< Point coordinates on an elliptic curve in Weierstrass form */
|
kLTC_Weierstrass = 0U, /*< Point coordinates on an elliptic curve in Weierstrass form */
|
||||||
kLTC_Curve25519 = 1U, /*< Point coordinates on an Curve25519 elliptic curve in Montgomery form */
|
kLTC_Curve25519 = 1U, /*< Point coordinates on an Curve25519 elliptic curve in Montgomery form */
|
||||||
kLTC_Ed25519 = 2U, /*< Point coordinates on an Ed25519 elliptic curve in twisted Edwards form */
|
kLTC_Ed25519 = 2U, /*< Point coordinates on an Ed25519 elliptic curve in twisted Edwards form */
|
||||||
} fsl_ltc_ecc_coordinate_system_t;
|
} fsl_ltc_ecc_coordinate_system_t;
|
||||||
|
|
||||||
int wc_ecc_point_add(ecc_point *mG, ecc_point *mQ, ecc_point *mR, mp_int *m);
|
int wc_ecc_point_add(ecc_point *mG, ecc_point *mQ, ecc_point *mR, mp_int *m);
|
||||||
|
|
||||||
#ifdef HAVE_CURVE25519
|
#ifdef HAVE_CURVE25519
|
||||||
int nxp_ltc_curve25519(ECPoint *q, const byte *n, const ECPoint *p, fsl_ltc_ecc_coordinate_system_t type);
|
int nxp_ltc_curve25519(ECPoint *q, const byte *n, const ECPoint *p, fsl_ltc_ecc_coordinate_system_t type);
|
||||||
const ECPoint *nxp_ltc_curve25519_GetBasePoint(void);
|
const ECPoint *nxp_ltc_curve25519_GetBasePoint(void);
|
||||||
status_t LTC_PKHA_Curve25519ToWeierstrass(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
status_t LTC_PKHA_Curve25519ToWeierstrass(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||||
status_t LTC_PKHA_WeierstrassToCurve25519(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
status_t LTC_PKHA_WeierstrassToCurve25519(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||||
status_t LTC_PKHA_Curve25519ComputeY(ltc_pkha_ecc_point_t *ltcPoint);
|
status_t LTC_PKHA_Curve25519ComputeY(ltc_pkha_ecc_point_t *ltcPoint);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ED25519
|
#ifdef HAVE_ED25519
|
||||||
status_t LTC_PKHA_Ed25519ToWeierstrass(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
status_t LTC_PKHA_Ed25519ToWeierstrass(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||||
status_t LTC_PKHA_WeierstrassToEd25519(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
status_t LTC_PKHA_WeierstrassToEd25519(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||||
status_t LTC_PKHA_Ed25519_PointMul(const ltc_pkha_ecc_point_t *ltcPointIn,
|
status_t LTC_PKHA_Ed25519_PointMul(const ltc_pkha_ecc_point_t *ltcPointIn,
|
||||||
const uint8_t *N,
|
const uint8_t *N,
|
||||||
size_t sizeN,
|
size_t sizeN,
|
||||||
ltc_pkha_ecc_point_t *ltcPointOut,
|
ltc_pkha_ecc_point_t *ltcPointOut,
|
||||||
fsl_ltc_ecc_coordinate_system_t typeOut);
|
fsl_ltc_ecc_coordinate_system_t typeOut);
|
||||||
const ltc_pkha_ecc_point_t *LTC_PKHA_Ed25519_BasePoint(void);
|
const ltc_pkha_ecc_point_t *LTC_PKHA_Ed25519_BasePoint(void);
|
||||||
status_t LTC_PKHA_Ed25519_PointDecompress(const uint8_t *pubkey, size_t pubKeySize, ltc_pkha_ecc_point_t *ltcPointOut);
|
status_t LTC_PKHA_Ed25519_PointDecompress(const uint8_t *pubkey, size_t pubKeySize, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||||
status_t LTC_PKHA_sc_reduce(uint8_t *a);
|
status_t LTC_PKHA_sc_reduce(uint8_t *a);
|
||||||
status_t LTC_PKHA_sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b, const uint8_t *c);
|
status_t LTC_PKHA_sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b, const uint8_t *c);
|
||||||
status_t LTC_PKHA_SignatureForVerify(uint8_t *rcheck, const unsigned char *a, const unsigned char *b, ed25519_key *key);
|
status_t LTC_PKHA_SignatureForVerify(uint8_t *rcheck, const unsigned char *a, const unsigned char *b, ed25519_key *key);
|
||||||
status_t LTC_PKHA_Ed25519_Compress(const ltc_pkha_ecc_point_t *ltcPointIn, uint8_t *p);
|
status_t LTC_PKHA_Ed25519_Compress(const ltc_pkha_ecc_point_t *ltcPointIn, uint8_t *p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* FREESCALE_LTC_ECC */
|
#endif /* FREESCALE_LTC_ECC */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user