Add randomized_pwd tests

This commit is contained in:
dAxpeDDa
2021-07-30 14:45:27 -07:00
committed by Kevin Lewi
parent 35886152ca
commit b90163a007
2 changed files with 13 additions and 0 deletions
+7
View File
@@ -278,6 +278,9 @@ pub struct ClientRegistrationFinishResult<CS: CipherSuite> {
/// Instance of the ClientRegistration, only used in tests for checking zeroize /// Instance of the ClientRegistration, only used in tests for checking zeroize
#[cfg(test)] #[cfg(test)]
pub state: ClientRegistration<CS>, pub state: ClientRegistration<CS>,
/// Password derived key, only used in tests
#[cfg(test)]
pub randomized_pwd: Vec<u8>,
} }
// Cannot be derived because it would require for CS to be Clone. // Cannot be derived because it would require for CS to be Clone.
@@ -289,6 +292,8 @@ impl<CS: CipherSuite> Clone for ClientRegistrationFinishResult<CS> {
server_s_pk: self.server_s_pk.clone(), server_s_pk: self.server_s_pk.clone(),
#[cfg(test)] #[cfg(test)]
state: self.state.clone(), state: self.state.clone(),
#[cfg(test)]
randomized_pwd: self.randomized_pwd.clone(),
} }
} }
} }
@@ -333,6 +338,8 @@ impl<CS: CipherSuite> ClientRegistration<CS> {
server_s_pk: r2.server_s_pk, server_s_pk: r2.server_s_pk,
#[cfg(test)] #[cfg(test)]
state: self, state: self,
#[cfg(test)]
randomized_pwd: password_derived_key
}) })
} }
} }
+6
View File
@@ -63,6 +63,7 @@ pub struct TestVectorParameters {
pub KE3: Vec<u8>, pub KE3: Vec<u8>,
pub export_key: Vec<u8>, pub export_key: Vec<u8>,
pub session_key: Vec<u8>, pub session_key: Vec<u8>,
pub randomized_pwd: Vec<u8>,
} }
// Pulled from "OPAQUE-3DH Test Vector 1" and "OPAQUE-3DH Test Vector 6" // Pulled from "OPAQUE-3DH Test Vector 1" and "OPAQUE-3DH Test Vector 6"
@@ -482,6 +483,7 @@ fn populate_test_vectors(values: &Value) -> TestVectorParameters {
blind_login: parse!(values, "blind_login"), blind_login: parse!(values, "blind_login"),
export_key: parse!(values, "export_key"), export_key: parse!(values, "export_key"),
session_key: parse!(values, "session_key"), session_key: parse!(values, "session_key"),
randomized_pwd: parse!(values, "randomized_pwd"),
} }
} }
@@ -567,6 +569,10 @@ fn test_registration_upload() -> Result<(), ProtocolError> {
}, },
)?; )?;
assert_eq!(
hex::encode(parameters.randomized_pwd),
hex::encode(result.randomized_pwd)
);
assert_eq!( assert_eq!(
hex::encode(parameters.registration_upload), hex::encode(parameters.registration_upload),
hex::encode(result.message.serialize()) hex::encode(result.message.serialize())