gaia-crypt
A hybrid encryption library in Rust that provides secure RSA + AES-GCM encryption and decryption functionality.
Overview
gaia-crypt implements a modern hybrid cryptographic system that combines:
- RSA encryption for secure key exchange
- AES-256-GCM for efficient data encryption with authentication
This approach leverages the strengths of both algorithms: RSA's security for key exchange and AES's performance for bulk data encryption.
Features
- Hybrid encryption model (RSA + AES-GCM)
- Strong 2048-bit RSA key generation
- AES-256-GCM authenticated encryption
- PEM key format support
- Rust-native implementation with minimal dependencies
- Comprehensive error handling
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage Examples
Generate a Key Pair
use generate_rsa_keypair;
Encrypt and Decrypt Data
use ;
How It Works
-
Encryption Process:
- A random AES-256 key is generated
- The plaintext is encrypted using AES-GCM with this key
- The AES key is encrypted using the recipient's RSA public key
- The encrypted key, nonce, and ciphertext are bundled and serialized
-
Decryption Process:
- The bundle is deserialized to extract components
- The AES key is decrypted using the recipient's RSA private key
- The ciphertext is decrypted using the recovered AES key and nonce
This approach securely encrypts data of arbitrary size while maintaining performance.
Security Considerations
- Uses standard, well-vetted cryptographic algorithms
- RSA keys are 2048 bits (sufficient for most use cases)
- AES-GCM provides authenticated encryption
- Nonces are generated randomly for each encryption
- No padding oracle vulnerabilities (uses PKCS#1 v1.5 for RSA)