pub struct EncryptedBlobStore { /* private fields */ }Expand description
Encrypted blob store that uses epoch-scoped keys for encryption.
Blobs are encrypted with the active epoch’s key at insertion time. The
epoch ID, nonce, and AAD are recorded in BlobInfo so the correct key
can be resolved at decryption time.
If the epoch has expired or is missing, decryption fails closed.
Implementations§
Source§impl EncryptedBlobStore
impl EncryptedBlobStore
Sourcepub fn new(key_manager: KeyEpochManager) -> Self
pub fn new(key_manager: KeyEpochManager) -> Self
Create a new blob store backed by the given key manager.
Sourcepub fn put(
&mut self,
blob_id: BlobId,
plaintext: &[u8],
) -> Result<BlobInfo, SecureStoreError>
pub fn put( &mut self, blob_id: BlobId, plaintext: &[u8], ) -> Result<BlobInfo, SecureStoreError>
Encrypt plaintext with the active epoch key and store it.
Returns the BlobInfo needed to later decrypt the blob.
§Errors
SecureStoreError::NoActiveEpochif no epoch is active.SecureStoreError::CryptoErrorif encryption fails.
Sourcepub fn get(&self, blob_info: &BlobInfo) -> Result<Vec<u8>, SecureStoreError>
pub fn get(&self, blob_info: &BlobInfo) -> Result<Vec<u8>, SecureStoreError>
Decrypt and return the plaintext for a previously stored blob.
The blob_info provides the epoch ID, nonce, and AAD needed for
decryption. The epoch’s key must still be available (not expired).
§Errors
SecureStoreError::EpochExpiredif the epoch has expired.SecureStoreError::EpochNotFoundif the epoch does not exist.SecureStoreError::StorageErrorif the blob is not found.SecureStoreError::CryptoErrorif decryption fails.
Sourcepub fn key_manager(&self) -> &KeyEpochManager
pub fn key_manager(&self) -> &KeyEpochManager
Access the underlying key manager.
Sourcepub fn key_manager_mut(&mut self) -> &mut KeyEpochManager
pub fn key_manager_mut(&mut self) -> &mut KeyEpochManager
Mutable access to the underlying key manager (for rotation/expiry).