Update code to v1.0.14 (10)

This commit is contained in:
Caten
2024-02-29 19:35:00 +08:00
parent c2ee3b694c
commit a956d26f6d
3188 changed files with 2317293 additions and 146 deletions

View File

@@ -0,0 +1,10 @@
- Open MCUEXPRESSO and set the workspace to wolfssl/IDE/MCUEXPRESSO
- File -> Open Projects From File System... -> Directory : and set the browse to wolfssl/IDE/MCUEXPROSSO directory then click "select directory"
- Select MCUEXPRESSO\wolfssl, MCUEXPRESSO\benchmark and MCUEXPRESSO\wolfcrypt_test then click "Finish"
- Right click the projects -> SDK Management -> Refresh SDK Components and click "yes"
- MCUEXPRESSO fails to generate the fils for wolfssl/MIMXRT685S, just copy the files from either benchmark or wolfcrypt_test into the directory
- increase the size of configTOTAL_HEAP_SIZE in FreeRTOSConfig.h to be 200000 for wolfcrypt_test and benchmark projects
- (note board files need to be recreated .... this can be done by creating a new project that has the same settings and copying over the generated board/* files)
- Build the projects

View File

@@ -0,0 +1,107 @@
/* run_benchmark.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <stdio.h>
#include "board.h"
#include "fsl_rtc.h"
#include "fsl_trng.h"
#include "FreeRTOS.h"
#include "task.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "MIMXRT685S_cm33.h"
#include "fsl_debug_console.h"
#include <wolfssl/wolfcrypt/wc_port.h>
#include "benchmark.h"
#define STACK_DEPTH 60000
/* start the RTC and TRNG */
static void setup()
{
rtc_datetime_t date;
trng_config_t trngConfig;
status_t status;
RTC_Init(RTC);
/* setup a default start date */
date.year = 2022U;
date.month = 8U;
date.day = 17U;
date.hour = 15U;
date.minute = 10;
date.second = 0;
RTC_EnableTimer(RTC, false);
RTC_SetDatetime(RTC, &date);
RTC_EnableTimer(RTC, true);
TRNG_GetDefaultConfig(&trngConfig);
/* Commented in example NXP TRNG as an optional, better random mode */
trngConfig.sampleMode = kTRNG_SampleModeVonNeumann;
/* Initialize TRNG */
status = TRNG_Init(TRNG0, &trngConfig);
if (status != kStatus_Success) {
PRINTF("Issues starting TRNG\n");
}
}
static void doBenchmark(void* params)
{
int ret;
/* initialize wolfCrypt and run tests */
if (wolfCrypt_Init() == 0) {
ret = benchmark_test(NULL);
PRINTF("Return of benchmark_test = %d\r\n", ret);
wolfCrypt_Cleanup();
}
else {
PRINTF("Failied to initialize wolfCrypt\r\n");
}
}
int main(void)
{
TaskHandle_t b = NULL;
/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif
setup(); /* set the RTC and start the TRNG */
if (xTaskCreate(doBenchmark, "wolfSSL Benchmark", STACK_DEPTH, NULL,
0, &b) != pdPASS) {
PRINTF("Error creating benchmark task\r\n");
}
vTaskStartScheduler();
TRNG_Deinit(TRNG0);
vTaskDelete(b);
return 0 ;
}

View File

@@ -0,0 +1,18 @@
# vim:ft=automake
# included from Top Level Makefile.am
# All paths should be given relative to the root
EXTRA_DIST += IDE/MCUEXPRESSO/wolfssl/.cproject
EXTRA_DIST += IDE/MCUEXPRESSO/wolfssl/.project
EXTRA_DIST += IDE/MCUEXPRESSO/wolfssl/.settings
EXTRA_DIST += IDE/MCUEXPRESSO/wolfssl/liblinks.xml
EXTRA_DIST += IDE/MCUEXPRESSO/wolfcrypt_test/.cproject
EXTRA_DIST += IDE/MCUEXPRESSO/wolfcrypt_test/.project
EXTRA_DIST += IDE/MCUEXPRESSO/wolfcrypt_test/source/wolfcrypt_test.c
EXTRA_DIST += IDE/MCUEXPRESSO/benchmark/.cproject
EXTRA_DIST += IDE/MCUEXPRESSO/benchmark/.project
EXTRA_DIST += IDE/MCUEXPRESSO/benchmark/source/run_benchmark.c
EXTRA_DIST += IDE/MCUEXPRESSO/user_settings.h

View File

@@ -0,0 +1,122 @@
/* user_settings.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef USER_SETTINGS_H_
#define USER_SETTINGS_H_
#define FREERTOS
#define NO_WOLFSSL_DIR
#define WOLFSSL_NO_SOCK
#define WOLFSSL_LWIP
#define WOLFSSL_USER_IO
#define DEBUG_WOLFSSL
#define WOLFSSL_LOG_PRINTF
/* macros for test suite and benchmark */
//#define NO_CRYPT_TEST
#ifndef NO_CRYPT_TEST
#define NO_MAIN_DRIVER
#include <stdio.h>
#include <stdarg.h>
static void myPrintf(const char* fmt, ...)
{
int ret;
char line[150];
va_list ap;
va_start(ap, fmt);
ret = vsnprintf(line, sizeof(line), fmt, ap);
line[sizeof(line)-1] = '\0';
DbgConsole_Printf("%s", line);
/* add CR on newlines */
if (ret > 0 && line[ret-1] == '\n') {
DbgConsole_Printf("\r");
}
}
#define XPRINTF myPrintf
#define USE_CERT_BUFFERS_2048
#define USE_CERT_BUFFERS_1024
#define USE_CERT_BUFFERS_256
#define NO_WRITE_TEMP_FILES
#define BENCH_EMBEDDED
/* set high for handling wolfcrypt tests */
#define WOLFSSL_STATIC_MEMORY_TEST_SZ 350000
#endif
/* math implementation (fast math or sp math, choose one) */
#define USE_FAST_MATH
#ifdef USE_FAST_MATH
/* big enough for even 4096 bit RSA key */
#define FP_MAX_BITS 8192
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#define ALT_ECC_SIZE
#endif
//#define WOLFSSL_SP_MATH_ALL
#ifdef WOLFSSL_SP_MATH_ALL
#endif
/* optimizations for common public key operations
* adds a lot of code size in exchange for performance increase */
#if 1
#define WOLFSSL_HAVE_SP_RSA
#define WOLFSSL_HAVE_SP_DH
#define WOLFSSL_HAVE_SP_ECC
#endif
/* RT685 uses the same fsl_trng API, note that the application
* needs to initialize and teardown the TRNG (TRNG_Init, TRNG_Deinit) */
#define FREESCALE_KSDK_2_0_TRNG
#define FREESCALE_RTC
/* use loaded stack as a pool of memory for allocations rather than
* using heap */
#define WOLFSSL_STATIC_MEMORY
#define WOLFSSL_SP_NO_MALLOC /* use no malloc version of SP if compiled in */
#define WOLFSSL_NO_REALLOC
/* this removes all system malloc calls, will fail on some compatibility
* layer API's and others that have no heap hint */
//#define WOLFSSL_NO_MALLOC
#define WC_RSA_BLINDING
#define HAVE_ECC
#define OPENSSL_EXTRA
#define OPENSSL_ALL
#define NO_WOLFSSL_SERVER
#define HAVE_TLS_EXTENSIONS
#define WC_RSA_PSS
#define WOLFSSL_KEY_GEN
#define HAVE_SMIME
#ifdef HAVE_SMIME
#define HAVE_PKCS7
#define HAVE_X963_KDF
#define HAVE_AES_KEYWRAP
#define WOLFSSL_AES_DIRECT
#endif
#endif /* USER_SETTINGS_H_ */

View File

@@ -0,0 +1,102 @@
/* wolfcrypt_test.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <stdio.h>
#include "board.h"
#include "fsl_rtc.h"
#include "fsl_trng.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "MIMXRT685S_cm33.h"
#include "fsl_debug_console.h"
#include <wolfssl/wolfcrypt/wc_port.h>
#include <wolfssl/wolfcrypt/logging.h>
#include "test.h"
/* start the RTC and TRNG */
static void setup()
{
rtc_datetime_t date;
trng_config_t trngConfig;
status_t status;
RTC_Init(RTC);
/* setup a default start date */
date.year = 2022U;
date.month = 8U;
date.day = 17U;
date.hour = 15U;
date.minute = 10;
date.second = 0;
RTC_EnableTimer(RTC, false);
RTC_SetDatetime(RTC, &date);
RTC_EnableTimer(RTC, true);
TRNG_GetDefaultConfig(&trngConfig);
/* Commented in example NXP TRNG as an optional, better random mode */
trngConfig.sampleMode = kTRNG_SampleModeVonNeumann;
/* Initialize TRNG */
status = TRNG_Init(TRNG0, &trngConfig);
if (status != kStatus_Success) {
PRINTF("Issues starting TRNG\n");
}
}
int main(void)
{
volatile static int i = 0;
int ret;
/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif
setup(); /* set the RTC and start the TRNG */
/* initialize wolfCrypt and run tests */
if (wolfCrypt_Init() == 0) {
PRINTF("Running wolfcrypt tests....\r\n");
wolfSSL_Debugging_ON();
ret = wolfcrypt_test(NULL);
PRINTF("Return of wolfcrypt_test = %d\r\n", ret);
wolfCrypt_Cleanup();
}
else {
PRINTF("Failied to initialize wolfCrypt\r\n");
}
TRNG_Deinit(TRNG0);
while(1) {
i++;
__asm volatile ("nop");
}
return 0 ;
}

View File

@@ -0,0 +1,53 @@
<!-- liblinks.xml
NXP MCUXpresso IDE "Smart update wizard" script file
When executed on a particular application project, will
add appropriate links to the specified library project.
Note that this script assumes that the application project
contains the standard 'Debug' and 'Release' build
configurations.
-->
<project name="" update="true">
<setting id="all.compiler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/lwIP${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/other${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/lists${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/CMSIS${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/source${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/FreeRTOS kernel${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/utilities${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/drivers${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/fatfs${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/board${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/ram${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/flash_config${MacroEnd}</value>
</setting>
<setting id="assembler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/lwIP${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/other${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/lists${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/CMSIS${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/source${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/FreeRTOS kernel${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/utilities${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/drivers${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/fatfs${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/board${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/ram${MacroEnd}</value>
<value>${MacroStart}workspace_loc:/${ProjName}/flash_config${MacroEnd}</value>
</setting>
<setting id="linker.libs">
<value>${ProjName}</value>
</setting>
<setting id="linker.paths" buildType="Debug">
<value>${MacroStart}workspace_loc:/${ProjName}/Debug${MacroEnd}</value>
</setting>
<setting id="linker.paths" buildType="Release">
<value>${MacroStart}workspace_loc:/${ProjName}/Release${MacroEnd}</value>
</setting>
<requires msg="Library project `${ProjName}` not found">
<value>${ProjName}</value>
</requires>
</project>