Skip to content

Commit

Permalink
Test P-521 (#349)
Browse files Browse the repository at this point in the history
* Test P-521

* De-duplicate generic calls

* Simplify full test vectors generation
  • Loading branch information
daxpedda committed Nov 16, 2023
1 parent c728c37 commit 56cdf9a
Show file tree
Hide file tree
Showing 6 changed files with 1,130 additions and 942 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ p384 = { version = "0.13", default-features = false, features = [
"hash2curve",
"voprf",
] }
p521 = { version = "0.13.3", default-features = false, features = [
"hash2curve",
"voprf",
] }
proptest = "1"
rand = "0.8"
regex = "1"
Expand Down
2 changes: 2 additions & 0 deletions src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ mod tests {
inner::<crate::Ristretto255>();
inner::<::p256::NistP256>();
inner::<::p384::NistP384>();
inner::<::p521::NistP521>();
}

macro_rules! test {
Expand Down Expand Up @@ -296,6 +297,7 @@ mod tests {
test!(ristretto, crate::Ristretto255);
test!(p256, ::p256::NistP256);
test!(p384, ::p384::NistP384);
test!(p521, ::p521::NistP521);

#[test]
fn remote_key() {
Expand Down
22 changes: 22 additions & 0 deletions src/serialization/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ impl CipherSuite for P384 {
type Ksf = crate::ksf::Identity;
}

struct P521;

impl CipherSuite for P521 {
type OprfCs = ::p521::NistP521;
type KeGroup = ::p521::NistP521;
type KeyExchange = TripleDh;
type Ksf = crate::ksf::Identity;
}

fn random_point<CS: CipherSuite>() -> <CS::KeGroup as KeGroup>::Pk
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
Expand Down Expand Up @@ -115,6 +124,7 @@ fn client_registration_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -169,6 +179,7 @@ fn server_registration_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -212,6 +223,7 @@ fn registration_request_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -264,6 +276,7 @@ fn registration_response_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -326,6 +339,7 @@ fn registration_upload_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -384,6 +398,7 @@ fn credential_request_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -473,6 +488,7 @@ fn credential_response_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -505,6 +521,7 @@ fn credential_finalization_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -573,6 +590,7 @@ fn client_login_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -613,6 +631,7 @@ fn ke1_message_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -657,6 +676,7 @@ fn ke2_message_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -692,6 +712,7 @@ fn ke3_message_roundtrip() -> Result<(), ProtocolError> {
inner::<Ristretto255>()?;
inner::<P256>()?;
inner::<P384>()?;
inner::<P521>()?;

Ok(())
}
Expand Down Expand Up @@ -783,3 +804,4 @@ macro_rules! test {
test!(ristretto255, Ristretto255);
test!(p256, P256);
test!(p384, P384);
test!(p521, P521);

0 comments on commit 56cdf9a

Please sign in to comment.