aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJ08nY2023-02-09 22:20:34 +0100
committerJ08nY2023-02-09 22:20:34 +0100
commit9eba76583fa99e38ec906fee918bcfc6772267bb (patch)
tree2454a803a8576eccc54a56d90b724d71f67a4330 /src
parent449750455bf1638489c83959da3632e8b666269e (diff)
downloadsec-certs-9eba76583fa99e38ec906fee918bcfc6772267bb.tar.gz
sec-certs-9eba76583fa99e38ec906fee918bcfc6772267bb.tar.zst
sec-certs-9eba76583fa99e38ec906fee918bcfc6772267bb.zip
Fix FIPS parsing of algorithms from site.
Some newer certs have different format of algo listing: https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/4392
Diffstat (limited to 'src')
-rw-r--r--src/sec_certs/sample/fips.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/sec_certs/sample/fips.py b/src/sec_certs/sample/fips.py
index 09f29fae..f93bf33b 100644
--- a/src/sec_certs/sample/fips.py
+++ b/src/sec_certs/sample/fips.py
@@ -125,11 +125,22 @@ class FIPSHTMLParser:
@staticmethod
def parse_algorithms(algorithms_div: Tag) -> dict[str, set[str]]:
- rows = algorithms_div.find("tbody").find_all("tr")
dct: dict[str, set[str]] = {}
- for row in rows:
- cells = row.find_all("td")
- dct[cells[0].text] = {m.group() for m in re.finditer(FIPS_ALGS_IN_TABLE, cells[1].text)}
+ table = algorithms_div.find("tbody")
+ # Two types of organization on the CMVP website:
+ # - One is a table with algo references in text
+ # - Other is just divs for rows, one per algo
+ if table:
+ rows = table.find_all("tr")
+ for row in rows:
+ cells = row.find_all("td")
+ dct[str(cells[0].text)] = {m.group() for m in re.finditer(FIPS_ALGS_IN_TABLE, cells[1].text)}
+ else:
+ rows = algorithms_div.find_all("div", class_="col-md-12")
+ for row in rows:
+ dct[str(row.find("div", class_="col-md-3").text)] = {
+ str(row.find("div", class_="col-md-4").text).strip()
+ }
return dct
@staticmethod