Encrypt with a caller-provided AAD slice (may be longer than HEADER_SIZE, e.g. preamble bytes prepended to the header).
(&self, lsn: u64, aad: &[u8], plaintext: &[u8])
| 187 | /// Encrypt with a caller-provided AAD slice (may be longer than HEADER_SIZE, |
| 188 | /// e.g. preamble bytes prepended to the header). |
| 189 | pub fn encrypt_aad(&self, lsn: u64, aad: &[u8], plaintext: &[u8]) -> Result<Vec<u8>> { |
| 190 | let nonce = lsn_to_nonce(&self.epoch, lsn); |
| 191 | self.cipher |
| 192 | .encrypt( |
| 193 | &nonce, |
| 194 | aes_gcm::aead::Payload { |
| 195 | msg: plaintext, |
| 196 | aad, |
| 197 | }, |
| 198 | ) |
| 199 | .map_err(|_| WalError::EncryptionError { |
| 200 | detail: "AES-256-GCM encryption failed".into(), |
| 201 | }) |
| 202 | } |
| 203 | |
| 204 | /// The random epoch for this key instance. |
| 205 | pub fn epoch(&self) -> &[u8; 4] { |
no test coverage detected