Skip to content

Commit

Permalink
Porting changes from ounsworth/pqc-cert-checker
Browse files Browse the repository at this point in the history
  • Loading branch information
ounsworth committed Jul 21, 2024
1 parent 4614044 commit 2bad921
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
11 changes: 11 additions & 0 deletions docs/gh-pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>PQC Artifact Test Results</title>
</head>
<body>
<p><a href="/pqc_hackathon_results_certs_r3.html">pqc_hackathon_results_certs_r3.html</a></p>
<p><a href="/pqc_hackathon_results_certs_r3.html">pqc_hackathon_results_certs_r3_automated_tests.html</a></p>
<p><a href="/pqc_hackathon_results_cms_v1.html">pqc_hackathon_results_cms_v1.html</a></p>
</body>
</html>
3 changes: 0 additions & 3 deletions src/pqc_report_writer_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,8 @@ def _get_alg_name_by_oid_str(oid_to_name_mappings, oid_str):
# <hybrid_format>_<oid1>_with_<oid2>
m = _HYBRID_FORMAT_NAME_REGEX.match(oid_str)

print(oid_str)

if m is not None:
# Display only the hybrid format, not the OIDs.
print('Matched hybrid format regex: '+m['hybrid_format'])
return m['hybrid_format']

# else it is a simple OID.
Expand Down
53 changes: 53 additions & 0 deletions src/test_certs_r3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh

certszipr3="artifacts_certs_r3.zip"
cmszipr1="artifacts_cms_v1.zip"
inputdir="./providers"
outputdir="./output/certs"

# Requires an input: the TA file to test
test_ta () {
tafile=$1
resultsfile=$2

printf "\nTesting %s\n" $tafile

# openssl always exits with 0, so we can't use exit status to tell if the cert was valid :/
ossl_output=$(openssl x509 -in $tafile -text -noout 2>&1)

# print it out for the logs
echo "$ossl_output"

tafileBasename=$(basename $tafile)
oid=${tafileBasename%_ta.pem} # remove the suffix "_ta.pem"

# test for an error
if (echo $ossl_output | grep "error\|Unable\|Error" >/dev/null); then
echo "Certificate Validation Result: FAIL"
echo $oid,N >> $resultsfile
else
echo "Certificate Validation Result: SUCCESS"
echo $oid,Y >> $resultsfile
fi
}

# First, recurse into any provider dir
for providerdir in $(ls -d $inputdir/*/); do
provider=$(basename $providerdir)

# process certs
zip=$providerdir/$certszipr3
printf "Unziping %s\n" $zip
unzip -o $zip -d "artifacts_certs_r3"

# Start the results CSV file
mkdir -p $outputdir
resultsfile=$outputdir/${provider}_oqsprovider.csv
echo "key_algorithm_oid,test_result" > $resultsfile

# test each TA file
for tafile in $(ls artifacts_certs_r3/*_ta.pem); do
test_ta "$tafile" "$resultsfile"
done
done

0 comments on commit 2bad921

Please sign in to comment.