Algorithm Selection Guide
This page covers the commonly used algorithms in cryptopp-modern and how to choose between them. It is a curated selection, not an exhaustive catalogue: the library also carries the wider inherited Crypto++ algorithm set, and fork additions such as XAES-256-GCM and AES-CTR-HMAC appear in their sections below.
Hash Functions
Recommended for new work
| Algorithm | Output Size | Standard | Use Case |
|---|---|---|---|
| BLAKE3 | 256-bit (variable) | BLAKE3 spec | Fast general-purpose hashing, file integrity, content addressing |
| SHA-256 | 256-bit | FIPS 180-4 | FIPS-standardised, general purpose |
| SHA-512 | 512-bit | FIPS 180-4 | FIPS-standardised, faster on 64-bit systems |
| SHA3-256 | 256-bit | FIPS 202 | NIST standard, alternative construction to SHA-2 |
| SHA3-512 | 512-bit | FIPS 202 | NIST standard, larger output |
| BLAKE2b | 512-bit (variable) | RFC 7693 | High performance alternative to SHA-2 |
| BLAKE2s | 256-bit (variable) | RFC 7693 | Optimised for 32-bit systems |
Legacy (Compatibility Only)
| Algorithm | Output Size | Status | Notes |
|---|---|---|---|
| SHA-1 | 160-bit | ⚠️ Deprecated | Use only for legacy compatibility |
| MD5 | 128-bit | ❌ Broken | Non-adversarial compatibility checks only |
| RIPEMD-160 | 160-bit | ⚠️ Legacy | Bitcoin compatibility |
| Tiger | 192-bit | ⚠️ Legacy | Rare use cases |
| Whirlpool | 512-bit | ⚠️ Legacy | Superseded by SHA-3 |
Header files: blake3.h, sha.h, sha3.h, blake2.h, md5.h, ripemd.h, tiger.h, whirlpool.h
Password Hashing & Key Derivation
Password Hashing
| Algorithm | Memory-Hard | Cost | Guidance |
|---|---|---|---|
| Argon2id | ✅ Yes | Tunable | Recommended for password hashing (RFC 9106 primary variant) |
| Argon2i | ✅ Yes | Tunable | Specialised side-channel-sensitive use |
| Argon2d | ✅ Yes | Tunable | Data-dependent access; not the general password default |
| scrypt | ✅ Yes | Tunable (N, r, p) | Compatibility or existing deployments (RFC 7914) |
| PBKDF2 | ❌ No | Tunable | Compatibility and constrained compliance profiles |
Key Derivation Functions (KDF)
| Algorithm | Type | Use Case |
|---|---|---|
| HKDF | Extract-and-expand | Key derivation from shared secrets |
| PBKDF2 | Iterative | Legacy key derivation, PKCS #5 |
| scrypt | Memory-hard | Existing scrypt-based deployments |
Header files: argon2.h, scrypt.h, pwdbased.h, hkdf.h
Symmetric Encryption
Block Ciphers
| Cipher | Key Sizes | Block Size | Standard | Notes |
|---|---|---|---|---|
| AES | 128, 192, 256-bit | 128-bit | FIPS 197 | Industry standard, hardware-accelerated where AES-NI exists |
| Serpent | 128, 192, 256-bit | 128-bit | AES finalist | High security margin, slower |
| Twofish | 128, 192, 256-bit | 128-bit | AES finalist | Compatibility |
| Camellia | 128, 192, 256-bit | 128-bit | ISO/IEC 18033-3 | International standard |
| ARIA | 128, 192, 256-bit | 128-bit | RFC 5794 | Korean standard |
Stream Ciphers
| Cipher | Key Size | Standard | Notes |
|---|---|---|---|
| ChaCha20 | 256-bit | RFC 8439 | Fast in software on platforms without AES hardware; use as part of ChaCha20-Poly1305 for authenticated encryption |
Authenticated Encryption
| Mode | Authentication | Notes |
|---|---|---|
| AES-GCM | Built-in | Fast authenticated encryption, the common default |
| ChaCha20-Poly1305 | Built-in | RFC 8439 AEAD, strong software performance |
| XAES-256-GCM | Built-in | Extended-nonce AES-GCM (C2SP specification), fork addition |
| AES-CTR-HMAC | Encrypt-then-MAC | Composed AEAD with explicit HMAC, fork addition |
| CCM | Built-in | Constrained environments |
| EAX | Built-in | Simple authenticated encryption |
Classical Modes (Require Separate MAC)
| Mode | Type | Use Case |
|---|---|---|
| CBC | Block | Traditional encryption (use with HMAC) |
| CTR | Stream | Parallelisable encryption |
| CFB | Stream | Self-synchronising stream cipher |
| OFB | Stream | Stream cipher mode |
| ECB | Block | ⚠️ Insecure - do not use |
Header files: aes.h, chacha.h, serpent.h, twofish.h, camellia.h, aria.h, modes.h, gcm.h, ccm.h, eax.h, chachapoly.h, xaes_256_gcm.h, aes_ctr_hmac.h
Public-Key Cryptography
Digital Signatures
| Algorithm | Classical Security Strength | Standard | Notes |
|---|---|---|---|
| Ed25519 | 128-bit | RFC 8032 | Default choice for new classical signatures |
| ECDSA (P-256) | 128-bit | FIPS 186-5 | NIST standard, wide compatibility |
| ECDSA (P-384) | 192-bit | FIPS 186-5 | Higher strength NIST curve |
| ECDSA (P-521) | 256-bit | FIPS 186-5 | Highest strength NIST curve |
| RSA (2048-bit) | 112-bit | PKCS #1 | Legacy compatibility |
| RSA (3072-bit) | 128-bit | PKCS #1 | Long-term classical security |
| RSA (4096-bit) | ~140-bit (estimated) | PKCS #1 | Larger keys at significant performance cost |
| DSA | Up to 128-bit | FIPS 186-4 (legacy) | Verification of existing signatures only; do not generate new DSA signatures |
Key Exchange
| Algorithm | Classical Security Strength | Standard | Notes |
|---|---|---|---|
| X25519 | 128-bit | RFC 7748 | Default choice for new classical key exchange |
| ECDH (P-256) | 128-bit | SP 800-56A | NIST standard key exchange |
| ECDH (P-384) | 192-bit | SP 800-56A | Higher strength key exchange |
| DH (2048-bit) | 112-bit | RFC 3526 groups | Traditional Diffie-Hellman, legacy |
Public-Key Encryption
| Algorithm | Key Size | Use Case |
|---|---|---|
| RSA-OAEP | 2048-4096-bit | Legacy public-key encryption |
| ECIES | Variable | Elliptic curve integrated encryption |
Header files: xed25519.h, eccrypto.h, rsa.h, dsa.h
Post-Quantum Cryptography
Key Encapsulation
| Algorithm | Standard | Security Category | Public Key Size | Ciphertext Size | Since |
|---|---|---|---|---|---|
| ML-KEM-512 | FIPS 203 | Category 1 | 800 bytes | 768 bytes | 2026.3.0 |
| ML-KEM-768 | FIPS 203 | Category 3 | 1,184 bytes | 1,088 bytes | 2026.3.0 |
| ML-KEM-1024 | FIPS 203 | Category 5 | 1,568 bytes | 1,568 bytes | 2026.3.0 |
| X-Wing | draft-connolly-cfrg-xwing-kem-09 | Category 3 | 1,216 bytes | 1,120 bytes | 2026.3.0 |
X-Wing is a hybrid of X25519 and ML-KEM-768. It implements a specific draft revision, named above; confirm the peer implements the same revision before relying on wire interoperability.
Digital Signatures
| Algorithm | Standard | Security | Public Key Size | Signature Size | Since |
|---|---|---|---|---|---|
| ML-DSA-44 | FIPS 204 | Category 2 | 1,312 bytes | 2,420 bytes | 2026.3.0 |
| ML-DSA-65 | FIPS 204 | Category 3 | 1,952 bytes | 3,309 bytes | 2026.3.0 |
| ML-DSA-87 | FIPS 204 | Category 5 | 2,592 bytes | 4,627 bytes | 2026.3.0 |
| SLH-DSA | FIPS 205 | Categories 1, 3 and 5 | 32-64 bytes | 7,856-49,856 bytes | 2026.3.0 |
| LMS/HSS | SP 800-208, SHA-256/N=32 parameter sets | Hash-based | 56-60 bytes | Varies by height, width and hierarchy | 2026.6.0 |
LMS/HSS is stateful: each signature consumes state that must be persisted durably. See the Stateful Signing Guide before using, and the Choosing LMS/HSS Parameters guide for signature sizes per configuration. Mixed per-level hierarchies and the LM-OTS W1/W2/W4 sets arrive in 2026.8.0.
Header files: mlkem.h, mldsa.h, slhdsa.h, xwing.h, lms.h, hss.h, stateful.h
Message Authentication Codes (MAC)
| Algorithm | Output Size | Standard | Use Case |
|---|---|---|---|
| HMAC-SHA256 | 256-bit | RFC 2104, FIPS 198-1 | General purpose MAC |
| HMAC-SHA512 | 512-bit | RFC 2104, FIPS 198-1 | Larger output MAC |
| BLAKE3 (keyed mode) | 256-bit | BLAKE3 spec | Native keyed hashing; fast MAC without the HMAC construction |
| CMAC-AES | 128-bit | SP 800-38B | Block cipher-based MAC |
| Poly1305 | 128-bit | RFC 8439 | One-time MAC; each key authenticates one message. Use the ChaCha20-Poly1305 AEAD rather than composing it yourself |
| GMAC | 128-bit | SP 800-38D | GCM authentication only |
| SipHash | 64-bit | SipHash spec | Keyed hashing for hash tables and short messages |
Header files: hmac.h, blake3.h, cmac.h, poly1305.h, siphash.h
Elliptic Curves
Modern Curves
| Curve | Type | Classical Security Strength | Use Case |
|---|---|---|---|
| Curve25519 | Montgomery | 128-bit | X25519 key exchange |
| Ed25519 | Edwards | 128-bit | Ed25519 signatures |
NIST Curves
| Curve | Type | Classical Security Strength | Use Case |
|---|---|---|---|
| P-256 (secp256r1) | Weierstrass | 128-bit | NIST standard, wide support |
| P-384 (secp384r1) | Weierstrass | 192-bit | Higher strength applications |
| P-521 (secp521r1) | Weierstrass | 256-bit | Highest strength NIST curve |
Other Curves
| Curve | Type | Notes |
|---|---|---|
| secp256k1 | Weierstrass | Bitcoin, Ethereum |
| brainpoolP256r1 | Weierstrass | European standard, 128-bit strength |
| brainpoolP384r1 | Weierstrass | European standard, 192-bit strength |
| brainpoolP512r1 | Weierstrass | European standard, 256-bit strength |
Header files: xed25519.h, eccrypto.h, asn.h (for curve OIDs)
Random Number Generators
Application CSPRNGs
| Generator | Type | Use Case |
|---|---|---|
| AutoSeededRandomPool | CSPRNG | The application default |
| OS_GenerateRandomBlock | OS entropy | Direct OS random source |
| RandomPool | CSPRNG | Manual seeding |
| LC_RNG | Deterministic | Testing only (not cryptographically secure) |
Hardware entropy sources
| Source | Type | Notes |
|---|---|---|
| RDRAND | CPU instruction | Intel/AMD instruction-level source; feed a CSPRNG rather than using directly |
| RDSEED | CPU instruction | Entropy-conditioning source; same guidance |
Header files: osrng.h, randpool.h, rdrand.h
Encoding & Utilities
Encoders
| Encoder | Use Case |
|---|---|
| HexEncoder | Hexadecimal encoding |
| Base64Encoder | Base64 encoding |
| Base32Encoder | Base32 encoding |
Compression
| Algorithm | Type |
|---|---|
| Gzip | Deflate compression |
| Zlib | Zlib compression |
Header files: hex.h, base64.h, base32.h, gzip.h, zlib.h
Algorithm Selection Guide
By Use Case
I need to hash data (file integrity, checksums):
- Modern projects: BLAKE3
- FIPS-standardised: SHA-256 or SHA-512
- Legacy compatibility: SHA-1 (deprecated)
I need to hash passwords:
- Modern projects: Argon2id
- Compatibility: PBKDF2 or scrypt
I need to encrypt data:
- Modern projects: AES-GCM or ChaCha20-Poly1305
- No AES hardware: ChaCha20-Poly1305
- FIPS-standardised: AES-GCM
I need digital signatures:
- Modern projects: Ed25519
- NIST-standardised: ECDSA (P-256)
- Legacy systems: RSA (2048-bit minimum)
- Long-lived or post-quantum requirements: ML-DSA, or a hybrid classical + PQC design where the protocol requires it
- Hash-based post-quantum: SLH-DSA for stateless use; LMS/HSS only where durable signer state can be managed
I need key exchange:
- Modern projects: X25519
- NIST-standardised: ECDH (P-256)
- Long-lived or post-quantum requirements: ML-KEM, or X-Wing where its exact draft revision is acceptable
- Legacy systems: DH (2048-bit minimum)
I need message authentication:
- General purpose: HMAC-SHA256
- Fast keyed hashing: BLAKE3 keyed mode
- Block cipher-based: CMAC-AES
Security Levels
Key Size Equivalents
| Symmetric | Hash output | RSA | ECC | Classical Strength |
|---|---|---|---|---|
| 128-bit | 256-bit | 3072-bit | 256-bit | 128-bit |
| 192-bit | 384-bit | 7680-bit | 384-bit | 192-bit |
| 256-bit | 512-bit | 15360-bit | 521-bit | 256-bit |
Hash equivalence in this table refers to collision resistance.
Recommended Minimum Sizes (2026)
- Symmetric encryption: 128-bit (AES-128)
- Hash functions: 256-bit (SHA-256, BLAKE3)
- RSA: 2048-bit (3072-bit for long-term)
- Elliptic curves: 256-bit (P-256, Curve25519)
- Diffie-Hellman: 2048-bit
Standards Compliance
FIPS 140-2/140-3
FIPS-standardised algorithms implemented by cryptopp-modern:
- AES (all key sizes)
- SHA-2 family (SHA-224, SHA-256, SHA-384, SHA-512)
- SHA-3 family
- RSA (2048-bit minimum)
- ECDSA (P-256, P-384, P-521)
- HMAC (with approved hash functions)
Note: implementing a FIPS-specified algorithm is not the same as providing a FIPS-approved operational implementation. cryptopp-modern is not a FIPS 140-validated module; it implements the algorithms in a form suitable for integration into an appropriately validated module.
FIPS Post-Quantum Standards
- FIPS 203 - ML-KEM (Module-Lattice-Based Key-Encapsulation Mechanism)
- FIPS 204 - ML-DSA (Module-Lattice-Based Digital Signature Algorithm)
- FIPS 205 - SLH-DSA (Stateless Hash-Based Digital Signature Algorithm)
- SP 800-208 - LMS/HSS (Stateful Hash-Based Signature Schemes). Conformant signing deployments have additional hardware-module and key-handling requirements beyond the algorithm implementation; see the LMS/HSS API reference.
NIST Recommendations
- Hash: SHA-256, SHA-384, SHA-512, SHA-3
- Symmetric: AES-128, AES-256
- Signatures: ECDSA (P-256+), RSA (2048-bit+), ML-DSA, SLH-DSA, LMS/HSS (stateful)
- Key Exchange: ECDH (P-256+), ML-KEM
RFC Standards
- Argon2: RFC 9106
- scrypt: RFC 7914
- ChaCha20-Poly1305: RFC 8439
- Ed25519: RFC 8032
- X25519: RFC 7748
- HMAC: RFC 2104
- HKDF: RFC 5869
- ARIA: RFC 5794
Deprecated Algorithms
Do not use for new projects:
| Algorithm | Status | Reason |
|---|---|---|
| DES | ❌ Broken | 56-bit key too small |
| 3DES | ⚠️ Deprecated | Slow, small block size |
| RC4 | ❌ Broken | Multiple vulnerabilities |
| MD5 | ❌ Broken | Collision attacks |
| SHA-1 | ⚠️ Deprecated | Collision attacks |
| DSA (1024-bit) | ❌ Insecure | Key size too small |
| RSA (1024-bit) | ❌ Insecure | Key size too small |
Quick Reference
Most common combinations:
// File hashing
BLAKE3 or SHA-256
// Password storage
Argon2id
// Symmetric encryption
AES-256-GCM or ChaCha20-Poly1305
// Digital signatures
Ed25519 or ECDSA-P256 (classical), ML-DSA (post-quantum)
// Key exchange
X25519 or ECDH-P256 (classical), ML-KEM (post-quantum)
// Message authentication
HMAC-SHA256 or BLAKE3 keyed modeDocumentation Links
- Hash Functions - Detailed hash function guide
- BLAKE3 - BLAKE3 documentation
- Argon2 - Password hashing guide
- Symmetric Encryption - AES, ChaCha20 guide
- Public-Key Cryptography - RSA, ECDSA, Ed25519, X25519
- Post-Quantum Cryptography - ML-KEM, ML-DSA, SLH-DSA, LMS/HSS, X-Wing
- Security Concepts - Security best practices
- Beginner’s Guide - Complete tutorial
Platform Support
The library baseline is C++11. See the build documentation and the repository CI matrix for the compilers and architectures currently built and tested; algorithm availability is not separately guaranteed per platform beyond what CI covers.
Hardware acceleration is used where the CPU supports it:
- AES (AES-NI on x86/x64)
- SHA-256 (SHA extensions)
- ChaCha20 (SSE2, SSSE3, AVX2, NEON, Altivec)
- BLAKE3 (SSE4.1, AVX2, AVX-512)