Skip to content

Commit a53cc21

Browse files
update macro guards for handling WOLFHSM_CFG_NO_CRYPTO
1 parent 52b34d6 commit a53cc21

5 files changed

Lines changed: 13 additions & 11 deletions

File tree

examples/posix/wh_posix_client/wh_posix_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ int main(int argc, char** argv)
211211
wh_PosixClient_ExampleTlsConfig(c_conf);
212212
}
213213
#endif
214-
#ifndef NO_PSK
214+
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_PSK)
215215
else if (strcmp(type, "psk") == 0) {
216216
printf("Using TLS PSK transport\n");
217217
wh_PosixClient_ExamplePskConfig(c_conf);

examples/posix/wh_posix_client/wh_posix_client_cfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ int wh_PosixClient_ExampleTcpConfig(void* c_conf);
77
#ifndef WOLFHSM_CFG_NO_CRYPTO
88
int wh_PosixClient_ExampleTlsConfig(void* c_conf);
99
#endif
10-
#ifndef NO_PSK
10+
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_PSK)
1111
int wh_PosixClient_ExamplePskConfig(void* c_conf);
1212
#endif
1313
int wh_PosixClient_ExampleSetupDmaMemory(void* ctx, void* c_conf);

examples/posix/wh_posix_server/wh_posix_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ int main(int argc, char** argv)
355355
return -1;
356356
}
357357
}
358-
#ifndef NO_PSK
358+
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_PSK)
359359
else if (strcmp(type, "psk") == 0) {
360360
printf("Using TLS PSK transport\n");
361361
rc = wh_PosixServer_ExamplePskConfig(s_conf);

examples/posix/wh_posix_server/wh_posix_server_cfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int wh_PosixServer_ExampleTcpConfig(void* s_conf);
99
#ifndef WOLFHSM_CFG_NO_CRYPTO
1010
int wh_PosixServer_ExampleTlsConfig(void* s_conf);
1111
#endif
12-
#ifndef NO_PSK
12+
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_PSK)
1313
int wh_PosixServer_ExamplePskConfig(void* s_conf);
1414
#endif
1515
int wh_PosixServer_ExampleNvmConfig(void* conf, const char* nvmInitFilePath);

port/posix/posix_transport_tls.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ extern int posixTransportTcp_HandleConnect(posixTransportTcpClientContext* c);
106106
int posixTransportTls_SendRequest(void* context, uint16_t size,
107107
const void* data)
108108
{
109-
int err;
110-
int rc;
111109
#ifndef WOLFHSM_CFG_NO_CRYPTO
112110
posixTransportTlsClientContext* ctx =
113111
(posixTransportTlsClientContext*)context;
112+
int err;
113+
int rc;
114114

115115
if (!ctx || !data || size == 0) {
116116
return WH_ERROR_BADARGS;
@@ -159,10 +159,11 @@ int posixTransportTls_SendRequest(void* context, uint16_t size,
159159
int posixTransportTls_RecvResponse(void* context, uint16_t* out_size,
160160
void* data)
161161
{
162-
int err;
163162
#ifndef WOLFHSM_CFG_NO_CRYPTO
164163
posixTransportTlsClientContext* ctx =
165164
(posixTransportTlsClientContext*)context;
165+
int rc;
166+
int err;
166167

167168
if (!ctx || !data || !out_size) {
168169
return WH_ERROR_BADARGS;
@@ -181,8 +182,8 @@ int posixTransportTls_RecvResponse(void* context, uint16_t* out_size,
181182
wolfSSL_set_fd(ctx->ssl, ctx->connect_fd_p1 - 1);
182183
}
183184

184-
int rc = wolfSSL_read(ctx->ssl, data, PTTLS_PACKET_MAX_SIZE);
185-
err = wolfSSL_get_error(ctx->ssl, rc);
185+
rc = wolfSSL_read(ctx->ssl, data, PTTLS_PACKET_MAX_SIZE);
186+
err = wolfSSL_get_error(ctx->ssl, rc);
186187
if (rc > 0) {
187188
*out_size = (uint16_t)rc;
188189
return WH_ERROR_OK;
@@ -276,6 +277,7 @@ int posixTransportTls_RecvRequest(void* context, uint16_t* out_size, void* data)
276277
posixTransportTlsServerContext* ctx =
277278
(posixTransportTlsServerContext*)context;
278279
int rc;
280+
int err;
279281

280282
if (!ctx || !data || !out_size) {
281283
return WH_ERROR_BADARGS;
@@ -339,8 +341,8 @@ int posixTransportTls_RecvRequest(void* context, uint16_t* out_size, void* data)
339341
}
340342

341343
/* Read data from SSL connection */
342-
rc = wolfSSL_read(ctx->ssl, data, PTTLS_PACKET_MAX_SIZE);
343-
int err = wolfSSL_get_error(ctx->ssl, rc);
344+
rc = wolfSSL_read(ctx->ssl, data, PTTLS_PACKET_MAX_SIZE);
345+
err = wolfSSL_get_error(ctx->ssl, rc);
344346
if (rc > 0) {
345347
*out_size = (uint16_t)rc;
346348
return WH_ERROR_OK;

0 commit comments

Comments
 (0)