use sha2::{Digest, Sha384};
use crate::profile::Profile;
pub const KEY_ID_SIZE: usize = 8;
const MLKEM_EK_BYTES: usize = 1568;
const P384_POINT_BYTES: usize = 97;
pub fn carried_key_size(profile: Profile) -> usize {
match profile {
Profile::PqPure => MLKEM_EK_BYTES,
Profile::PqHybrid => MLKEM_EK_BYTES + P384_POINT_BYTES,
}
}
pub fn is_carried_key_size(len: usize) -> bool {
[Profile::PqPure, Profile::PqHybrid]
.into_iter()
.any(|p| carried_key_size(p) == len)
}
pub fn key_id(carried: &[u8]) -> [u8; KEY_ID_SIZE] {
let hash = Sha384::digest(carried);
let mut id = [0; KEY_ID_SIZE];
id.copy_from_slice(&hash[..KEY_ID_SIZE]);
id
}