Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to align with DMA and connected features with wolfHSM PR#23 #4

Merged
merged 2 commits into from
Apr 19, 2024
Merged
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
16 changes: 1 addition & 15 deletions posix/tcp/wh_client_tcp/wh_client_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,7 @@
#include <string.h> /* For memset, memcpy */
#include <unistd.h> /* For usleep */

#if 0
#ifndef WOLFSSL_USER_SETTINGS
#include "wolfssl/options.h"
#endif
#include "wolfssl/wolfcrypt/settings.h"
#endif


#include "wolfhsm/wh_error.h"

#if 0
#include "wolfhsm/nvm.h"
#include "wolfhsm/nvm_flash.h"
#endif

#include "wolfhsm/wh_comm.h"
#include "wolfhsm/wh_message.h"
#include "wolfhsm/wh_client.h"
Expand Down Expand Up @@ -100,7 +86,7 @@ static void* wh_ClientTask(void* cf)
break;
}
}

wh_Client_CommClose(client);
ret = wh_Client_Cleanup(client);
printf("wh_Client_Cleanup:%d\n", ret);
return NULL;
Expand Down
1 change: 1 addition & 0 deletions posix/tcp/wh_server_tcp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ SRC_C += \
SRC_C += \
$(WOLFHSM_DIR)/src/wh_server.c \
$(WOLFHSM_DIR)/src/wh_server_customcb.c \
$(WOLFHSM_DIR)/src/wh_server_dma.c \
$(WOLFHSM_DIR)/src/wh_server_nvm.c \
$(WOLFHSM_DIR)/src/wh_server_crypto.c \
$(WOLFHSM_DIR)/src/wh_server_keystore.c \
Expand Down
5 changes: 3 additions & 2 deletions posix/tcp/wh_server_tcp/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

/* Common configuration */
#define WOLFCRYPT_ONLY
//#define BIG_ENDIAN_ORDER
/* #define BIG_ENDIAN_ORDER */
#define WOLF_CRYPTO_CB
//#define WOLFSSL_KEY_GEN
/* Key gen is currently required on the server */
#define WOLFSSL_KEY_GEN
#define SINGLE_THREADED
#define WC_NO_ASYNC_THREADING
#define WOLFSSL_USE_ALIGN
Expand Down
46 changes: 15 additions & 31 deletions posix/tcp/wh_server_tcp/wh_server_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,7 @@
#include <string.h> /* For memset, memcpy */
#include <unistd.h> /* For sleep */

#if 0
#ifndef WOLFSSL_USER_SETTINGS
#include "wolfssl/options.h"
#endif
#include "wolfssl/wolfcrypt/settings.h"
#endif


#include "wolfhsm/wh_error.h"

#if 0
#include "wolfhsm/nvm.h"
#include "wolfhsm/nvm_flash.h"
#endif

#include "wolfhsm/wh_comm.h"
#include "wolfhsm/wh_message.h"
#include "wolfhsm/wh_server.h"
Expand All @@ -31,7 +17,6 @@
static void* wh_ServerTask(void* cf);

enum {
REPEAT_COUNT = 10,
ONE_MS = 1000,
};

Expand All @@ -41,10 +26,10 @@ enum {

static void* wh_ServerTask(void* cf)
{
whServerContext server[1];
whServerConfig* config = (whServerConfig*)cf;
int ret = 0;
whServerContext server[1];
int counter = 1;
whCommConnected am_connected = WH_COMM_CONNECTED;

if (config == NULL) {
return NULL;
Expand All @@ -53,25 +38,24 @@ static void* wh_ServerTask(void* cf)
ret = wh_Server_Init(server, config);
printf("wh_Server_Init:%d\n", ret);

for(counter = 0; counter < REPEAT_COUNT; counter++)
{
do {
if (ret == 0) {
wh_Server_SetConnected(server, am_connected);

while(am_connected == WH_COMM_CONNECTED) {
ret = wh_Server_HandleRequestMessage(server);
if (ret != WH_ERROR_NOTREADY) {
if (ret == WH_ERROR_NOTREADY) {
usleep(ONE_MS);
} else if (ret == WH_ERROR_OK) {
printf("Server HandleRequestMessage:%d\n",ret);
} else {
printf("Failed to wh_Server_HandleRequestMessage: %d\n", ret);
break;
}
} while ((ret == WH_ERROR_NOTREADY) && (usleep(ONE_MS)==0));

if (ret != 0) {
printf("Server had failure. Exiting\n");
break;
} else {
printf("Server processed message %d of %d\n", counter + 1, REPEAT_COUNT);
wh_Server_GetConnected(server, &am_connected);
}
ret = wh_Server_Cleanup(server);
printf("ServerCleanup:%d\n", ret);
}
ret = wh_Server_Cleanup(server);
printf("ServerCleanup:%d\n", ret);

return NULL;
}

Expand Down