xmtp_cryptography/lib.rs
1pub mod post_quantum;
2pub use post_quantum::{GeneratePostQuantumKeyError, generate_post_quantum_key};
3pub mod basic_credential;
4pub mod configuration;
5pub mod ethereum;
6pub mod hash;
7pub mod rand;
8pub mod secret;
9pub mod signature;
10pub mod utils;
11
12pub use basic_credential::*;
13pub use openmls;
14
15pub use secret::Secret;
16
17// When upgrading to reqwest 0.13 and disabling the default aws-lc-rs crypto provider
18// some tests fail without initializing the ring crypto provider. Doing this here because
19// it is crypto related and all crates depend on this crate.
20//
21// Installs the process-default rustls crypto provider. Idempotent: subsequent calls are
22// cheap no-ops via `Once`, and `install_default` returning `Err` (provider already set) is
23// ignored, so it is safe to call even when a host process pre-installs its own provider.
24//
25// This is exposed publicly and must be called explicitly from binding entry points because
26// the `#[ctor::ctor(unsafe)]` below does not run on Apple platforms: `ctor` relies on the
27// `__DATA,__mod_init_func` Mach-O link section, which Apple no longer supports. When
28// `libxmtpv3.a` is statically linked into a Swift binary the constructor record is orphaned
29// and never fires, leaving the provider uninstalled and causing `reqwest` (rustls-no-provider)
30// to `panic!("No provider set")` on the first HTTP client build. See issue #3846.
31#[cfg(not(target_arch = "wasm32"))]
32pub fn install_crypto_provider() {
33 use std::sync::Once;
34 static INSTALL: Once = Once::new();
35 INSTALL.call_once(|| {
36 let _ = rustls::crypto::ring::default_provider().install_default();
37 });
38}
39
40#[cfg(not(target_arch = "wasm32"))]
41#[ctor::ctor(unsafe)]
42fn install_rustls_crypto_provider() {
43 install_crypto_provider();
44}