gcm_rs
What It Does
- AES-256 in CTR-32 mode with GHASH per NIST SP 800-38D
- 12 byte nonce, 16 byte tag
- Constant time tag verification
- Zeroize for sensitive in-memory data
- Rust crate for direct use
- Python wheels built with maturin
Setup
Python
Rust
Usage
Rust
use ;
use ;
Python
Current helpers:
= # 32 bytes
= # 12 bytes
Planned in the next release: a
Gcmclass withnew,encrypt,decrypt,compute_tag, andverify_tagthat returns and acceptsbytes.
API overview (rs)
use ;
// construct
let mut gcm = new?;
// streaming style
gcm.encrypt;
gcm.encrypt;
let tag = gcm.compute_tag;
// decrypt + verify
let mut gcm2 = new?;
gcm2.decrypt;
gcm2.verify_tag?;
key:&[u8]length 32nonce:&[u8]length 12associated_data:&[u8]any lengthtag: 16 bytes
Internals
- CTR starts at block
J0 + 1per the spec. - GHASH runs over associated data and ciphertext, then final length block, then pads with the precomputed keystream block.
License
GPL-3.0