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

Method encrypt

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

Encrypt a payload. Returns ciphertext + auth_tag (16 bytes appended). - `lsn`: used to derive a deterministic nonce - `header_bytes`: used as AAD (additional authenticated data) - `plaintext`: the payload to encrypt

(
        &self,
        lsn: u64,
        header_bytes: &[u8; HEADER_SIZE],
        plaintext: &[u8],
    )

Source from the content-addressed store, hash-verified

176 /// - `header_bytes`: used as AAD (additional authenticated data)
177 /// - `plaintext`: the payload to encrypt
178 pub fn encrypt(
179 &self,
180 lsn: u64,
181 header_bytes: &[u8; HEADER_SIZE],
182 plaintext: &[u8],
183 ) -> Result<Vec<u8>> {
184 self.encrypt_aad(lsn, header_bytes, plaintext)
185 }
186
187 /// Encrypt with a caller-provided AAD slice (may be longer than HEADER_SIZE,
188 /// e.g. preamble bytes prepended to the header).

Callers 12

encrypt_aadMethod · 0.80
wrong_key_failsFunction · 0.80
wrong_lsn_failsFunction · 0.80
tampered_header_failsFunction · 0.80
empty_payloadFunction · 0.80
aes_encryptFunction · 0.80
generate_dekMethod · 0.80
rotateMethod · 0.80

Calls 1

encrypt_aadMethod · 0.80

Tested by 7

wrong_key_failsFunction · 0.64
wrong_lsn_failsFunction · 0.64
tampered_header_failsFunction · 0.64
empty_payloadFunction · 0.64