can pass slh_dsa schemes to copy_from_upstream

Signed-off-by: Ganyu (Bruce) Xu <g66xu@uwaterloo.ca>
This commit is contained in:
Ganyu (Bruce) Xu 2025-09-30 13:05:47 -04:00
parent e64026e27a
commit 50f3771fd0
2 changed files with 35 additions and 3 deletions

View File

@ -337,5 +337,18 @@ def main():
# apply patches # apply patches
apply_patches(slh_patch_dir) apply_patches(slh_patch_dir)
# NOTE: from [issue 2203](https://github.com/open-quantum-safe/liboqs/issues/2203)
# SLH-DSA is not described in copy_from_upstream.yml. It is instead described
# here in this separate module. This makes replacing SPHINCS+ with SLH-DSA
# in list_standardized_algs.fragment non-trivial because this Jinja template
# is rendered from copy_from_upstream.yml.
# As a necessary hack, the list of variants (e.g. "pure_sha2_128s") is returned
# so that copy_from_upstream.py can use this list to construct a dictionary
# that resembles the structure of copy_from_upstream.yml.
# In the near future I want to consider refactoring build configuration
# management and upstream integration scripts. The status quo is a mess and
# will make future integrations all the more difficult.
return variants
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -16,6 +16,7 @@ import json
import platform import platform
import update_upstream_alg_docs import update_upstream_alg_docs
import copy_from_slh_dsa_c import copy_from_slh_dsa_c
from copy import deepcopy
# kats of all algs # kats of all algs
kats = {} kats = {}
@ -701,12 +702,20 @@ def process_families(instructions, basedir, with_kat, with_generator, with_libja
) )
def copy_from_upstream(): def copy_from_upstream(slh_dsa_inst: dict):
"""Integrate upstreams implementations and algorithms described in
copy_from_upstream.yml.
:param slh_dsa_inst: instruction for integrating SLH-DSA, only used for
rendering alg_support.cmake
"""
for t in ["kem", "sig"]: for t in ["kem", "sig"]:
with open(os.path.join(os.environ['LIBOQS_DIR'], 'tests', 'KATs', t, 'kats.json'), 'r') as fp: with open(os.path.join(os.environ['LIBOQS_DIR'], 'tests', 'KATs', t, 'kats.json'), 'r') as fp:
kats[t] = json.load(fp) kats[t] = json.load(fp)
instructions = load_instructions('copy_from_upstream.yml') instructions = load_instructions('copy_from_upstream.yml')
patched_inst: dict = deepcopy(instructions)
patched_inst["sigs"].append(slh_dsa_instruction["sigs"][0])
process_families(instructions, os.environ['LIBOQS_DIR'], True, True) process_families(instructions, os.environ['LIBOQS_DIR'], True, True)
replacer('.CMake/alg_support.cmake', instructions, '#####') replacer('.CMake/alg_support.cmake', instructions, '#####')
replacer('CMakeLists.txt', instructions, '#####') replacer('CMakeLists.txt', instructions, '#####')
@ -839,9 +848,19 @@ non_upstream_kems = count_non_upstream_kems(['bike', 'frodokem', 'ntruprime', 'n
if args.operation == "copy": if args.operation == "copy":
# copy_from_slh_dsa_c will modify slh_dsa.yml before copy_from_upstream modifies md files # copy_from_slh_dsa_c will modify slh_dsa.yml before copy_from_upstream modifies md files
copy_from_slh_dsa_c.main() slh_dsa_schemes: list[str] = copy_from_slh_dsa_c.main()
slh_dsa_instruction = {
"sigs": [
{
"name": "slh_dsa",
"schemes": {
"scheme": scheme for scheme in slh_dsa_schemes
}
}
]
}
os.chdir(os.path.join(os.environ['LIBOQS_DIR'],"scripts","copy_from_upstream")) os.chdir(os.path.join(os.environ['LIBOQS_DIR'],"scripts","copy_from_upstream"))
copy_from_upstream() copy_from_upstream(slh_dsa_instruction)
elif args.operation == "libjade": elif args.operation == "libjade":
copy_from_libjade() copy_from_libjade()
elif args.operation == "verify": elif args.operation == "verify":