diff --git a/libpaket/src/locker/crypto.rs b/libpaket/src/locker/crypto.rs index abb0688..85f8e94 100644 --- a/libpaket/src/locker/crypto.rs +++ b/libpaket/src/locker/crypto.rs @@ -6,9 +6,10 @@ use ed25519_dalek::Signer; pub struct CustomerKeySeed { - postnumber: String, - seed: Seed, - uuid: Uuid, + pub postnumber: String, + pub seed: Seed, + pub uuid: Uuid, + pub device_id: Option, } pub struct Seed { @@ -44,17 +45,25 @@ impl CustomerKeySeed { postnumber, seed: Seed::random(), uuid: uuid::Uuid::new_v4(), + device_id: None, } } - pub fn from(postnumber: &String, seed: Vec, uuid: &Uuid) -> Self { + pub fn from(postnumber: &String, seed: Vec, uuid: &Uuid, device_id: String) -> Self { CustomerKeySeed { postnumber: postnumber.clone(), seed: Seed::from_bytes(seed), - uuid: uuid.clone() + uuid: uuid.clone(), + device_id: Some(device_id), } } + pub fn set_device_id(&mut self, device_id: String) { + assert!(self.device_id.is_none()); + + self.device_id = Some(device_id); + } + pub(crate) fn sign(&self, message: &[u8]) -> String { let signing_key = SigningKey::from_bytes(self.seed.as_bytes());