Skip to main content

capsule_core/crypto/keys/
mod.rs

1//! Capsule's key hierarchy (SSoT: [Cryptography — Keys]).
2//!
3//! One backed-up root (the account master key) wraps device identity private keys and
4//! anchors the AMK escrow. Album keys (AMKs) are random per-epoch keys; per-file keys are
5//! derived from them. Device signing/encryption keys are hybrid [`HybridSigningKey`] /
6//! [`kem::DekKeypair`].
7//!
8//! [Cryptography — Keys]: https://docs/design/cryptography/keys/
9
10pub(crate) mod album;
11// The sealed album-key store: its format, sealing and escrow. Persisting it to
12// `{root}/.library/albums.cbor` is `capsule-library`'s. Gated with the rest of the native surface,
13// which no browser sealing path needs.
14#[cfg(feature = "native")]
15pub mod albumstore;
16pub mod directory;
17pub(crate) mod hardware;
18pub(crate) mod hybrid_sig;
19pub(crate) mod kem;
20pub(crate) mod kem_p256;
21pub(crate) mod keystore;
22pub(crate) mod master;
23pub(crate) mod p256;
24pub(crate) mod safety_code;
25pub(crate) mod signer;
26pub(crate) mod software;
27
28pub use album::{Amk, AmkVersion};
29#[cfg(feature = "native")]
30pub use albumstore::{
31    ALBUM_STORE_FILE, AlbumStore, AlbumStoreError, AmkRow, EscrowCoverage, PersistedAlbum,
32    PersistedAuthority,
33};
34pub use directory::{DekPublic, DeviceDirectory, DeviceEntry, DirectoryCore, DirectoryError};
35// The in-memory secure-element doubles, for `capsule-library`'s and the FFI's tests. Never in a
36// shipping build: `test-support` rides dev-dependencies only.
37#[cfg(any(test, feature = "test-support"))]
38pub use hardware::MockHardwareSigner;
39pub use hardware::{
40    HardwareBackedSigner, HardwareKeyAgreement, HardwareSigner, HardwareSignerError,
41};
42pub use hybrid_sig::{ClassicalAlgorithm, HybridSignature, HybridSigningKey, HybridVerifyingKey};
43// Derandomized encapsulation: crate-internal, for the deterministic drop-seal known-answer path
44// (`drop::seal_drop_derand`). Never on the public API. Its eseed length is public, because
45// `seal_drop_derand` (already public, for the KAT generator) takes a seed of that length.
46pub use kem::ESEED_LEN;
47pub(crate) use kem::encapsulate_to_public_derand;
48pub use kem::{DEK_CIPHERTEXT_LEN, DEK_PUBLIC_LEN, DekKeypair, encapsulate_to_public};
49#[cfg(any(test, feature = "test-support"))]
50pub use kem_p256::MockP256KeyAgreement;
51pub use kem_p256::{
52    DEK_P256_CIPHERTEXT_LEN, DEK_P256_PUBLIC_LEN, P256HybridDek, encapsulate_to_p256_public,
53};
54pub use keystore::{Account, AccountFile, DekBinding, DeviceDek, DeviceKeys};
55pub use master::MasterKey;
56pub use p256::P256HybridSigningKey;
57pub use safety_code::{
58    KEY_COMMITMENT_LEN, SAFETY_CODE_CHUNK, SAFETY_CODE_DIGITS, commitment_matches, key_commitment,
59    safety_code,
60};
61pub use signer::Signer;
62pub use software::SoftwareSigner;