11# WISeKey / SealSQ VaultIC Port
22
3- This port offloads TLS ECC P-256 operations to a WISeKey/SealSQ VaultIC secure
4- element (for example the VaultIC 408 on the DEVKIT_VIC408) using wolfSSL's
5- public-key (PK) callbacks. The private key never leaves the chip.
3+ This port offloads ECC P-256 operations to a WISeKey/SealSQ VaultIC secure
4+ element (for example the VaultIC 408 on the DEVKIT_VIC408). The private key
5+ never leaves the chip.
6+
7+ It exposes the device through two mechanisms, which can be used independently
8+ or together:
9+
10+ * ** TLS PK callbacks** - route the ECC operations of a TLS handshake
11+ (` WOLFSSL_CTX ` / ` WOLFSSL ` ) to the device via wolfSSL's public-key (PK)
12+ callback framework.
13+ * ** wolfCrypt crypto callback (devId)** - route wolfCrypt ECC operations (not
14+ just the TLS handshake) to the device via the ` WOLF_CRYPTO_CB ` / devId
15+ framework, so bare ` wc_ecc_* ` calls and a whole ` WOLFSSL_CTX ` can be pointed
16+ at the chip with a single devId.
17+
18+ Both share the same underlying VaultIC-TLS SDK entry points; see "Usage" for
19+ which one to pick.
620
721## What it does
822
923` wolfcrypt/src/port/sealsq/vaultic.c ` provides:
1024
25+ ECC operations on the device (used by both mechanisms):
26+
1127* ` WOLFSSL_VAULTIC_EccSignCb ` - ECDSA P-256 sign on the device
1228* ` WOLFSSL_VAULTIC_EccVerifyCb ` - ECDSA P-256 verify on the device
1329* ` WOLFSSL_VAULTIC_EccKeyGenCb ` - ephemeral P-256 key generation on the device
1430* ` WOLFSSL_VAULTIC_EccSharedSecretCb ` - ECDH P-256 shared secret on the device
31+
32+ TLS PK callback registration:
33+
34+ * ` WOLFSSL_VAULTIC_SetupPkCallbacks ` / ` WOLFSSL_VAULTIC_SetupPkCallbackCtx ` -
35+ register the PK callbacks on a ` WOLFSSL_CTX ` / ` WOLFSSL `
36+
37+ Crypto callback (devId) registration:
38+
39+ * ` WOLFSSL_VAULTIC_RegisterCryptoCb ` - register the VaultIC crypto callback
40+ under a devId (` WOLF_VAULTIC_DEVID ` )
41+
42+ Certificate helper:
43+
1544* ` WOLFSSL_VAULTIC_LoadCertificates ` - read the device and CA certificates
1645 stored on the chip into a ` WOLFSSL_CTX `
17- * ` WOLFSSL_VAULTIC_SetupPkCallbacks ` / ` WOLFSSL_VAULTIC_SetupPkCallbackCtx ` -
18- register the callbacks on a ` WOLFSSL_CTX ` / ` WOLFSSL `
1946
2047The key-generation and shared-secret (ECDH) callbacks can be compiled out by
2148defining ` VLT_TLS_NO_ECDH ` , matching the vendor library configuration.
@@ -37,8 +64,9 @@ Enable the port and point the compiler/linker at the vendor SDK:
3764make
3865```
3966
40- ` --enable-vaultic ` defines ` WOLFSSL_VAULTIC ` and enables PK callbacks
41- (` HAVE_PK_CALLBACKS ` ) automatically. The port compiles to nothing when
67+ ` --enable-vaultic ` defines ` WOLFSSL_VAULTIC ` and automatically enables both PK
68+ callbacks (` HAVE_PK_CALLBACKS ` ) and crypto callbacks (` WOLF_CRYPTO_CB ` ), so
69+ either mechanism is available out of the box. The port compiles to nothing when
4270` WOLFSSL_VAULTIC ` is not defined.
4371
4472### Building the port outside libwolfssl
@@ -50,8 +78,11 @@ separate target (for example the SealSQ devkit builds it into its own
5078` vaultic_wolfssl ` library alongside an ` add_subdirectory(wolfssl) ` CMake
5179build), two things are required so the file sees the wolfSSL configuration:
5280
53- * Define ` WOLFSSL_USE_OPTIONS_H ` when compiling ` vaultic.c ` , so
54- ` settings.h ` pulls in the generated ` wolfssl/options.h ` . Without it the
81+ * Make the file see the wolfSSL configuration. For an autotools build define
82+ ` WOLFSSL_USE_OPTIONS_H ` , so ` settings.h ` pulls in the generated
83+ ` wolfssl/options.h ` . For a build that does not use ` ./configure ` (so there is
84+ no generated ` options.h ` ), define ` WOLFSSL_USER_SETTINGS ` instead and provide
85+ a ` user_settings.h ` that lists all the build options. Without one of these the
5586 wolfSSL headers fall back to defaults (` ecc_key ` is incomplete,
5687 ` ECC_SECP256R1 ` is undeclared).
5788* Enable PK callbacks through the wolfSSL build option
@@ -62,6 +93,14 @@ build), two things are required so the file sees the wolfSSL configuration:
6293
6394## Usage
6495
96+ The port offers two ways to route ECC to the chip (see the overview at the
97+ top). Use the PK callbacks when you only need the TLS handshake offloaded and
98+ want per-` WOLFSSL ` control; use the crypto callback (devId) when you want all
99+ wolfCrypt ECC - including bare ` wc_ecc_* ` calls - routed to the device, or
100+ prefer a single devId on the ` WOLFSSL_CTX ` .
101+
102+ ### TLS PK callbacks
103+
65104``` c
66105WOLFSSL_CTX * ctx = wolfSSL_CTX_new(wolfTLS_client_method());
67106
@@ -76,9 +115,34 @@ WOLFSSL_VAULTIC_SetupPkCallbackCtx(ssl, NULL);
76115/* ... proceed with the TLS handshake ... * /
77116```
78117
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.
118+ ### Crypto callback (devId)
119+
120+ The crypto callback dispatches wolfCrypt ECC operations (not just the TLS
121+ handshake) to the VaultIC through the `WOLF_CRYPTO_CB` / devId framework.
122+ Register the device once, then select it with a devId:
123+
124+ ```c
125+ /* register the VaultIC crypto callback under a devId */
126+ WOLFSSL_VAULTIC_RegisterCryptoCb(WOLF_VAULTIC_DEVID);
127+
128+ /* TLS: route this CTX's crypto to the device */
129+ wolfSSL_CTX_SetDevId(ctx, WOLF_VAULTIC_DEVID);
130+
131+ /* or bare wolfCrypt: init a key against the device */
132+ wc_ecc_init_ex(&key, NULL, WOLF_VAULTIC_DEVID);
133+ ```
134+
135+ The VaultIC-TLS SDK must be initialized (` vlt_tls_init() ` ) before use and
136+ closed (` vlt_tls_close() ` ) afterwards; see the SealSQ devkit sample
137+ applications.
138+
139+ ### Curve support
140+
141+ The port offloads P-256 (SECP256R1) only. The VaultIC 408 silicon supports
142+ P-384, but the vendor ` vlt_tls ` API exposes P-256 entry points only, so
143+ P-384 would require vendor ` vlt_tls_*_P384 ` functions. For any other curve
144+ the crypto callback returns ` CRYPTOCB_UNAVAILABLE ` and the PK callbacks
145+ return ` NOT_COMPILED_IN ` , so wolfSSL falls back to software.
82146
83147## Building and provisioning with the SealSQ devkit
84148
0 commit comments