Adding deserialization checks (#10)

This commit is contained in:
Kevin Lewi
2021-09-27 18:29:08 -07:00
committed by GitHub
parent 0445a9461c
commit f6f85e0a25
11 changed files with 155 additions and 55 deletions
+15
View File
@@ -7,3 +7,18 @@ mod mock_rng;
mod parser;
mod voprf_test_vectors;
mod voprf_vectors;
/// Ciphersuite definitions for tests
pub(crate) struct Ristretto255Sha512;
impl crate::CipherSuite for Ristretto255Sha512 {
type Group = curve25519_dalek::ristretto::RistrettoPoint;
type Hash = sha2::Sha512;
}
#[cfg(feature = "p256")]
pub(crate) struct P256Sha256;
#[cfg(feature = "p256")]
impl crate::CipherSuite for P256Sha256 {
type Group = p256_::ProjectivePoint;
type Hash = sha2::Sha256;
}
+3 -13
View File
@@ -15,10 +15,8 @@ use crate::{
};
use alloc::string::ToString;
use alloc::vec::Vec;
use curve25519_dalek::ristretto::RistrettoPoint;
use generic_array::GenericArray;
use json::JsonValue;
use sha2::Sha512;
#[derive(Debug)]
struct VOPRFTestVectorParameters {
@@ -82,15 +80,11 @@ macro_rules! json_to_test_vectors {
#[test]
fn test_vectors() -> Result<(), InternalError> {
struct Ristretto255Sha512;
impl CipherSuite for Ristretto255Sha512 {
type Group = RistrettoPoint;
type Hash = Sha512;
}
let rfc = json::parse(rfc_to_json(super::voprf_vectors::VECTORS).as_str())
.expect("Could not parse json");
use crate::tests::Ristretto255Sha512;
let ristretto_base_tvs = json_to_test_vectors!(
rfc,
String::from("ristretto255, SHA-512"),
@@ -115,11 +109,7 @@ fn test_vectors() -> Result<(), InternalError> {
#[cfg(feature = "p256")]
{
struct P256Sha256;
impl CipherSuite for P256Sha256 {
type Group = p256_::ProjectivePoint;
type Hash = sha2::Sha256;
}
use crate::tests::P256Sha256;
let p256_base_tvs =
json_to_test_vectors!(rfc, String::from("P-256, SHA-256"), String::from("Base"));
+1 -1
View File
@@ -4,7 +4,7 @@
// LICENSE file in the root directory of this source tree.
//! The VOPRF test vectors taken from:
//! https://github.com/cfrg/draft-irtf-cfrg-opaque/blob/master/draft-irtf-cfrg-opaque.md
//! https://github.com/cfrg/draft-irtf-cfrg-voprf/blob/master/draft-irtf-cfrg-voprf.md
pub(crate) static VECTORS: &str = r#"
## OPRF(ristretto255, SHA-512)