add pid type

This commit is contained in:
Maple Nebel 2026-06-21 02:58:49 +02:00
commit b233568601

View file

@ -3,15 +3,17 @@ use md5::Md5;
pub mod grpc;
pub const GUEST_PID: i32 = 100;
pub const RDV_AUTHENTICATION_PID: i32 = 1;
pub const RDV_SECURE_PID: i32 = 2;
pub type PID = i32;
pub const GUEST_PID: PID = 100;
pub const RDV_AUTHENTICATION_PID: PID = 1;
pub const RDV_SECURE_PID: PID = 2;
pub type NexKey = [u8; 16];
type HmacMd5 = Hmac<Md5>;
pub fn derive_pid_hmac(pid: u32, key: &NexKey) -> [u8; 4] {
pub fn derive_pid_hmac(pid: PID, key: &NexKey) -> [u8; 4] {
let mut hmac = HmacMd5::new_from_slice(&key[..]).expect("infallible");
hmac.update(&pid.to_be_bytes());
hmac.finalize().as_bytes().as_slice()[0..4]