aboutsummaryrefslogtreecommitdiffhomepage
path: root/sec_certs/sample/fips_algorithm.py
diff options
context:
space:
mode:
authorJán Jančár2022-07-12 01:46:27 +0200
committerGitHub2022-07-12 01:46:27 +0200
commitbf94b0ea4c245af115f011a9fedf1f9aac8ad706 (patch)
tree2f6cc2c8da52c2863f6eb30b91f0c5a7a20c9ead /sec_certs/sample/fips_algorithm.py
parent3d17e0f3bebab559db7bfda6fc1288cdca1aee34 (diff)
parent9a4407c19735e284eeb34a18ab7c4f4b46ee0bd1 (diff)
downloadsec-certs-bf94b0ea4c245af115f011a9fedf1f9aac8ad706.tar.gz
sec-certs-bf94b0ea4c245af115f011a9fedf1f9aac8ad706.tar.zst
sec-certs-bf94b0ea4c245af115f011a9fedf1f9aac8ad706.zip
Merge pull request #246 from crocs-muni/fix/fips-algos
Harmonize FIPS code
Diffstat (limited to 'sec_certs/sample/fips_algorithm.py')
-rw-r--r--sec_certs/sample/fips_algorithm.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/sec_certs/sample/fips_algorithm.py b/sec_certs/sample/fips_algorithm.py
new file mode 100644
index 00000000..fcfd42b6
--- /dev/null
+++ b/sec_certs/sample/fips_algorithm.py
@@ -0,0 +1,31 @@
+from dataclasses import dataclass
+
+from sec_certs import constants
+from sec_certs.serialization.json import ComplexSerializableType
+
+
+@dataclass(eq=True)
+class FIPSAlgorithm(ComplexSerializableType):
+ """
+ Data structure for algorithm of `FIPSCertificate`
+ """
+
+ cert_id: int
+ vendor: str
+ implementation: str
+ algorithm_type: str
+ date: str
+
+ @property
+ def dgst(self) -> str:
+ return f"{self.algorithm_type}#{self.cert_id}"
+
+ @property
+ def page_url(self) -> str:
+ return constants.FIPS_ALG_URL.format(self.algorithm_type, self.cert_id)
+
+ def __repr__(self) -> str:
+ return f"FIPSAlgorithm({self.dgst})"
+
+ def __str__(self) -> str:
+ return f"{self.algorithm_type} algorithm # {self.cert_id} created by {self.vendor}"