oxicrypto-adapter-aws-lc — aws-lc-rs backend for OxiCrypto
oxicrypto-adapter-aws-lc implements the core OxiCrypto traits (Aead, Hash, Signer, Verifier from oxicrypto-core) on top of aws-lc-rs, the FIPS-validated cryptographic library maintained by AWS. It lets an application that is already written against the OxiCrypto trait surface swap selected primitives for the hardware-accelerated, FIPS-mode aws-lc-rs implementations without changing call sites.
Not Pure Rust.
aws-lc-rswraps the AWS-LC C library (a BoringSSL/OpenSSL derivative) and pulls in a C toolchain (or a prebuilt binary) at build time. This adapter is therefore C/FFI-backed, in deliberate contrast to the default Pure-Rust OxiCrypto stack. It is opt-in and non-default: the crate exposes no types unless theaws-lcfeature is enabled, and the parentoxicryptofacade only re-exports it underoxicrypto::aws_lcwhen built withfeatures = ["aws-lc"]. Use it when FIPS 140 validation or AWS-LC parity is a hard requirement; otherwise prefer the Pure-Rust crates.
Installation
[]
# Types are only compiled in when the `aws-lc` feature is on.
= { = "0.1.0", = ["aws-lc"] }
Or, more commonly, enable it transitively through the facade:
[]
= { = "0.1.0", = ["aws-lc"] }
A C compiler / build environment compatible with aws-lc-rs is required at
build time. See the aws-lc-rs requirements
for platform details.
Quick Start
#
#
# Ok::
Signing with the aws-lc-rs Ed25519 backend:
#
#
# Ok::
API Overview
All items below are compiled only when the aws-lc feature is enabled.
aead module
| Item | Implements | Description |
|---|---|---|
AwsLcAead |
oxicrypto_core::Aead |
AEAD cipher backed by aws-lc-rs. Variant chosen via constructor. |
AwsLcAead::aes128_gcm() |
— | AES-128-GCM (key 16 B, nonce 12 B, tag 16 B). |
AwsLcAead::aes256_gcm() |
— | AES-256-GCM (key 32 B, nonce 12 B, tag 16 B). |
AwsLcAead::chacha20_poly1305() |
— | ChaCha20-Poly1305 (key 32 B, nonce 12 B, tag 16 B). |
The Aead impl provides name(), key_len(), nonce_len(), tag_len(),
seal(...), and open(...) (plus the *_to_vec default helpers from the
trait). nonce_len() is 12 and tag_len() is 16 for every variant.
hash module
| Type | Implements | Output |
|---|---|---|
AwsLcSha256 |
oxicrypto_core::Hash |
SHA-256, 32 bytes |
AwsLcSha384 |
oxicrypto_core::Hash |
SHA-384, 48 bytes |
AwsLcSha512 |
oxicrypto_core::Hash |
SHA-512, 64 bytes |
Each is a unit struct (Debug + Default + Clone + Copy) exposing the Hash
trait methods name(), output_len(), hash() (and the hash_to_vec
default helper).
sign module
| Type | Implements | Notes |
|---|---|---|
AwsLcEd25519Signer |
oxicrypto_core::Signer |
Deterministic Ed25519; sk is the 32-byte seed; 64-byte signature. Byte-comparable with RustCrypto. |
AwsLcEd25519Verifier |
oxicrypto_core::Verifier |
Verifies Ed25519 over a raw 32-byte public key. |
AwsLcEcdsaP256Signer |
oxicrypto_core::Signer |
ECDSA P-256 / SHA-256, fixed r‖s (64-byte) signature. sk is a raw 32-byte big-endian scalar. Uses a random per-message nonce (not deterministic RFC 6979) → not byte-comparable. |
AwsLcEcdsaP256Verifier |
oxicrypto_core::Verifier |
Verifies ECDSA P-256 fixed signatures; pk is the 65-byte uncompressed SEC1 key. |
All four are unit structs (Debug + Default + Clone + Copy).
Feature Flags
| Feature | Default | Description |
|---|---|---|
aws-lc |
off | Activates the aead, hash, and sign modules (pulls in the aws-lc-rs C-backed dependency). With this flag off, the crate compiles to an empty surface. |
Error variants
This adapter returns the shared oxicrypto_core::CryptoError.
The variants it actually produces are:
| Variant | When it is returned |
|---|---|
InvalidKey |
Key length/format rejected by aws-lc-rs (UnboundKey::new, EC key parse, ≠ 32-byte scalar). |
InvalidNonce |
Nonce not accepted by Nonce::try_assume_unique_for_key. |
InvalidTag |
AEAD open authentication failure, or signature verification failure. |
BufferTooSmall |
Output buffer smaller than required (pt.len() + tag_len(), or < 64 for signatures). |
BadInput |
Ciphertext shorter than tag_len(); overflow computing required length. |
Sign |
ECDSA signing call failed. |
Internal(&'static str) |
Unexpected aws-lc-rs error or signature-length mismatch. |
Cross-references
oxicrypto-core— theAead,Hash,Signer,Verifier, andCryptoErrordefinitions this adapter implements.oxicrypto— Pure-Rust facade; re-exports this adapter atoxicrypto::aws_lcunder theaws-lcfeature.oxicrypto-aead/oxicrypto-hash/oxicrypto-sig— the Pure-Rust counterparts these primitives can substitute for.oxicrypto-adapter-pkcs11— the other opt-in, non-Pure-Rust adapter (HSM via PKCS#11).oxicrypto-bench— benchmarks that compare OxiCrypto againstaws-lc-rsandring.
License
Apache-2.0 — COOLJAPAN OU (Team Kitasan)