Skip to content

Commit 5a0ad52

Browse files
committed
Add VaultIC wolfCrypt crypto callback (devId) support
1 parent 0f15af3 commit 5a0ad52

6 files changed

Lines changed: 261 additions & 56 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ USE_TLSV13
688688
USE_WINDOWS_API
689689
USE_WOLF_STRNSTR
690690
USS_API
691+
VLT_TLS_NO_ECDH
691692
W64LIT_FORCE_LONG_LONG
692693
WC_AESXTS_STREAM_NO_REQUEST_ACCOUNTING
693694
WC_AES_BS_WORD_SIZE

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,11 @@ 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().
527+
# VaultIC port supports PK callbacks and crypto callbacks (mirror autotools
528+
# --enable-vaultic). These options are declared later, so force them before
529+
# their add_option() calls.
529530
force_option(WOLFSSL_PKCALLBACKS "yes")
531+
force_option(WOLFSSL_CRYPTOCB "yes")
530532
endif()
531533

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

configure.ac

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12488,11 +12488,15 @@ if test "$ENABLED_VAULTIC" != "no"
1248812488
then
1248912489
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_VAULTIC"
1249012490
ENABLED_VAULTIC=yes
12491-
# VaultIC port is implemented via PK callbacks
12491+
# VaultIC port supports TLS PK callbacks and wolfCrypt crypto callbacks
1249212492
if test "$ENABLED_PKCALLBACKS" = "no"; then
1249312493
ENABLED_PKCALLBACKS=yes
1249412494
AM_CFLAGS="$AM_CFLAGS -DHAVE_PK_CALLBACKS"
1249512495
fi
12496+
if test "$ENABLED_CRYPTOCB" = "no"; then
12497+
ENABLED_CRYPTOCB=yes
12498+
AM_CFLAGS="$AM_CFLAGS -DWOLF_CRYPTO_CB"
12499+
fi
1249612500
fi
1249712501
1249812502
if test "x$ENABLED_WOLFENGINE" = "xyes"

wolfcrypt/src/port/sealsq/README.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ separate target (for example the SealSQ devkit builds it into its own
5050
`vaultic_wolfssl` library alongside an `add_subdirectory(wolfssl)` CMake
5151
build), two things are required so the file sees the wolfSSL configuration:
5252

53-
* Define `WOLFSSL_USE_OPTIONS_H` when compiling `vaultic.c`, so
54-
`settings.h` pulls in the generated `wolfssl/options.h`. Without it the
53+
* Make the file see the wolfSSL configuration. For an autotools build define
54+
`WOLFSSL_USE_OPTIONS_H`, so `settings.h` pulls in the generated
55+
`wolfssl/options.h`. For a build that does not use `./configure` (so there is
56+
no generated `options.h`), define `WOLFSSL_USER_SETTINGS` instead and provide
57+
a `user_settings.h` that lists all the build options. Without one of these the
5558
wolfSSL headers fall back to defaults (`ecc_key` is incomplete,
5659
`ECC_SECP256R1` is undeclared).
5760
* Enable PK callbacks through the wolfSSL build option
@@ -62,6 +65,11 @@ build), two things are required so the file sees the wolfSSL configuration:
6265

6366
## Usage
6467

68+
The port offers two ways to route ECC to the chip. They can be used
69+
independently or together.
70+
71+
### TLS PK callbacks
72+
6573
```c
6674
WOLFSSL_CTX* ctx = wolfSSL_CTX_new(wolfTLS_client_method());
6775

@@ -76,9 +84,34 @@ WOLFSSL_VAULTIC_SetupPkCallbackCtx(ssl, NULL);
7684
/* ... proceed with the TLS handshake ... */
7785
```
7886
79-
The VaultIC-TLS SDK must be initialized (`vlt_tls_init()`) before the
80-
handshake and closed (`vlt_tls_close()`) afterwards; see the SealSQ devkit
81-
sample applications.
87+
### Crypto callback (devId)
88+
89+
The crypto callback dispatches wolfCrypt ECC operations (not just the TLS
90+
handshake) to the VaultIC through the `WOLF_CRYPTO_CB` / devId framework.
91+
Register the device once, then select it with a devId:
92+
93+
```c
94+
/* register the VaultIC crypto callback under a devId */
95+
WOLFSSL_VAULTIC_RegisterCryptoCb(WOLF_VAULTIC_DEVID);
96+
97+
/* TLS: route this CTX's crypto to the device */
98+
wolfSSL_CTX_SetDevId(ctx, WOLF_VAULTIC_DEVID);
99+
100+
/* or bare wolfCrypt: init a key against the device */
101+
wc_ecc_init_ex(&key, NULL, WOLF_VAULTIC_DEVID);
102+
```
103+
104+
The VaultIC-TLS SDK must be initialized (`vlt_tls_init()`) before use and
105+
closed (`vlt_tls_close()`) afterwards; see the SealSQ devkit sample
106+
applications.
107+
108+
### Curve support
109+
110+
The port offloads P-256 (SECP256R1) only. The VaultIC 408 silicon supports
111+
P-384, but the vendor `vlt_tls` API exposes P-256 entry points only, so
112+
P-384 would require vendor `vlt_tls_*_P384` functions. For any other curve
113+
the crypto callback returns `CRYPTOCB_UNAVAILABLE` and the PK callbacks
114+
return `NOT_COMPILED_IN`, so wolfSSL falls back to software.
82115

83116
## Building and provisioning with the SealSQ devkit
84117

0 commit comments

Comments
 (0)