Skip to main content

bitwarden_crypto/
lib.rs

1#![doc = include_str!("../README.md")]
2
3//! # Pinned heap data
4//!
5//! This crate uses a `Pin<Box<>>` strategy to ensure data is stored on the heap and not moved
6//! around. This pattern is commonly used for `hybrid_array::Array` as it's equivalent to `[u8; N]`
7//! which is a Copy type placed on the stack. To keep the compiler from making stack copies when
8//! moving this struct around, we use a Box to keep the values on the heap. We also pin the box to
9//! make sure that the contents can't be pulled out of the box and moved.
10
11#[cfg(not(feature = "no-memory-hardening"))]
12#[global_allocator]
13static ALLOC: ZeroizingAllocator<std::alloc::System> = ZeroizingAllocator(std::alloc::System);
14
15mod content_format;
16pub use content_format::*;
17mod enc_string;
18pub use enc_string::{EncString, UnsignedSharedKey};
19mod error;
20pub(crate) use error::Result;
21pub use error::{CryptoError, EncodingError};
22mod fingerprint;
23pub use fingerprint::fingerprint;
24mod keys;
25pub use keys::*;
26mod rsa;
27pub use crate::rsa::RsaKeyPair;
28mod stream;
29pub use stream::*;
30mod util;
31pub use util::{generate_random_alphanumeric, generate_random_bytes, pbkdf2};
32mod wordlist;
33pub use wordlist::EFF_LONG_WORD_LIST;
34mod store;
35#[expect(deprecated)]
36pub use store::{
37    CipherSuite, KeyStore, KeyStoreContext, RotatedUserKeys, dangerous_get_v2_rotated_account_keys,
38};
39mod cose;
40pub(crate) use cose::CONTENT_TYPE_PADDED_CBOR;
41pub use cose::{CoseKeyThumbprint, CoseKeyThumbprintExt, CoseSerializable};
42pub mod safe;
43mod signing;
44pub use signing::*;
45mod hazmat;
46mod traits;
47pub use traits::{
48    CompositeEncryptable, Decryptable, IdentifyKey, KeySlotId, KeySlotIds, LocalId,
49    PrimitiveEncryptable,
50};
51pub use zeroizing_alloc::ZeroAlloc as ZeroizingAllocator;
52
53#[cfg(feature = "uniffi")]
54uniffi::setup_scaffolding!();
55
56#[cfg(feature = "uniffi")]
57mod uniffi_support;