From 787e11e8e42bdc7b9c69e9b3d7b67f532b9a9df1 Mon Sep 17 00:00:00 2001 From: Luca Fulchir Date: Wed, 7 Jun 2023 11:07:46 +0200 Subject: [PATCH] Fixes for Hati Signed-off-by: Luca Fulchir --- src/enc/asym.rs | 12 ++++++++++-- src/lib.rs | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/enc/asym.rs b/src/enc/asym.rs index ea67ac3..4b6c09f 100644 --- a/src/enc/asym.rs +++ b/src/enc/asym.rs @@ -282,11 +282,19 @@ impl PrivKey { PrivKey::Signing => todo!(), } } + /// return the kind of public key + pub fn kind(&self) -> KeyKind { + match self { + PrivKey::Signing => todo!(), + PrivKey::Exchange(ex) => ex.kind(), + } + } /// serialize the key into the buffer /// NOTE: Assumes there is enough space pub fn serialize_into(&self, out: &mut [u8]) { + out[0] = self.kind() as u8; match self { - PrivKey::Exchange(ex) => ex.serialize_into(out), + PrivKey::Exchange(ex) => ex.serialize_into(&mut out[1..]), PrivKey::Signing => todo!(), } } @@ -336,7 +344,7 @@ impl ExchangePrivKey { pub fn serialize_into(&self, out: &mut [u8]) { match self { ExchangePrivKey::X25519(key) => { - out[..32].copy_from_slice(&key.to_bytes()); + out[0..32].copy_from_slice(&key.to_bytes()); } } } diff --git a/src/lib.rs b/src/lib.rs index 508c29f..cac07b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -354,6 +354,7 @@ impl Fenrir { } } + // TODO: start work on a LocalSet provided by the user /// Start one working thread for each physical cpu /// threads are pinned to each cpu core. /// Work will be divided and rerouted so that there is no need to lock