Skip to content

Commit

Permalink
Fixes bug in FIPS204 crate (interim)
Browse files Browse the repository at this point in the history
  • Loading branch information
codespree committed Nov 4, 2024
1 parent b3de0d6 commit 35967cf
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 9 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ der_derive = "0.7.3"
sha3 = "0.10.8"
hkdf = "0.12.4"
hex = "0.4.3"
fips204 = { package = "fips204", version = "0.4.4" }
#TODO: Switch to original repository once the bug is fixed
fips204 = { git="https://github.com/codespree/fips204" }
fips205 = { package = "fips205", version = "0.4.0" }
ed25519-dalek = { version="2.1.1", features=["rand_core"]}
ed448-rust = "0.1.1"
Expand Down
Binary file modified artifacts/r4_certs/certs-ietf-hackathon.zip
Binary file not shown.
34 changes: 28 additions & 6 deletions src/asn1/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ mod tests {
let ml_dsa_composites_prefix = "MLDSA";
let ml_dsa_pure_prefix = "ml-dsa";
let slh_dsa_prefix = "slh-dsa";
let dsa_prehash = "-with-";
for file in files {
let file = file.unwrap();
let path = file.path();
Expand All @@ -560,11 +559,6 @@ mod tests {
continue;
}

// TODO: Check for bug in BC ML-DSA Prehash or bug in our code
if path.contains(dsa_prehash) && !path.contains(slh_dsa_prefix) {
continue;
}

let cert = crate::certificates::Certificate::from_file(path).unwrap();

assert!(cert.verify_self_signed().unwrap());
Expand Down Expand Up @@ -596,4 +590,32 @@ mod tests {
let _ = pk.encap().unwrap();
}
}

#[test]
fn test_cw_cert_artifacts() {
let base_folder_path = "test/data/cw_artifacts_certs_r4/";
// Load all the certificates
let files = std::fs::read_dir(base_folder_path).unwrap();

for file in files {
let file = file.unwrap();
let path = file.path();
let path = path.to_str().unwrap();

let cert = crate::certificates::Certificate::from_file(path).unwrap();

let is_verified = cert.verify_self_signed();

if is_verified.is_err() {
println!("Failed to verify: {}", path);
} else if !is_verified.unwrap() {
println!("Failed to verify: {}", path);
} else {
println!("Verified: {}", path);
}

//assert!(cert.verify_self_signed().unwrap());
//println!("Verified: {}", path);
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 35967cf

Please sign in to comment.