Skip to content

Commit

Permalink
Remove k256 vectors file, add k256 vectors to main vectors and reset …
Browse files Browse the repository at this point in the history
…kat test file.
  • Loading branch information
erskingardner committed Aug 29, 2024
1 parent d365cd1 commit e5ffa99
Show file tree
Hide file tree
Showing 3 changed files with 19,174 additions and 19,173 deletions.
17 changes: 10 additions & 7 deletions tests/test_hpke_kat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate hpke_rs as hpke;

// use hpke_rs_evercrypt::HpkeEvercrypt;
use hpke_rs_rust_crypto::HpkeRustCrypto;
// use rayon::iter::{IntoParallelIterator, ParallelIterator};
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use serde::{self, Deserialize, Serialize};
use std::convert::TryInto;
use std::fs::File;
Expand Down Expand Up @@ -62,8 +62,11 @@ struct ExportsKAT {

fn kat<Crypto: HpkeCrypto + 'static>(tests: Vec<HpkeTestVector>) {
// Replace into_par_iter() with into_iter() to run tests sequentially.
// tests.into_par_iter().for_each(|test| {
tests.into_iter().for_each(|test| {
tests.into_par_iter().for_each(|test| {
println!(
"Testing mode {:?} with ciphersuite {:?}_{:?}_{:?}",
test.mode, test.kem_id, test.kdf_id, test.aead_id
);
let mode: HpkeMode = test.mode.try_into().unwrap();
let kem_id: KemAlgorithm = test.kem_id.try_into().unwrap();
let kdf_id: KdfAlgorithm = test.kdf_id.try_into().unwrap();
Expand Down Expand Up @@ -153,9 +156,9 @@ fn kat<Crypto: HpkeCrypto + 'static>(tests: Vec<HpkeTestVector>) {

// Check setup info
// Note that key and nonce are empty for exporter only key derivation.
// assert_eq!(direct_ctx.key(), key);
// assert_eq!(direct_ctx.nonce(), nonce);
// assert_eq!(direct_ctx.exporter_secret(), exporter_secret);
assert_eq!(direct_ctx.key(), key);
assert_eq!(direct_ctx.nonce(), nonce);
assert_eq!(direct_ctx.exporter_secret(), exporter_secret);
assert_eq!(direct_ctx.sequence_number(), 0);

// Test key pair derivation.
Expand Down Expand Up @@ -274,7 +277,7 @@ fn kat<Crypto: HpkeCrypto + 'static>(tests: Vec<HpkeTestVector>) {
#[test]
fn test_kat() {
let _ = pretty_env_logger::try_init();
let file = "tests/test_vectors_k256.json";
let file = "tests/test_vectors.json";
let file = match File::open(file) {
Ok(f) => f,
Err(_) => panic!("Couldn't open file {}.", file),
Expand Down
Loading

0 comments on commit e5ffa99

Please sign in to comment.