aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2022-05-30 12:39:51 +0200
committerJ08nY2022-05-30 12:39:51 +0200
commitff6deb939f5235e4a3610cd43c711b2d5485df53 (patch)
treeafc93f277e3abfddbc36de7595dfb48ba2c3cba5
parentde9e12c2b319aae9c72a396abff449fe6d52001d (diff)
downloadsec-certs-ff6deb939f5235e4a3610cd43c711b2d5485df53.tar.gz
sec-certs-ff6deb939f5235e4a3610cd43c711b2d5485df53.tar.zst
sec-certs-ff6deb939f5235e4a3610cd43c711b2d5485df53.zip
Add document hashes.
Fixes #220.
-rw-r--r--sec_certs/sample/common_criteria.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/sec_certs/sample/common_criteria.py b/sec_certs/sample/common_criteria.py
index a9721672..9f8825e9 100644
--- a/sec_certs/sample/common_criteria.py
+++ b/sec_certs/sample/common_criteria.py
@@ -98,8 +98,12 @@ class CommonCriteriaCert(
st_pdf_path: Path
report_pdf_path: Path
+ st_pdf_hash: Optional[str]
+ report_pdf_hash: Optional[str]
st_txt_path: Path
report_txt_path: Path
+ st_txt_hash: Optional[str]
+ report_txt_hash: Optional[str]
def __init__(
self,
@@ -124,8 +128,12 @@ class CommonCriteriaCert(
return [
"st_download_ok",
"report_download_ok",
+ "st_pdf_hash",
+ "report_pdf_hash",
"st_convert_ok",
"report_convert_ok",
+ "st_txt_hash",
+ "report_txt_hash",
"st_extract_ok",
"report_extract_ok",
"errors",
@@ -673,6 +681,8 @@ class CommonCriteriaCert(
logger.error(f"Cert dgst: {cert.dgst} " + error_msg)
cert.state.report_download_ok = False
cert.state.errors.append(error_msg)
+ else:
+ cert.state.report_pdf_hash = helpers.get_sha256_filepath(cert.state.report_pdf_path)
return cert
@staticmethod
@@ -693,6 +703,8 @@ class CommonCriteriaCert(
logger.error(f"Cert dgst: {cert.dgst}" + error_msg)
cert.state.st_download_ok = False
cert.state.errors.append(error_msg)
+ else:
+ cert.state.st_pdf_hash = helpers.get_sha256_filepath(cert.state.st_pdf_path)
return cert
@staticmethod
@@ -709,6 +721,8 @@ class CommonCriteriaCert(
logger.error(f"Cert dgst: {cert.dgst}" + error_msg)
cert.state.report_convert_ok = False
cert.state.errors.append(error_msg)
+ else:
+ cert.state.report_txt_hash = helpers.get_sha256_filepath(cert.state.report_txt_path)
return cert
@staticmethod
@@ -725,6 +739,8 @@ class CommonCriteriaCert(
logger.error(f"Cert dgst: {cert.dgst}" + error_msg)
cert.state.st_convert_ok = False
cert.state.errors.append(error_msg)
+ else:
+ cert.state.st_txt_hash = helpers.get_sha256_filepath(cert.state.st_txt_path)
return cert
@staticmethod