1#![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#[cfg(feature = "jwk")]
73pub use envelopes_jwk as jwk;
74
75#[cfg(feature = "jwk-multikey")]
77pub use envelopes_jwk_multikey as jwk_multikey;
78
79#[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#[cfg(feature = "proto-process")]
93pub mod proto_process;
94
95#[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#[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#[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#[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#[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#[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#[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#[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#[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 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
198 pub use crypto_ed25519::generate_ed25519_keypair_from_seed;
199}
200
201#[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#[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#[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#[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#[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#[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#[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#[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 #[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#[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 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
318 pub use crypto_x25519::generate_x25519_keypair_from_seed;
319}
320
321#[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#[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#[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#[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 #[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#[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 #[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#[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 #[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#[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#[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 #[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#[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 #[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#[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 #[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#[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#[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}