Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RPi-Pico/src/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ int time_init()
}
printf("%d, %d, %d, %d, %d, %d\n",
t.tm_year, t.tm_mon, t.tm_mday,
t.tm_hour, t.tm_min, &t.tm_sec);
t.tm_hour, t.tm_min, t.tm_sec);
if (t.tm_year < 70)
t.tm_year += 100; /* base year of 1900 */
t.tm_mon--;
epoch_base = mktime(&t);
printf("epoch base = %d\n", epoch_base);
printf("epoch base = %ld\n", epoch_base);
return 0;

}
2 changes: 1 addition & 1 deletion Renesas/cs+/RH850/rsapss_sign_verify/example_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ size_t _REL_sizeof_sysheap = SIZEOF_HEAP;

void main(void)
{
byte ret;
int ret;

R_SYSTEM_ClockInit();
R_SYSTEM_TimerInit();
Expand Down
12 changes: 7 additions & 5 deletions Renesas/cs+/RH850/rsapss_sign_verify/rsapss.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,19 @@ static int load_rsa_private_key(RsaKey* pRsaKey)
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 ) {
ret = hash_msg(msg, hash);
if (ret != 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");
printf(" RSA private encryption failed with error %d\n", ret);
goto sign_end;
}

Expand All @@ -135,7 +136,8 @@ static int verify_with_rsa_public_key(RsaKey* pRsaKey, const char* msg)
byte pDecrypted[RSA_KEY_SIZE/8];
byte* pt;
/* Hash message to be signed. */
if (hash_msg(msg, hash) != 0) {
ret = hash_msg(msg, hash);
if (ret != 0) {
goto verify_end;
}

Expand Down
12 changes: 1 addition & 11 deletions SGX_Linux/trusted/Wolfssl_Enclave.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ int enc_wolfSSL_Cleanup(void)
/* free up all WOLFSSL_CTX's */
for (id = 0; id < MAX_WOLFSSL_CTX; id++)
RemoveCTX(id);
wolfSSL_Cleanup();
return wolfSSL_Cleanup();
}

void printf(const char *fmt, ...)
Expand All @@ -349,16 +349,6 @@ void printf(const char *fmt, ...)
ocall_print_string(buf);
}

int sprintf(char* buf, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = vsnprintf(buf, BUFSIZ, fmt, ap);
va_end(ap);
return ret;
}

double current_time(void)
{
double curr;
Expand Down
1 change: 0 additions & 1 deletion SGX_Linux/trusted/Wolfssl_Enclave.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ extern "C" {
#endif

void printf(const char *fmt, ...);
int sprintf(char* buf, const char *fmt, ...);
double current_time(void);

#if defined(__cplusplus)
Expand Down
6 changes: 6 additions & 0 deletions TOPPERS/README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ If you have used the smart configurator to generate code for [r_bsp],[r_cmt_rx],
Note:<br>
`T4_Library_ether_ccrx_rxv1_little` may be an error in the linker immediately after configuration/build Clear There is, but `T4_Library_ether_ccrx_rxv1_little`` from [Linker]/[Archives]/[User defined archive (library) files (-I)]/[×] in [Settings] of the [Properties] dialog [C/C++ Build] of the project. Please delete it.

3-10. Local Verification of ECC Configuration (USE_ECC_CERT)

To locally compile and verify the build with ECC certificate support:
1. Define the macro `USE_ECC_CERT` in `TOPPERS/WolfSSLDemo/src/wolfDemo/user_settings.h` (e.g., `#define USE_ECC_CERT`) or add it to the compiler preprocessor macros list in the e² studio project configuration.
2. Build the project as described in step 3-8 to ensure that the code under `#if defined(USE_ECC_CERT)` compiles without errors.

### 3-1 Run Server Program

3-1-1. Enable `#define WOLFSSL_SERVER_TEST` in `wolf_demo.h`. IP addres will be assigned by DHCP.
Expand Down
2 changes: 1 addition & 1 deletion TOPPERS/WolfSSLDemo/src/wolfDemo/wolf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int wolfSSL_TLS_client(void *v_ctx, func_args *args)
cliecc_cert_der_256,
sizeof_cliecc_cert_der_256,
WOLFSSL_FILETYPE_ASN1);
if(err != SSL_SUCCESS) {
if(ret != SSL_SUCCESS) {
printf("ERROR: can't load client-certificate\n");
ret = -1;
goto exit_;
Expand Down
13 changes: 11 additions & 2 deletions caam/seco/cryptodev/ecc-sign-verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ static int createSignature(ecc_key* key, byte* sigOut, word32* sigOutSz,
int ret;
WC_RNG rng;

wc_InitRng(&rng);
ret = wc_InitRng(&rng);
if (ret != 0) {
printf("wc_InitRng failed with error %d\n", ret);
return ret;
}
ret = wc_ecc_sign_hash(msg, msgSz, sigOut, sigOutSz, &rng, key);
if (ret != 0) {
printf("sign hash failed with error %d\n", ret);
Expand Down Expand Up @@ -164,7 +168,12 @@ int main(int argc, char** argv)
printf("Could not initialize wolfSSL library!\n");
return -1;
}
wc_InitRng(&rng);
ret = wc_InitRng(&rng);
if (ret != 0) {
printf("wc_InitRng failed with error %d\n", ret);
wolfCrypt_Cleanup();
return -1;
}

XMEMSET(sig, 0, sigSz);
ret = createEccKey(&rng, &hardKey, 32, WOLFSSL_CAAM_DEVID);
Expand Down
7 changes: 6 additions & 1 deletion caam/seco/cryptodev/ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ int main(int argc, char** argv)
return -1;
}

wc_InitRng(&rng);
ret = wc_InitRng(&rng);
if (ret != 0) {
printf("wc_InitRng failed with error %d\n", ret);
wolfCrypt_Cleanup();
return -1;
}

ret = createEccKey(&rng, &hwKey, WOLFSSL_CAAM_DEVID);
if (ret != 0) {
Expand Down
3 changes: 3 additions & 0 deletions caam/seco/import-key.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ int main(int argc, char** argv)

TestAesCbc(&enc, &dec);

wc_AesFree(&enc);
wc_AesFree(&dec);

wc_SECO_CloseHSM();
wolfCrypt_Cleanup();
return 0;
Expand Down
17 changes: 15 additions & 2 deletions fullstack/freertos-wolfip-wolfssl-https/src/wolfip_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "wolfip_freertos.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
Expand All @@ -36,8 +37,20 @@

/* Implementation of wolfIP's required random number generator */
uint32_t wolfIP_getrandom(void) {
uint32_t ret;
getrandom(&ret, sizeof(ret), 0);
uint32_t ret = 0;
size_t got = 0;

while (got < sizeof(ret)) {
ssize_t r = getrandom(((uint8_t*)&ret) + got, sizeof(ret) - got, 0);
if (r <= 0) {
if (r < 0 && errno == EINTR) {
continue;
}
fprintf(stderr, "getrandom() failed, aborting\n");
abort();
}
got += (size_t)r;
}
return ret;
}

Expand Down
10 changes: 4 additions & 6 deletions lwip/example-lwip-native-echoclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#endif

#ifndef MAX_MSG_SIZE
#define MAX_MSG_SIZE
#define MAX_MSG_SIZE 1024
#endif

#define TEST_MSG "TLS **TEST 1** "
Expand Down Expand Up @@ -127,7 +127,7 @@ void tls_echoclient_connect(void)
/* read a reply from the server */
if (tlsWaitingForReply == 1) {
memset(reply, 0, sizeof(reply));
ret = wolfSSL_read(ssl, reply, sizeof(reply));
ret = wolfSSL_read(ssl, reply, sizeof(reply) - 1);
if (ret <= 0) {
err = wolfSSL_get_error(ssl, 0);
if (err != SSL_ERROR_WANT_READ &&
Expand All @@ -137,6 +137,7 @@ void tls_echoclient_connect(void)
}
}
if (ret > 0) {
reply[ret] = '\0';
loggingCb(0, reply);
shutdown(); /* received reply, done with connection */
}
Expand Down Expand Up @@ -181,10 +182,7 @@ static int TLS_setup(void)
return ERR_MEM;
}

#if 1
/* Disable peer certificate validation for testing */
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_NONE, NULL);
#endif
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, NULL);

ssl = wolfSSL_new(ctx);
if (ssl == NULL) {
Expand Down
10 changes: 5 additions & 5 deletions mynewt/client-tls-mn.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <shell/shell.h>
#include <mn_socket/mn_socket.h>
// #include <inet_def_service/inet_def_service.h>
/* #include <inet_def_service/inet_def_service.h> */

#include <assert.h>
#include <string.h>
Expand All @@ -57,7 +57,7 @@ extern time_t time(time_t*);
#define USE_CERT_BUFFERS_2048
#include <wolfssl/certs_test.h>

#define DEFAULT_IPADDR "93.184.216.34" // www.example.com
#define DEFAULT_IPADDR "93.184.216.34" /* www.example.com */
#define DEFAULT_PORT 443

struct os_sem test_sem;
Expand Down Expand Up @@ -173,11 +173,11 @@ net_cli(int argc, char **argv)
int port = DEFAULT_PORT;

if(argc > 3) {
// get ip address from argument
/* get ip address from argument */
addrStr = argv[2];
}
if(argc > 4) {
// get port number from argument
/* get port number from argument */
char *eptr = NULL;
port = strtoul(argv[3], &eptr, 0);
if (*eptr != '\0') {
Expand Down Expand Up @@ -381,7 +381,7 @@ static WOLFSSL* ssl = NULL;
static int wolfssl_ctx_init() {
if(wolfsslCtx && ssl) {
console_printf("ERROR: already initialize WOLFSSL_CTX and ssl\n");
return -1; // already init
return -1; /* already init */
}

/* Create and initialize WOLFSSL_CTX */
Expand Down
4 changes: 2 additions & 2 deletions psk/server-psk-tls13-multi-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ int main()
if (n > 0) {
printf("%s\n", buf);
/* server response */
if (wolfSSL_write(ssl, response, strlen(response)) >
strlen(response)) {
if (wolfSSL_write(ssl, response, strlen(response)) !=
(int)strlen(response)) {
printf("Fatal error : respond: write error\n");
return 1;
}
Expand Down
12 changes: 12 additions & 0 deletions stsafe/platform/stse_platform_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ stse_ReturnCode_t stse_platform_i2c_send_continue(
(void)speed;

if (data_size != 0) {
if ((PLAT_UI32)i2c_tx_frame_offset + data_size > I2C_BUFFER_SIZE) {
return STSE_PLATFORM_BUFFER_ERR;
}
if (pData == NULL) {
memset((I2c_tx_buffer + i2c_tx_frame_offset), 0x00, data_size);
} else {
Expand Down Expand Up @@ -150,6 +153,9 @@ stse_ReturnCode_t stse_platform_i2c_send_stop(

/* Add final element if provided */
if (pElement != NULL && element_size > 0) {
if ((PLAT_UI32)i2c_tx_frame_offset + element_size > I2C_BUFFER_SIZE) {
return STSE_PLATFORM_BUFFER_ERR;
}
memcpy((I2c_tx_buffer + i2c_tx_frame_offset), pElement, element_size);
i2c_tx_frame_offset += element_size;
}
Expand Down Expand Up @@ -203,6 +209,7 @@ stse_ReturnCode_t stse_platform_i2c_send(
return STSE_OK;
}

/* \note pFrame_payload must be at least I2C_BUFFER_SIZE bytes. */
stse_ReturnCode_t stse_platform_i2c_receive(
PLAT_UI8 busID,
PLAT_UI8 devAddr,
Expand Down Expand Up @@ -242,6 +249,11 @@ stse_ReturnCode_t stse_platform_i2c_receive(
}

PLAT_UI16 payload_len = ((PLAT_UI16)len_bytes[0] << 8) | len_bytes[1];

if (payload_len > I2C_BUFFER_SIZE) {
return STSE_PLATFORM_BUFFER_ERR;
}

*pFrame_payload_Length = payload_len;

if (payload_len > 0 && pFrame_payload != NULL) {
Expand Down
Loading