1#![forbid(unsafe_code)]
54
55#[cfg(all(feature = "wasm", not(target_arch = "wasm32"), not(feature = "native")))]
56compile_error!(
57 "reallyme-crypto's `wasm` backend lane must be checked with \
58 `--target wasm32-unknown-unknown`. Host builds should use the `native` \
59 backend lane, or include `native` when running all-feature host checks."
60);
61
62pub use crypto_core as core;
63
64#[cfg(feature = "jwk")]
66pub use envelopes_jwk as jwk;
67
68#[cfg(feature = "jwk-multikey")]
70pub use envelopes_jwk_multikey as jwk_multikey;
71
72#[cfg(feature = "dispatch")]
75pub mod dispatch {
76 pub use crypto_dispatch::{
77 aead_decrypt, aead_encrypt, derive_shared_secret, generate_keypair,
78 generate_multikey_keypair, hash_digest, kem_decapsulate, kem_encapsulate, mac_authenticate,
79 mac_verify, public_key_to_multikey, sign, validate_verification_method_multikey, verify,
80 AeadParams, AlgorithmError, GeneratedKeypair, MacParams,
81 };
82}
83
84#[cfg(feature = "signer")]
87pub mod signer {
88 pub use crypto_signer::{
89 DispatchSigner, DispatchVerifier, Signer, SignerError, SignerFailureKind, Verifier,
90 VerifierError, VerifierFailureKind,
91 };
92}
93
94#[cfg(feature = "aes")]
97pub mod aes {
98 pub use crypto_aes256_gcm::{
99 decrypt, decrypt_aes128_gcm, decrypt_aes192_gcm, encrypt, encrypt_aes128_gcm,
100 encrypt_aes192_gcm, Aes128GcmDecryptRequest, Aes128GcmEncryptRequest, Aes128GcmKey,
101 Aes128GcmNonce, Aes192GcmDecryptRequest, Aes192GcmEncryptRequest, Aes192GcmKey,
102 Aes192GcmNonce, Aes256GcmKey, Aes256GcmNonce, CiphertextWithTag, DecryptRequest,
103 EncryptRequest, AES_128_GCM_KEY_LENGTH, AES_128_GCM_NONCE_LENGTH, AES_128_GCM_TAG_LENGTH,
104 AES_192_GCM_KEY_LENGTH, AES_192_GCM_NONCE_LENGTH, AES_192_GCM_TAG_LENGTH,
105 AES_256_GCM_KEY_LENGTH, AES_256_GCM_NONCE_LENGTH, AES_256_GCM_TAG_LENGTH,
106 };
107}
108
109#[cfg(feature = "aes-kw")]
111pub mod aes_kw {
112 pub use crypto_aes_kw::{
113 unwrap_key, wrap_key, Aes256KwKek, AesKwKeyData, AesKwWrappedKey, AES_256_KW_KEK_LENGTH,
114 AES_KW_BLOCK_LENGTH, AES_KW_INTEGRITY_CHECK_LENGTH, AES_KW_MAX_KEY_DATA_LENGTH,
115 AES_KW_MIN_KEY_DATA_LENGTH, AES_KW_MIN_WRAPPED_KEY_LENGTH,
116 };
117}
118
119#[cfg(feature = "aes-gcm-siv")]
122pub mod aes_gcm_siv {
123 pub use crypto_aes256_gcm_siv::{
124 decrypt, encrypt, Aes256GcmSivKey, Aes256GcmSivNonce, CiphertextWithTag, DecryptRequest,
125 EncryptRequest, AES_256_GCM_SIV_KEY_LENGTH, AES_256_GCM_SIV_NONCE_LENGTH,
126 AES_256_GCM_SIV_TAG_LENGTH,
127 };
128}
129
130#[cfg(feature = "chacha20-poly1305")]
133pub mod chacha20_poly1305 {
134 pub use crypto_chacha20_poly1305::{
135 decrypt, decrypt_xchacha20_poly1305, encrypt, encrypt_xchacha20_poly1305,
136 ChaCha20Poly1305Key, ChaCha20Poly1305Nonce, CiphertextWithTag, DecryptRequest,
137 EncryptRequest, XChaCha20Poly1305DecryptRequest, XChaCha20Poly1305EncryptRequest,
138 XChaCha20Poly1305Nonce, CHACHA20_POLY1305_KEY_LENGTH, CHACHA20_POLY1305_NONCE_LENGTH,
139 CHACHA20_POLY1305_TAG_LENGTH, XCHACHA20_POLY1305_NONCE_LENGTH,
140 };
141}
142
143#[cfg(feature = "argon2id")]
146pub mod argon2id {
147 pub use crypto_argon2id::{
148 derive_key, derive_key_for_version, resolve_mobile_profile_for_unlock,
149 resolve_profile_params_for_platform, resolve_profile_params_with_caps, Argon2Caps,
150 Argon2KdfVersion, Argon2ParamsProfile, Argon2PlatformClass, Argon2Profile, Argon2Salt,
151 Argon2Secret, Argon2idDerivedKey, DeriveKeyRequest, ARGON2ID_DERIVED_KEY_LENGTH,
152 ARGON2ID_SALT_MAX_LENGTH, ARGON2ID_SALT_MIN_LENGTH, ARGON2ID_V1_LANES,
153 ARGON2ID_V1_MEMORY_COST_KIB, ARGON2ID_V1_TIME_COST, ARGON2ID_V2_LANES,
154 ARGON2ID_V2_MEMORY_COST_KIB, ARGON2ID_V2_TIME_COST,
155 };
156}
157
158#[cfg(feature = "constant-time")]
160pub mod constant_time {
161 pub use crypto_constant_time::{ct_eq, ct_eq_fixed, require_ct_eq};
162}
163
164#[cfg(feature = "csprng")]
167pub mod csprng {
168 pub use crypto_csprng::{
169 generate_aead_nonce_12, generate_argon2_salt_16, generate_argon2_salt_32, generate_bytes,
170 AeadNonce12, Argon2Salt16, Argon2Salt32, OsSecureRandom, RandomBytes, SecureRandom,
171 AEAD_NONCE_12_LENGTH, ARGON2_SALT_16_LENGTH, ARGON2_SALT_32_LENGTH,
172 };
173}
174
175#[cfg(feature = "ed25519")]
177pub mod ed25519 {
178 pub use crypto_ed25519::{
179 assert_public_key, decode_public_key, encode_public_key, generate_ed25519_keypair,
180 sign_ed25519, verify_ed25519,
181 };
182
183 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
187 pub use crypto_ed25519::generate_ed25519_keypair_from_seed;
188}
189
190#[cfg(feature = "hmac")]
192pub mod hmac {
193 pub use crypto_hmac::{
194 authenticate, verify, HmacKey, HmacTag, HMAC_MAX_KEY_LENGTH, HMAC_SHA256_TAG_LENGTH,
195 HMAC_SHA512_TAG_LENGTH,
196 };
197}
198
199#[cfg(feature = "concat-kdf")]
202pub mod concat_kdf {
203 pub use crypto_concat_kdf::{
204 derive_jwa_concat_kdf_sha256, JwaAlgorithmId, JwaConcatKdfOutput, JwaConcatKdfRequest,
205 JwaPartyInfo, JwaSharedSecret, JWA_CONCAT_KDF_MAX_INFO_LENGTH,
206 JWA_CONCAT_KDF_MAX_SHARED_SECRET_LENGTH, JWA_CONCAT_KDF_SHA256_DIGEST_LENGTH,
207 };
208}
209
210#[cfg(feature = "p256")]
213pub mod p256 {
214 pub use crypto_p256::{
215 compress_public_key, decode_se_handle, decompress_public_key, derive_p256_shared_secret,
216 encode_se_handle, generate_p256_keypair, generate_p256_keypair_from_secret_key,
217 p256_ecdsa_der_to_jose_signature, p256_ecdsa_der_to_jose_signature_permissive,
218 p256_ecdsa_jose_signature_to_der, sign_p256_der_prehash, verify_p256_der_prehash,
219 P256_ECDSA_JOSE_SIGNATURE_LEN, SE_HANDLE_PREFIX,
220 };
221
222 #[cfg(feature = "native")]
223 pub use crypto_p256::{
224 compressed_public_key_from_private_key, private_key_from_pem, private_key_from_pkcs8_der,
225 private_key_from_pkcs8_pem, private_key_from_sec1_der, private_key_from_sec1_pem,
226 public_key_from_spki_der, public_key_from_spki_pem,
227 };
228}
229
230#[cfg(feature = "p384")]
233pub mod p384 {
234 pub use crypto_p384::{
235 compress_p384, compress_public_key, decompress_p384, decompress_public_key,
236 derive_p384_shared_secret, generate_p384_keypair, generate_p384_keypair_from_secret_key,
237 sign_p384_der_prehash, verify_p384_der_prehash, P384_PUBLIC_KEY_COMPRESSED_LEN,
238 P384_PUBLIC_KEY_RAW_LEN, P384_PUBLIC_KEY_UNCOMPRESSED_LEN, P384_SECRET_KEY_LEN,
239 P384_SHARED_SECRET_LEN, P384_SIGNATURE_DER_MAX_LEN,
240 };
241}
242
243#[cfg(feature = "p521")]
246pub mod p521 {
247 pub use crypto_p521::{
248 compress_p521, compress_public_key, decompress_p521, decompress_public_key,
249 derive_p521_shared_secret, generate_p521_keypair, generate_p521_keypair_from_secret_key,
250 sign_p521_der_prehash, verify_p521_der_prehash, P521_PUBLIC_KEY_COMPRESSED_LEN,
251 P521_PUBLIC_KEY_RAW_LEN, P521_PUBLIC_KEY_UNCOMPRESSED_LEN, P521_SECRET_KEY_LEN,
252 P521_SHARED_SECRET_LEN, P521_SIGNATURE_DER_MAX_LEN,
253 };
254}
255
256#[cfg(feature = "pbkdf2")]
258pub mod pbkdf2 {
259 pub use crypto_pbkdf2::{
260 derive_key, Pbkdf2Iterations, Pbkdf2Output, Pbkdf2Password, Pbkdf2Prf, Pbkdf2Request,
261 Pbkdf2Salt, PBKDF2_MAX_OUTPUT_LENGTH, PBKDF2_MAX_PASSWORD_LENGTH, PBKDF2_MAX_SALT_LENGTH,
262 PBKDF2_MIN_ITERATIONS, PBKDF2_MIN_OUTPUT_LENGTH, PBKDF2_MIN_PASSWORD_LENGTH,
263 PBKDF2_MIN_SALT_LENGTH,
264 };
265}
266
267#[cfg(feature = "rsa")]
269pub mod rsa {
270 pub use crypto_rsa::{
271 verify_rsa_pkcs1v15, verify_rsa_pss, RsaHash, RsaPssParams, RsaPublicKeyDerEncoding,
272 RSA_MAX_MODULUS_BITS, RSA_MIN_MODULUS_BITS, RSA_PUBLIC_KEY_DER_MAX_LEN,
273 RSA_SIGNATURE_MAX_LEN,
274 };
275}
276
277#[cfg(feature = "secp256k1")]
280pub mod secp256k1 {
281 pub use crypto_secp256k1::{
282 decode_bip340_schnorr_public_key, decode_public_key, decompress_public_key,
283 derive_bip340_schnorr_public_key, encode_bip340_schnorr_public_key, encode_public_key,
284 generate_secp256k1_keypair, secp256k1_ecdsa_der_to_jose_signature,
285 secp256k1_ecdsa_der_to_jose_signature_permissive, secp256k1_ecdsa_jose_signature_to_der,
286 sign_bip340_schnorr, sign_secp256k1, verify_bip340_schnorr, verify_secp256k1,
287 BIP340_SCHNORR_AUX_RAND_LEN, BIP340_SCHNORR_MESSAGE_LEN, BIP340_SCHNORR_PUBLIC_KEY_LEN,
288 BIP340_SCHNORR_SIGNATURE_LEN, SECP256K1_ECDSA_JOSE_SIGNATURE_LEN, SECP256K1_SECRET_KEY_LEN,
289 };
290
291 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
294 pub use crypto_secp256k1::generate_secp256k1_keypair_from_secret_key;
295}
296
297#[cfg(feature = "x25519")]
299pub mod x25519 {
300 pub use crypto_x25519::{
301 decode_public_key, derive_x25519_shared_secret, encode_public_key, generate_x25519_keypair,
302 };
303
304 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
307 pub use crypto_x25519::generate_x25519_keypair_from_seed;
308}
309
310#[cfg(feature = "x-wing")]
312pub mod x_wing {
313 pub use crypto_x_wing::{
314 generate_x_wing_1024_keypair, generate_x_wing_1024_keypair_derand,
315 generate_x_wing_768_keypair, generate_x_wing_768_keypair_derand, x_wing_1024_decapsulate,
316 x_wing_1024_encapsulate, x_wing_1024_encapsulate_derand, x_wing_768_decapsulate,
317 x_wing_768_encapsulate, x_wing_768_encapsulate_derand, X_WING_1024_CIPHERTEXT_LEN,
318 X_WING_1024_PUBLIC_KEY_LEN, X_WING_768_CIPHERTEXT_LEN, X_WING_768_PUBLIC_KEY_LEN,
319 X_WING_ENCAPS_SEED_LEN, X_WING_SECRET_KEY_LEN, X_WING_SHARED_SECRET_LEN,
320 };
321}
322
323#[cfg(feature = "hpke")]
325pub mod hpke {
326 pub use crypto_hpke::{
327 open_base, seal_base, HpkeError, HpkeOpenOutput, HpkeOpenRequest, HpkePrivateKeyBytes,
328 HpkeSealOutput, HpkeSealRequest, HpkeSuite, HPKE_AEAD_AES_256_GCM,
329 HPKE_AEAD_CHACHA20_POLY1305, HPKE_AEAD_TAG_LEN, HPKE_ENCAPSULATED_KEY_MAX_LEN,
330 HPKE_KDF_HKDF_SHA256, HPKE_KEM_DHKEM_P256_HKDF_SHA256, HPKE_KEM_DHKEM_X25519_HKDF_SHA256,
331 HPKE_P256_PRIVATE_KEY_LEN, HPKE_P256_PUBLIC_KEY_LEN, HPKE_X25519_PRIVATE_KEY_LEN,
332 HPKE_X25519_PUBLIC_KEY_LEN,
333 };
334}
335
336#[cfg(feature = "hkdf")]
339pub mod hkdf {
340 pub use crypto_hkdf::{
341 derive, derive_domain_key_32, DeriveRequest, DomainKeyPurpose, DomainTag, HkdfInfo,
342 HkdfInputKeyMaterial, HkdfOutput, HkdfSalt, HkdfSuite,
343 };
344}
345
346#[cfg(feature = "ml-dsa-44")]
349pub mod ml_dsa_44 {
350 pub use crypto_ml_dsa_44::{
351 decode_public_key, encode_public_key, generate_ml_dsa_44_keypair, sign_ml_dsa_44,
352 verify_ml_dsa_44,
353 };
354
355 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
358 pub use crypto_ml_dsa_44::generate_ml_dsa_44_keypair_from_seed;
359}
360
361#[cfg(feature = "ml-dsa-65")]
364pub mod ml_dsa_65 {
365 pub use crypto_ml_dsa_65::{
366 decode_public_key, encode_public_key, generate_ml_dsa_65_keypair, sign_ml_dsa_65,
367 verify_ml_dsa_65,
368 };
369
370 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
373 pub use crypto_ml_dsa_65::generate_ml_dsa_65_keypair_from_seed;
374}
375
376#[cfg(feature = "ml-dsa-87")]
379pub mod ml_dsa_87 {
380 pub use crypto_ml_dsa_87::{
381 decode_public_key, encode_public_key, generate_ml_dsa_87_keypair, sign_ml_dsa_87,
382 verify_ml_dsa_87,
383 };
384
385 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
388 pub use crypto_ml_dsa_87::generate_ml_dsa_87_keypair_from_seed;
389}
390
391#[cfg(feature = "slh-dsa")]
393pub mod slh_dsa {
394 pub use crypto_slh_dsa::{
395 decode_slh_dsa_sha2_128s_public_key, derive_slh_dsa_sha2_128s_keypair,
396 encode_slh_dsa_sha2_128s_public_key, generate_slh_dsa_sha2_128s_keypair,
397 sign_slh_dsa_sha2_128s, verify_slh_dsa_sha2_128s, SLH_DSA_SHA2_128S_KEYGEN_SEED_LEN,
398 SLH_DSA_SHA2_128S_PUBLIC_KEY_LEN, SLH_DSA_SHA2_128S_SECRET_KEY_LEN,
399 SLH_DSA_SHA2_128S_SIGNATURE_LEN,
400 };
401}
402
403#[cfg(feature = "ml-kem-512")]
406pub mod ml_kem_512 {
407 pub use crypto_ml_kem_512::{
408 generate_ml_kem_512_keypair, ml_kem_512_decapsulate, ml_kem_512_encapsulate,
409 };
410
411 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
414 pub use crypto_ml_kem_512::{
415 generate_ml_kem_512_keypair_from_seed, ml_kem_512_encapsulate_derand,
416 };
417}
418
419#[cfg(feature = "ml-kem-768")]
422pub mod ml_kem_768 {
423 pub use crypto_ml_kem_768::{
424 generate_ml_kem_768_keypair, ml_kem_768_decapsulate, ml_kem_768_encapsulate,
425 };
426
427 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
430 pub use crypto_ml_kem_768::{
431 generate_ml_kem_768_keypair_from_seed, ml_kem_768_encapsulate_derand,
432 };
433}
434
435#[cfg(feature = "ml-kem-1024")]
438pub mod ml_kem_1024 {
439 pub use crypto_ml_kem_1024::{
440 generate_ml_kem_1024_keypair, ml_kem_1024_decapsulate, ml_kem_1024_encapsulate,
441 };
442
443 #[cfg(not(all(feature = "wasm", target_arch = "wasm32", not(feature = "native"))))]
446 pub use crypto_ml_kem_1024::{
447 generate_ml_kem_1024_keypair_from_seed, ml_kem_1024_encapsulate_derand,
448 };
449}
450
451#[cfg(feature = "sha2")]
453pub mod sha2 {
454 pub use crypto_sha2::{
455 digest_sha2_384, digest_sha2_512, Sha2_384Digest, Sha2_512Digest, SHA2_384_DIGEST_LENGTH,
456 SHA2_512_DIGEST_LENGTH,
457 };
458 pub use crypto_sha2_256::{digest, Sha2_256Digest, SHA2_256_DIGEST_LENGTH};
459}
460
461#[cfg(feature = "sha3")]
463pub mod sha3 {
464 pub use crypto_sha3::{
465 digest_sha3_224, digest_sha3_384, digest_sha3_512, Sha3_224Digest, Sha3_384Digest,
466 Sha3_512Digest, SHA3_224_DIGEST_LENGTH, SHA3_384_DIGEST_LENGTH, SHA3_512_DIGEST_LENGTH,
467 };
468 pub use crypto_sha3_256::{digest, Sha3_256Digest, SHA3_256_DIGEST_LENGTH};
469}
470
471#[cfg(feature = "codec")]
474pub mod codec {
475 #[cfg(feature = "codec-base64")]
477 pub mod base64 {
478 pub use codec_base64::{base64_to_bytes, bytes_to_base64, Base64Error};
479 }
480
481 #[cfg(feature = "codec-base64url")]
483 pub mod base64url {
484 pub use codec_base64url::{
485 base64url_bytes_to_bytes, base64url_to_bytes, bytes_to_base64url, Base64UrlError,
486 };
487
488 #[cfg(feature = "codec-base64url-serde")]
489 pub use codec_base64url::{serde_bytes, serde_option_bytes};
490 }
491
492 #[cfg(feature = "codec-cbor")]
495 pub mod cbor {
496 pub use codec_cbor::{
497 compute_cid_dag_cbor, dag_cbor_multihash, decode_dag_cbor, encode_dag_cbor,
498 is_valid_cid_string, sha2_256_content_hash, try_parse_cid, verify_dag_cbor_cid,
499 CborError, CborValue, ContentHash, DagCborMultihash, DAG_CBOR_CODEC,
500 };
501 }
502
503 #[cfg(feature = "codec-hex")]
505 pub mod hex {
506 pub use codec_hex::{bytes_to_lower_hex, lower_hex_to_bytes, write_lower_hex, HexError};
507 }
508
509 #[cfg(feature = "codec-jcs")]
511 pub mod jcs {
512 pub use codec_jcs::{canonicalize_json, JcsError};
513 }
514
515 #[cfg(feature = "codec-multibase")]
517 pub mod multibase {
518 pub use codec_multibase::{
519 base58btc_decode, base58btc_encode, bytes_to_multibase58btc,
520 bytes_to_multibase_base64url, multibase_to_bytes, Base58Error, MultibaseError,
521 };
522 }
523
524 #[cfg(feature = "codec-multicodec")]
526 pub mod multicodec {
527 pub use codec_multicodec::{
528 lookup_codec_prefix, strip_codec_prefix, CodecLookupResult, CodecSpec, MULTICODEC_TABLE,
529 };
530 }
531
532 #[cfg(feature = "codec-multikey")]
534 pub mod multikey {
535 pub use codec_multikey::{
536 binding_type_matches_codec, encode_multikey, parse_multikey, validate_key_binding,
537 KeyBindingInput, MultikeyError, ParsedMultikey,
538 };
539 }
540
541 #[cfg(feature = "codec-pem")]
543 pub mod pem {
544 pub use codec_pem::{
545 decode_pem, encode_pem, PemDecodePolicy, PemDocument, PemEncodeOptions, PemError,
546 PemLabel, PemLineEnding,
547 };
548 }
549}