feat(rust): update key exchange trait
)]
use ockam_core::Result;
-use ockam_vault_core::{PublicKey, Secret};
+use ockam_vault_core::Secret;
use zeroize::Zeroize;
/// A trait implemented by both Initiator and Responder peers.
pub trait KeyExchanger {
- /// Run the current phase of the key exchange process.
- fn process(&mut self, data: &[u8]) -> Result<Vec<u8>>;
+ /// Generate request that should be sent to the other party.
+ fn generate_request(&mut self, payload: &[u8]) -> Result<Vec<u8>>;
+ /// Handle response from other party and return payload.
+ fn handle_response(&mut self, response: &[u8]) -> Result<Vec<u8>>;
/// Returns true if the key exchange process is complete.
fn is_complete(&self) -> bool;
/// Return the data and keys needed for channels. Key exchange must be completed prior to calling this function.
@@ -48,8 +50,6 @@ pub struct CompletedKeyExchange {
h: [u8; 32],
encrypt_key: Secret,
decrypt_key: Secret,
- local_static_secret: Secret,
- remote_static_public_key: PublicKey,
}
impl CompletedKeyExchange {
@@ -65,31 +65,15 @@ impl CompletedKeyExchange {
pub fn decrypt_key(&self) -> &Secret {
&self.decrypt_key
}
- /// The long term static key.
- pub fn local_static_secret(&self) -> &Secret {
- &self.local_static_secret
- }
- /// Remote peer well known public key.
- pub fn remote_static_public_key(&self) -> &PublicKey {
- &self.remote_static_public_key
- }
}
impl CompletedKeyExchange {
/// Build a CompletedKeyExchange comprised of the input parameters.
- pub fn new(
- h: [u8; 32],
- encrypt_key: Secret,
- decrypt_key: Secret,
- local_static_secret: Secret,
- remote_static_public_key: PublicKey,
- ) -> Self {
+ pub fn new(h: [u8; 32], encrypt_key: Secret, decrypt_key: Secret) -> Self {
CompletedKeyExchange {
h,
encrypt_key,
decrypt_key,
- local_static_secret,
- remote_static_public_key,
}
}
}
