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

Method encrypt_aad

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

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])

Source from the content-addressed store, hash-verified

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] {

Callers 5

encryptMethod · 0.80
encrypt_segment_envelopeFunction · 0.80
newMethod · 0.80
write_encrypted_segmentFunction · 0.80
encrypt_segment_bytesFunction · 0.80

Calls 2

lsn_to_nonceFunction · 0.85
encryptMethod · 0.80

Tested by

no test coverage detected