From f43236fbf8ce4123c1c67652f3fcbc9c016cec71 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Fri, 10 Nov 2023 20:40:09 +0100 Subject: [PATCH] Test P-521 --- Cargo.toml | 4 ++++ src/group/tests.rs | 4 ++++ src/oprf.rs | 8 ++++++++ src/poprf.rs | 8 ++++++++ src/serialization.rs | 1 + src/tests/test_cfrg_vectors.rs | 28 ++++++++++++++++++++++++++++ src/voprf.rs | 10 ++++++++++ 7 files changed, 63 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 3ee9fdb..91793f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,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" diff --git a/src/group/tests.rs b/src/group/tests.rs index a453593..58737ce 100644 --- a/src/group/tests.rs +++ b/src/group/tests.rs @@ -17,6 +17,7 @@ use crate::{Error, Group, Result}; fn test_group_properties() -> Result<()> { use p256::NistP256; use p384::NistP384; + use p521::NistP521; #[cfg(feature = "ristretto255")] { @@ -32,6 +33,9 @@ fn test_group_properties() -> Result<()> { test_identity_element_error::()?; test_zero_scalar_error::()?; + test_identity_element_error::()?; + test_zero_scalar_error::()?; + Ok(()) } diff --git a/src/oprf.rs b/src/oprf.rs index 092b1c4..710b748 100644 --- a/src/oprf.rs +++ b/src/oprf.rs @@ -427,6 +427,7 @@ mod tests { fn test_functionality() -> Result<()> { use p256::NistP256; use p384::NistP384; + use p521::NistP521; #[cfg(feature = "ristretto255")] { @@ -454,6 +455,13 @@ mod tests { zeroize_oprf_client::(); zeroize_oprf_server::(); + base_retrieval::(); + base_inversion_unsalted::(); + server_evaluate::(); + + zeroize_oprf_client::(); + zeroize_oprf_server::(); + Ok(()) } } diff --git a/src/poprf.rs b/src/poprf.rs index b2acd18..a0fd531 100644 --- a/src/poprf.rs +++ b/src/poprf.rs @@ -967,6 +967,7 @@ mod tests { fn test_functionality() -> Result<()> { use p256::NistP256; use p384::NistP384; + use p521::NistP521; #[cfg(feature = "ristretto255")] { @@ -994,6 +995,13 @@ mod tests { zeroize_verifiable_client::(); zeroize_verifiable_server::(); + verifiable_retrieval::(); + verifiable_bad_public_key::(); + verifiable_server_evaluate::(); + + zeroize_verifiable_client::(); + zeroize_verifiable_server::(); + Ok(()) } } diff --git a/src/serialization.rs b/src/serialization.rs index a2bb6c2..a4dacd3 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -391,6 +391,7 @@ mod test { let _ = $item::::deserialize(&$bytes[..]); let _ = $item::::deserialize(&$bytes[..]); + let _ = $item::::deserialize(&$bytes[..]); }; } diff --git a/src/tests/test_cfrg_vectors.rs b/src/tests/test_cfrg_vectors.rs index aa31239..47c2b3a 100644 --- a/src/tests/test_cfrg_vectors.rs +++ b/src/tests/test_cfrg_vectors.rs @@ -89,6 +89,7 @@ macro_rules! json_to_test_vectors { fn test_vectors() -> Result<()> { use p256::NistP256; use p384::NistP384; + use p521::NistP521; let rfc: Value = serde_json::from_str(rfc_to_json(super::cfrg_vectors::VECTORS).as_str()) .expect("Could not parse json"); @@ -188,6 +189,33 @@ fn test_vectors() -> Result<()> { test_poprf_finalize::(&p384_poprf_tvs)?; test_poprf_evaluate::(&p384_poprf_tvs)?; + let p521_oprf_tvs = + json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("OPRF")); + assert_ne!(p521_oprf_tvs.len(), 0); + test_oprf_seed_to_key::(&p521_oprf_tvs)?; + test_oprf_blind::(&p521_oprf_tvs)?; + test_oprf_blind_evaluate::(&p521_oprf_tvs)?; + test_oprf_finalize::(&p521_oprf_tvs)?; + test_oprf_evaluate::(&p521_oprf_tvs)?; + + let p521_voprf_tvs = + json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("VOPRF")); + assert_ne!(p521_voprf_tvs.len(), 0); + test_voprf_seed_to_key::(&p521_voprf_tvs)?; + test_voprf_blind::(&p521_voprf_tvs)?; + test_voprf_blind_evaluate::(&p521_voprf_tvs)?; + test_voprf_finalize::(&p521_voprf_tvs)?; + test_voprf_evaluate::(&p521_voprf_tvs)?; + + let p521_poprf_tvs = + json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("POPRF")); + assert_ne!(p521_poprf_tvs.len(), 0); + test_poprf_seed_to_key::(&p521_poprf_tvs)?; + test_poprf_blind::(&p521_poprf_tvs)?; + test_poprf_blind_evaluate::(&p521_poprf_tvs)?; + test_poprf_finalize::(&p521_poprf_tvs)?; + test_poprf_evaluate::(&p521_poprf_tvs)?; + Ok(()) } diff --git a/src/voprf.rs b/src/voprf.rs index 4b37000..9871952 100644 --- a/src/voprf.rs +++ b/src/voprf.rs @@ -836,6 +836,7 @@ mod tests { fn test_functionality() -> Result<()> { use p256::NistP256; use p384::NistP384; + use p521::NistP521; #[cfg(feature = "ristretto255")] { @@ -869,6 +870,15 @@ mod tests { zeroize_voprf_client::(); zeroize_voprf_server::(); + verifiable_retrieval::(); + verifiable_batch_retrieval::(); + verifiable_bad_public_key::(); + verifiable_batch_bad_public_key::(); + verifiable_server_evaluate::(); + + zeroize_voprf_client::(); + zeroize_voprf_server::(); + Ok(()) } }