aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2022-07-11 16:23:35 +0200
committerJ08nY2022-07-11 16:23:35 +0200
commitbea6c7b9387ecebc474c7d7f82acc35f9b071311 (patch)
treebcdac30a3ae411ca785895e8532bbc3723d2013e
parentd6e6230c4e8a3a5e7b702908e217e0fe66c41e59 (diff)
downloadsec-certs-bea6c7b9387ecebc474c7d7f82acc35f9b071311.tar.gz
sec-certs-bea6c7b9387ecebc474c7d7f82acc35f9b071311.tar.zst
sec-certs-bea6c7b9387ecebc474c7d7f82acc35f9b071311.zip
FIPS: Move Algorithm class into a separate file.
-rw-r--r--sec_certs/dataset/fips_algorithm.py3
-rw-r--r--sec_certs/sample/fips.py25
-rw-r--r--sec_certs/sample/fips_algorithm.py29
3 files changed, 31 insertions, 26 deletions
diff --git a/sec_certs/dataset/fips_algorithm.py b/sec_certs/dataset/fips_algorithm.py
index f0ddca6c..a029a768 100644
--- a/sec_certs/dataset/fips_algorithm.py
+++ b/sec_certs/dataset/fips_algorithm.py
@@ -10,6 +10,7 @@ from sec_certs import constants as constants
from sec_certs.config.configuration import config
from sec_certs.dataset.dataset import Dataset
from sec_certs.sample.fips import FIPSCertificate
+from sec_certs.sample.fips_algorithm import FIPSAlgorithm
from sec_certs.serialization.json import ComplexSerializableType, CustomJSONDecoder, CustomJSONEncoder
from sec_certs.utils import helpers as helpers
from sec_certs.utils import parallel_processing as cert_processing
@@ -88,7 +89,7 @@ class FIPSAlgorithmDataset(Dataset, ComplexSerializableType):
)
alg_type, alg_id = split_alg(validation)
- fips_alg = FIPSCertificate.Algorithm(alg_id, vendor, product, alg_type, date)
+ fips_alg = FIPSAlgorithm(alg_id, vendor, product, alg_type, date)
if alg_id not in self.certs:
self.certs[alg_id] = []
self.certs[alg_id].append(fips_alg)
diff --git a/sec_certs/sample/fips.py b/sec_certs/sample/fips.py
index b64a9fc1..d8fc3d10 100644
--- a/sec_certs/sample/fips.py
+++ b/sec_certs/sample/fips.py
@@ -71,31 +71,6 @@ class FIPSCertificate(Certificate["FIPSCertificate", "FIPSCertificate.FIPSHeuris
self.state.html_path = (Path(html_dir) / (str(self.cert_id))).with_suffix(".html")
@dataclass(eq=True)
- class Algorithm(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)
-
- @dataclass(eq=True)
class WebData(ComplexSerializableType):
"""
Data structure for data obtained from scanning certificate webpage at NIST.gov
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)