use sha2::{Digest, Sha256};
pub fn compute_cia_hex(encrypted_bytes: &[u8], aad: &[u8], device_hint: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(encrypted_bytes);
hasher.update(aad);
hasher.update(device_hint.as_bytes());
let out = hasher.finalize();
hex::encode(out)
}
mod hex {
pub fn encode(bytes: impl AsRef<[u8]>) -> String {
const LUT: &[u8; 16] = b"0123456789abcdef";
let b = bytes.as_ref();
let mut s = String::with_capacity(b.len() * 2);
for &x in b {
s.push(LUT[(x >> 4) as usize] as char);
s.push(LUT[(x & 0x0f) as usize] as char);
}
s
}
}