Skip to content

ehanoc/softKMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

95 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Disclaimer

This is a personal project, for the purpose of learning and also build a software based KSM with old and new crypto schemes; such as HD derivation or post-quantum FALCON signatures. It is not intended for production use, use at your own risk.

softKMS - Modern Software Key Management System

A secure, modern alternative to SoftHSM with HD wallet support, written in Rust.

License: AGPL--3.0 Rust

Use Cases: Enterprise key management, HD wallet infrastructure, PKCS#11 HSM replacement, development/testing environments.

Why softKMS?

Feature SoftHSM softKMS
Language C Rust (memory-safe)
HD Wallets ❌ βœ… BIP32/44
Crypto Fixed (RSA/ECC) Pluggable (Ed25519, P-256, Falcon-512, Falcon-1024)
APIs PKCS#11 only PKCS#11 + gRPC + CLI
Deployment Manual Docker + systemd
Identity Single user Multi-identity with isolation

Dependencies

  • libclang-dev

Setup

git submodule update --init --recursive

60-Second Quick Start

# Build
cargo build --release

# Start daemon
./target/release/softkms-daemon --foreground &

# Initialize with passphrase (admin)
./target/release/softkms init

# Create a client identity (for services/agents)
./target/release/softkms identity create --type ai-agent
# Token: <SAVE THIS!>

# Use token to generate keys (isolated to this identity)
./target/release/softkms --token <token> generate --algorithm ed25519 --label mykey

# Sign data
./target/release/softkms --token <token> sign --label mykey --data "Hello World"

Identity-Based Access Control

softKMS uses ECC public keys for identity and provides isolated access between clients:

  • Admin (passphrase): Full access to all keys
  • Clients (token): Access only to keys they create
  • Isolation: Each identity's keys are namespace-isolated

Creating Identities

# Create Ed25519 identity (default, fast)
$ softkms identity create --type ai-agent --description "Trading Bot"
Public Key: ed25519:MCowBQYDK2VwAyE...
Token: <SAVE THIS - never shown again!>

# Create P-256 identity (for PKCS#11 compatibility)
$ softkms identity create --type service --key-type p256
Public Key: p256:BL5a5tD5x0vM...
Token: <SAVE THIS>

Using Tokens

# Set token environment variable
export SOFTKMS_TOKEN="..."

# Or pass directly
softkms --token <token> list

# PKCS#11 (use token as PIN)
pkcs11-tool --module libsoftkms.so --login --pin "<token>" --list-keys

See Identity Management for complete documentation.

Key Features

  • πŸ” Secure Key Storage - AES-256-GCM encrypted at rest with PBKDF2 key derivation
  • πŸ‘₯ Identity Isolation - Multi-tenant with ECC-based identities (Ed25519 default, P-256 optional)
  • 🎟️ Bearer Tokens - Simple token-based auth with ownership isolation
  • 🌳 HD Wallet Support - BIP32/BIP44 hierarchical deterministic keys (Ed25519)
  • 🎯 Deterministic Derivation - P-256 for WebAuthn, Ed25519 BIP32/BIP44
  • πŸ“₯ xPub Import - Import BIP32 extended public keys for watch-only wallets
  • πŸ”„ Key Portability - Re-wrap keys for SSH/GPG use, never expose plaintext
  • πŸ›‘οΈ Post-Quantum Crypto - Falcon-512 and Falcon-1024 signatures (NIST PQC standard)
  • πŸ“‹ Audit Logging - Complete operation trail with identity context
  • πŸ”Œ Multiple APIs - PKCS#11, gRPC, REST, and CLI interfaces
  • πŸš€ Modern Architecture - Async Rust with pluggable storage backends
  • 🐳 Container-Ready - Docker and Kubernetes support
  • πŸ“Š Memory Safe - Zeroization of sensitive data, secure memory handling

Architecture

flowchart TB
    subgraph "Client Environment"
        CLI[CLI Client]
        PKCS[PKCS#11 Module]
        APP[Applications]
    end
    
    subgraph "Daemon Process"
        API[API Layer<br/>gRPC & REST]
        AUTH[Auth & Identity]
        KEYS[Key Service &<br/>Crypto Engines]
        SEC[Security Manager]
    end
    
    subgraph "Persistent Storage"
        STORE[Encrypted File Storage]
    end
    
    CLI --> API
    PKCS --> API
    APP --> API
    API --> AUTH
    AUTH --> KEYS
    KEYS --> SEC
    SEC --> STORE
    
    style Client Environment fill:#ffcccc
    style Daemon Process fill:#ccffcc
    style Persistent Storage fill:#ffffcc
Loading

Key Security Features:

  • Process Isolation: Keys never leave the daemon process
  • Client Isolation: CLI/PKCS#11 only send requests, receive signatures
  • Encrypted at Rest: AES-256-GCM with PBKDF2 key derivation

Project Structure

Component Location Key Files Description
CLI Client cli/src/ main.rs Command-line interface
gRPC API src/api/ grpc.rs, auth.rs, interceptor.rs gRPC server & auth
REST API src/api/ rest.rs HTTP REST endpoints
Identity src/identity/ mod.rs, types.rs, storage.rs, validation.rs Token-based auth
Key Service src/ key_service.rs Main key operations
Security src/security/ mod.rs, master_key.rs, wrapper.rs Encryption, key wrapping
Crypto src/crypto/ ed25519.rs, p256.rs, hd_ed25519.rs Signing algorithms
Falcon PQC src/crypto/falcon/ mod.rs, bindings.rs Post-quantum signatures
PKCS#11 src/pkcs11/ mod.rs, session.rs, rest_client.rs PKCS#11 provider
Storage src/storage/ mod.rs, file.rs, encrypted.rs File-based storage
Audit src/audit/ mod.rs Audit logging
HD Wallet src/crypto/ hd_ed25519.rs, p256.rs BIP32/BIP44 derivation

Installation

From Source

git clone https://github.com/your-org/softkms.git
cd softkms
cargo build --release

# Install binaries
sudo cp target/release/softkms-daemon /usr/local/bin/
sudo cp target/release/softkms /usr/local/bin/

Docker

docker build -t softkms -f docker/Dockerfile .
docker run -p 50051:50051 softkms

Documentation

Quick Commands

# Initialize daemon (admin)
softkms init

# Generate keys as admin
softkms generate --algorithm ed25519 --label mykey

# Create client identity
softkms identity create --type ai-agent

# Import HD wallet seed
softkms --token <token> import-seed --mnemonic "word1 word2 ..." --label wallet

# Derive child keys
softkms --token <token> derive --algorithm ed25519 --seed wallet --path "m/44'/283'/0'/0/0" --label derived-key

# Sign and verify
softkms --token <token> sign --label mykey --data "message"
softkms --token <token> verify --label mykey --data "message" --signature "..."

# Export key to SSH format (re-wrapped with passphrase)
softkms export-ssh --label mykey --output ~/.ssh/id_ed25519

# Export key to GPG format
softkms export-gpg --label mykey --user-id "User <user@example.com>"

# PKCS#11 usage
pkcs11-tool --module libsoftkms.so --list-slots
pkcs11-tool --module libsoftkms.so --login --pin "<token>" --keypairgen --key-type EC:prime256v1

Development

# Run tests
cargo test

# Run specific test
cargo test --test pkcs11_e2e_tests

# Build release
./build.sh

Project Status

Version: v0.1 - Functional with Tests

Implemented:

  • βœ… Daemon with gRPC and REST APIs
  • βœ… Ed25519 and P-256 crypto engines
  • βœ… Falcon-512 and Falcon-1024 post-quantum signatures
  • βœ… HD wallet derivation (BIP32/44)
  • βœ… PKCS#11 compatibility layer
  • βœ… Encrypted file storage
  • βœ… CLI client
  • βœ… Multi-identity with token-based auth
  • βœ… Key ownership isolation

In Progress:

  • 🚧 REST API (skeleton)
  • 🚧 WebAuthn module (skeleton)

Future:

  • TPM2 hardware integration
  • HashiCorp Vault backend
  • Prometheus metrics
  • Custom policies per identity

Security

softKMS uses industry-standard security practices:

  • AES-256-GCM for key encryption at rest
  • PBKDF2 with 210k iterations for master key derivation
  • Ed25519 and P-256 for cryptographic operations
  • Identity Isolation - Each client sees only their own keys
  • Secure memory handling with automatic zeroization
  • Key portability - Re-wrap keys for SSH/GPG use, never expose plaintext
  • Audit logging - All operations logged with identity context

See SECURITY.md for details.

License

AGPLv3 License - See LICENSE file

Contributing

Contributions welcome! Please read our Contributing Guide (TODO).

Support


Note: softKMS is currently in active development. APIs may change until v1.0.

Releases

No releases published

Packages

 
 
 

Contributors

Languages