1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 15:39:07 +00:00
This commit is contained in:
Henry Case 2021-03-26 10:05:25 +00:00
parent a8bb139ea6
commit ec4f21b2de
2 changed files with 51 additions and 4 deletions

View File

@ -4,7 +4,7 @@ extern crate bindgen;
fn main() { fn main() {
let dst = Config::new("../../../") let dst = Config::new("../../../")
.profile("Release") .profile("Debug")
.very_verbose(true) .very_verbose(true)
.build(); .build();

View File

@ -5,6 +5,18 @@ use std::env;
use std::path::Path; use std::path::Path;
use threadpool::ThreadPool; use threadpool::ThreadPool;
// Used for signature algorithm registration
macro_rules! REG_SIGN {
($ID:expr,$F:expr) => {
Register{
kat:Kat{
scheme_type: AlgType::AlgSignature,
scheme_id: $ID,
kat_file: $F},
execfn: signature_scheme}
}
}
const KAT_DIR : &'static str= "."; const KAT_DIR : &'static str= ".";
type ExecFn = fn(&TestVector); type ExecFn = fn(&TestVector);
struct Register { struct Register {
@ -32,14 +44,49 @@ fn signature_scheme(el: &TestVector) {
} }
// KAT test register // KAT test register
const REG: [Register; 1] = [ const KATS: &'static[Register] = &[
Register{kat:Kat{scheme_type: AlgType::AlgSignature, scheme_id: DILITHIUM2, kat_file: "round3/dilithium/dilithium2/PQCsignKAT_2544.rsp"}, execfn: signature_scheme}, REG_SIGN!(DILITHIUM2, "round3/dilithium/dilithium2/PQCsignKAT_2544.rsp"),
REG_SIGN!(DILITHIUM3, "round3/dilithium/dilithium3/PQCsignKAT_4016.rsp"),
REG_SIGN!(DILITHIUM5, "round3/dilithium/dilithium5/PQCsignKAT_4880.rsp"),
//REG_SIGN!(FALCON512, "round3/falcon/falcon512-KAT.rsp"),
//REG_SIGN!(FALCON1024, "round3/falcon/falcon1024-KAT.rsp"),
//REG_SIGN!(RAINBOWVCLASSIC),
//REG_SIGN!(RAINBOWICLASSIC),
//REG_SIGN!(RAINBOWIIICLASSIC),
// Some implementations of sphincs are for round3
REG_SIGN!(SPHINCSSHA256192FSIMPLE,"round3/sphincs/sphincs-sha256-192f-simple/PQCsignKAT_96.rsp"),
REG_SIGN!(SPHINCSSHA256192FROBUST,"round3/sphincs/sphincs-sha256-192f-robust/PQCsignKAT_96.rsp"),
REG_SIGN!(SPHINCSSHA256256SSIMPLE,"round3/sphincs/sphincs-sha256-256s-simple/PQCsignKAT_128.rsp"),
REG_SIGN!(SPHINCSSHA256256SROBUST,"round3/sphincs/sphincs-sha256-256s-robust/PQCsignKAT_128.rsp"),
REG_SIGN!(SPHINCSSHAKE256192FROBUST,"round3/sphincs/sphincs-shake256-192f-robust/PQCsignKAT_96.rsp"),
REG_SIGN!(SPHINCSSHAKE256192FSIMPLE,"round3/sphincs/sphincs-shake256-192f-simple/PQCsignKAT_96.rsp"),
REG_SIGN!(SPHINCSSHAKE256256SSIMPLE,"round3/sphincs/sphincs-shake256-256s-simple/PQCsignKAT_128.rsp"),
REG_SIGN!(SPHINCSSHAKE256256SROBUST,"round3/sphincs/sphincs-shake256-256s-robust/PQCsignKAT_128.rsp"),
// And some for round 2
REG_SIGN!(SPHINCSSHA256128SSIMPLE,"round2/sphincs/sphincs-sha256-128s-simple/PQCsignKAT_64.rsp"),
REG_SIGN!(SPHINCSSHA256128SROBUST,"round2/sphincs/sphincs-sha256-128s-robust/PQCsignKAT_64.rsp"),
REG_SIGN!(SPHINCSSHA256128FSIMPLE,"round2/sphincs/sphincs-sha256-128f-simple/PQCsignKAT_64.rsp"),
REG_SIGN!(SPHINCSSHA256128FROBUST,"round2/sphincs/sphincs-sha256-128f-robust/PQCsignKAT_64.rsp"),
REG_SIGN!(SPHINCSSHA256192SSIMPLE,"round2/sphincs/sphincs-sha256-192s-simple/PQCsignKAT_96.rsp"),
REG_SIGN!(SPHINCSSHA256192SROBUST,"round2/sphincs/sphincs-sha256-192s-robust/PQCsignKAT_96.rsp"),
REG_SIGN!(SPHINCSSHA256256FROBUST,"round2/sphincs/sphincs-sha256-256f-robust/PQCsignKAT_128.rsp"),
REG_SIGN!(SPHINCSSHA256256FSIMPLE,"round2/sphincs/sphincs-sha256-256f-simple/PQCsignKAT_128.rsp"),
REG_SIGN!(SPHINCSSHAKE256128FSIMPLE,"round2/sphincs/sphincs-shake256-128f-simple/PQCsignKAT_64.rsp"),
REG_SIGN!(SPHINCSSHAKE256128SSIMPLE,"round2/sphincs/sphincs-shake256-128s-simple/PQCsignKAT_64.rsp"),
REG_SIGN!(SPHINCSSHAKE256128FROBUST,"round2/sphincs/sphincs-shake256-128f-robust/PQCsignKAT_64.rsp"),
REG_SIGN!(SPHINCSSHAKE256128SROBUST,"round2/sphincs/sphincs-shake256-128s-robust/PQCsignKAT_64.rsp"),
REG_SIGN!(SPHINCSSHAKE256192SSIMPLE,"round2/sphincs/sphincs-shake256-192s-simple/PQCsignKAT_96.rsp"),
REG_SIGN!(SPHINCSSHAKE256192SROBUST,"round2/sphincs/sphincs-shake256-192s-robust/PQCsignKAT_96.rsp"),
REG_SIGN!(SPHINCSSHAKE256256FROBUST,"round2/sphincs/sphincs-shake256-256f-robust/PQCsignKAT_128.rsp"),
REG_SIGN!(SPHINCSSHAKE256256FSIMPLE,"round2/sphincs/sphincs-shake256-256f-simple/PQCsignKAT_128.rsp"),
]; ];
fn execute(kat_dir: String) { fn execute(kat_dir: String) {
// Can't do multi-threads as DRBG context is global // Can't do multi-threads as DRBG context is global
let pool = ThreadPool::new(1); let pool = ThreadPool::new(1);
for k in REG.iter() { for k in KATS.iter() {
let tmp = kat_dir.clone(); let tmp = kat_dir.clone();
pool.execute(move || { pool.execute(move || {
let f = Path::new(&tmp.to_string()).join(k.kat.kat_file); let f = Path::new(&tmp.to_string()).join(k.kat.kat_file);