Decrypt with a caller-provided AAD slice.
(
&self,
epoch: &[u8; 4],
lsn: u64,
aad: &[u8],
ciphertext: &[u8],
)
| 226 | |
| 227 | /// Decrypt with a caller-provided AAD slice. |
| 228 | pub fn decrypt_aad( |
| 229 | &self, |
| 230 | epoch: &[u8; 4], |
| 231 | lsn: u64, |
| 232 | aad: &[u8], |
| 233 | ciphertext: &[u8], |
| 234 | ) -> Result<Vec<u8>> { |
| 235 | let nonce = lsn_to_nonce(epoch, lsn); |
| 236 | self.cipher |
| 237 | .decrypt( |
| 238 | &nonce, |
| 239 | aes_gcm::aead::Payload { |
| 240 | msg: ciphertext, |
| 241 | aad, |
| 242 | }, |
| 243 | ) |
| 244 | .map_err(|_| WalError::EncryptionError { |
| 245 | detail: "AES-256-GCM decryption failed (corrupted or wrong key)".into(), |
| 246 | }) |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /// Key ring supporting dual-key reads for seamless key rotation. |
no test coverage detected