pub trait KeyManager: Sized {
    // Required methods
    fn get_latest_key_version(key_id: u32) -> Result<u32, KeyError>;
    fn get_key(
        key_id: u32,
        key_version: u32,
        dst: &mut [u8]
    ) -> Result<(), KeyError>;
    fn key_length(key_id: u32, key_version: u32) -> Result<usize, KeyError>;
}
Expand description

A key maagment implementation with optional key rotation

Required Methods§

source

fn get_latest_key_version(key_id: u32) -> Result<u32, KeyError>

Get the latest version of a key ID. Return VersionInvalid if not found.

This cannot return key version of 0 or the server will think something is wrong.

source

fn get_key( key_id: u32, key_version: u32, dst: &mut [u8] ) -> Result<(), KeyError>

Return a key for a key version and ID.

Given a key ID and a version, write the key to the key buffer. If the buffer is too small, return KeyError::BufferTooSmall.

source

fn key_length(key_id: u32, key_version: u32) -> Result<usize, KeyError>

Calculate the length of a key. Usually this is constant, but the key ID and version can be taken into account if needed.

This will be called before each get_key call to prepare the destination buffer size.

On the C side, this function is combined with get_key.

Object Safety§

This trait is not object safe.

Implementors§