mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-04 00:02:01 -04:00
use doc YMLs to count non-copy-from-upstream algs [skip ci] (#1063)
* use doc YMLs to count non-upstream provided algs [skip ci]
This commit is contained in:
parent
0f6d6a93b6
commit
35155ce481
@ -17,6 +17,8 @@ import json
|
|||||||
# kats of all algs
|
# kats of all algs
|
||||||
kats = {}
|
kats = {}
|
||||||
|
|
||||||
|
non_upstream_lengths = {}
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-v", "--verbosity", type=int)
|
parser.add_argument("-v", "--verbosity", type=int)
|
||||||
parser.add_argument("-k", "--keep_data", action='store_true')
|
parser.add_argument("-k", "--keep_data", action='store_true')
|
||||||
@ -34,6 +36,19 @@ if 'LIBOQS_DIR' not in os.environ:
|
|||||||
print("Must set environment variable LIBOQS_DIR")
|
print("Must set environment variable LIBOQS_DIR")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
# pass this function the list of non-upstream algs to count
|
||||||
|
# kemsig either 'kem' or 'sig'
|
||||||
|
# scours the documentation for non-upstream algorithms
|
||||||
|
# returns the number of documented algorithms
|
||||||
|
def count_non_upstream_algs(kemsig, alglist):
|
||||||
|
counted=0
|
||||||
|
docs_dir = os.path.join(os.environ['LIBOQS_DIR'], 'docs', 'algorithms', kemsig)
|
||||||
|
for alg in alglist:
|
||||||
|
with open(os.path.join(docs_dir, alg+".yml"), mode='r', encoding='utf-8') as f:
|
||||||
|
algyml = yaml.safe_load(f.read())
|
||||||
|
counted = counted + len(algyml['parameter-sets'])
|
||||||
|
return counted
|
||||||
|
|
||||||
|
|
||||||
def file_get_contents(filename, encoding=None):
|
def file_get_contents(filename, encoding=None):
|
||||||
with open(filename, mode='r', encoding=encoding) as fh:
|
with open(filename, mode='r', encoding=encoding) as fh:
|
||||||
@ -79,7 +94,7 @@ def replacer(filename, instructions, delimiter):
|
|||||||
preamble = contents[:contents.find(identifier_start)]
|
preamble = contents[:contents.find(identifier_start)]
|
||||||
postamble = contents[contents.find(identifier_end):]
|
postamble = contents[contents.find(identifier_end):]
|
||||||
contents = preamble + identifier_start + jinja2.Template(template).render(
|
contents = preamble + identifier_start + jinja2.Template(template).render(
|
||||||
{'instructions': instructions}) + postamble
|
{'instructions': instructions, 'non_upstream_lengths': non_upstream_lengths}) + postamble
|
||||||
file_put_contents(os.path.join(os.environ['LIBOQS_DIR'], filename), contents)
|
file_put_contents(os.path.join(os.environ['LIBOQS_DIR'], filename), contents)
|
||||||
|
|
||||||
def load_instructions():
|
def load_instructions():
|
||||||
@ -497,7 +512,7 @@ def copy_from_upstream():
|
|||||||
if not keepdata:
|
if not keepdata:
|
||||||
shutil.rmtree('repos')
|
shutil.rmtree('repos')
|
||||||
|
|
||||||
#print("Remember to update the docs by running scripts/copy_from_upstream/update_pqclean_alg_docs.py -> scripts/format_docs_yaml.py -> scripts/update_docs_from_yaml.py")
|
print("Remember to update the docs by running update_pqclean_alg_docs.py")
|
||||||
|
|
||||||
|
|
||||||
def verify_from_upstream():
|
def verify_from_upstream():
|
||||||
@ -564,6 +579,8 @@ def verify_from_upstream():
|
|||||||
if (differ > 0):
|
if (differ > 0):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
non_upstream_lengths['kem'] = count_non_upstream_algs('kem', ['bike', 'frodokem', 'sike'])
|
||||||
|
non_upstream_lengths['sig'] = count_non_upstream_algs('sig', ['picnic'])
|
||||||
|
|
||||||
if args.operation == "copy":
|
if args.operation == "copy":
|
||||||
copy_from_upstream()
|
copy_from_upstream()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% set unary %}{% for family in instructions['kems'] %}{% for scheme in family['schemes'] %}1{% endfor %}{% endfor %}{% endset %}
|
{% set unary %}{% for family in instructions['kems'] %}{% for scheme in family['schemes'] %}1{% endfor %}{% endfor %}{% endset %}
|
||||||
/** Number of algorithm identifiers above. */
|
/** Number of algorithm identifiers above. */
|
||||||
#define OQS_KEM_algs_length {{ unary|length + 24 }}
|
#define OQS_KEM_algs_length {{ unary|length + non_upstream_lengths['kem'] }}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% set unary %}{% for family in instructions['sigs'] %}{% for scheme in family['schemes'] %}1{% endfor %}{% endfor %}{% endset %}
|
{% set unary %}{% for family in instructions['sigs'] %}{% for scheme in family['schemes'] %}1{% endfor %}{% endfor %}{% endset %}
|
||||||
/** Number of algorithm identifiers above. */
|
/** Number of algorithm identifiers above. */
|
||||||
#define OQS_SIG_algs_length {{ unary|length + 12 }}
|
#define OQS_SIG_algs_length {{ unary|length + non_upstream_lengths['sig'] }}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user