Skip to content

Commit 0f15af3

Browse files
committed
Fix VaultIC port PR review feedback
1 parent 8c01380 commit 0f15af3

4 files changed

Lines changed: 19 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ endif()
524524
add_option("WOLFSSL_VAULTIC" "Enable WISeKey/SealSQ VaultIC support (default: disabled)" "no" "yes;no")
525525
if(WOLFSSL_VAULTIC)
526526
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_VAULTIC")
527+
# VaultIC port requires PK callbacks (mirror autotools --enable-vaultic).
528+
# WOLFSSL_PKCALLBACKS is declared later, so force it before its add_option().
529+
force_option(WOLFSSL_PKCALLBACKS "yes")
527530
endif()
528531

529532
add_option("WOLFSSL_WOLFSENTRY" "Enable wolfSentry support (default: disabled)" "no" "yes;no")

wolfcrypt/src/port/sealsq/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ controller base addresses for the Pi 2/3 (`0x3f804000`) and Pi 4
145145
### Raspberry Pi 5 (RP1 / DesignWare I2C) - use a bit-banged bus
146146
147147
The Pi 5 does not work with the SDK's built-in bitrate control: its I2C
148-
controller lives in the RP1 chip (a Synopsys DesignWare controller behind
148+
controller lives in the RP1 chip (a DesignWare I2C controller behind
149149
PCIe) at a different address, so the SDK's `/dev/mem` register poke targets a
150150
controller that is not there and has no effect. Worse, the RP1 DesignWare
151151
controller itself hangs on the VaultIC's clock stretching during longer

wolfcrypt/src/port/sealsq/vaultic.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ int WOLFSSL_VAULTIC_EccVerifyCb(WOLFSSL* ssl,
114114

115115
(void)ssl;
116116
(void)ctx;
117-
*result = 0;
118117

119118
if (keyDer == NULL || sig == NULL || hash == NULL || result == NULL) {
120119
return BAD_FUNC_ARG;
121120
}
121+
*result = 0;
122122

123123
if ((err = wc_ecc_init(&key)) != 0) {
124124
WOLFSSL_MSG("wc_ecc_init");
@@ -369,7 +369,9 @@ int WOLFSSL_VAULTIC_LoadCertificates(WOLFSSL_CTX* ctx)
369369
}
370370

371371
WOLFSSL_MSG("[Device certificate]");
372+
#ifdef WOLFSSL_VAULTIC_DEBUG
372373
WOLFSSL_BUFFER(device_cert, sizeof_device_cert);
374+
#endif
373375

374376
/* Read CA certificate in VaultIC */
375377
WOLFSSL_MSG("Read CA Certificate in VaultIC");
@@ -391,19 +393,23 @@ int WOLFSSL_VAULTIC_LoadCertificates(WOLFSSL_CTX* ctx)
391393
}
392394

393395
WOLFSSL_MSG("[CA certificate]");
396+
#ifdef WOLFSSL_VAULTIC_DEBUG
394397
WOLFSSL_BUFFER(ca_cert, sizeof_ca_cert);
398+
#endif
395399

396400
/* Load CA certificate into WOLFSSL_CTX */
397-
if ((ret = wolfSSL_CTX_load_verify_buffer(ctx, ca_cert,
398-
sizeof_ca_cert, WOLFSSL_FILETYPE_ASN1)) != WOLFSSL_SUCCESS) {
401+
if (wolfSSL_CTX_load_verify_buffer(ctx, ca_cert,
402+
sizeof_ca_cert, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
399403
WOLFSSL_MSG("failed to load CA certificate");
404+
ret = WC_HW_E;
400405
goto free_cert_buffers;
401406
}
402407

403408
/* Load Device certificate into WOLFSSL_CTX */
404-
if ((ret = wolfSSL_CTX_use_certificate_buffer(ctx, device_cert,
405-
sizeof_device_cert, WOLFSSL_FILETYPE_ASN1)) != WOLFSSL_SUCCESS) {
409+
if (wolfSSL_CTX_use_certificate_buffer(ctx, device_cert,
410+
sizeof_device_cert, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
406411
WOLFSSL_MSG("failed to load Device certificate");
412+
ret = WC_HW_E;
407413
goto free_cert_buffers;
408414
}
409415

wolfssl/wolfcrypt/port/sealsq/vaultic.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
/* WISeKey/SealSQ VaultIC secure element port (PK callbacks) */
2323

24-
#ifndef _WOLFPORT_VAULTIC_H_
25-
#define _WOLFPORT_VAULTIC_H_
24+
#ifndef WOLFPORT_SEALSQ_VAULTIC_H
25+
#define WOLFPORT_SEALSQ_VAULTIC_H
2626

2727
#include <wolfssl/wolfcrypt/settings.h>
2828

@@ -57,7 +57,7 @@ WOLFSSL_API int WOLFSSL_VAULTIC_EccSharedSecretCb(WOLFSSL* ssl,
5757

5858
WOLFSSL_API int WOLFSSL_VAULTIC_LoadCertificates(WOLFSSL_CTX* ctx);
5959

60-
/* Helper API's for setting up callbacks */
60+
/* Helper APIs for setting up callbacks */
6161
WOLFSSL_API int WOLFSSL_VAULTIC_SetupPkCallbacks(WOLFSSL_CTX* ctx);
6262
WOLFSSL_API int WOLFSSL_VAULTIC_SetupPkCallbackCtx(WOLFSSL* ssl, void* user_ctx);
6363

@@ -67,4 +67,4 @@ WOLFSSL_API int WOLFSSL_VAULTIC_SetupPkCallbackCtx(WOLFSSL* ssl, void* user_ctx)
6767

6868
#endif /* WOLFSSL_VAULTIC */
6969

70-
#endif /* _WOLFPORT_VAULTIC_H_ */
70+
#endif /* WOLFPORT_SEALSQ_VAULTIC_H */

0 commit comments

Comments
 (0)