Secure Key and Secrets Management
A comprehensive cryptographic key and secrets management system providing hardware-backed storage, automatic rotation, and integration with all SecureExecutionEnvironment components.
crypto-vault provides enterprise-grade secrets management with support for hardware security modules (HSM), Trusted Platform Modules (TPM), and secure enclaves. It ensures that cryptographic keys, passwords, certificates, and other sensitive data are protected both at rest and in transit.
- Hardware-Backed Storage: TPM 2.0, HSM, Intel SGX support
- Key Management: Generation, storage, rotation, revocation
- Secrets Storage: Encrypted storage for passwords, tokens, API keys
- Certificate Management: X.509 certificate lifecycle
- Key Derivation: HKDF, PBKDF2, Argon2 support
- Encryption Services: Encrypt/decrypt data with managed keys
- Signing Services: Digital signatures and verification
- Access Control: Fine-grained permission model
- Automatic Key Rotation: Policy-based rotation schedules
- Audit Trail: Comprehensive access logging
- Key Versioning: Multiple versions of keys
- Key Backup: Encrypted key escrow
- Namespace Isolation: Multi-tenant support
- Sealed Secrets: Bind secrets to specific system states
- Integration Hooks: Works with deterministic-executor
- High Availability: Distributed vault support
┌─────────────────────────────────────────────┐
│ Application Layer │
│ (Applications using crypto-vault) │
└─────────────────┬───────────────────────────┘
│
┌─────────────────▼───────────────────────────┐
│ Crypto Vault API │
│ - Key Management │
│ - Secret Storage │
│ - Encryption Services │
│ - Signing Services │
└─────────────────┬───────────────────────────┘
│
┌─────────────────▼───────────────────────────┐
│ Storage Backend │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ TPM │ │ HSM │ │ Secure │ │
│ │ 2.0 │ │ (PKCS11) │ │ Enclave │ │
│ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────┘
git submodule add https://github.com/navinBRuas/_SecureExecutionEnvironment.git vendor/secure-execution
cd vendor/secure-execution/crypto-vault
make#include <crypto-vault/vault.h>
int main() {
// Initialize vault
vault_context_t *vault = vault_new();
// Configure backend (TPM, HSM, or software)
vault_config_t config = {
.backend = VAULT_BACKEND_TPM,
.storage_path = "/var/lib/crypto-vault"
};
vault_set_config(vault, &config);
// Generate a key
vault_key_t *key = vault_generate_key(vault,
"my-app-key", VAULT_KEY_TYPE_AES_256);
// Encrypt data
const uint8_t *plaintext = (uint8_t*)"Secret data";
uint8_t *ciphertext;
size_t ciphertext_len;
vault_encrypt(vault, key, plaintext, 11,
&ciphertext, &ciphertext_len);
// Decrypt data
uint8_t *decrypted;
size_t decrypted_len;
vault_decrypt(vault, key, ciphertext, ciphertext_len,
&decrypted, &decrypted_len);
// Clean up
vault_key_free(key);
vault_free(vault);
return 0;
}// Store a secret
vault_store_secret(vault, "db-password",
(uint8_t*)"P@ssw0rd!", 9);
// Retrieve secret
uint8_t *secret;
size_t secret_len;
vault_get_secret(vault, "db-password", &secret, &secret_len);
// Delete secret
vault_delete_secret(vault, "db-password");// Generate certificate
vault_cert_t *cert = vault_generate_cert(vault,
"my-service",
"CN=my-service.example.com",
3650 // 10 years validity
);
// Sign data with certificate
vault_sign_with_cert(vault, cert, data, data_len, &signature);
// Verify signature
bool valid = vault_verify_signature(vault, cert,
data, data_len, signature);Create a new vault context.
Free vault context.
Configure vault parameters.
Generate a new cryptographic key.
Retrieve an existing key.
Delete a key.
Rotate a key to a new version.
List all keys.
Encrypt data with a key.
Decrypt data with a key.
Store a secret securely.
Retrieve a secret.
Delete a secret.
Create digital signature.
Verify digital signature.
Seal data to TPM PCR values.
Unseal TPM-sealed data.
crypto-vault:
# Backend configuration
backend:
type: tpm # tpm, hsm, sgx, software
device: /dev/tpm0
# Storage
storage:
path: /var/lib/crypto-vault
encrypted: true
# Key rotation
rotation:
enabled: true
default_period: 90d
# Access control
access:
require_authentication: true
audit_all_access: true
# High availability
ha:
enabled: false
replicas: 3// Seal secrets to deterministic execution state
vault_seal_to_execution_state(vault, secret,
deterministic_hash);
// Secrets only unsealable in same execution state// Provide secrets only to sandboxed processes
sandbox_config_t config = sandbox_config_new();
vault_context_t *vault = vault_new();
sandbox_config_set_vault(&config, vault);
sandbox_config_grant_secret(&config, "api-key");
// Sandboxed process can only access granted secrets- Linux kernel 5.0+
- libtss2-dev (for TPM support)
- libp11-dev (for PKCS#11/HSM support)
- OpenSSL 3.0+
make
sudo make installMIT License - See LICENSE
git submodule add https://github.com/navinBRuas/_SecureExecutionEnvironment.git vendor/secure-executionUse vendor/secure-execution/crypto-vault for local builds and integration.
Follow the C examples above and module headers for API details.
Configure vault backend, storage, rotation, and access policies via the YAML
config and vault_config_t.
Current version: 0.1.0 (see VERSION.md).
See CHANGELOG.md for release history.