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

Function build_aad

nodedb-wal/src/record/wal_record.rs:192–205  ·  view source on GitHub ↗

Build the AAD buffer: `preamble_bytes || header_bytes`. When `preamble_bytes` is `None` (no encryption or legacy path), the AAD is just the header bytes. When present, the preamble is prepended.

(
    preamble_bytes: Option<&[u8; PREAMBLE_SIZE]>,
    header_bytes: &[u8; HEADER_SIZE],
)

Source from the content-addressed store, hash-verified

190/// When `preamble_bytes` is `None` (no encryption or legacy path), the AAD
191/// is just the header bytes. When present, the preamble is prepended.
192pub(crate) fn build_aad(
193 preamble_bytes: Option<&[u8; PREAMBLE_SIZE]>,
194 header_bytes: &[u8; HEADER_SIZE],
195) -> Vec<u8> {
196 match preamble_bytes {
197 Some(p) => {
198 let mut aad = Vec::with_capacity(PREAMBLE_SIZE + HEADER_SIZE);
199 aad.extend_from_slice(p);
200 aad.extend_from_slice(header_bytes);
201 aad
202 }
203 None => header_bytes.to_vec(),
204 }
205}
206
207#[cfg(test)]
208mod tests {

Callers 3

newMethod · 0.85
decrypt_payloadMethod · 0.85
decrypt_payload_ringMethod · 0.85

Calls 1

to_vecMethod · 0.45

Tested by

no test coverage detected