MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / decrypt_aad

Method decrypt_aad

nodedb-wal/src/crypto.rs:228–247  ·  view source on GitHub ↗

Decrypt with a caller-provided AAD slice.

(
        &self,
        epoch: &[u8; 4],
        lsn: u64,
        aad: &[u8],
        ciphertext: &[u8],
    )

Source from the content-addressed store, hash-verified

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.

Callers 6

decryptMethod · 0.80
decrypt_segment_envelopeFunction · 0.80
decrypt_payloadMethod · 0.80
decrypt_payload_ringMethod · 0.80
decrypt_segment_bytesFunction · 0.80
read_encrypted_segmentFunction · 0.80

Calls 3

lsn_to_nonceFunction · 0.85
decryptMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected