Implement client_mac_key test
This commit is contained in:
@@ -28,7 +28,12 @@ pub type GenerateKe2Result<K, D, G> = (
|
||||
#[cfg(not(test))]
|
||||
pub type GenerateKe3Result<K, D, G> = (Vec<u8>, <K as KeyExchange<D, G>>::KE3Message);
|
||||
#[cfg(test)]
|
||||
pub type GenerateKe3Result<K, D, G> = (Vec<u8>, <K as KeyExchange<D, G>>::KE3Message, Vec<u8>);
|
||||
pub type GenerateKe3Result<K, D, G> = (
|
||||
Vec<u8>,
|
||||
<K as KeyExchange<D, G>>::KE3Message,
|
||||
Vec<u8>,
|
||||
generic_array::GenericArray<u8, <D as digest::Digest>::OutputSize>,
|
||||
);
|
||||
|
||||
pub trait KeyExchange<D: Hash, G: Group> {
|
||||
type KE1State: FromBytes + ToBytesWithPointers + Zeroize + Clone;
|
||||
|
||||
@@ -189,6 +189,8 @@ impl<D: Hash, G: Group> KeyExchange<D, G> for TripleDH {
|
||||
},
|
||||
#[cfg(test)]
|
||||
result.3,
|
||||
#[cfg(test)]
|
||||
result.2,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -576,6 +576,9 @@ pub struct ClientLoginFinishResult<CS: CipherSuite> {
|
||||
/// Handshake secret, only used tests
|
||||
#[cfg(test)]
|
||||
pub handshake_secret: Vec<u8>,
|
||||
/// Client MAC key, only used in tests
|
||||
#[cfg(test)]
|
||||
pub client_mac_key: GenericArray<u8, <CS::Hash as Digest>::OutputSize>,
|
||||
}
|
||||
|
||||
// Cannot be derived because it would require for CS to be Clone.
|
||||
@@ -590,6 +593,8 @@ impl<CS: CipherSuite> Clone for ClientLoginFinishResult<CS> {
|
||||
state: self.state.clone(),
|
||||
#[cfg(test)]
|
||||
handshake_secret: self.handshake_secret.clone(),
|
||||
#[cfg(test)]
|
||||
client_mac_key: self.client_mac_key.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -703,6 +708,8 @@ impl<CS: CipherSuite> ClientLogin<CS> {
|
||||
state: self,
|
||||
#[cfg(test)]
|
||||
handshake_secret: result.2,
|
||||
#[cfg(test)]
|
||||
client_mac_key: result.3,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ pub struct TestVectorParameters {
|
||||
pub randomized_pwd: Vec<u8>,
|
||||
pub handshake_secret: Vec<u8>,
|
||||
pub server_mac_key: Vec<u8>,
|
||||
pub client_mac_key: Vec<u8>,
|
||||
}
|
||||
|
||||
// Pulled from "OPAQUE-3DH Test Vector 1" and "OPAQUE-3DH Test Vector 6"
|
||||
@@ -490,6 +491,7 @@ fn populate_test_vectors(values: &Value) -> TestVectorParameters {
|
||||
randomized_pwd: parse!(values, "randomized_pwd"),
|
||||
handshake_secret: parse!(values, "handshake_secret"),
|
||||
server_mac_key: parse!(values, "server_mac_key"),
|
||||
client_mac_key: parse!(values, "client_mac_key"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,6 +708,10 @@ fn test_ke3() -> Result<(), ProtocolError> {
|
||||
hex::encode(¶meters.handshake_secret),
|
||||
hex::encode(&client_login_finish_result.handshake_secret)
|
||||
);
|
||||
assert_eq!(
|
||||
hex::encode(¶meters.client_mac_key),
|
||||
hex::encode(&client_login_finish_result.client_mac_key)
|
||||
);
|
||||
assert_eq!(
|
||||
hex::encode(¶meters.KE3),
|
||||
hex::encode(client_login_finish_result.message.serialize())
|
||||
|
||||
Reference in New Issue
Block a user