Skip to content

Commit

Permalink
Python 3.7: Switch from yml to json to not rely on pyyaml
Browse files Browse the repository at this point in the history
The recent pyyaml 6.0.2 dropped support for anything
before Python 3.8. As we want to support Python 3.7,
we cannot use the most recent version of pyyaml.
Using an old version (6.0.1) would be a workaround.

This commit eliminates the dependency on pyyaml.
We only use yaml in a single place to parse META.yml
which contains meta-information (we mostly care
about various testvector hashes that we compare to).
This commit switches that to a json representation
as json parsing is well supported natively in all
Python versions we care about (and we use json
parsing in the ACVP tests anyway).

Signed-off-by: Matthias J. Kannwischer <[email protected]>
  • Loading branch information
mkannwischer committed Dec 21, 2024
1 parent 0f00d5e commit 07f7dc9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 39 deletions.
43 changes: 43 additions & 0 deletions META.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "ML-KEM",
"type": "kem",
"implementations":
[
{
"name": "ML-KEM-512",
"claimed-nist-level": "1",
"claimed-security": "IND-CCA2",
"length-public-key": "800",
"length-ciphertext": "768",
"length-secret-key": "1632",
"length-shared-secret": "32",
"kat-sha256": "cc398096eee868ea6164b5f51e9a751da65d8ed44e636b09573ed57bc50ac4ed",
"nistkat-sha256": "a30184edee53b3b009356e1e31d7f9e93ce82550e3c622d7192e387b0cc84f2e",
"nistkat-shake256-256": "8517b4bed03f8f97f464ccbebbb395e887530d3426f171d77dd3b3a0e5add7ce"
},
{
"name": "ML-KEM-768",
"claimed-nist-level": "3",
"claimed-security": "IND-CCA2",
"length-public-key": "1184",
"length-ciphertext": "1088",
"length-secret-key": "2400",
"length-shared-secret": "32",
"kat-sha256": "b328a57e85808d78766d994f17c9d85a2e554b80a6a16fb8c099534353350551",
"nistkat-sha256": "729367b590637f4a93c68d5e4a4d2e2b4454842a52c9eec503e3a0d24cb66471",
"nistkat-shake256-256": "1383531be7867e0eab6c914472abfaed2f3846e518e401195880f8d25239c93e"
},
{
"name": "ML-KEM-1024",
"claimed-nist-level": "5",
"claimed-security": "IND-CCA2",
"length-public-key": "1568",
"length-ciphertext": "1568",
"length-secret-key": "3168",
"length-shared-secret": "32",
"kat-sha256": "8854d2ee93e01d07dd91807fb033194f08decde49fffc5a56e38fc41f984330f",
"nistkat-sha256": "3fba7327d0320cb6134badf2a1bcb963a5b3c0026c7dece8f00d6a6155e47b33",
"nistkat-shake256-256": "2c567fe56c8a1f60b7757d7c5367ec57d9b41e7cae3f157fd24616f3ce952f17"
}
]
}
35 changes: 0 additions & 35 deletions META.yml

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# SPDX-License-Identifier: Apache-2.0
click==8.1.7
pyyaml==6.0.2
6 changes: 3 additions & 3 deletions scripts/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
from enum import IntEnum
from functools import reduce
import yaml
import json

CWD = os.getcwd()
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
Expand Down Expand Up @@ -107,8 +107,8 @@ def bin_path(self, scheme):


def parse_meta(scheme, field):
with open("META.yml", "r") as f:
meta = yaml.safe_load(f)
with open("META.json", "r") as f:
meta = json.load(f)
return meta["implementations"][int(scheme) - 1][field]


Expand Down

0 comments on commit 07f7dc9

Please sign in to comment.