age Rust library (Anubis Rage Edition)
Post-quantum secure file encryption library with ML-KEM-1024 support
age is a simple, modern, and secure file encryption library. This is the Anubis Rage edition, which extends the original age library with NIST Level-5 post-quantum cryptography through ML-KEM-1024 (Module-Lattice-Based Key-Encapsulation Mechanism).
Features
- 🔐 Quantum-Resistant: ML-KEM-1024 (NIST FIPS 203) for post-quantum security
- 🎯 Classical Algorithms: X25519, scrypt, and SSH key support remain available
- 🚀 Simple API: Small explicit keys, no config options, UNIX-style composability
- ⚡ High Performance: Efficient implementations via liboqs and Rust crypto ecosystem
- 🔒 NIST Level-5: Highest standardized post-quantum security level (256-bit equivalent)
What's New in Anubis Rage
This crate provides a set of Rust APIs that can be used to build tools based on the age format, with additional support for post-quantum cryptography:
- ML-KEM-1024 Recipients: Encrypt to quantum-resistant public keys
- ML-KEM-1024 Identities: Decrypt with quantum-resistant private keys
- Backward Compatible: Still supports X25519, scrypt, and SSH keys
- NIST Standardized: Implements FIPS 203 approved post-quantum KEM
The primary consumer of these APIs is the anubis-rage CLI tool, which provides straightforward quantum-resistant encryption and decryption of files or streams.
Format Specification
The age format specification is at age-encryption.org/v1.
Anubis Rage extends this with ML-KEM-1024 recipient stanzas:
-> MLKEM-1024 [base64-encoded-ciphertext]
[base64-encoded-wrapped-file-key]
The age format was designed by @Benjojo and @FiloSottile.
The reference interoperable Go implementation is available at filippo.io/age.
Installation
Add this line to your Cargo.toml:
= "0.11"
For post-quantum features, ensure you have liboqs installed:
macOS:
Ubuntu/Debian:
&& &&
&&
Usage
Basic Encryption/Decryption
use ;
use ;
use ;
// Generate a new ML-KEM-1024 identity (quantum-resistant)
let identity = generate;
let recipient = identity.to_public;
// Encrypt
let encryptor = with_recipients
.expect;
let mut encrypted = vec!;
let mut writer = encryptor.wrap_output?;
writer.write_all?;
writer.finish?;
// Decrypt
let decryptor = match new? ;
let mut decrypted = vec!;
let mut reader = decryptor.decrypt?;
reader.read_to_end?;
assert_eq!;
Using X25519 (Classical)
use x25519;
let identity = generate;
let recipient = identity.to_public;
// Use same Encryptor/Decryptor API as above
Using Passphrase Encryption
use scrypt;
let identity = new;
// Encrypt
let encryptor = with_user_passphrase;
// Decrypt using scrypt::Identity
API Documentation
See the documentation for complete API details and examples.
Feature Flags
armor- Enables theage::armormodule for ASCII-armored age filesasync- Enables asynchronous APIs for encryption and decryptioncli-common- Common helper functions for building age CLI toolsssh- Enables theage::sshmodule for reusing SSH key filesweb-sys- WebAssembly support for passphrase work factor calculationunstable- In-development functionality (no stability guarantees)
Security Considerations
Post-Quantum Security
ML-KEM-1024 provides:
- IND-CCA2 security: Indistinguishability under adaptive chosen-ciphertext attack
- NIST Level-5: Equivalent to AES-256 classical security
- Quantum resistance: Secure against Shor's and Grover's algorithms
- Standardized: NIST FIPS 203 compliant
Classical Security
X25519, scrypt, and SSH support remain available for:
- Backward compatibility with existing age files
- Integration with existing SSH infrastructure
- Scenarios where post-quantum security is not required
Recommendations
For long-term data protection or high-security scenarios, use ML-KEM-1024 recipients to ensure quantum resistance.
For short-term encryption or integration with existing systems, X25519 and SSH keys remain secure against classical attacks.
Comparison with Original rage
| Feature | Anubis Rage | Original rage |
|---|---|---|
| Post-Quantum Security | ✅ ML-KEM-1024 | ❌ No |
| NIST Standardized PQC | ✅ FIPS 203 | ❌ |
| X25519 Support | ✅ Yes | ✅ Yes |
| SSH Key Support | ✅ Yes | ✅ Yes |
| Passphrase Encryption | ✅ Yes | ✅ Yes |
| File Compatibility | ✅ Full | ✅ Standard age |
| Quantum Resistant | ✅ With ML-KEM | ❌ No |
Examples
Multiple Recipients
use ;
let x25519_identity = generate;
let mlkem_identity = generate;
// Encrypt to both classical and post-quantum recipients
let recipients: = vec!;
let encryptor = with_recipients
.expect;
Streaming Encryption
use Encryptor;
use Write;
let recipient = generate.to_public;
let encryptor = with_recipients?;
let output = create?;
let mut writer = encryptor.wrap_output?;
// Stream data in chunks
for chunk in data_chunks
writer.finish?;
ASCII Armoring
use ArmoredWriter;
let recipient = generate.to_public;
let encryptor = with_recipients?;
let output = Vecnew;
let armored = wrap_output?;
let mut writer = encryptor.wrap_output?;
writer.write_all?;
let armored_output = writer.finish?.into_inner?;
// armored_output contains ASCII-armored ciphertext
Library Development
Building
# Build the library
# Run tests
# Build with all features
Contributing
See CONTRIBUTING.md for guidelines on:
- Code style and conventions
- Adding new features
- Localization support
- Testing requirements
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Acknowledgments
- NIST - For post-quantum cryptography standardization (FIPS 203)
- Open Quantum Safe - For the liboqs ML-KEM-1024 implementation
- Filippo Valsorda & Ben Cox - For designing the age format
- Original rage contributors - For the excellent foundation
- Rust crypto community - For high-quality cryptography crates
Further Reading
- NIST Post-Quantum Cryptography
- FIPS 203: ML-KEM Standard
- age specification v1
- Open Quantum Safe Project
- Anubis Rage GitHub
Anubis Rage - Protecting your data in the quantum era.