From f1c7f088f138dcca0d9c1c6681ac8068cfba76dd Mon Sep 17 00:00:00 2001 From: dAxpeDDa Date: Wed, 7 Dec 2022 16:42:25 +0100 Subject: [PATCH] Test P-384 --- Cargo.toml | 5 +++++ 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, 64 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 25f4599..acdadd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,10 @@ p256 = { version = "=0.13.0-pre", default-features = false, features = [ "hash2curve", "voprf", ] } +p384 = { version = "=0.13.0-pre", default-features = false, features = [ + "hash2curve", + "voprf", +] } proptest = "1" rand = "0.8" regex = "1" @@ -62,3 +66,4 @@ targets = [] [patch.crates-io] p256 = { git = "https://github.com/RustCrypto/elliptic-curves", rev = "136fed7944d53c0508b1a93cd97bdab46891bcf7" } +p384 = { git = "https://github.com/RustCrypto/elliptic-curves", rev = "136fed7944d53c0508b1a93cd97bdab46891bcf7" } diff --git a/src/group/tests.rs b/src/group/tests.rs index f12571f..6cda7d7 100644 --- a/src/group/tests.rs +++ b/src/group/tests.rs @@ -15,6 +15,7 @@ use crate::{Error, Group, Result}; #[test] fn test_group_properties() -> Result<()> { use p256::NistP256; + use p384::NistP384; #[cfg(feature = "ristretto255")] { @@ -27,6 +28,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 e153ab9..f2b3df9 100644 --- a/src/oprf.rs +++ b/src/oprf.rs @@ -425,6 +425,7 @@ mod tests { #[test] fn test_functionality() -> Result<()> { use p256::NistP256; + use p384::NistP384; #[cfg(feature = "ristretto255")] { @@ -445,6 +446,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 ed2c08e..0a4632a 100644 --- a/src/poprf.rs +++ b/src/poprf.rs @@ -965,6 +965,7 @@ mod tests { #[test] fn test_functionality() -> Result<()> { use p256::NistP256; + use p384::NistP384; #[cfg(feature = "ristretto255")] { @@ -985,6 +986,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 6a6fa60..640f4f7 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -389,6 +389,7 @@ mod test { } 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 f16152b..454cb10 100644 --- a/src/tests/test_cfrg_vectors.rs +++ b/src/tests/test_cfrg_vectors.rs @@ -87,6 +87,7 @@ macro_rules! json_to_test_vectors { #[test] fn test_vectors() -> Result<()> { use p256::NistP256; + use p384::NistP384; let rfc: Value = serde_json::from_str(rfc_to_json(super::cfrg_vectors::VECTORS).as_str()) .expect("Could not parse json"); @@ -159,6 +160,33 @@ fn test_vectors() -> Result<()> { test_poprf_finalize::(&p256_poprf_tvs)?; test_poprf_evaluate::(&p256_poprf_tvs)?; + let p384_oprf_tvs = + json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("OPRF")); + assert_ne!(p384_oprf_tvs.len(), 0); + test_oprf_seed_to_key::(&p384_oprf_tvs)?; + test_oprf_blind::(&p384_oprf_tvs)?; + test_oprf_blind_evaluate::(&p384_oprf_tvs)?; + test_oprf_finalize::(&p384_oprf_tvs)?; + test_oprf_evaluate::(&p384_oprf_tvs)?; + + let p384_voprf_tvs = + json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("VOPRF")); + assert_ne!(p384_voprf_tvs.len(), 0); + test_voprf_seed_to_key::(&p384_voprf_tvs)?; + test_voprf_blind::(&p384_voprf_tvs)?; + test_voprf_blind_evaluate::(&p384_voprf_tvs)?; + test_voprf_finalize::(&p384_voprf_tvs)?; + test_voprf_evaluate::(&p384_voprf_tvs)?; + + let p384_poprf_tvs = + json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("POPRF")); + assert_ne!(p384_poprf_tvs.len(), 0); + test_poprf_seed_to_key::(&p384_poprf_tvs)?; + test_poprf_blind::(&p384_poprf_tvs)?; + test_poprf_blind_evaluate::(&p384_poprf_tvs)?; + test_poprf_finalize::(&p384_poprf_tvs)?; + test_poprf_evaluate::(&p384_poprf_tvs)?; + Ok(()) } diff --git a/src/voprf.rs b/src/voprf.rs index 925c270..0fc5c99 100644 --- a/src/voprf.rs +++ b/src/voprf.rs @@ -834,6 +834,7 @@ mod tests { #[test] fn test_functionality() -> Result<()> { use p256::NistP256; + use p384::NistP384; #[cfg(feature = "ristretto255")] { @@ -858,6 +859,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(()) } }