pub struct KeyRing { /* private fields */ }Expand description
Key ring for managing multiple key versions.
Supports key rotation by maintaining multiple key versions. New encryptions use the active key, decryptions use the version embedded in the ciphertext.
Implementations§
Source§impl KeyRing
impl KeyRing
Sourcepub fn add_key(&mut self, key: VersionedKey)
pub fn add_key(&mut self, key: VersionedKey)
Add a key to the ring.
Sourcepub fn active_key(&self) -> Option<&VersionedKey>
pub fn active_key(&self) -> Option<&VersionedKey>
Get the active key for encryption.
Sourcepub fn get_key(&self, version: u32) -> Option<&VersionedKey>
pub fn get_key(&self, version: u32) -> Option<&VersionedKey>
Get a key by version for decryption.
Sourcepub fn rotate(&mut self, new_key: EncryptionKey) -> u32
pub fn rotate(&mut self, new_key: EncryptionKey) -> u32
Rotate to a new key.
Sourcepub fn all_keys(&self) -> &[VersionedKey]
pub fn all_keys(&self) -> &[VersionedKey]
Get all keys (for re-encryption during rotation).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KeyRing
impl RefUnwindSafe for KeyRing
impl Send for KeyRing
impl Sync for KeyRing
impl Unpin for KeyRing
impl UnsafeUnpin for KeyRing
impl UnwindSafe for KeyRing
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