| Crates.io | hiae |
| lib.rs | hiae |
| version | 0.1.1 |
| created_at | 2025-02-12 00:52:32.043174+00 |
| updated_at | 2025-07-18 08:37:37.819531+00 |
| description | High-throughput Authenticated Encryption (HiAE) algorithm implementation |
| homepage | |
| repository | https://github.com/hiae-aead/draft-pham-hiae |
| max_upload_size | |
| id | 1552200 |
| size | 91,389 |
A Rust implementation of the HiAE (High-throughput Authenticated Encryption) algorithm, providing authenticated encryption with associated data (AEAD) optimized for high performance across different architectures.
Add this to your Cargo.toml:
[dependencies]
hiae = "0.1.0"
Basic usage:
use hiae::{encrypt, decrypt};
let key = [0u8; 32]; // 256-bit key
let nonce = [0u8; 16]; // 128-bit nonce
let plaintext = b"Hello, world!";
let aad = b"additional data";
// Encrypt
let (ciphertext, tag) = encrypt(plaintext, aad, &key, &nonce)?;
// Decrypt
let decrypted = decrypt(&ciphertext, &tag, aad, &key, &nonce)?;
assert_eq!(decrypted, plaintext);
To get maximum performance, compile with native CPU optimizations enabled. This allows the library to automatically detect and use the best available SIMD instructions for your CPU.
Set the RUSTFLAGS environment variable before building:
# For maximum performance on your current CPU
export RUSTFLAGS="-C target-cpu=native"
cargo build --release
# Or run directly
RUSTFLAGS="-C target-cpu=native" cargo build --release
Create or edit .cargo/config.toml in your project root:
[build]
rustflags = ["-C", "target-cpu=native"]
Then build normally:
cargo build --release
For specific CPU features, you can enable them explicitly:
# For x86-64 with AES-NI
RUSTFLAGS="-C target-feature=+aes,+pclmul" cargo build --release
# For ARM with NEON
RUSTFLAGS="-C target-feature=+neon" cargo build --release
The library includes optional feature flags for explicit architecture support:
# Build with x86-64 AES-NI support
cargo build --features aes-ni --release
# Build with ARM NEON support
cargo build --features neon --release
# Build without std for embedded use
cargo build --no-default-features --release
Run the benchmarks to verify performance gains:
cargo bench
The benchmarks will show throughput improvements when CPU-specific optimizations are enabled.
# Development build
cargo build
# Optimized release build
cargo build --release
# Run tests
cargo test
# Run tests with output
cargo test -- --nocapture
# Generate documentation
cargo doc --open
# Basic usage example
cargo run --example basic_usage
# With optimizations
RUSTFLAGS="-C target-cpu=native" cargo run --example basic_usage --release
# Run performance benchmarks
cargo bench
# With native optimizations
RUSTFLAGS="-C target-cpu=native" cargo bench
HiAE is based on the IETF Internet-Draft and provides:
The library automatically detects and uses the best available implementation:
| Platform | SIMD Instructions | Performance |
|---|---|---|
| x86-64 | AES-NI + PCLMUL | Highest |
| ARM64 | NEON + AES | Highest |
| Other | Portable fallback | Good |
For detailed API documentation, run:
cargo doc --open
See the examples/ directory for comprehensive usage examples:
basic_usage.rs - Encryption, decryption, and error handlingLicensed under either of:
at your option.
This implementation follows the HiAE specification. For bugs or improvements, please open an issue or pull request.