Add wolfCrypt sample on RH850 using CS+

pull/509/head
Hideki Miyazaki 2025-06-19 08:57:54 +09:00
parent 41d61d2e95
commit 932dbf73a4
9 changed files with 3813 additions and 0 deletions

View File

@ -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||
|<a id="sw_package"></a> 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 `<wolfssl-examples>\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 `<wolfssl-examples>\Renesas\cs+\RH850`
### Build RSA PSS Sign and Verify Sample
1. Open [CS+](#DeviceFile) project file under `<wolfssl-examples>\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
```

View File

@ -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 <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/aes.h>
#include <wolfssl/wolfcrypt/cmac.h>
#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 <stddef.h>
#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);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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;
}

View File

@ -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 <stddef.h>
#include <string.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
/* 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*/

View File

@ -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, 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0,
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);

View File

@ -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,
0xF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48, 0xFC, 0x44, 0x25, 0xED,
0x83, 0x93, 0xAB, 0x00, 0x41, 0x8C, 0x56, 0x80, 0x9D, 0xE3,
0xFE, 0x7B, 0x7F, 0xED, 0xA3, 0x71, 0xEA, 0x79, 0x8A, 0x2A,
0x15, 0xA7, 0x7F, 0x58, 0x1F, 0x4D, 0x4A, 0x65, 0x1D, 0x04,
0x9D, 0x78, 0x0D, 0xC0, 0x1A, 0x62, 0xF9, 0x6B, 0x65, 0x82,
0x8C, 0x57, 0x6C, 0xB3, 0x49, 0xE1, 0xFC, 0xF0, 0x74, 0xF7,
0x87, 0x90, 0xDA, 0x8F, 0xD6, 0xCD, 0x80, 0x35, 0xB5, 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);

View File

@ -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 <wolfssl/wolfcrypt/rsa.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/asn_public.h>
#include <wolfssl/wolfcrypt/signature.h>
/* 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;
}

View File

@ -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