redact_crypto/
lib.rs

1//! # redact-crypto
2//!
3//! The `redact-crypto` crate contains all of the interfaces, data structures,
4//! and abstractions necessary to work with cryptographic primitives and Redact data-types.
5//!
6//! The motivation behind this crate is to provide a unified interface for interacting with serialized
7//! data that may be encrypted. Serializable data types are represented as an enum tree, with the base
8//! types being:
9//! - bool
10//! - u64
11//! - i64
12//! - f64
13//! - Vec<u8>
14//! These should cover most use cases for now. In the case of serializing a custom data type,
15//! that type can be serialized into bytes and then those bytes turned into a Vec<u8> to
16//! be stored in the redact type system.
17//!
18//! The other set of types in the tree covers cryptographic keys, which are themselves
19//! split into symmetric and asymmetric enums. Current keys are exclusively implemented via
20//! libsodium, but other implementations will be added based on need.
21//!
22//! This crate also provides a storage interface for CRUD operations on these data types. The
23//! provided implementation can transparently perform these operations on unencrypted data,
24//! encrypted data, or references to data. This means it can, for example, search for all
25//! data of type `AsymmetricKey` and return all possible keys regardless of if that key
26//! is encrypted. It also provides resolution functionality that accepts an encrypted piece of
27//! data and decrypts it into its final type by fetching the appropriate key from storage. It can
28//! do this recursively to resolve an entire chain of encryption.
29//!
30//! The final interface provided by this crate covers sources. Currently, the only supported source
31//! is a byte source, meaning it represents some device which returns a vector of bytes. Current supported
32//! bytes sources are memory and filesystem. These can be used interchangeably when a bytes source is
33//! required and they will correctly resolve the set of bytes if possible.
34//!
35//! File directory:
36//! - lib.rs: exports root-level public types from otherwise private submodules
37//! - error.rs: custom errors that can arise from various redact-crypto operations
38//! - sources.rs: types, traits, and implementations for sources of data
39//! - typebuilders.rs: types that build types
40//! - types.rs: all redact types that can be serialized and stored as unencrypted/
41//!             encrypted/referenced
42//! - keys.rs: exports key submodules such as sodiumoxide key implementations
43//! - keys/sodiumoxide.rs: key implementations backed by sodiumoxide
44//! - nonces.rs: nonce hierarchy for each implemented key type
45//! - nonces/sodiumoxide.rs: sodiumoxide nonce implementations
46//! - storage.rs: trait for a data type that stores `Entry` types
47//! - storage/mongodb.rs: storage implentation for mongodb
48//! - storage/redact.rs: storage implementation for a redact-store server
49
50mod algorithm;
51pub mod cert;
52mod data;
53mod entry;
54mod error;
55pub mod key;
56pub mod nonce;
57mod source;
58pub mod storage;
59pub mod x509;
60
61pub use algorithm::{Algorithm, ByteAlgorithm};
62pub use data::{
63    BinaryData, BinaryDataBuilder, BinaryType, BoolDataBuilder, Data, DataBuilder, F64DataBuilder,
64    I64DataBuilder, StringDataBuilder, U64DataBuilder,
65};
66pub use entry::{
67    Builder, Entry, EntryPath, HasBuilder, State, StorableType, ToEntry, Type, TypeBuilder,
68    TypeBuilderContainer,
69};
70pub use error::CryptoError;
71pub use key::{
72    AsymmetricKey, AsymmetricKeyBuilder, HasAlgorithmIdentifier, HasPublicKey, Key, KeyBuilder,
73    PublicAsymmetricKey, PublicAsymmetricKeyBuilder, PublicAsymmetricSealer,
74    PublicAsymmetricUnsealer, SecretAsymmetricKey, SecretAsymmetricKeyBuilder,
75    SecretAsymmetricSealer, SecretAsymmetricUnsealer, Signer, SymmetricKey, SymmetricKeyBuilder,
76    SymmetricSealer, SymmetricUnsealer, ToPublicAsymmetricByteAlgorithm,
77    ToSecretAsymmetricByteAlgorithm, ToSymmetricByteAlgorithm, Verifier,
78};
79pub use nonce::{AsymmetricNonce, Nonce, SymmetricNonce};
80pub use source::{
81    ByteSource, FsByteSource, HasByteSource, Path, Source, SourceError, VectorByteSource,
82};
83pub use storage::{
84    mongodb::{MongoStorer, MongoStorerError},
85    redact::{RedactStorer, RedactStorerError},
86    HasIndex, IndexedStorer, IndexedTypeStorer, NonIndexedTypeStorer, Storer, TypeStorer,
87};