diff --git a/Renesas/cs+/RH850/README.md b/Renesas/cs+/RH850/README.md new file mode 100644 index 00000000..a96a35dd --- /dev/null +++ b/Renesas/cs+/RH850/README.md @@ -0,0 +1,81 @@ +# wolfCrypt Examples on Renesas RH850 + +This repository contains the Renesas RH850 examples. + +# Building wolfCrypt and sample code + +Before you begin, make sure you have the necessary tools and libraries installed. +## Tools and Libraries +| Tool/Library| Version| Description|| +|:--|:--|:--|:--| +|Board||Renesas RH850/F1KM-S4|| +|Device||DR7F701649|| +|Toolchain|V2.06.00 [28 Nov 2023]|CC-RH RH850 Family Compiler|| +|IDE|V8.11.00 [30 Nov 2023]|CS+ for CC|| +| Software Package||[Y-ASK-RH850F1KM-S4-V3 Software Package](https://www.renesas.com/en/document/sws/y-ask-rh850f1km-s4-v3-software-package?r=1261056)|| + +### Prepare boot.asm, cstart.asm and iodefine.h +1. Open CS+ +2. Menu `File` -> `Create New Project`. Select `R7F01649`. Input `Dummy_Project` as project name. Click `Create` button. +3. Copy `boot.asm`, `cstart.asm` and `iodefine.h` to `wolfssl-examples\Renesas\cs+\RH850\rsapss_sign_verify` + +### Prepare modules and peripherals by [Y-ASK-RH850F1KM-S4-V3 Software Package](https://www.renesas.com/en/document/sws/y-ask-rh850f1km-s4-v3-software-package?r=1261056) +1. Download the package from [https://www.renesas.com/en/document/sws/y-ask-rh850f1km-s4-v3-software-package?r=1261056](https://www.renesas.com/en/document/sws/y-ask-rh850f1km-s4-v3-software-package?r=1261056) +2. Unzip the package +3. Copy the folder `Y-ASK-RH850F1KM-S4-V3_sample_V101\source\modules and peripherals` to the folder `\Renesas\cs+\RH850` +4. Copy the folder `Y-ASK-RH850F1KM-S4-V3_sample_V101\device\r_typedefs.h, r_device.h, intVecNumF1KM.h and dr7f701649.dvf.h` to the folder `\Renesas\cs+\RH850` + +### Build RSA PSS Sign and Verify Sample +1. Open [CS+](#DeviceFile) project file under `\Renesas\cs+\RH850\rsapss_sign_verify\rh850_rsapss_sign.mtpj` +2. Modify `boot.asm` + 2-1. Uncomment `USE_TABLE_REFERENCE_METHOD` so that the sample program is able to use table reference for interrupt + 2-2. Change `section "EINTTBL", const` as follows: + ``` + .section "EIINTTBL", const + .align 512 + .offset (0x22*4) + .dw #_INTRLIN30UR0 + .offset (0x51*4) + .dw #_INTTAUJ0I1 + .offset (0x54*4) + .dw #_INTCOSTM0 + ;.dw #_Dummy_EI ; INT0 + ;.dw #_Dummy_EI ; INT1 + ;.dw #_Dummy_EI ; INT2 + ;.rept 512 - 0x54 + ;.dw #_Dummy_EI ; INTn + ;.endm + ``` + 2-3. Specify RAM addresses as follows: + ``` + GLOBAL_RAM_ADDR .set 0xFEEE8000 + GLOBAL_RAM_END .set 0xFEEE7FFF + LOCAL_RAM_ADDR .set 0xFEBC0000 + LOCAL_RAM_END .set 0xFEBFFFFF + ``` +3. Modify `cstart.asm` + 3-1. Change `STACKSIZE` from `0x200` to `0XA000` + +2. Build project, Menu `Build` -> `Build Project` +3. Download the project to target device, `Debug` -> `Download...` + +The result can be observed through UART. Please connect to the cable to the board and open terminal with the following properties. + +||| +|:-|:-| +|baud rate | 9600| +|data | 8| +|parity | none| +|stop bit | 1| +|flow control | none| + +Example output +``` +System Initializetion finish. +RSA Sign and Verify Example +Hashing message: This is the string to be signed +Signing hash of message +Hashing message: This is the string to be signed +Verify hash of message +RSA PSS verify success +``` diff --git a/Renesas/cs+/RH850/rsapss_sign_verify/example_main.c b/Renesas/cs+/RH850/rsapss_sign_verify/example_main.c new file mode 100644 index 00000000..a486e428 --- /dev/null +++ b/Renesas/cs+/RH850/rsapss_sign_verify/example_main.c @@ -0,0 +1,115 @@ +/* example_main.c + * + * Copyright (C) 2006-2025 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 +#include +#include +#include "iodefine.h" +#include "rh_string.h" +#include "r_system.h" +#include "r_intc.h" + +void R_LIN_Init(void); +void R_UART_Init(void); +void R_UART_SendString(char string[]); + +#define INTC2ICOSTM0 INTC2.ICOSTM0.UINT16 + +#define MSG_LEN 128 + +char msg_buf[MSG_LEN + 1]; +size_t msg_offset = 0; + +int rsapss_sign_verify(); + +/* 1ms tick timer */ +static long tick = 0; +#define NUMINTCOSTM0 0x54 +#pragma interrupt INTCOSTM0(enable=true, channel=NUMINTCOSTM0) +void INTCOSTM0(void) +{ + tick++; +} + +#define YEAR ( \ + ((__DATE__)[7] - '0') * 1000 + \ + ((__DATE__)[8] - '0') * 100 + \ + ((__DATE__)[9] - '0') * 10 + \ + ((__DATE__)[10] - '0') * 1 \ +) + +#define MONTH ( \ + __DATE__[2] == 'n' ? (__DATE__[1] == 'a' ? 1 : 6) \ + : __DATE__[2] == 'b' ? 2 \ + : __DATE__[2] == 'r' ? (__DATE__[0] == 'M' ? 3 : 4) \ + : __DATE__[2] == 'y' ? 5 \ + : __DATE__[2] == 'l' ? 7 \ + : __DATE__[2] == 'g' ? 8 \ + : __DATE__[2] == 'p' ? 9 \ + : __DATE__[2] == 't' ? 10 \ + : __DATE__[2] == 'v' ? 11 \ + : 12 \ + ) + +time_t time(time_t *t) +{ + (void)t; + return ((YEAR-1970)*365+30*MONTH)*24*60*60 + tick++; +} + +void PrintTextln(char* TextArray) +{ + R_UART_SendString(TextArray); + R_UART_SendString("\r\n"); +} + +void main(void); + +#if !defined(WOLFSSL_STATIC_MEMORY) +#include +#define SIZEOF_HEAP 0xB000 +int _REL_sysheap[SIZEOF_HEAP >> 2]; +size_t _REL_sizeof_sysheap = SIZEOF_HEAP; +#endif + +void main(void) +{ + byte ret; + + R_SYSTEM_ClockInit(); + R_SYSTEM_TimerInit(); + R_SYSTEM_TimerStart(); + R_UART_Init(); + R_LIN_Init(); + /* Enable Table Interrupt */ + R_INTC_SetTableBit((uint16_t*)R_ICOSTM0); + R_INTC_UnmaskInterrupt((uint16_t*)R_ICOSTM0); + /* Enable interrupts */ + __EI(); + + rh_string_init(MSG_LEN + 1, &msg_offset, msg_buf); + printf("System Initialization finish."); + printf("RSA Sign and Verify Example"); + + ret = rsapss_sign_verify(); + if (ret != 0) { + printf("rsapss_sign_verify failed ret=%d.", ret); + } +} diff --git a/Renesas/cs+/RH850/rsapss_sign_verify/rh850_rsapss_sign.mtpj b/Renesas/cs+/RH850/rsapss_sign_verify/rh850_rsapss_sign.mtpj new file mode 100644 index 00000000..5fda1d32 --- /dev/null +++ b/Renesas/cs+/RH850/rsapss_sign_verify/rh850_rsapss_sign.mtpj @@ -0,0 +1,2631 @@ + + 9.11.00.00 + + + 2.0 + 9.11 + 95e018ad-62cb-4237-a441-778ab320af03 + 8c3fcf13-b7b7-4f9a-bf8c-2b79746b7750 + 7ba20357-e563-4e3f-9694-e6f715845a17 + fb98844b-2c27-4275-9804-f6e63e204da0 + 95e018ad-62cb-4237-a441-778ab320af03 + + + boot.asm + File + boot.asm + f654126d-e7ad-426d-be34-8455271d959b + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + cstart.asm + File + cstart.asm + f654126d-e7ad-426d-be34-8455271d959b + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + example_main.c + File + example_main.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + iodefine.h + File + iodefine.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + wolfssl + Category + 7ba20357-e563-4e3f-9694-e6f715845a17 + b878173e-7c3b-4003-81c4-94e1042c815e + + + misc + Category + 7ba20357-e563-4e3f-9694-e6f715845a17 + 2ee9af6e-e5aa-410f-9a11-d89981f09b62 + + + rsapss.c + File + rsapss.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + user_settings.h + File + user_settings.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + modules + Category + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + peripherals + Category + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + r_device.h + File + ..\r_device.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + dr7f701649.dvf.h + File + ..\dr7f701649.dvf.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 7ba20357-e563-4e3f-9694-e6f715845a17 + + + wolfcrypt + Category + 7512652b-8015-4016-9ea2-f0080732aa12 + 8487d6e8-8f55-4551-8154-e71d7ea7aa08 + + + aes.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\aes.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + asn.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\asn.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + cmac.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\cmac.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + ecc.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\ecc.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + fe_low_mem.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\fe_low_mem.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + fe_operations.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\fe_operations.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + ge_operations.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\ge_operations.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + hash.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\hash.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + hmac.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\hmac.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + logging.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\logging.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + memory.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\memory.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + random.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\random.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + rsa.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\rsa.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + sha.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\sha.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + sha256.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\sha256.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + sp_int.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\sp_int.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + signature.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\signature.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + tfm.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\tfm.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + wc_encrypt.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\wc_encrypt.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + wc_port.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\wc_port.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + wolfmath.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\wolfmath.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + coding.c + File + ..\..\..\..\..\wolfSSL\wolfcrypt\src\coding.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c7c4ec9c-30e5-4720-8f7c-0096d5aa2f96 + + + rh_string.c + File + rh_string.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 6d8bfc0c-dd5d-45c1-96fe-0d6fe16ebef3 + + + rh_string.h + File + rh_string.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 6d8bfc0c-dd5d-45c1-96fe-0d6fe16ebef3 + + + led + Category + 96e33b5b-1454-4bdf-be30-f0b356794654 + + + lin + Category + 96e33b5b-1454-4bdf-be30-f0b356794654 + + + system + Category + 96e33b5b-1454-4bdf-be30-f0b356794654 + + + uart + Category + 96e33b5b-1454-4bdf-be30-f0b356794654 + + + user_input + Category + 96e33b5b-1454-4bdf-be30-f0b356794654 + + + r_led.c + File + ..\modules\led\r_led.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 10e09705-8c20-483f-8a55-d3a1a15190c3 + + + r_lin.c + File + ..\modules\lin\r_lin.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + e36220e2-9a0c-48d4-9c54-69423d8f745f + + + r_lin.h + File + ..\modules\lin\r_lin.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + e36220e2-9a0c-48d4-9c54-69423d8f745f + + + r_system.c + File + ..\modules\system\r_system.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + e9e90b73-d1ff-4a9d-bb11-3b534d8e5f97 + + + r_system.h + File + ..\modules\system\r_system.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + e9e90b73-d1ff-4a9d-bb11-3b534d8e5f97 + + + r_uart.c + File + ..\modules\uart\r_uart.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + ae8c5dd0-e106-4dd5-8bc5-efa692deb7cf + + + r_uart.h + File + ..\modules\uart\r_uart.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + ae8c5dd0-e106-4dd5-8bc5-efa692deb7cf + + + r_ui.c + File + ..\modules\user_input\r_ui.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 67d41c37-b6a7-4166-a5ec-6dfd98d4dbfe + + + adc + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + clkc + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + csi + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + enc + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + intc + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + lps + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + ostm + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + port + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + pwmd + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + rlin + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + stbc + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + tau + Category + 75a16e24-bf25-4ffb-a2bc-9968a4b2aec4 + + + r_adc.c + File + ..\peripherals\adc\r_adc.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 634d28fa-14ec-4820-ae9a-66d1c542ce03 + + + r_clkc.c + File + ..\peripherals\clkc\r_clkc.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 46ffdf05-6929-46a6-8fc6-98135cc529b7 + + + r_clkc.h + File + ..\peripherals\clkc\r_clkc.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 46ffdf05-6929-46a6-8fc6-98135cc529b7 + + + r_csi.c + File + ..\peripherals\csi\r_csi.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 3c1aa476-fa1e-48c9-954b-5512baa66f04 + + + r_csi.h + File + ..\peripherals\csi\r_csi.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 3c1aa476-fa1e-48c9-954b-5512baa66f04 + + + r_enc.c + File + ..\peripherals\enc\r_enc.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 84e0de71-f289-4bbf-8a1b-82d1150797f9 + + + r_enc.h + File + ..\peripherals\enc\r_enc.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 84e0de71-f289-4bbf-8a1b-82d1150797f9 + + + r_intc.c + File + ..\peripherals\intc\r_intc.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 9d26d649-8c08-4dde-af59-a25a71643235 + + + r_intc.h + File + ..\peripherals\intc\r_intc.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 9d26d649-8c08-4dde-af59-a25a71643235 + + + r_lps.c + File + ..\peripherals\lps\r_lps.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 1ed2dc6a-625d-4170-a80f-06e65b8acdf4 + + + r_lps.h + File + ..\peripherals\lps\r_lps.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 1ed2dc6a-625d-4170-a80f-06e65b8acdf4 + + + r_ostm.c + File + ..\peripherals\ostm\r_ostm.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c2bdb165-7128-43bb-a335-17839a4448c0 + + + r_ostm.h + File + ..\peripherals\ostm\r_ostm.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + c2bdb165-7128-43bb-a335-17839a4448c0 + + + r_port.c + File + ..\peripherals\port\r_port.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 174b8ea5-0b1c-4638-8e5c-e40944d82ac6 + + + r_pwmd.c + File + ..\peripherals\pwmd\r_pwmd.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + b0103772-fdd3-450a-996c-1532d803927d + + + r_pwmd.h + File + ..\peripherals\pwmd\r_pwmd.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + b0103772-fdd3-450a-996c-1532d803927d + + + r_rlin.c + File + ..\peripherals\rlin\r_rlin.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + c576659a-b4b5-4005-86ab-2be2e4eda029 + + + r_rlin.h + File + ..\peripherals\rlin\r_rlin.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + c576659a-b4b5-4005-86ab-2be2e4eda029 + + + r_stbc.c + File + ..\peripherals\stbc\r_stbc.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 260b624b-3005-40d2-ae72-7d35dc7b2240 + + + r_stbc.h + File + ..\peripherals\stbc\r_stbc.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 260b624b-3005-40d2-ae72-7d35dc7b2240 + + + r_tau.c + File + ..\peripherals\tau\r_tau.c + 941832c1-fc3b-4e1b-94e8-01ea17128b42 + 1a11ba45-901f-4237-a18a-2dea0b0be7df + + + r_tau.h + File + ..\peripherals\tau\r_tau.h + 03cad1e8-2eb3-4cde-a8a3-982423631122 + 1a11ba45-901f-4237-a18a-2dea0b0be7df + + + + + UserMtudFile + True + 0 + + + + + 0 + + + 0 + + + 0 + + + + + 93e1d175-ef17-4e54-92c1-859212520d31 + ad4033fe-5c64-4017-8723-5539a6e004f7 + + + + + 096f2041-c115-4158-959e-885938314c77 + + + + + 1.0 + + + R7F701649 + 0 + True + 0 + + + + + True + + + + + 2 + R7F701649 + + + + + eb3b4b69-af1a-4dc1-b2bc-4b81a50fb2a4 + + + + + 1.9 + 1 + RABlAGYAYQB1AGwAdABCAHUAaQBsAGQA + False + DefaultBuild + 1bf35bf6-1a8e-49f4-8d54-0b422c036198 + AsmSource + a0207472-a2c0-4fc9-8a55-c58b17037418 + AsmSource + aac77e89-4f1e-4456-ac1a-28aa90c4fa8f + CSource + 14ed808b-b49e-4002-bdc1-71db853e4b7f + CSource + f393f6fc-8017-476d-babc-8f27cc143cc8 + CSource + f647b6cd-7d74-46dd-8fef-3bb8530d1030 + CSource + 301ba18d-ffdf-4d70-8e0b-f5e6a177fefb + CSource + a67955bb-fbc2-419e-a3d7-a34d4f3e54e3 + CSource + 64c7a031-890b-41d2-8d7f-46041f1a3096 + CSource + be71138a-c387-4343-80e7-dcd6ea32aeb2 + CSource + ce251efc-f4b8-4c2d-aaea-3a9124dc2a1d + CSource + 0cc6d9f0-8625-44ea-b254-aea52febff02 + CSource + 991927b7-5aee-4e15-8b41-ca2eeb6e51b0 + CSource + 85ad8cbe-f35b-4f49-ad69-84c06c11f187 + CSource + 7bb54267-e8c1-47c8-b5e0-757966f2ce86 + CSource + b6d584bd-7faa-45d3-ae7b-c75495898233 + CSource + 2202b576-fd2d-419a-9b4c-72609d2baa3c + CSource + 4e38f87a-2814-4a32-91fb-1d2e9b7acb07 + CSource + 7bd9a63c-1abb-4c39-af17-abc591f97131 + CSource + 66d6c11d-5088-4a75-9259-738bc1381320 + CSource + 62662926-256a-4c73-b132-ce9ba49f4760 + CSource + 80caa2f2-5d35-4b05-9e07-13c6027a8084 + CSource + e7c9bf67-4ac8-4560-a16e-b12cf0525b50 + CSource + 3c0ba7b9-c9f9-4e0a-9599-f910db917c3f + CSource + 7c012188-130b-4947-9f90-d1ea58e8b3dc + CSource + 48122d08-3d07-4ecb-9b37-99438926c6ca + CSource + 50c299c2-dddd-4ea9-bba4-c93f6e0868a8 + CSource + d2b88685-1c73-4852-a27c-7d0cb807da0a + CSource + a450a415-0d33-40af-8920-87934f645ed3 + CSource + ab219c67-32a8-4bda-a42e-4f27df6f56e2 + CSource + 9393582c-3f7d-4116-bffb-333b51472b97 + CSource + 24bb4917-16d2-4a68-a0c3-ec75286ba1dd + CSource + c22e94e8-bb5a-4865-9cc9-15b0d0822302 + CSource + 0ece9581-1af5-4a15-8217-f516d5a68749 + CSource + ed79b373-8af1-4094-81e5-546269d2dc5c + CSource + c3cc09ea-7f52-48e0-b38a-2f07865d8f7c + CSource + eeb17597-e284-44c8-acd0-55b1ddf54d45 + CSource + c5382bb4-ef10-4a50-932e-82febd06a1b3 + CSource + 215031d0-7cdf-4d3a-9014-57f93df69231 + CSource + 79caa681-5980-4e68-a5f9-728e1f3a5fca + CSource + cc3c7eed-aab1-41de-bf2b-03b44e342963 + CSource + 6e32df1d-eec9-4557-a6f1-cd7436755580 + CSource + 58f04a19-0cf9-4e5c-b899-e25902115f01 + CSource + c415b376-e0ba-4983-969f-ff19086945b9 + CSource + 44 + 2 + + + + DefaultBuild + Default + LoadModuleFile + False + 0 + False + False + False + RegisterMode32 + True + LibraryU + + + %TargetFiles% + + + + +0 + %TargetFiles% : %Program% %Options% + True + + False + + RH850 + %BuildModeName% + + False + Stype + %BuildModeName% + %BuildModeName% + False + + + Rebuild + G3KH + DR7F701649.DVF, V1.40 + None + + None + %ProjectName%.err + %BuildModeName% + %ProjectName%.lib + %ProjectName%.abs + + False + + False + %ProjectName%.mot + False + True + + + %BuildModeName% + + NotUse + Use + + + False + True + + + False + True + + False + True + + False + True + + True + True + + False + False + + + + + + False + -8584507941217188734 + DefaultBuild + + False + + + LoadModuleFile + False + 0 + False + False + False + RegisterMode32 + %TargetFiles% + + +0 + %TargetFiles% : %Program% %Options% + True + + False + RH850 + %BuildModeName% + + False + Rebuild + G3KH + None + + None + %ProjectName%.err + False + + False + + %BuildModeName% + + + + + V2.06.00 + 0 + + + No + True + + None + -c + Default + + False + Auto + Xmisra2012 + None + False + None + + True + + False + None + + False + %BuildModeName% + None + %BuildModeName% + None + FitToOptimization + + False + False + Align2 + + + + 100 + None + SignedInteger + + %BuildModeName% + None + + + False + False + None + None + + False + Auto + None + None + + False + None + None + None + None + + None + + Nearest + None + False + + False + + False + SinglePrecision + False + + False + + False + False + False + False + False + 1 + None + False + False + False + False + None + + None + None + False + False + False + False + + + + + + + + False + + Level0 + False + -8584513181136061742 + No + True + %ProjectDir%\..\modules\lin +%ProjectDir%\..\modules\uart +%ProjectDir%\..\modules\system +%ProjectDir%\..\peripherals\tau +%ProjectDir%\..\peripherals\stbc +%ProjectDir%\..\peripherals\rscanfd +%ProjectDir%\..\peripherals\rlin +%ProjectDir%\..\peripherals\pwmd +%ProjectDir%\..\peripherals\port +%ProjectDir%\..\peripherals\ostm +%ProjectDir%\..\peripherals\lps +%ProjectDir%\..\peripherals\intc +%ProjectDir%\..\peripherals\enc +%ProjectDir%\..\peripherals\csi +%ProjectDir%\..\peripherals\clkc +%ProjectDir%\..\peripherals\adc +..\..\..\..\..\wolfssl +. +.. +%ProjectDir% +%ProjectDir%\..\peripherals + + C99 + -c + AdvancedSize + + False + Auto + Xmisra2012 + None + False + None + + True + + False + OdeleteStaticFuncOn + + False + %BuildModeName% + None + %BuildModeName% + None + FitToOptimization + + False + False + Align2 + + + USE_RH_UART +WOLFSSL_USER_SETTINGS +__CSP__ + + 100 + None + SignedInteger + + %BuildModeName% + None + + + False + False + None + None + + False + Auto + None + None + + False + None + None + None + None + + None + + Nearest + None + False + + False + + False + SinglePrecision + False + + False + + False + False + False + False + False + 1 + None + False + False + False + False + None + + None + None + False + False + False + False + + + + + + + + False + + Level0 + + + False + -c + + True + + False + Auto + False + + + %BuildModeName% + + + + False + -8584539936198847648 + False + -c + + True + + False + Auto + False + + + %BuildModeName% + + + + + + False + False + Debug + False + + + List + False + None + %BuildModeName% + False + RESET,EIINTTBL/%ResetVectorPE1%,.const,.INIT_DSEC.const,.INIT_BSEC.const,.text,.data/00008000,.data.R,.bss,.stack.bss/FEDE8000 + + False + + + + False + + %ProjectName%.abs + False + + + + + False + True + False + False + + False + False + + None + Use + False + False + True + False + + + True + False + + None + False + None + True + + + .data=.data.R + + False + False + + True + + False + + None + True + False + + + True + False + False + False + -8584507837370244157 + False + False + Debug + False + + + List + False + None + %BuildModeName% + False + RESET,EIINTTBL/%ResetVectorPE1%,.const,.INIT_DSEC.const,.INIT_BSEC.const,.text,.data/00008000,.data.R,.bss,.stack.bss/FEDE8000 + + False + + + + False + + %ProjectName%.abs + False + + + + + False + True + False + False + + False + False + + None + Use + False + False + True + False + + + True + False + + None + False + None + True + + + .data=.data.R + + False + False + + True + + False + + None + True + False + + + True + False + False + 0 +0 +0 +0 +0 +0 +0 + + + + False + Stype + True + True + True + 0 + + False + %BuildModeName% + None + + + 16 + %ProjectName%.mot + None + None + Ethernet + + + None + + + + FF + None + Little + False + False + + 1 + %BuildModeName%_merged + None + + 1 + False + + False + FF + None + False + False + -8584542612476933887 + False + Stype + True + True + True + 0 + + False + %BuildModeName% + None + + + 16 + %ProjectName%.mot + None + None + Ethernet + + + None + + + + FF + None + Little + False + False + + 1 + %BuildModeName%_merged + None + + 1 + False + + False + FF + None + False + + + Debug + LibraryU + + + None + False + False + + False + + + %BuildModeName% + False + False + False + False + %ProjectName%.lib + False + None + NotUse + + False + + False + + False + None + False + + + False + None + False + + True + False + False + False + False + -8584507837370244157 + Debug + LibraryU + + + None + False + False + + False + + + %BuildModeName% + False + False + False + False + %ProjectName%.lib + False + None + NotUse + + False + + False + + False + None + False + + + False + None + False + + True + False + False + False + + + None + + DR7F701649.DVF, V1.40 + DR7F701649.DVF, V1.40 + False + False + + False + False + False + False + False + True + False + False + -8584542612476706255 + None + + DR7F701649.DVF, V1.40 + DR7F701649.DVF, V1.40 + False + False + + False + False + False + False + False + True + False + + + 0 + 638829748379447647 + 0 + + + 1 + 638829748379587555 + 0 + + + 2 + + + 638829748400523349 + 0 + + + 638842975613674799 + 0 + + + 638842913443979456 + 0 + + + 638858372039608763 + 0 + + + 638858372219630233 + 0 + + + 638858372593649207 + 0 + + + 638858488958120041 + 0 + + + 638858489872173933 + 0 + + + 638858490067098267 + 0 + + + 638842847730417284 + 1 + + + 638842847730417284 + 2 + + + 638842847990205042 + 0 + + + 638842847990205042 + 1 + + + 638842847990205042 + 2 + + + 638842847990205042 + 3 + + + 638842847990205042 + 4 + + + 638842848509084254 + 0 + + + 638842848509084254 + 1 + + + 638842848509084254 + 2 + + + 638842848509084254 + 3 + + + 638858372406005662 + 0 + + + 638842849014858172 + 1 + + + 638842849014858172 + 2 + + + 638842849014858172 + 3 + + + 638842849477119720 + 0 + + + 638842849853753072 + 0 + + + 638858371247213054 + 0 + + + 638858684937968643 + 0 + + + 638859162600855412 + 0 + + + 638858667498346784 + 1 + + + 638858667498346784 + 2 + + + 638858667498346784 + 3 + + + 638858667498346784 + 4 + + + 638858667657229236 + 1 + + + 638858667657229236 + 2 + + + 638858667657229236 + 3 + + + 638858667657387393 + 8 + + + 638858667657387393 + 9 + + + 638858667657387393 + 10 + + + 638858667657387393 + 12 + + + 638858667657387393 + 13 + + + 638858667657387393 + 16 + + + 638858667657387393 + 17 + + + 638859168921730113 + 0 + + + 638859168849272856 + 0 + + + 638858685175772935 + 0 + + + 638858668697748673 + 0 + + + 638858668822350405 + 0 + + + 638858668955064198 + 0 + + + 638858669268726782 + 0 + + + 638858669409212971 + 0 + + + 638858669538918349 + 0 + + + 638858670012297452 + 0 + + + 638858670153223100 + 0 + + + 638858670455043608 + 0 + + + 638858670591153284 + 0 + + + 638859128590246401 + 0 + + + 638859129116683748 + 0 + + + 638859129235279885 + 0 + + + 638864523222475896 + 0 + + + -8584542612475248330 + False + True + False + -8584542612475188253 + False + True + False + + + -8584513989106059514 + False + True + True + -8584513989607562754 + False + False + True + -8584513988815167045 + False + False + True + -8584513988635145575 + False + False + True + -8584513988448770146 + False + False + True + -8584513988261126601 + False + False + True + -8584513871896655767 + False + False + True + -8584513870982601875 + False + False + True + -8584513870787677541 + False + False + True + -8584529513124358524 + False + False + True + -8584529511839917636 + False + False + True + -8584529513124358524 + False + False + True + -8584529512864570766 + False + False + True + -8584529512864570766 + False + False + True + -8584529512864570766 + False + False + True + -8584529512864570766 + False + False + True + -8584529511839917636 + False + False + True + -8584529512864570766 + False + False + True + -8584529512345691554 + False + False + True + -8584529512345691554 + False + False + True + -8584529512345691554 + False + False + True + -8584529512345691554 + False + False + True + -8584529511839917636 + False + False + True + -8584529511377656088 + False + False + True + -8584513198253920396 + False + False + True + -8584513693356429024 + False + False + True + -8584513693356429024 + False + False + True + -8584513693356429024 + False + False + True + -8584513693356429024 + False + False + True + -8584513675679002873 + False + False + True + -8584513693197546572 + False + False + True + -8584513693197546572 + False + False + True + -8584513693197546572 + False + False + True + -8584513693197388415 + False + False + True + -8584513693197388415 + False + False + True + -8584513693197388415 + False + False + True + -8584513675916807165 + False + False + True + -8584513693197388415 + False + False + True + -8584513693197388415 + False + False + True + -8584513693197388415 + False + False + True + -8584513693197388415 + False + False + True + -8584507837632299912 + False + False + True + + + -8584529431792100596 + False + No + True + + C99 + False + + AdvancedDebug + + Auto + False + Xmisra2012 + False + None + + True + True + OdeleteStaticFuncOn + + Align2 + False + False + %BuildModeName% + None + + %BuildModeName% + None + FitToOptimization + + False + %BuildModeName% + %ProjectName%.err + + False + + WOLFSSL_USER_SETTINGS + + 100 + False + + Auto + False + None + None + + None + + %BuildModeName% + None + + False + False + None + False + + False + None + False + None + None + 1 + + None + None + + None + + False + False + False + + False + False + + + False + False + False + None + False + False + + False + False + False + Level0 + + + + + False + 00000000-0000-0000-0000-000000000000 + + + + + C:\workspace\wolfssl_clean\IDE\Renesas\cs+\cmac_test\boot.asm + C:\workspace\wolfssl_clean\IDE\Renesas\cs+\cmac_test\cstart.asm + C:\workspace\wolfssl_clean\IDE\Renesas\cs+\cmac_test\main.c + C:\workspace\wolfssl_clean\IDE\Renesas\cs+\cmac_test\iodefine.h + + + + + False + R7F701649 + 2 + + + + + 4a734220-ac9a-474b-bde9-fac27f567276 + + + + + 1.0 + 1.0 + + + + + 00000000-0000-0000-0000-000000000000 + + + + + 1 + R7F701646 + 320000 + SelectCpuClockFrequency + MHz + 8000000 + No + + 1 + + True + 95e018ad-62cb-4237-a441-778ab320af03 + DefaultBuild\cmac_test_import.abs + LoadModuleFile + Auto + 0 + 0 + True + True + False + False + 0 + 0 + 0 + True + True + False + SuspendEvent + True + XwBtAGEAaQBuAA== + 500 + True + No + 500 + 0 + False + Yes + 500 + No + True + False + True + True + True + Yes + Free + No + 4096 + 0 + No + No + No + 1048576 + False + 0 + 4196925391 + 4294966783 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + + + 1 + R7F701646 + 16 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + True + 16000 + 10000 + Four + 500 + 4294967295 + Yes + Use3_3V + + Yes + No + True + False + No + Yes + False + + False + 1 + + True + 95e018ad-62cb-4237-a441-778ab320af03 + DefaultBuild\cmac_test_import.abs + LoadModuleFile + Auto + 0 + 0 + True + True + False + False + 0 + 0 + 0 + True + True + False + SuspendEvent + True + XwBtAGEAaQBuAA== + 500 + False + True + No + 500 + Yes + No + Yes + 500 + No + False + No + HardwareBreak + No + Yes + Nonstop + True + True + True + True + True + False + True + True + True + True + True + SpeedPriority + RangeIn + No + No + TargetAndInternal + True + SymbolOffset + 1 + External + 805306368 + 872415231 + 8 + False + 0 + 4196925391 + 4294966783 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + + + + + 99f55032-f012-4b4e-afd0-07710f37568e + + + + + 4a734220-ac9a-474b-bde9-fac27f567276 + + + + + 1 + R7F701646 + 320000 + SelectCpuClockFrequency + MHz + 8000000 + No + + 1 + + True + 95e018ad-62cb-4237-a441-778ab320af03 + DefaultBuild\cmac_test_import.abs + LoadModuleFile + Auto + 0 + 0 + True + True + False + False + 0 + 0 + 0 + True + True + False + SuspendEvent + True + XwBtAGEAaQBuAA== + 500 + True + No + 500 + 0 + False + Yes + 500 + No + True + False + True + True + True + Yes + Free + No + 4096 + 0 + No + No + No + 1048576 + False + 0 + 4196925391 + 4294966783 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + + + 2 + R7F701649 + 16 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + True + 16000 + 10000 + Four + 500 + 4294967295 + Yes + Use5_0V + Yes + No + True + False + No + Yes + 4273986048 + 9728 + False + + False + 1 + + True + 95e018ad-62cb-4237-a441-778ab320af03 + DefaultBuild\rh850_rsapss_sign.abs + LoadModuleFile + Auto + 0 + 0 + True + True + False + False + 0 + 0 + 0 + True + True + False + SuspendEvent + True + XwBtAGEAaQBuAA== + 500 + True + No + 500 + Yes + No + Yes + 500 + No + False + No + HardwareBreak + No + Yes + Nonstop + True + True + True + True + True + False + True + True + True + True + True + SpeedPriority + RangeIn + No + No + TargetAndInternal + True + SymbolOffset + 5 + External + 536870912 + 545259519 + 8 + External + 570425344 + 578813951 + 8 + External + 603979776 + 612368383 + 8 + External + 671088640 + 679477247 + 8 + External + 805306368 + 872415231 + 8 + False + 0 + 4196925391 + 4294966783 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + + + + + + 7d577131-4ec1-4e88-968d-89381f6c178a + + + + + 1.1 + + + False + False + False + True + Yes + Nanosecond + False + False + False + False + False + True + FilesNotToAnalyze + 0 + All + 0 + False + %ProjectName%.mtfl + %ProjectName%.mtvl + 10 + + + RealtimeSampling + + Synchronized + AtProgramStop + 20 + 1000000 + LineChart + False + PaleGreen + PaleTurquoise + 40ff0a4f + 405be416 + 40056def + 40ff541c + False + Auto + Channel01 + 0 + Rising + 0 + Orange + 10 + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + Auto + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 25.5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + c0ff0a4f + c05be416 + c0056dff + c0ff541c + c04fc1ff + c0a932ff + c0ffd91c + c0ff30a5 + c0bee02f + c05510ff + c0ff97e4 + c0913a37 + c0c68e15 + c0317f0c + c060493e + c072808e + c0ff6666 + c0ffcc66 + c066cc66 + c06666ff + c0cc66ff + c0ff9900 + c000aa00 + c00000ff + c0cc00ff + c0ff0000 + c0006600 + c02222cc + c09900cc + c0990000 + c0004400 + c0663399 + + + + + 4d843d40-b00f-4fff-b0c0-ffd1a818b9a0 + + + + + C:\workspace\wolfssl_clean\IDE\Renesas\cs+\cmac_test + C:\Program Files (x86)\Renesas Electronics\SmartConfigurator\RH850\eclipse\SmartConfigurator.exe + e3038f3c-feb7-4ddf-9bd7-fa1e3ed4102c + cmac_test.scfg + + + + + 9.11.00.00 + + + \ No newline at end of file diff --git a/Renesas/cs+/RH850/rsapss_sign_verify/rh_string.c b/Renesas/cs+/RH850/rsapss_sign_verify/rh_string.c new file mode 100644 index 00000000..8667c2f9 --- /dev/null +++ b/Renesas/cs+/RH850/rsapss_sign_verify/rh_string.c @@ -0,0 +1,331 @@ +/* rh_string.c + * + * Copyright (C) 2006-2025 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 "rh_string.h" + +void PrintTextln(char* TextArray); + +/* Provide a limit of the printf format string to limit execution time */ +#define MAX_FMT_LEN 64 +int snprintf(char* buffer, size_t bufsz, const char* format, ...); + +static int _my_write(const char *buf, unsigned int sz); + +static char *my_buffer = NULL; +static size_t *my_offset = 0; +static size_t my_size = 0; + +typedef int (*write_func)(const char* buf, unsigned int sz); +static int my_writenum(write_func f, int num, int base); +static int _my_vprintf(write_func f, const char* fmt, va_list argp); + +static void _set_string_write(char* buffer, unsigned int sz); +static int _string_write(const char* buf, unsigned int sz); + +static char* _string_write_buffer = NULL; +static unsigned int _string_write_space = 0; +#if 0 +int strcmp(const char *s1, const char *s2) +{ + int diff = 0; + + while (!diff && *s1) { + diff = (int)*s1 - (int)*s2; + s1++; + s2++; + } + + return diff; +} + +int strncmp(const char *s1, const char *s2, size_t n) +{ + int diff = 0; + + while (n > 0) { + diff = (unsigned char)*s1 - (unsigned char)*s2; + if (diff || !*s1) + break; + s1++; + s2++; + n--; + } + + return diff; +} +#endif + +static void _set_string_write(char* buffer, unsigned int sz) +{ + _string_write_buffer = buffer; + _string_write_space = sz; +} + +static int _string_write(const char* buf, unsigned int sz) +{ + if ( (buf == NULL) || + (_string_write_buffer == NULL) || + (sz == 0) || + (_string_write_space == 0) ) { + /* Nothing to do */ + return 0; + } + + if (sz > _string_write_space) { + sz = _string_write_space; + } + memcpy(_string_write_buffer, buf, sz); + _string_write_buffer += sz; + _string_write_space -= sz; + return sz; +} + +static int my_writenum(write_func f, int num, int base) +{ + int i = 0; + char buf[sizeof(int)*2+1]; + const char* kDigitLut = "0123456789ABCDEF"; + unsigned int val = (unsigned int)num; + int sz = 0; + + if(f == NULL) { + return 0; + } + if (base == 10 && num < 0) { /* handle negative */ + buf[i++] = '-'; + val = -num; + } + do { + buf[sizeof(buf)-sz-1] = kDigitLut[(val % base)]; + sz++; + val /= base; + } while (val > 0U); + memmove(&buf[i], &buf[sizeof(buf)-sz], sz); + i+=sz; + return f(buf, i); +} + +static int _my_vprintf(write_func f, const char* fmt, va_list argp) +{ + char* fmtp = (char*)fmt; + char c; + int ret = 0; +#if defined(USE_RH_UART) || defined(RH_PRINTF) + *my_offset = 0; + memset(my_buffer, 0, my_size); +#endif + if (f == NULL) { + return 0; + } + + while (fmtp != NULL && *fmtp != '\0' && ((fmtp - fmt)< MAX_FMT_LEN)) { + /* print non formatting characters */ + if (*fmtp != '%') { +#if defined(USE_RH_UART) + if (f == _my_write && (*fmtp == '\r' || *fmtp == '\n')) + fmtp++; + else +#endif + ret += f(fmtp++, 1); + continue; + } + + fmtp++; /* skip % */ + + /* find formatters */ + while (*fmtp != '\0') { + if (*fmtp >= '0' && *fmtp <= '9') { + /* length formatter keep only one digit */ + fmtp++; + } + else if (*fmtp == 'l') { + /* long - skip */ + fmtp++; + } + else if (*fmtp == 'z') { + /* auto type - skip */ + fmtp++; + } + else if (*fmtp == '-') { + /* left indent - skip */ + fmtp++; + } + else if (*fmtp == '*') { + /* valiable width */ + c = '0'; + int i; + int w = (char)va_arg(argp, int); + for(i = 0; i < w; i++) { + ret += f(&c, 1); + } + fmtp++; + } + else { + break; + } + } + + switch (*fmtp) { + case '%': + ret += f(fmtp, 1); + break; + case 'u': + case 'i': + case 'd': + { + int n = (int)va_arg(argp, int); + ret += my_writenum(f, n, 10); + break; + } + case 'x': + case 'p': + { + int n = (int)va_arg(argp, int); + ret += my_writenum(f, n, 16); + break; + } + case 's': + { + char* str = (char*)va_arg(argp, char*); + ret += f(str, (uint32_t)strlen(str)); + break; + } + case 'c': + { + char c = (char)va_arg(argp, int); + ret += f(&c, 1); + break; + } + default: + break; + } + fmtp++; + } +#if defined(USE_RH_UART) + if (f == _my_write) { + my_buffer[*my_offset + 1] = '\0'; + PrintTextln(my_buffer); + } +#elif defined(RH_PRINTF) + if (f == _my_write) { + my_buffer[*my_offset + 1] = '\0'; + dummy_printf(my_buffer); + } +#endif + return ret; +} + +int snprintf(char* buffer, size_t bufsz, const char* format, ...) +{ + int ret = 0; + va_list argp; + va_start(argp,format); + _set_string_write(buffer, bufsz); + ret = _my_vprintf(_string_write, format, argp); + va_end(argp); + return ret; +} + +int printf(const char* fmt, ...) +{ + int ret = 0; + va_list argp; + va_start(argp, fmt); + ret = _my_vprintf(_my_write, fmt, argp); + va_end(argp); + return ret; +} + +int hex_dump(uint32_t size, const uint8_t* data ) +{ + int ret = 0; + while (size > 0) { + if (data[0] < 0x10) { + ret += printf("0%x ", data[0]); + } else { + ret += printf("%x "); + } + data++; + size--; + } + return ret; +} + + + + + +/* Called by printf */ +static int _my_write(const char *buf, unsigned int sz) { + + if (buf == NULL) + return 0; + if (my_buffer == NULL) + return 0; + if (my_offset == NULL) + return 0; + if (sz == 0) + return 0; + if (sz > my_size) + return 0; + unsigned int offset = 0; + if (*my_offset + sz > my_size) { + offset = my_size - *my_offset; + memcpy(&my_buffer[*my_offset], buf, offset); + sz -= offset; + *my_offset = 0; + #if defined(USE_RH_UART) + my_buffer[my_size + 1] = '\0'; + PrintTextln(my_buffer); + #elif defined(RH_PRINTF) + my_buffer[my_size + 1] = '\0'; + #endif + } + memcpy(&my_buffer[*my_offset], buf + offset, sz); + *my_offset += sz; + return sz; +} + +void rh_string_init(size_t size, size_t* offset, char* buffer) +{ + my_size = size; + my_offset = offset; + my_buffer = buffer; + + /* Reset my_offset to be valid */ + if ( (my_offset != NULL) && + (my_buffer != NULL) && + (my_size != 0)) { + *my_offset = 0; + } +} + +int strncasecmp(const char *s1, const char * s2, unsigned int sz) +{ + for( ; sz>0; sz--, s1++, s2++){ + if(toupper(*s1) < toupper(*s2)){ + return -1; + } + if(toupper(*s1) > toupper(*s2)){ + return 1; + } + } + return 0; +} \ No newline at end of file diff --git a/Renesas/cs+/RH850/rsapss_sign_verify/rh_string.h b/Renesas/cs+/RH850/rsapss_sign_verify/rh_string.h new file mode 100644 index 00000000..54ab2d0f --- /dev/null +++ b/Renesas/cs+/RH850/rsapss_sign_verify/rh_string.h @@ -0,0 +1,43 @@ +/* rh_string.c + * + * Copyright (C) 2006-2025 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 PORT_RH_STRING_H_ +#define PORT_RH_STRING_H_ + +/* Use the system declarations */ +#include +#include +#include +#include +#include +#include + +/* Provide a limit of the printf format string to limit execution time */ +#define MAX_FMT_LEN 64 + + +/* Set up a user-provided circular buffer to capture printf output */ +void rh_string_init(size_t buffer_size, size_t *offset, char* buffer); + +/* Wrapper around printf that provides formatted hex output */ +int snprintf(char* buffer, size_t bufsz, const char* format, ...); + + +#endif /* !PORT_RH_STRING_H*/ \ No newline at end of file diff --git a/Renesas/cs+/RH850/rsapss_sign_verify/rsa_private_2048.c b/Renesas/cs+/RH850/rsapss_sign_verify/rsa_private_2048.c new file mode 100644 index 00000000..382067e8 --- /dev/null +++ b/Renesas/cs+/RH850/rsapss_sign_verify/rsa_private_2048.c @@ -0,0 +1,129 @@ +/* /mnt/c/tmp/rsa_private_2048.c */ + +static const unsigned char rsa_private_2048[] = +{ + 0x30, 0x82, 0x04, 0xBD, 0x02, 0x01, 0x00, 0x30, 0x0D, 0x06, + 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, + 0x05, 0x00, 0x04, 0x82, 0x04, 0xA7, 0x30, 0x82, 0x04, 0xA3, + 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xBB, 0xE3, + 0xDD, 0xF4, 0x68, 0x22, 0x6D, 0x30, 0x33, 0x17, 0xFF, 0x35, + 0xA2, 0xEE, 0x31, 0xA2, 0x65, 0x31, 0x7A, 0xF4, 0x2B, 0x79, + 0x95, 0x9F, 0x87, 0x75, 0x07, 0x5C, 0x74, 0x85, 0x3F, 0x84, + 0x93, 0x5E, 0x84, 0x80, 0xC4, 0x40, 0x52, 0xA7, 0x64, 0x36, + 0xCB, 0x0E, 0xC4, 0xF1, 0xFF, 0x96, 0x89, 0x4E, 0x82, 0x8B, + 0x84, 0x9C, 0x0F, 0x3E, 0x1B, 0x85, 0x9E, 0x95, 0x81, 0x7D, + 0xF1, 0x65, 0xC8, 0x1A, 0x71, 0xC6, 0x88, 0xEB, 0x0C, 0x2E, + 0x59, 0x7B, 0x44, 0xC6, 0xD7, 0x37, 0x01, 0x79, 0x3D, 0x3C, + 0x3C, 0xF3, 0x5C, 0xF7, 0xF2, 0xA9, 0xB9, 0x3F, 0xDE, 0x4C, + 0x0F, 0x45, 0x6D, 0x8F, 0xB4, 0xC8, 0xC2, 0x05, 0x81, 0x7A, + 0x7A, 0x3E, 0x18, 0x49, 0xEF, 0xBB, 0x5F, 0xC1, 0xC2, 0xE2, + 0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 0x31, 0x48, 0x6E, 0x44, 0xF3, 0x46, 0x96, 0x8C, 0xD3, 0xF4, + 0xE6, 0xD2, 0x94, 0xFC, 0x89, 0x45, 0xE8, 0x57, 0xB2, 0x59, + 0xF3, 0xFE, 0xB3, 0xA7, 0xFC, 0x8B, 0x8E, 0x4A, 0xFA, 0x4F, + 0x5E, 0xA8, 0xF3, 0x43, 0xC4, 0x01, 0x02, 0x81, 0x80, 0x40, + 0x33, 0x33, 0xCB, 0x30, 0x26, 0xFD, 0x8A, 0x7C, 0xF3, 0xCF, + 0xAA, 0xC5, 0xC5, 0x2B, 0x82, 0x0D, 0x90, 0x28, 0xFB, 0xB0, + 0x25, 0xB2, 0xB5, 0x3E, 0x20, 0x3A, 0x8E, 0xFF, 0x4C, 0x80, + 0x1F, 0xD9, 0xB1, 0x07, 0x5C, 0x12, 0x67, 0xC5, 0xD8, 0x83, + 0x1C, 0x61, 0x86, 0x19, 0x25, 0x44, 0x33, 0x93, 0x45, 0x2D, + 0xFA, 0xBC, 0xBF, 0x4E, 0x2B, 0xE6, 0x20, 0x41, 0x61, 0x13, + 0x28, 0xDC, 0xE5, 0xB4, 0x19, 0x93, 0xD0, 0xF8, 0xF1, 0x0C, + 0xCB, 0x8E, 0x3D, 0x26, 0xF4, 0x48, 0x62, 0xAD, 0xDA, 0x0D, + 0x60, 0xC1, 0x5F, 0xAF, 0x30, 0x35, 0x32, 0xCB, 0xE9, 0x80, + 0x72, 0x43, 0xAB, 0x1E, 0x1B, 0x43, 0xDA, 0x6E, 0x2D, 0x4D, + 0x28, 0x0E, 0x7A, 0x60, 0xE6, 0xB0, 0xE5, 0xDE, 0x63, 0x0D, + 0x0E, 0xC7, 0xCE, 0x6A, 0x6B, 0xE0, 0x6F, 0xC5, 0x43, 0x26, + 0xBD, 0x27, 0xD8, 0x49, 0xCF, 0x34, 0xF8 +}; +static const int sizeof_rsa_private_2048 = sizeof(rsa_private_2048); + diff --git a/Renesas/cs+/RH850/rsapss_sign_verify/rsa_private_3072.c b/Renesas/cs+/RH850/rsapss_sign_verify/rsa_private_3072.c new file mode 100644 index 00000000..56bb2866 --- /dev/null +++ b/Renesas/cs+/RH850/rsapss_sign_verify/rsa_private_3072.c @@ -0,0 +1,187 @@ +/* /mnt/c/tmp/rsa_private_3072.c */ + +static const unsigned char rsa_private_3072[] = +{ + 0x30, 0x82, 0x06, 0xFC, 0x02, 0x01, 0x00, 0x30, 0x0D, 0x06, + 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, + 0x05, 0x00, 0x04, 0x82, 0x06, 0xE6, 0x30, 0x82, 0x06, 0xE2, + 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x81, 0x00, 0xB2, 0xB7, + 0x6D, 0x19, 0xFA, 0x11, 0x4A, 0x1F, 0xF1, 0x86, 0xAE, 0x19, + 0x07, 0x4C, 0x31, 0xEB, 0x72, 0xED, 0xA1, 0x09, 0xA8, 0x48, + 0xF6, 0xC1, 0x81, 0xD5, 0x4A, 0x88, 0xA0, 0xED, 0x4C, 0xD7, + 0x77, 0x2C, 0xC8, 0xAF, 0x0A, 0xB1, 0xD1, 0x58, 0x33, 0x4E, + 0xF6, 0x4D, 0x31, 0x4F, 0x8E, 0x37, 0x87, 0xB8, 0xBE, 0x27, + 0x08, 0x93, 0x59, 0xAF, 0xC4, 0x78, 0xBF, 0xED, 0x94, 0x2F, + 0x07, 0xB9, 0x77, 0xB5, 0xAF, 0x12, 0x7F, 0x0E, 0x6C, 0x50, + 0x50, 0x70, 0xE6, 0x92, 0x96, 0x23, 0x81, 0x4B, 0x55, 0x3F, + 0xCB, 0x7B, 0x0E, 0xC3, 0x8A, 0xBF, 0x2C, 0xED, 0x62, 0xF3, + 0x4F, 0xF7, 0x9F, 0x2B, 0x7C, 0xE7, 0xB6, 0x9E, 0x9F, 0x86, + 0xBF, 0x43, 0x46, 0x50, 0xBF, 0x34, 0xFB, 0x73, 0x06, 0xF3, + 0xA4, 0xE6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B5, 0x4E, + 0x36, 0x6D, 0xBB, 0x12, 0xCC, 0x46, 0x8E, 0x0A, 0xF1, 0x7B, + 0x67, 0x00, 0xE1, 0x29, 0xC8, 0x37, 0x86, 0x9B, 0x89, 0xAD, + 0xA9, 0x9F +}; +static const int sizeof_rsa_private_3072 = sizeof(rsa_private_3072); + diff --git a/Renesas/cs+/RH850/rsapss_sign_verify/rsapss.c b/Renesas/cs+/RH850/rsapss_sign_verify/rsapss.c new file mode 100644 index 00000000..cd95cea9 --- /dev/null +++ b/Renesas/cs+/RH850/rsapss_sign_verify/rsapss.c @@ -0,0 +1,227 @@ +/* rsapss.c + * + * Copyright (C) 2006-2025 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 "rh_string.h" +#include +#include +#include +#include +#include + +/* enable one of two */ +#define USE_RSA2048 +/*#define USE_RSA3072*/ + +#if defined(USE_RSA2048) + #include "rsa_private_2048.c" + /* Key size in bits. */ + #define RSA_KEY_SIZE 2048 +#else + #include "rsa_private_3072.c" + /* Key size in bits. */ + #define RSA_KEY_SIZE 3072 +#endif + + + +byte hash[WC_SHA256_DIGEST_SIZE]; +byte pSignature[RSA_KEY_SIZE/8]; + +static int hash_msg(const char* msg, byte* hash) +{ + wc_Sha256 sha256; + int ret; + + printf("Hashing message: %s\n", msg); + + /* Initialize hash for use */ + ret = wc_InitSha256(&sha256); + if (ret < 0) { + printf(" error initializing SHA-256 hash", ret); + goto hash_end; + } + + /* Hash the message string. */ + ret = wc_Sha256Update(&sha256, (unsigned char*)msg, XSTRLEN(msg)); + if (ret < 0) { + printf(" error SHA-256 hashing msg ret=%d\n", ret); + goto hash_end; + } + + /* Generate hash value */ + ret = wc_Sha256Final(&sha256, hash); + if (ret < 0) { + printf(" error creating SHA-256 hash ret=%d\n", ret); + goto hash_end; + } + + ret = 0; +hash_end: + return ret; +} +/* load rsa private key */ +static int load_rsa_private_key(RsaKey* pRsaKey) +{ + int ret; + word32 idx = 0; + + /* Read Private key from pem format */ + const byte* keyData = + #if defined(USE_RSA2048) + (const byte*)rsa_private_2048; + #else + (const byte*)rsa_private_3072; + #endif + + word32 keySz = + #if defined(USE_RSA2048) + sizeof_rsa_private_2048; + #else + sizeof_rsa_private_3072; + #endif + + if ((ret = wc_RsaPrivateKeyDecode(keyData, &idx, pRsaKey, keySz)) != 0) { + wc_FreeRsaKey(pRsaKey); + ret = -1; + } + + return ret; +} + +static int sign_with_rsa_key(RsaKey* pRsaKey, WC_RNG* rng, const char* msg) +{ + int ret; + + /* Hash message to b signed */ + if (hash_msg(msg, hash) != 0 ) { + goto sign_end; + } + + printf("Signing hash of message\n"); + /* RSA-PSS sign */ + ret = wc_RsaPSS_Sign(hash, sizeof(hash), pSignature, sizeof(pSignature), + WC_HASH_TYPE_SHA256, WC_MGF1SHA256, pRsaKey, rng); + if (ret <= 0) { + printf(" RSA private encryption failed with error %d\n"); + goto sign_end; + } + + ret = 0; +sign_end: + return ret; +} + +static int verify_with_rsa_public_key(RsaKey* pRsaKey, const char* msg) +{ + int ret; + int sz = sizeof(pSignature); + byte pDecrypted[RSA_KEY_SIZE/8]; + byte* pt; + /* Hash message to be signed. */ + if (hash_msg(msg, hash) != 0) { + goto verify_end; + } + + printf("Verify hash of message\n"); + + /* Verify hash against signature with RSA public key. */ + pt = pDecrypted; + /* Verify the signature decrypts. */ + ret = wc_RsaPSS_VerifyInline(pSignature, sz, &pt, + WC_HASH_TYPE_SHA256, WC_MGF1SHA256, pRsaKey); + if (ret < 0) { + printf(" error verify signature ret=%d\n", ret); + goto verify_end; + } + sz = ret; + + /* Check PSS padding on decrypted signature. */ + ret = wc_RsaPSS_CheckPadding(hash, sizeof(hash), pt, sz, + WC_HASH_TYPE_SHA256); + if (ret < 0) { + printf(" error checking padding ret=%d\n", ret); + goto verify_end; + } + + printf("RSA PSS verify success\n"); + +verify_end: + return ret; +} + +int rsapss_sign_verify() +{ + RsaKey RsaKey; + WC_RNG rng; + const char* msg = "This is the string to be signed"; + int ret = 0; + + /* Initialize wolfCrypt for operations. */ + wolfCrypt_Init(); + + /* Initialize an random number generator for key generation and signing. */ + ret = wc_InitRng(&rng); + if (ret != 0) { + printf("Init RNG failed ret = %d\n", ret); + goto func_end; + } + + /* Initialize RSA key. */ + ret = wc_InitRsaKey(&RsaKey, NULL); + if (ret != 0) { + printf("Init RSA key failed ret=%d\n", ret); + goto func_end; + } + + /* Set the random number generator against RSA key for signing. */ + ret = wc_RsaSetRNG(&RsaKey, &rng); + if (ret != 0) { + printf("Set RSA RNG failed ret=%d\n", ret); + goto func_end; + } + + /* Load the RSA private key including Public */ + if (load_rsa_private_key(&RsaKey) != 0) { + ret = -1; + goto func_end; + } + + /* Sign the message with the RSA private key. */ + if (sign_with_rsa_key(&RsaKey, &rng, msg) != 0) { + ret = -1; + goto func_end; + } + /* Verify the message with the RSA public key. */ + if (verify_with_rsa_public_key(&RsaKey, msg) != 0) { + ret = -1; + goto func_end; + } + +func_end: + /* Zeroize and free any internally allocated data in RSA key. */ + wc_FreeRsaKey(&RsaKey); + /* Free any internally allocated data in random number generator. */ + wc_FreeRng(&rng); + + /* Cleanup wolfCrypt after operations. */ + wolfCrypt_Cleanup(); + return ret; +} + diff --git a/Renesas/cs+/RH850/rsapss_sign_verify/user_settings.h b/Renesas/cs+/RH850/rsapss_sign_verify/user_settings.h new file mode 100644 index 00000000..a084622d --- /dev/null +++ b/Renesas/cs+/RH850/rsapss_sign_verify/user_settings.h @@ -0,0 +1,69 @@ +/* user_settings.h + * + * Copyright (C) 2006-2025 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 + */ + +#define SIZEOF_LONG_LONG 8 + +#define WOLFSSL_NO_CURRDIR +#define WOLFSSL_LOG_PRINTF +#define NO_WOLFSSL_STUB +#define NO_DYNAMIC_ARRAY /* for compilers not allowed dynamic size array */ +#define WOLFSSL_SMALL_STACK +#define WOLFSSL_DH_CONST +#define TFM_TIMING_RESISTANT +#define ECC_TIMING_RESISTANT +#define WC_RSA_BLINDING +#define USER_TIME +#define XTIME time +#define USE_WOLF_SUSECONDS_T +#define USE_WOLF_TIMEVAL_T +#define WOLFSSL_USER_CURRTIME /* for benchmark */ +#define WOLFSSL_GENSEED_FORTEST /* Wardning: define your own seed gen */ +#define SINGLE_THREADED /* or define RTOS option */ + +#define HAVE_RSA +#define WC_RSA_PSS +#define XSTRCASECMP(s1,s2) strcmp((s1),(s2)) + +#define WOLFSSL_GMTIME +#define WOLFCRYPT_ONLY +#define WOLFSSL_CMAC + +#define NO_MAIN_DRIVER +#define NO_WRITEV +#define NO_DEV_RANDOM +#define NO_FILESYSTEM +#define NO_WOLFSSL_DIR +#define NO_DH +#define NO_DES3 +#define NO_DSA +#define NO_RC4 +#define NO_MD4 +#define NO_MD5 +#define NO_PSK +#define NO_PWDBASED +#define NO_ERROR_STRINGS +#define NO_WOLFSSL_SERVER +#define NO_WOLFSSL_CLIENT +#define NO_CRYPT_TEST +#define NO_CRYPT_BENCHMARK + +#define XVSNPRINTF snprintf +#define XSNPRINTF snprintf \ No newline at end of file