shield-core
EXPTIME-secure encryption library for Rust - symmetric cryptography with proven exponential-time security.
Why Shield?
Shield uses only symmetric primitives with EXPTIME-hard security guarantees. Breaking requires 2^256 operations - no shortcut exists:
- PBKDF2-SHA256 for key derivation (100,000 iterations)
- SHA256-based stream cipher (AES-256-CTR equivalent)
- HMAC-SHA256 for authentication
Installation
[]
= "2.2"
For WebAssembly:
[]
= { = "2.2", = ["wasm"] }
For Confidential Computing (TEE attestation):
[]
= { = "2.2", = ["confidential"] }
Quick Start
Basic Encryption
use Shield;
// Password-based encryption
let shield = new;
let encrypted = shield.encrypt?;
let decrypted = shield.decrypt?;
Pre-shared Key
use ;
let key = ; // Your 32-byte key
let encrypted = quick_encrypt?;
let decrypted = quick_decrypt?;
Large File Encryption
use StreamCipher;
let cipher = from_password;
let data = vec!; // 1MB
let encrypted = cipher.encrypt?;
let decrypted = cipher.decrypt?;
Forward Secrecy (Ratchet)
use RatchetSession;
let root_key = ; // Exchanged via secure channel
let mut alice = new;
let mut bob = new;
// Each message uses a new key
let encrypted = alice.encrypt?;
let decrypted = bob.decrypt?;
Features
std(default): Standard library supportcli(default): Command-line interface (shieldbinary)wasm: WebAssembly support via wasm-bindgenasync: Async runtime support (Tokio)confidential: Confidential Computing with TEE attestationopenapi: OpenAPI/Swagger schema generation for APIs
CLI Tool
# Install
# Encrypt/decrypt files
# Check password strength
# Encrypt text directly
# Generate random key
# Show info
Password Strength
use ;
let result = check_password;
println!;
println!; // Strong
println!;
if !result.is_acceptable
Confidential Computing
Hardware-based attestation for Trusted Execution Environments (requires confidential feature).
Supported Platforms
| Platform | Provider | Attestation |
|---|---|---|
| AWS Nitro Enclaves | NitroAttestationProvider |
COSE-signed PCR measurements |
| GCP Confidential VMs | SEVAttestationProvider |
AMD SEV-SNP + vTPM |
| Azure Confidential | MAAAttestationProvider |
Microsoft Azure Attestation |
| Intel SGX | SGXAttestationProvider |
DCAP quotes (MRENCLAVE/MRSIGNER) |
Usage
use ;
use Arc;
// Create provider for your platform
let provider = new;
// Key manager with attestation gating
let key_manager = new;
// Get keys only after attestation verification
let key = key_manager.derive_key.await?;
SGX Sealed Storage
use ;
let storage = new;
storage.store.await?;
let data = storage.load.await?;
API Reference
Shield
Main encryption struct with password-derived keys.
StreamCipher
Streaming encryption for large files.
RatchetSession
Forward secrecy with key ratcheting.
PasswordStrength
Password strength analysis.
Interoperability
Shield produces byte-identical output across all implementations:
- Python:
pip install shield-crypto - Rust:
cargo add shield-core - JavaScript:
npm install @dikestra/shield
Security Model
Shield uses only symmetric primitives with unconditional security:
- Symmetric encryption (AES-256 equivalent)
- Hash functions (SHA-256)
- HMAC authentication (all MAC verifications use
subtle::ConstantTimeEq) - Key derivation (PBKDF2 + HMAC-SHA256 domain separation for enc_key/mac_key)
- Memory safety (
Zeroize/ZeroizeOnDropon all key-holding structs)
Breaking requires 2^256 operations - no shortcut exists.
v2.1 Security Hardening
Comprehensive hardening based on 189-finding security assessment:
- Key separation via HMAC-SHA256 domain labels (
shield-encrypt/shield-authenticate) - HMAC-SHA256 in all 13 internal modules (ratchet, rotation, group, identity, exchange, signatures)
- Counter overflow guards in all 8 keystream generators
- Timing-safe authentication preventing user enumeration
- 121 tests (106 unit + 7 interop + 8 doc-tests), clippy clean with
-D warnings
Safety
This crate uses #![forbid(unsafe_code)] and relies on audited cryptographic libraries:
ringfor PBKDF2, HMAC-SHA256, and random number generationsubtlefor constant-time operations
License
MIT License - Use freely.
See Also
- Shield Python Package
- Shield npm Package
- GitHub Repository
- BENCHMARKS.md - Performance comparison vs AES-GCM
- MIGRATION.md - Migration from Fernet, NaCl, etc.