Il WvdS Crypto Service è una black box pronta all'uso. Non dovete compilare o configurare nulla. Seguite semplicemente questi tre passi.
Aggiungete il Crypto Service alla vostra modules.list:
-- modules.list module wvds_crypto_service module libcrypto.so.3 module libssl.so.3
Avviate il daemon nel vostro Ned-Script:
local L4 = require("L4") -- Crea memoria condivisa per comunicazione local crypto_ds = L4.Env.ram:create(64 * 1024, L4.Dataspace.ALL):m("rw") -- Avvia Crypto Daemon local crypto_daemon = L4.default_loader:start( { caps = { crypto_ep = crypto_ds:svr() } }, "rom/wvds_crypto_service" ) -- Il vostro Gateway ottiene il lato client local gateway = L4.default_loader:start( { caps = { crypto_ep = crypto_ds } }, "rom/iss_gateway" )
Spiegazione:
crypto_ds - Dataspace memoria condivisa (64 KB)crypto_ep = crypto_ds:svr() - Lato server per daemoncrypto_ep = crypto_ds - Lato client per il vostro GatewayIncludete l'header e usate le funzioni helper:
#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); // Costruisci richiesta int rc = wvds_build_aes_encrypt_request( request, &request_len, 1, // Key-ID "sensor", 6, // AAD data, len // Testo in chiaro ); if (rc == 0) { // Copia richiesta in memoria condivisa memcpy(shared_memory, request, request_len); // Segnala al daemon signal_crypto_daemon(); // Attendi risposta wait_for_response(); // Analizza risposta 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 ); } }
Questo è tutto!
Se volete modificare le impostazioni predefinite, potete fornire un 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"
}
}
| Tipo | Descrizione |
file | Chiavi nel filesystem (predefinito) |
tpm | Chiavi nel TPM 2.0 |
hsm | Chiavi in HSM esterno |
Controllate se il daemon funziona correttamente:
# Console L4Re l4> ps ... wvds_crypto_service ... # Invia richiesta di test l4> crypto_test encrypt "Hello World" OK: Ciphertext = 0x...
| Problema | Soluzione |
| Daemon non si avvia | libcrypto.so.3 in modules.list? |
| Errore memoria condivisa | Dataspace abbastanza grande (min 64 KB)? |
| Errore capability | crypto_ep mappato correttamente? |
| Errore FIPS | fipsmodule.cnf presente? |
Vedi anche Sicurezza > Risoluzione problemi per errori aggiuntivi.