mod bundle;
mod kdf;
mod name_key;
mod node;
mod owner;
mod random;
mod token;
#[cfg(feature = "vectors")]
pub mod vectors;
mod writer;
pub use bundle::{
AppendBundle, Bundle, ConfigBundle, ConfigSecret, ConfigWriteBundle, FullBundle, NamesBundle,
ReadBundle, VaultSecret, random_config_secret, random_vault_secret, seal_child_key,
seal_for_scope, seal_owner_bundle,
};
pub use kdf::SALT;
pub use name_key::{NameContext, NameKey};
pub use node::NodeKey;
pub use owner::OwnerKeys;
pub use token::TokenKeys;
pub use writer::WriterKey;
use crate::proto::FormatError;
use crate::proto::children::ChildrenError;
use crate::proto::integrity::IntegrityError;
#[derive(Debug, thiserror::Error)]
pub enum KeyError {
#[error(transparent)]
Format(#[from] FormatError),
#[error(transparent)]
Integrity(#[from] IntegrityError),
#[error("the sealed bundle does not open with this key")]
Unseal,
#[error("the bundle is version {0}, which this client does not know")]
UnknownVersion(u8),
#[error("the bundle is of kind {0}, which this client does not know")]
UnknownKind(u8),
#[error("a {kind} bundle cannot hold {len} bytes of keys")]
BadLength { kind: &'static str, len: usize },
#[error("the bundle is shorter than its header")]
Truncated,
#[error("scope {0} has no bundle kind in this client")]
UnsupportedScope(String),
#[error("the bundle names a different {0} than expected")]
Binding(&'static str),
#[error("expected a {expected} bundle, found a {found} bundle")]
Kind {
expected: &'static str,
found: &'static str,
},
#[error("a record name does not decrypt with this name key")]
NameDecrypt,
#[error("a record name does not match its index; the server may have swapped entries")]
NameMismatch,
#[error("the children record is invalid: {0}")]
Children(ChildrenError),
#[error("encrypting {0} failed")]
Encrypt(&'static str),
}