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 aes;
16mod content_format;
17pub use content_format::*;
18mod enc_string;
19pub use enc_string::{EncString, UnsignedSharedKey};
20mod error;
21pub(crate) use error::Result;
22pub use error::{CryptoError, EncodingError};
23mod fingerprint;
24pub use fingerprint::fingerprint;
25mod keys;
26pub use keys::*;
27mod rsa;
28pub use crate::rsa::RsaKeyPair;
29mod stream;
30pub use stream::*;
31mod util;
32pub use util::{generate_random_alphanumeric, generate_random_bytes, pbkdf2};
33mod wordlist;
34pub use wordlist::EFF_LONG_WORD_LIST;
35mod store;
36#[expect(deprecated)]
37pub use store::{
38    KeyStore, KeyStoreContext, RotatedUserKeys, dangerous_get_v2_rotated_account_keys,
39};
40mod cose;
41pub(crate) use cose::CONTENT_TYPE_PADDED_CBOR;
42pub use cose::CoseSerializable;
43pub mod safe;
44mod signing;
45pub use signing::*;
46mod traits;
47mod xchacha20;
48pub use traits::{
49    CompositeEncryptable, Decryptable, IdentifyKey, KeySlotId, KeySlotIds, LocalId,
50    PrimitiveEncryptable,
51};
52pub use zeroizing_alloc::ZeroAlloc as ZeroizingAllocator;
53
54#[cfg(feature = "uniffi")]
55uniffi::setup_scaffolding!();
56
57#[cfg(feature = "uniffi")]
58mod uniffi_support;