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],
)
| 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. |
| 192 | pub(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)] |
| 208 | mod tests { |
no test coverage detected