aboutsummaryrefslogtreecommitdiffhomepage
path: root/sec_certs/sample/fips_algorithm.py
diff options
context:
space:
mode:
authorJ08nY2022-07-11 16:23:35 +0200
committerJ08nY2022-07-11 16:23:35 +0200
commitbea6c7b9387ecebc474c7d7f82acc35f9b071311 (patch)
treebcdac30a3ae411ca785895e8532bbc3723d2013e /sec_certs/sample/fips_algorithm.py
parentd6e6230c4e8a3a5e7b702908e217e0fe66c41e59 (diff)
downloadsec-certs-bea6c7b9387ecebc474c7d7f82acc35f9b071311.tar.gz
sec-certs-bea6c7b9387ecebc474c7d7f82acc35f9b071311.tar.zst
sec-certs-bea6c7b9387ecebc474c7d7f82acc35f9b071311.zip
FIPS: Move Algorithm class into a separate file.
Diffstat (limited to 'sec_certs/sample/fips_algorithm.py')
-rw-r--r--sec_certs/sample/fips_algorithm.py29
1 files changed, 29 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..1085f076
--- /dev/null
+++ b/sec_certs/sample/fips_algorithm.py
@@ -0,0 +1,29 @@
+from dataclasses import dataclass
+
+from sec_certs.serialization.json import ComplexSerializableType
+
+
+@dataclass(eq=True)
+class FIPSAlgorithm(ComplexSerializableType):
+ """
+ Data structure for algorithm of `FIPSCertificate`
+ """
+
+ cert_id: str
+ vendor: str
+ implementation: str
+ algorithm_type: str
+ date: str
+
+ @property
+ def dgst(self) -> str:
+ # certs in dataset are in format { id: [FIPSAlgorithm] }, there is only one type of algorithm
+ # for each id
+ # TODO: This is probably not a good digest.
+ return self.algorithm_type
+
+ def __repr__(self) -> str:
+ return self.algorithm_type + " algorithm #" + self.cert_id + " created by " + self.vendor
+
+ def __str__(self) -> str:
+ return str(self.algorithm_type + " algorithm #" + self.cert_id + " created by " + self.vendor)