Skip to main content

KeyManifest

Struct KeyManifest 

Source
pub struct KeyManifest {
    pub format_version: u32,
    pub kek: KeyId,
    pub storage_keys: Vec<StorageKey>,
    pub classes: Vec<ProtectionClassKey>,
}
Expand description

The keys:<db> root record.

Fields§

§format_version: u32

Manifest format version. Readers reject manifests from newer formats.

§kek: KeyId

Key-encryption key, recorded per database rather than per deployment so per-tenant key isolation needs no format change. A deployment-wide KEK is the case where every database names the same one.

§storage_keys: Vec<StorageKey>

Storage data keys, ascending by epoch.

§classes: Vec<ProtectionClassKey>

Protection-class key identities, ascending by class entity id.

Implementations§

Source§

impl KeyManifest

Source

pub async fn create( keyring: &dyn Keyring, kek: KeyId, created_at_unix_ms: i64, ) -> Result<Self, StoreError>

Mints a database’s first storage key and returns its manifest.

§Errors

Returns StoreError::Keyring when the KEK cannot be resolved or the fresh data key cannot be wrapped, and StoreError::Encryption when the platform has no usable random source. A database is created empty, so its first epoch opens at t 0 and covers every transaction until the first rotation.

Source

pub fn active_storage_epoch(&self) -> Option<u32>

Returns the epoch new writes use, if any epoch is active.

Self::validate admits at most one active epoch, so the max below is a tie-break that a decoded manifest never needs; it keeps a manifest assembled in memory from silently writing under a superseded key.

Source

pub fn storage_key(&self, epoch: u32) -> Option<&StorageKey>

Returns the entry for one storage epoch.

Source

pub async fn unwrap_storage_keys( &self, keyring: &dyn Keyring, ) -> Result<BTreeMap<u32, SecretKey>, StoreError>

Unwraps every storage epoch the manifest carries.

The result is the immutable key snapshot EncryptedBlobStore and the log cipher hold: KMS access happens here, at open and on manifest reload, never on a blob read or a log append. Retired epochs are included while their material still resolves — a live object may still carry one, and reading it must not depend on when the mark pass last ran.

§Errors

Returns StoreError::Keyring when an epoch cannot be unwrapped. A misconfigured process therefore fails at open, naming the epoch, rather than at its first read.

Source

pub fn log_records_sealed(&self, epoch: u32, current_t: u64) -> Option<u64>

Log records sealed under one epoch as of basis current_t.

An epoch covers t from where it opened to where its successor did, or to the current basis if it is the newest. The log seals one record per transaction, so that span is the number of nonces drawn under the epoch’s key — see LOG_RECORDS_PER_EPOCH_LIMIT.

Returns None for an epoch the manifest does not carry.

Source

pub fn storage_rotation_due(&self, current_t: u64) -> bool

Reports whether the active epoch has drawn enough nonces to want a rotation, at LOG_RECORDS_PER_EPOCH_WARN.

Source

pub async fn rotate_storage_key( &mut self, keyring: &dyn Keyring, created_at_unix_ms: i64, current_t: u64, ) -> Result<u32, StoreError>

Opens a new storage epoch that new writes will use, from basis current_t.

Rotation is layered and cheap: no stored object is rewritten. The previous active epoch becomes Retiring and stays readable until ordinary re-indexing drains it. current_t closes the outgoing epoch’s nonce budget and opens the new one’s, so it must be the basis the rotation commits at.

§Errors

Returns StoreError::Keyring when the new key cannot be wrapped, StoreError::Encryption when randomness is unavailable, and StoreError::InvalidKeyManifest when current_t precedes the newest epoch’s opening, which would leave the epochs unordered in t.

Source

pub async fn rewrap( &mut self, keyring: &dyn Keyring, kek: KeyId, ) -> Result<(), StoreError>

Re-wraps every storage key under kek, touching no stored data.

keyring must resolve both the outgoing and incoming KEK: the manifest’s own KEK to unwrap, and kek to wrap again.

§Errors

Returns StoreError::Keyring when either KEK cannot be resolved. The manifest is left untouched unless every key re-wraps.

Source

pub fn encode(&self) -> Vec<u8>

Encodes the manifest for the root store.

Source

pub fn decode(bytes: &[u8]) -> Result<Self, StoreError>

Decodes stored manifest bytes.

§Errors

Returns StoreError::InvalidKeyManifest for malformed bytes and StoreError::UnsupportedKeyManifest for a manifest written by a newer release, which a reader must refuse rather than half-understand.

Source

pub fn validate(&self) -> Result<(), StoreError>

Rejects a manifest that is well-formed but structurally impossible.

This record bootstraps every storage access a process makes, and it is cleartext, so “it parsed” is not the bar. A manifest that names an epoch twice, or none to write under, or two, describes a database that cannot exist — and each of those would surface much later as a wrong key, a failed open, or a silent choice between two active epochs.

§Errors

Returns StoreError::InvalidKeyManifest naming the violated invariant.

Trait Implementations§

Source§

impl Clone for KeyManifest

Source§

fn clone(&self) -> KeyManifest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyManifest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for KeyManifest

Source§

impl PartialEq for KeyManifest

Source§

fn eq(&self, other: &KeyManifest) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KeyManifest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more