The WvdS Crypto Service is a ready-to-use black box. You don't need to compile or configure anything. Simply follow these three steps.
Add the Crypto Service to your modules.list:
-- modules.list module wvds_crypto_service module libcrypto.so.3 module libssl.so.3
Start the daemon in your Ned-Script:
local L4 = require("L4") -- Create shared memory for communication local crypto_ds = L4.Env.ram:create(64 * 1024, L4.Dataspace.ALL):m("rw") -- Start Crypto Daemon local crypto_daemon = L4.default_loader:start( { caps = { crypto_ep = crypto_ds:svr() } }, "rom/wvds_crypto_service" ) -- Your Gateway gets the client side local gateway = L4.default_loader:start( { caps = { crypto_ep = crypto_ds } }, "rom/iss_gateway" )
Explanation:
crypto_ds - Shared Memory Dataspace (64 KB)crypto_ep = crypto_ds:svr() - Server side for daemoncrypto_ep = crypto_ds - Client side for your GatewayInclude the header and use the helper functions:
#include "wvds_crypto.h" void encrypt_sensor_data(const uint8_t* data, size_t len) { uint8_t request[1024]; size_t request_len = sizeof(request); // Build request int rc = wvds_build_aes_encrypt_request( request, &request_len, 1, // Key-ID "sensor", 6, // AAD data, len // Plaintext ); if (rc == 0) { // Copy request to shared memory memcpy(shared_memory, request, request_len); // Signal daemon signal_crypto_daemon(); // Wait for response wait_for_response(); // Parse response uint8_t nonce[12], tag[16], ciphertext[1024]; size_t ct_len; wvds_parse_aes_encrypt_response( shared_memory, response_len, nonce, tag, ciphertext, &ct_len ); } }
That's all!
If you want to change the default settings, you can provide a config.json:
{
"version": "0.2.0",
"key_storage": {
"type": "file",
"path": "/data/keys",
"encryption": "aes-256-gcm"
},
"rate_limit": {
"max_requests_per_second": 1000,
"burst": 100
},
"logging": {
"level": "info",
"destination": "syslog"
}
}
| Type | Description |
file | Keys in filesystem (default) |
tpm | Keys in TPM 2.0 |
hsm | Keys in external HSM |
Check if the daemon is running correctly:
# L4Re Console l4> ps ... wvds_crypto_service ... # Send test request l4> crypto_test encrypt "Hello World" OK: Ciphertext = 0x...
| Problem | Solution |
| Daemon doesn't start | libcrypto.so.3 in modules.list? |
| Shared memory error | Dataspace large enough (min 64 KB)? |
| Capability error | crypto_ep correctly mapped? |
| FIPS error | fipsmodule.cnf present? |
See also Security > Troubleshooting for additional errors.