Implement server_mac_key test

This commit is contained in:
dAxpeDDa
2021-07-30 14:45:27 -07:00
committed by Kevin Lewi
parent 4298deadff
commit ec528eb4d9
4 changed files with 15 additions and 0 deletions
+1
View File
@@ -23,6 +23,7 @@ pub type GenerateKe2Result<K, D, G> = (
<K as KeyExchange<D, G>>::KE2State,
<K as KeyExchange<D, G>>::KE2Message,
Vec<u8>,
generic_array::GenericArray<u8, <D as digest::Digest>::OutputSize>,
);
#[cfg(not(test))]
pub type GenerateKe3Result<K, D, G> = (Vec<u8>, <K as KeyExchange<D, G>>::KE3Message);
+2
View File
@@ -128,6 +128,8 @@ impl<D: Hash, G: Group> KeyExchange<D, G> for TripleDH {
},
#[cfg(test)]
result.3,
#[cfg(test)]
result.1,
))
}
+6
View File
@@ -748,6 +748,8 @@ pub struct ServerLoginStartResult<CS: CipherSuite> {
/// Handshake secret, only used tests
#[cfg(test)]
pub handshake_secret: Vec<u8>,
#[cfg(test)]
pub server_mac_key: GenericArray<u8, <CS::Hash as Digest>::OutputSize>,
}
// Cannot be derived because it would require for CS to be Clone.
@@ -758,6 +760,8 @@ impl<CS: CipherSuite> Clone for ServerLoginStartResult<CS> {
state: self.state.clone(),
#[cfg(test)]
handshake_secret: self.handshake_secret.clone(),
#[cfg(test)]
server_mac_key: self.server_mac_key.clone(),
}
}
}
@@ -885,6 +889,8 @@ impl<CS: CipherSuite> ServerLogin<CS> {
},
#[cfg(test)]
handshake_secret: result.2,
#[cfg(test)]
server_mac_key: result.3,
})
}
+6
View File
@@ -66,6 +66,7 @@ pub struct TestVectorParameters {
pub auth_key: Vec<u8>,
pub randomized_pwd: Vec<u8>,
pub handshake_secret: Vec<u8>,
pub server_mac_key: Vec<u8>,
}
// Pulled from "OPAQUE-3DH Test Vector 1" and "OPAQUE-3DH Test Vector 6"
@@ -488,6 +489,7 @@ fn populate_test_vectors(values: &Value) -> TestVectorParameters {
auth_key: parse!(values, "auth_key"),
randomized_pwd: parse!(values, "randomized_pwd"),
handshake_secret: parse!(values, "handshake_secret"),
server_mac_key: parse!(values, "server_mac_key"),
}
}
@@ -659,6 +661,10 @@ fn test_ke2() -> Result<(), ProtocolError> {
hex::encode(&parameters.handshake_secret),
hex::encode(server_login_start_result.handshake_secret)
);
assert_eq!(
hex::encode(&parameters.server_mac_key),
hex::encode(server_login_start_result.server_mac_key)
);
assert_eq!(
hex::encode(&parameters.KE2),
hex::encode(server_login_start_result.message.serialize())