Skip to main content

auths_crypto/
lib.rs

1//! Cryptographic primitives for Auths.
2//!
3//! Layer 0: a curve-agnostic provider abstraction (sign / verify / keygen /
4//! AEAD / KDF), key parsing, and `did:key` encoding, isolated from concrete
5//! backends to keep everything above dependency-light. The default curve is
6//! **P-256** (the iOS Secure Enclave only supports P-256); Ed25519 is a
7//! fully-supported peer. Keys, seeds, and signatures carry their curve tag
8//! in-band — never dispatch on byte length. See `README.md` for the full
9//! curve policy and build profiles.
10//!
11//! - [`provider`] — Pluggable [`CryptoProvider`] trait (curve-agnostic
12//!   `sign_typed` / `verify_typed` / `generate_typed_keypair`), [`CurveType`],
13//!   and `default_provider`
14//! - [`key_ops`] — [`TypedSignerKey`], the curve-tagged signer that replaces
15//!   `(SecureSeed, CurveType)` pairs
16//! - [`did_key`] — DID:key ↔ raw key, auto-detecting the curve from the
17//!   multicodec ([`DidKeyError`], [`did_key_decode`], [`did_key_to_p256`])
18
19#[cfg(all(feature = "fips", not(target_arch = "wasm32")))]
20pub mod aws_lc_provider;
21#[cfg(all(feature = "cnsa", not(target_arch = "wasm32")))]
22pub mod cnsa_provider;
23pub mod did_key;
24pub mod error;
25pub mod hash256;
26pub mod key_material;
27pub mod key_ops;
28pub mod pkcs8;
29pub mod provider;
30#[cfg(all(feature = "native", not(target_arch = "wasm32")))]
31pub mod ring_provider;
32pub mod secret;
33pub mod ssh;
34pub mod suite;
35#[cfg(feature = "wasm")]
36pub mod webcrypto_provider;
37
38#[cfg(all(feature = "fips", not(target_arch = "wasm32")))]
39pub use aws_lc_provider::AwsLcProvider;
40#[cfg(all(feature = "cnsa", not(target_arch = "wasm32")))]
41pub use cnsa_provider::CnsaProvider;
42pub use did_key::{
43    DecodedDidKey, DidKeyError, did_key_decode, did_key_encode, did_key_to_p256,
44    ed25519_pubkey_to_did_keri,
45};
46pub use error::AuthsErrorInfo;
47pub use hash256::Hash256;
48pub use key_material::{build_ed25519_pkcs8_v2, parse_ed25519_key_material, parse_ed25519_seed};
49pub use key_ops::{ParsedKey, TypedSeed, TypedSignerKey, normalize_verkey, parse_key_material};
50#[cfg(all(feature = "native", not(target_arch = "wasm32")))]
51pub use key_ops::{
52    generate as typed_generate, public_key as typed_public_key, sign as typed_sign,
53    verify as typed_verify,
54};
55pub use pkcs8::Pkcs8Der;
56#[cfg(all(feature = "native", not(target_arch = "wasm32")))]
57pub use provider::default_provider;
58pub use provider::{
59    CryptoError, CryptoProvider, CurveType, ED25519_PUBLIC_KEY_LEN, ED25519_SIGNATURE_LEN,
60    P256_PUBLIC_KEY_LEN, P256_SIGNATURE_LEN, ParseCurveError, SecureSeed, SeedDecodeError,
61    decode_seed_hex,
62};
63#[cfg(all(feature = "native", not(target_arch = "wasm32")))]
64pub use ring_provider::RingCryptoProvider;
65pub use secret::Secret;
66pub use ssh::{SshKeyError, openssh_pub_to_raw};
67pub use suite::SignatureSuite;
68#[cfg(all(any(test, feature = "test-utils"), not(target_arch = "wasm32")))]
69#[allow(clippy::unwrap_used, clippy::expect_used)]
70pub mod testing;
71
72#[cfg(feature = "wasm")]
73pub use webcrypto_provider::WebCryptoProvider;