Skip to content

Commit

Permalink
Fix to smoke test for older ROM version's KAT output
Browse files Browse the repository at this point in the history
  • Loading branch information
nquarton authored and jhand2 committed Jul 9, 2024
1 parent eb80750 commit 418f56f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ caliptra-runtime = { workspace = true, default-features = false }
elf.workspace = true
openssl.workspace = true
rand.workspace = true
regex.workspace = true
zerocopy.workspace = true
caliptra-hw-model.workspace = true
dpe.workspace = true
Expand Down
12 changes: 11 additions & 1 deletion test/tests/caliptra_integration_tests/smoke_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use openssl::nid::Nid;
use openssl::sha::{sha384, Sha384};
use rand::rngs::StdRng;
use rand::SeedableRng;
use regex::Regex;
use std::mem;
use zerocopy::AsBytes;

Expand All @@ -31,6 +32,15 @@ fn assert_output_contains(haystack: &str, needle: &str) {
);
}

#[track_caller]
fn assert_output_contains_regex(haystack: &str, needle: &str) {
let re = Regex::new(needle).unwrap();
assert! {
re.is_match(haystack),
"Expected substring in output not found: {needle}"
}
}

#[test]
fn retrieve_csr_test() {
const GENERATE_IDEVID_CSR: u32 = 1;
Expand Down Expand Up @@ -177,7 +187,7 @@ fn smoke_test() {
assert_output_contains(&output, "[kat] sha1");
assert_output_contains(&output, "[kat] SHA2-256");
assert_output_contains(&output, "[kat] SHA2-384");
assert_output_contains(&output, "[kat] SHA2-512-ACC");
assert_output_contains_regex(&output, r"\[kat\] SHA2-(384|512)-ACC");
assert_output_contains(&output, "[kat] HMAC-384");
assert_output_contains(&output, "[kat] LMS");
assert_output_contains(&output, "[kat] --");
Expand Down

0 comments on commit 418f56f

Please sign in to comment.