pub struct KeyRotationManager { /* private fields */ }Expand description
Key rotation manager.
Manages multiple versions of keys and supports:
- rotating to generate a new key version
- signing with the latest key
- verifying with any historical key (backward compatibility)
- automatic eviction of expired keys
Implementations§
Source§impl KeyRotationManager
impl KeyRotationManager
Sourcepub fn new(max_versions: usize) -> Self
pub fn new(max_versions: usize) -> Self
Create a key rotation manager with the specified maximum number of retained versions.
Sourcepub fn with_initial_key(key: Vec<u8>) -> Self
pub fn with_initial_key(key: Vec<u8>) -> Self
Initialize with the first key version.
Sourcepub fn rotate_key(&mut self, new_key: Vec<u8>) -> u32
pub fn rotate_key(&mut self, new_key: Vec<u8>) -> u32
Rotate to a new key and return the new version number.
Sourcepub fn verify(&self, message: &[u8], version: u32, signature: &[u8]) -> bool
pub fn verify(&self, message: &[u8], version: u32, signature: &[u8]) -> bool
Verify a signature (tries all retained key versions).
Sourcepub fn current_version(&self) -> u32
pub fn current_version(&self) -> u32
Return the current key version number.
Sourcepub fn version_count(&self) -> usize
pub fn version_count(&self) -> usize
Return the number of retained key versions.
Sourcepub fn key_created_at(&self, version: u32) -> Option<u64>
pub fn key_created_at(&self, version: u32) -> Option<u64>
Return the creation time (Unix seconds) of the key for the specified
version, or None if the version does not exist.
Auto Trait Implementations§
impl Freeze for KeyRotationManager
impl RefUnwindSafe for KeyRotationManager
impl Send for KeyRotationManager
impl Sync for KeyRotationManager
impl Unpin for KeyRotationManager
impl UnsafeUnpin for KeyRotationManager
impl UnwindSafe for KeyRotationManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more