add pid type
This commit is contained in:
parent
438819c34b
commit
b233568601
1 changed files with 6 additions and 4 deletions
10
src/lib.rs
10
src/lib.rs
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in a new issue