Skip to main content

reallyme_crypto/
lib.rs

1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: Apache-2.0
4
5//! # reallyme-crypto
6//!
7//! Umbrella crate that re-exports the ReallyMe cryptographic primitives,
8//! dispatch and signer abstractions behind one dependency and a consistent
9//! feature set.
10//!
11//! ## Platform lanes
12//!
13//! Rust exposes two backend lanes selected by Cargo feature and target:
14//! `native` (portable Rust) and `wasm` (browser/Node host bindings).
15//! Swift and Kotlin provider selection lives in their package facades; those
16//! facades call this Rust workspace through FFI/JNI only for algorithms whose
17//! provider policy explicitly selects Rust. A lane never silently falls back to
18//! another backend.
19//!
20//! The canonical contract is not the Rust API by itself. It is the shared set
21//! of protobuf/enums, package algorithm identifiers, typed error taxonomy,
22//! provider manifest, and conformance vectors. Rust is the reference
23//! implementation and the shared implementation for selected primitives; native
24//! platform routes are interchangeable only when vectors and typed-error tests
25//! prove identical input, output, failure, and edge-case behavior.
26//!
27//! ## Security posture
28//!
29//! `#![forbid(unsafe_code)]` here; secret material is returned in zeroizing
30//! wrappers; signature verification fails closed; and cross-implementation
31//! conformance vectors pin the Rust output against an independent oracle.
32//! See `SECURITY.md` and `SECURITY_MEMORY_MODEL.md` at the repository root.
33//!
34//! ## Example: sign then verify
35//!
36//! A detached signature round-trip through [`dispatch`] (requires the
37//! `dispatch` and `ed25519` features, both on by default). Verification
38//! fails closed — tampering with the message yields `Err`, never `Ok(false)`.
39//!
40//! ```
41//! # #[cfg(all(feature = "dispatch", feature = "ed25519"))]
42//! # fn main() -> Result<(), reallyme_crypto::dispatch::AlgorithmError> {
43//! use reallyme_crypto::core::Algorithm;
44//! use reallyme_crypto::dispatch::{generate_keypair, sign, verify};
45//!
46//! let (public, secret) = generate_keypair(Algorithm::Ed25519)?;
47//! let message = b"attested payload";
48//!
49//! let signature = sign(Algorithm::Ed25519, &secret, message)?;
50//! verify(Algorithm::Ed25519, &public, message, &signature)?;
51//!
52//! // A signature never covers a different message: verify returns Err.
53//! assert!(verify(Algorithm::Ed25519, &public, b"tampered", &signature).is_err());
54//! # Ok(())
55//! # }
56//! # #[cfg(not(all(feature = "dispatch", feature = "ed25519")))]
57//! # fn main() {}
58//! ```
59
60#![forbid(unsafe_code)]
61
62#[cfg(all(feature = "wasm", not(target_arch = "wasm32"), not(feature = "native")))]
63compile_error!(
64    "reallyme-crypto's `wasm` backend lane must be checked with \
65     `--target wasm32-unknown-unknown`. Host builds should use the `native` \
66     backend lane, or include `native` when running all-feature host checks."
67);
68
69pub use crypto_core as core;
70
71/// JSON Web Key envelope types and public-key conversion helpers.
72#[cfg(feature = "jwk")]
73pub use envelopes_jwk as jwk;
74
75/// Bidirectional conversion between JWK and Multikey public-key envelopes.
76#[cfg(feature = "jwk-multikey")]
77pub use envelopes_jwk_multikey as jwk_multikey;
78
79/// Algorithm-selected dispatch: keygen, sign/verify, key agreement, KEM, AEAD,
80/// hashing, and multikey binding routed by an [`core::Algorithm`] selector.
81#[cfg(feature = "dispatch")]
82pub mod dispatch {
83    pub use crypto_dispatch::{
84        aead_decrypt, aead_encrypt, derive_shared_secret, generate_keypair,
85        generate_multikey_keypair, hash_digest, kem_decapsulate, kem_encapsulate, mac_authenticate,
86        mac_verify, public_key_to_multikey, sign, validate_verification_method_multikey, verify,
87        AeadParams, AlgorithmError, GeneratedKeypair, MacParams,
88    };
89}
90
91/// Codec-style protobuf operation entrypoint for service adapters.
92#[cfg(feature = "proto-process")]
93pub mod proto_process;
94
95/// Signer/verifier traits and dispatch-backed implementations for producing and
96/// checking detached signatures.
97#[cfg(feature = "signer")]
98pub mod signer {
99    pub use crypto_signer::{
100        DispatchSigner, DispatchVerifier, Signer, SignerError, SignerFailureKind, Verifier,
101        VerifierError, VerifierFailureKind,
102    };
103}
104
105/// AES-GCM authenticated encryption primitives and their typed key/nonce
106/// wrappers and length constants.
107#[cfg(feature = "aes")]
108pub mod aes {
109    pub use crypto_aes256_gcm::{
110        decrypt, decrypt_aes128_gcm, decrypt_aes192_gcm, encrypt, encrypt_aes128_gcm,
111        encrypt_aes192_gcm, Aes128GcmDecryptRequest, Aes128GcmEncryptRequest, Aes128GcmKey,
112        Aes128GcmNonce, Aes192GcmDecryptRequest, Aes192GcmEncryptRequest, Aes192GcmKey,
113        Aes192GcmNonce, Aes256GcmKey, Aes256GcmNonce, CiphertextWithTag, DecryptRequest,
114        EncryptRequest, AES_128_GCM_KEY_LENGTH, AES_128_GCM_NONCE_LENGTH, AES_128_GCM_TAG_LENGTH,
115        AES_192_GCM_KEY_LENGTH, AES_192_GCM_NONCE_LENGTH, AES_192_GCM_TAG_LENGTH,
116        AES_256_GCM_KEY_LENGTH, AES_256_GCM_NONCE_LENGTH, AES_256_GCM_TAG_LENGTH,
117    };
118}
119
120/// AES-256 Key Wrap (RFC 3394) for wrapping compact key material.
121#[cfg(feature = "aes-kw")]
122pub mod aes_kw {
123    pub use crypto_aes_kw::{
124        unwrap_key, wrap_key, Aes256KwKek, AesKwKeyData, AesKwWrappedKey, AES_256_KW_KEK_LENGTH,
125        AES_KW_BLOCK_LENGTH, AES_KW_INTEGRITY_CHECK_LENGTH, AES_KW_MAX_KEY_DATA_LENGTH,
126        AES_KW_MIN_KEY_DATA_LENGTH, AES_KW_MIN_WRAPPED_KEY_LENGTH,
127    };
128}
129
130/// AES-256-GCM-SIV nonce-misuse-resistant authenticated encryption primitive and
131/// its typed key/nonce wrappers and length constants.
132#[cfg(feature = "aes-gcm-siv")]
133pub mod aes_gcm_siv {
134    pub use crypto_aes256_gcm_siv::{
135        decrypt, encrypt, Aes256GcmSivKey, Aes256GcmSivNonce, CiphertextWithTag, DecryptRequest,
136        EncryptRequest, AES_256_GCM_SIV_KEY_LENGTH, AES_256_GCM_SIV_NONCE_LENGTH,
137        AES_256_GCM_SIV_TAG_LENGTH,
138    };
139}
140
141/// ChaCha20-Poly1305 and XChaCha20-Poly1305 authenticated encryption
142/// primitives with typed key and nonce wrappers.
143#[cfg(feature = "chacha20-poly1305")]
144pub mod chacha20_poly1305 {
145    pub use crypto_chacha20_poly1305::{
146        decrypt, decrypt_xchacha20_poly1305, encrypt, encrypt_xchacha20_poly1305,
147        ChaCha20Poly1305Key, ChaCha20Poly1305Nonce, CiphertextWithTag, DecryptRequest,
148        EncryptRequest, XChaCha20Poly1305DecryptRequest, XChaCha20Poly1305EncryptRequest,
149        XChaCha20Poly1305Nonce, CHACHA20_POLY1305_KEY_LENGTH, CHACHA20_POLY1305_NONCE_LENGTH,
150        CHACHA20_POLY1305_TAG_LENGTH, XCHACHA20_POLY1305_NONCE_LENGTH,
151    };
152}
153
154/// Argon2id password-based key derivation, including platform-tuned cost
155/// profiles and typed salt/secret/derived-key wrappers.
156#[cfg(feature = "argon2id")]
157pub mod argon2id {
158    pub use crypto_argon2id::{
159        derive_key, derive_key_for_version, resolve_mobile_profile_for_unlock,
160        resolve_profile_params_for_platform, resolve_profile_params_with_caps, Argon2Caps,
161        Argon2KdfVersion, Argon2ParamsProfile, Argon2PlatformClass, Argon2Profile, Argon2Salt,
162        Argon2Secret, Argon2idDerivedKey, DeriveKeyRequest, ARGON2ID_DERIVED_KEY_LENGTH,
163        ARGON2ID_SALT_MAX_LENGTH, ARGON2ID_SALT_MIN_LENGTH, ARGON2ID_V1_LANES,
164        ARGON2ID_V1_MEMORY_COST_KIB, ARGON2ID_V1_TIME_COST, ARGON2ID_V2_LANES,
165        ARGON2ID_V2_MEMORY_COST_KIB, ARGON2ID_V2_TIME_COST,
166    };
167}
168
169/// Constant-time (non-short-circuiting) byte-slice equality checks.
170#[cfg(feature = "constant-time")]
171pub mod constant_time {
172    pub use crypto_constant_time::{ct_eq, ct_eq_fixed, require_ct_eq};
173}
174
175/// OS-backed cryptographically secure randomness and typed generators for AEAD
176/// nonces and Argon2 salts.
177#[cfg(feature = "csprng")]
178pub mod csprng {
179    pub use crypto_csprng::{
180        generate_aead_nonce_12, generate_argon2_salt_16, generate_argon2_salt_32, generate_bytes,
181        AeadNonce12, Argon2Salt16, Argon2Salt32, OsSecureRandom, RandomBytes, SecureRandom,
182        AEAD_NONCE_12_LENGTH, ARGON2_SALT_16_LENGTH, ARGON2_SALT_32_LENGTH,
183    };
184}
185
186/// Ed25519 signatures: keypair generation, sign/verify, and public-key encoding.
187#[cfg(feature = "ed25519")]
188pub mod ed25519 {
189    pub use crypto_ed25519::{
190        assert_public_key, decode_public_key, encode_public_key, generate_ed25519_keypair,
191        sign_ed25519, verify_ed25519,
192    };
193
194    // Pure wasm primitive crates intentionally expose only their host-provider
195    // contract. Import/deterministic helpers stay native here; TypeScript
196    // consumers get equivalent deriveKeyPair APIs from the package facade.
197    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
198    pub use crypto_ed25519::generate_ed25519_keypair_from_seed;
199}
200
201/// HMAC authentication tags over SHA-256 and SHA-512.
202#[cfg(feature = "hmac")]
203pub mod hmac {
204    pub use crypto_hmac::{
205        authenticate, verify, HmacKey, HmacTag, HMAC_MAX_KEY_LENGTH, HMAC_SHA256_TAG_LENGTH,
206        HMAC_SHA512_TAG_LENGTH,
207    };
208}
209
210/// JWA ECDH-ES Concat KDF over SHA-256 for deriving content-encryption keys
211/// from an ECDH shared secret.
212#[cfg(feature = "concat-kdf")]
213pub mod concat_kdf {
214    pub use crypto_concat_kdf::{
215        derive_jwa_concat_kdf_sha256, JwaAlgorithmId, JwaConcatKdfOutput, JwaConcatKdfRequest,
216        JwaPartyInfo, JwaSharedSecret, JWA_CONCAT_KDF_MAX_INFO_LENGTH,
217        JWA_CONCAT_KDF_MAX_SHARED_SECRET_LENGTH, JWA_CONCAT_KDF_SHA256_DIGEST_LENGTH,
218    };
219}
220
221/// NIST P-256 (secp256r1) ECDSA over pre-hashed messages, with public-key
222/// compression and Secure Enclave handle encoding.
223#[cfg(feature = "p256")]
224pub mod p256 {
225    pub use crypto_p256::{
226        compress_public_key, decode_se_handle, decompress_public_key, derive_p256_shared_secret,
227        encode_se_handle, generate_p256_keypair, generate_p256_keypair_from_secret_key,
228        p256_ecdsa_der_to_jose_signature, p256_ecdsa_der_to_jose_signature_permissive,
229        p256_ecdsa_jose_signature_to_der, sign_p256_der_prehash, verify_p256_der_prehash,
230        P256_ECDSA_JOSE_SIGNATURE_LEN, SE_HANDLE_PREFIX,
231    };
232
233    #[cfg(feature = "native")]
234    pub use crypto_p256::{
235        compressed_public_key_from_private_key, private_key_from_pem, private_key_from_pkcs8_der,
236        private_key_from_pkcs8_pem, private_key_from_sec1_der, private_key_from_sec1_pem,
237        public_key_from_spki_der, public_key_from_spki_pem,
238    };
239}
240
241/// NIST P-384 (secp384r1) ECDSA and ECDH, with public-key
242/// compression/decompression helpers.
243#[cfg(feature = "p384")]
244pub mod p384 {
245    pub use crypto_p384::{
246        compress_p384, compress_public_key, decompress_p384, decompress_public_key,
247        derive_p384_shared_secret, generate_p384_keypair, generate_p384_keypair_from_secret_key,
248        sign_p384_der_prehash, verify_p384_der_prehash, P384_PUBLIC_KEY_COMPRESSED_LEN,
249        P384_PUBLIC_KEY_RAW_LEN, P384_PUBLIC_KEY_UNCOMPRESSED_LEN, P384_SECRET_KEY_LEN,
250        P384_SHARED_SECRET_LEN, P384_SIGNATURE_DER_MAX_LEN,
251    };
252}
253
254/// NIST P-521 (secp521r1) ECDSA and ECDH, with public-key
255/// compression/decompression helpers.
256#[cfg(feature = "p521")]
257pub mod p521 {
258    pub use crypto_p521::{
259        compress_p521, compress_public_key, decompress_p521, decompress_public_key,
260        derive_p521_shared_secret, generate_p521_keypair, generate_p521_keypair_from_secret_key,
261        sign_p521_der_prehash, verify_p521_der_prehash, P521_PUBLIC_KEY_COMPRESSED_LEN,
262        P521_PUBLIC_KEY_RAW_LEN, P521_PUBLIC_KEY_UNCOMPRESSED_LEN, P521_SECRET_KEY_LEN,
263        P521_SHARED_SECRET_LEN, P521_SIGNATURE_DER_MAX_LEN,
264    };
265}
266
267/// PBKDF2 (RFC 8018) for legacy password-based key derivation.
268#[cfg(feature = "pbkdf2")]
269pub mod pbkdf2 {
270    pub use crypto_pbkdf2::{
271        derive_key, Pbkdf2Iterations, Pbkdf2Output, Pbkdf2Password, Pbkdf2Prf, Pbkdf2Request,
272        Pbkdf2Salt, PBKDF2_MAX_OUTPUT_LENGTH, PBKDF2_MAX_PASSWORD_LENGTH, PBKDF2_MAX_SALT_LENGTH,
273        PBKDF2_MIN_ITERATIONS, PBKDF2_MIN_OUTPUT_LENGTH, PBKDF2_MIN_PASSWORD_LENGTH,
274        PBKDF2_MIN_SALT_LENGTH,
275    };
276}
277
278/// RSA signature verification for PKCS#1 v1.5 and PSS.
279#[cfg(feature = "rsa")]
280pub mod rsa {
281    pub use crypto_rsa::{
282        verify_rsa_pkcs1v15, verify_rsa_pss, RsaHash, RsaPssParams, RsaPublicKeyDerEncoding,
283        RSA_MAX_MODULUS_BITS, RSA_MIN_MODULUS_BITS, RSA_PUBLIC_KEY_DER_MAX_LEN,
284        RSA_SIGNATURE_MAX_LEN,
285    };
286}
287
288/// secp256k1 ECDSA signs SHA-256(message) once, returns compact low-S `r || s`,
289/// and uses compressed SEC1 public keys as the canonical API representation.
290#[cfg(feature = "secp256k1")]
291pub mod secp256k1 {
292    pub use crypto_secp256k1::{
293        decode_bip340_schnorr_public_key, decode_public_key, decompress_public_key,
294        derive_bip340_schnorr_public_key, encode_bip340_schnorr_public_key, encode_public_key,
295        generate_secp256k1_keypair, secp256k1_ecdsa_der_to_jose_signature,
296        secp256k1_ecdsa_der_to_jose_signature_permissive, secp256k1_ecdsa_jose_signature_to_der,
297        sign_bip340_schnorr, sign_secp256k1, verify_bip340_schnorr, verify_secp256k1,
298        BIP340_SCHNORR_AUX_RAND_LEN, BIP340_SCHNORR_MESSAGE_LEN, BIP340_SCHNORR_PUBLIC_KEY_LEN,
299        BIP340_SCHNORR_SIGNATURE_LEN, SECP256K1_ECDSA_JOSE_SIGNATURE_LEN, SECP256K1_SECRET_KEY_LEN,
300    };
301
302    // See the Ed25519 gate: pure wasm does not widen the JS host-provider
303    // contract for import helpers.
304    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
305    pub use crypto_secp256k1::generate_secp256k1_keypair_from_secret_key;
306}
307
308/// X25519 Diffie–Hellman key agreement and public-key encoding.
309#[cfg(feature = "x25519")]
310pub mod x25519 {
311    pub use crypto_x25519::{
312        decode_public_key, derive_x25519_shared_secret, encode_public_key, generate_x25519_keypair,
313    };
314
315    // See the Ed25519 gate: pure wasm does not widen the JS host-provider
316    // contract for import helpers.
317    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
318    pub use crypto_x25519::generate_x25519_keypair_from_seed;
319}
320
321/// X-Wing hybrid KEM suites over X25519 plus ML-KEM-768 or ML-KEM-1024.
322#[cfg(feature = "x-wing")]
323pub mod x_wing {
324    pub use crypto_x_wing::{
325        generate_x_wing_1024_keypair, generate_x_wing_1024_keypair_derand,
326        generate_x_wing_768_keypair, generate_x_wing_768_keypair_derand, x_wing_1024_decapsulate,
327        x_wing_1024_encapsulate, x_wing_1024_encapsulate_derand, x_wing_768_decapsulate,
328        x_wing_768_encapsulate, x_wing_768_encapsulate_derand, X_WING_1024_CIPHERTEXT_LEN,
329        X_WING_1024_PUBLIC_KEY_LEN, X_WING_768_CIPHERTEXT_LEN, X_WING_768_PUBLIC_KEY_LEN,
330        X_WING_ENCAPS_SEED_LEN, X_WING_SECRET_KEY_LEN, X_WING_SHARED_SECRET_LEN,
331    };
332}
333
334/// RFC 9180 HPKE Base-mode encryption over supported DHKEM/HKDF/AEAD suites.
335#[cfg(feature = "hpke")]
336pub mod hpke {
337    pub use crypto_hpke::{
338        open_base, seal_base, HpkeError, HpkeOpenOutput, HpkeOpenRequest, HpkePrivateKeyBytes,
339        HpkeSealOutput, HpkeSealRequest, HpkeSuite, HPKE_AEAD_AES_256_GCM,
340        HPKE_AEAD_CHACHA20_POLY1305, HPKE_AEAD_TAG_LEN, HPKE_ENCAPSULATED_KEY_MAX_LEN,
341        HPKE_KDF_HKDF_SHA256, HPKE_KEM_DHKEM_P256_HKDF_SHA256, HPKE_KEM_DHKEM_X25519_HKDF_SHA256,
342        HPKE_P256_PRIVATE_KEY_LEN, HPKE_P256_PUBLIC_KEY_LEN, HPKE_X25519_PRIVATE_KEY_LEN,
343        HPKE_X25519_PUBLIC_KEY_LEN,
344    };
345}
346
347/// HKDF (RFC 5869) extract-and-expand key derivation over the SHA-2/SHA-3 suites,
348/// with domain-separated key derivation helpers.
349#[cfg(feature = "hkdf")]
350pub mod hkdf {
351    pub use crypto_hkdf::{
352        derive, derive_domain_key_32, DeriveRequest, DomainKeyPurpose, DomainTag, HkdfInfo,
353        HkdfInputKeyMaterial, HkdfOutput, HkdfSalt, HkdfSuite,
354    };
355}
356
357/// ML-DSA-44 (FIPS 204) post-quantum signatures: keygen, sign/verify, and
358/// public-key encoding.
359#[cfg(feature = "ml-dsa-44")]
360pub mod ml_dsa_44 {
361    pub use crypto_ml_dsa_44::{
362        decode_public_key, encode_public_key, generate_ml_dsa_44_keypair, sign_ml_dsa_44,
363        verify_ml_dsa_44,
364    };
365
366    // See the Ed25519 gate: pure wasm does not widen the JS host-provider
367    // contract for deterministic helpers.
368    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
369    pub use crypto_ml_dsa_44::generate_ml_dsa_44_keypair_from_seed;
370}
371
372/// ML-DSA-65 (FIPS 204) post-quantum signatures: keygen, sign/verify, and
373/// public-key encoding.
374#[cfg(feature = "ml-dsa-65")]
375pub mod ml_dsa_65 {
376    pub use crypto_ml_dsa_65::{
377        decode_public_key, encode_public_key, generate_ml_dsa_65_keypair, sign_ml_dsa_65,
378        verify_ml_dsa_65,
379    };
380
381    // See the Ed25519 gate: pure wasm does not widen the JS host-provider
382    // contract for deterministic helpers.
383    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
384    pub use crypto_ml_dsa_65::generate_ml_dsa_65_keypair_from_seed;
385}
386
387/// ML-DSA-87 (FIPS 204) post-quantum signatures: keygen, sign/verify, and
388/// public-key encoding.
389#[cfg(feature = "ml-dsa-87")]
390pub mod ml_dsa_87 {
391    pub use crypto_ml_dsa_87::{
392        decode_public_key, encode_public_key, generate_ml_dsa_87_keypair, sign_ml_dsa_87,
393        verify_ml_dsa_87,
394    };
395
396    // See the Ed25519 gate: pure wasm does not widen the JS host-provider
397    // contract for deterministic helpers.
398    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
399    pub use crypto_ml_dsa_87::generate_ml_dsa_87_keypair_from_seed;
400}
401
402/// SLH-DSA-SHA2-128s (FIPS 205) hash-based post-quantum signatures.
403#[cfg(feature = "slh-dsa")]
404pub mod slh_dsa {
405    pub use crypto_slh_dsa::{
406        decode_slh_dsa_sha2_128s_public_key, derive_slh_dsa_sha2_128s_keypair,
407        encode_slh_dsa_sha2_128s_public_key, generate_slh_dsa_sha2_128s_keypair,
408        sign_slh_dsa_sha2_128s, verify_slh_dsa_sha2_128s, SLH_DSA_SHA2_128S_KEYGEN_SEED_LEN,
409        SLH_DSA_SHA2_128S_PUBLIC_KEY_LEN, SLH_DSA_SHA2_128S_SECRET_KEY_LEN,
410        SLH_DSA_SHA2_128S_SIGNATURE_LEN,
411    };
412}
413
414/// ML-KEM-512 (FIPS 203) post-quantum key encapsulation: keygen, encapsulate,
415/// and decapsulate.
416#[cfg(feature = "ml-kem-512")]
417pub mod ml_kem_512 {
418    pub use crypto_ml_kem_512::{
419        generate_ml_kem_512_keypair, ml_kem_512_decapsulate, ml_kem_512_encapsulate,
420    };
421
422    // See the Ed25519 gate: pure wasm does not widen the JS host-provider
423    // contract for deterministic helpers.
424    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
425    pub use crypto_ml_kem_512::{
426        generate_ml_kem_512_keypair_from_seed, ml_kem_512_encapsulate_derand,
427    };
428}
429
430/// ML-KEM-768 (FIPS 203) post-quantum key encapsulation: keygen, encapsulate,
431/// and decapsulate.
432#[cfg(feature = "ml-kem-768")]
433pub mod ml_kem_768 {
434    pub use crypto_ml_kem_768::{
435        generate_ml_kem_768_keypair, ml_kem_768_decapsulate, ml_kem_768_encapsulate,
436    };
437
438    // See the Ed25519 gate: pure wasm does not widen the JS host-provider
439    // contract for deterministic helpers.
440    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
441    pub use crypto_ml_kem_768::{
442        generate_ml_kem_768_keypair_from_seed, ml_kem_768_encapsulate_derand,
443    };
444}
445
446/// ML-KEM-1024 (FIPS 203) post-quantum key encapsulation: keygen, encapsulate,
447/// and decapsulate.
448#[cfg(feature = "ml-kem-1024")]
449pub mod ml_kem_1024 {
450    pub use crypto_ml_kem_1024::{
451        generate_ml_kem_1024_keypair, ml_kem_1024_decapsulate, ml_kem_1024_encapsulate,
452    };
453
454    // See the Ed25519 gate: pure wasm does not widen the JS host-provider
455    // contract for deterministic helpers.
456    #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
457    pub use crypto_ml_kem_1024::{
458        generate_ml_kem_1024_keypair_from_seed, ml_kem_1024_encapsulate_derand,
459    };
460}
461
462/// SHA-2-256 hashing and its fixed-length digest wrapper.
463#[cfg(feature = "sha2")]
464pub mod sha2 {
465    pub use crypto_sha2::{
466        digest_sha2_384, digest_sha2_512, Sha2_384Digest, Sha2_512Digest, SHA2_384_DIGEST_LENGTH,
467        SHA2_512_DIGEST_LENGTH,
468    };
469    pub use crypto_sha2_256::{digest, Sha2_256Digest, SHA2_256_DIGEST_LENGTH};
470}
471
472/// SHA-3-256 hashing and its fixed-length digest wrapper.
473#[cfg(feature = "sha3")]
474pub mod sha3 {
475    pub use crypto_sha3::{
476        digest_sha3_224, digest_sha3_384, digest_sha3_512, Sha3_224Digest, Sha3_384Digest,
477        Sha3_512Digest, SHA3_224_DIGEST_LENGTH, SHA3_384_DIGEST_LENGTH, SHA3_512_DIGEST_LENGTH,
478    };
479    pub use crypto_sha3_256::{digest, Sha3_256Digest, SHA3_256_DIGEST_LENGTH};
480}