Skip to content

Commit

Permalink
Adds proper key generation and exchange
Browse files Browse the repository at this point in the history
This change adds proper key generation and exchange to Session::new()
and removes the garbage key.

Signed-off-by: Dhanuka Warusadura <[email protected]>
  • Loading branch information
warusadura committed Mar 1, 2024
1 parent c76feda commit 9a7f106
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions server/src/daemon/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ impl Session {
manager: Arc<Mutex<ServiceManager>>,
sessions_counter: i32,
) -> (Self, Option<Key>) {
// make use of the keys
let service_key = vec![0];
let service_key = if client_public_key.is_none() {
Some(Key::new(vec![0]))
} else {
let private_key = Key::generate_private_key();
let public_key = Key::generate_public_key(&private_key);
Some(public_key)
};

let instance = Self {
client_public_key: Arc::new(client_public_key),
path: OwnedObjectPath::try_from(format!(
Expand All @@ -47,7 +53,7 @@ impl Session {
manager,
};

(instance, Some(Key::new(service_key)))
(instance, service_key)
}

pub fn path(&self) -> ObjectPath<'_> {
Expand Down

0 comments on commit 9a7f106

Please sign in to comment.