STM32, IAR, STATIC_MEMORY
i have some problems - cant get "method", in function wolfTLSv1_2_client_method - always getting NULL
this is my user_settnigs.h :
#define SINGLE_THREADED /* or define RTOS option */
#define NO_FILESYSTEM
#define NO_ASN_TIME
#define NO_WOLFSSL_SERVER
#define NO_INLINE
#define USER_TIME
#define WOLFSSL_USER_IO
#define SIZEOF_LONG_LONG 8
#define WOLFSSL_STATIC_MEMORY
#define USE_FAST_MATH
#define WOLFSSL_NO_MALLOC
this is my settnigs.h :
This is my tls-client function:
#define MAXSZ 1024
#define MAXxxx 256
/*------------------------------------------------------------------------*/
/* TLS CLIENT */
/*------------------------------------------------------------------------*/
int tls_client_func(void)
{
char reply[MAXSZ];
int msgSz, error;
char msg[] = "Hello WolfSSL!\r\n";
WOLFSSL_CTX* ctx;
WOLFSSL* ssl;
int ret;
int MAX_CONCURRENT_HANDSHAKES = 1024;
int MAX_CONCURRENT_IO = 1024;
unsigned char memory[MAXxxx];
int memorySz = MAXxxx;
unsigned char IO[MAXxxx];
int IOSz = MAXxxx;
int flag = WOLFMEM_IO_POOL | WOLFMEM_TRACK_STATS;
// create ctx also using static memory, start with general memory to use
ctx = NULL;
wolfSSL_Init();
[b] // Here, next function doesnt work, gets not SSL_SUCCESS[/b]
ret = wolfSSL_CTX_load_static_memory(&ctx, wolfTLSv1_2_client_method_ex, memory, memorySz, 0, MAX_CONCURRENT_HANDSHAKES);
if (ret != SSL_SUCCESS) {
// handle error case
goto fail;
}
// load in memory for use with IO
ret = wolfSSL_CTX_load_static_memory(&ctx, NULL, IO, IOSz, flag, MAX_CONCURRENT_IO);
if (ret != SSL_SUCCESS) {
// handle error case
goto fail;
}
/*------------------------------------------------------------------------*/
/* ECDHE-ECDSA */
/*------------------------------------------------------------------------*/
/*--------------------*/
/* for peer auth use: */
/*--------------------*/
// wolfSSL_CTX_load_verify_buffer(ctx, rsa_key_der_1024,
// sizeof_rsa_key_der_1024, SSL_FILETYPE_ASN1);
// wolfSSL_CTX_load_verify_buffer(ctx, server_cert_der_1024,
// sizeof_server_cert_der_1024, SSL_FILETYPE_ASN1);
/*---------------------*/
/* for no peer auth: */
/*---------------------*/
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
/*---------------------*/
/* end peer auth option*/
/*---------------------*/
if ((ret = wolfSSL_CTX_set_cipher_list(ctx, "ECDHE-ECDSA-AES128-SHA256")) != SSL_SUCCESS) {
wolfSSL_CTX_free(ctx);
//printf("CTXset_cipher_list failed, error: %d\n", ret);
goto fail;
}
/*------------------------------------------------------------------------*/
/* END CIPHER SUITE OPTIONS */
/*------------------------------------------------------------------------*/
wolfSSL_CTX_SetIORecv(ctx, CbIORecv);
wolfSSL_CTX_SetIOSend(ctx, CbIOSend);
/*
if ((ssl = wolfSSL_new(ctx)) == NULL) {
error = wolfSSL_get_error(ssl, 0);
//printf("wolfSSL_new failed %d\n", error);
wolfSSL_CTX_free(ctx);
return -1;
}
*/
/* non blocking accept and connect */
ret = SSL_FAILURE;
while (ret != SSL_SUCCESS) {
/* client connect */
ret = wolfSSL_connect(ssl);
error = wolfSSL_get_error(ssl, 0);
if (ret != SSL_SUCCESS) {
if (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_WRITE) {
/* Fail */
//printf("wolfSSL connect failed with return code %d\n", error);
goto fail;
}
}
/* Success */
}
/* read and write */
while (1) {
/* client send/read */
msgSz = sizeof(msg);
ret = wolfSSL_write(ssl, msg, msgSz);
error = wolfSSL_get_error(ssl, 0);
if (ret != msgSz) {
if (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_WRITE) {
/* Write failed */
goto fail;
}
}
/* Write succeeded */
break;
}
while (1) {
ret = wolfSSL_read(ssl, reply, sizeof(reply) - 1);
error = wolfSSL_get_error(ssl, 0);
if (ret < 0) {
if (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_WRITE) {
/* Can put print here, the server enters a loop waiting to read
* a confirmation message at this point */
// printf("client read failed\n");
goto fail;
}
continue;
}
else {
/* Can put print here, the server enters a loop waiting to read
* a confirmation message at this point */
reply[ret] = '\0';
// printf("Client Received Reply: %s\n", reply);
break;
}
}
return 0;
fail:
wolfSSL_shutdown(ssl);
wolfSSL_free(ssl);
wolfSSL_CTX_free(ctx);
return -1;
}