Skip to content

Commit

Permalink
Use the new KATs for non-eph Frodo from ref repo
Browse files Browse the repository at this point in the history
  • Loading branch information
atreiber94 authored and reneme committed Sep 28, 2023
1 parent 54fbf9e commit fe72599
Show file tree
Hide file tree
Showing 2 changed files with 471 additions and 465 deletions.
29 changes: 20 additions & 9 deletions src/scripts/dev_tools/gen_frodo_kat.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,34 @@ def compress_kat(kat):

return kat

def map_mode(mode):
def map_mode(mode, is_ephemeral = False):
out = None
if mode == "PQCkemKAT_19888":
return "eFrodoKEM-640-AES"
out = "eFrodoKEM-640-AES"
if mode == "PQCkemKAT_19888_shake":
return "eFrodoKEM-640-SHAKE"
out = "eFrodoKEM-640-SHAKE"
if mode == "PQCkemKAT_31296":
return "eFrodoKEM-976-AES"
out = "eFrodoKEM-976-AES"
if mode == "PQCkemKAT_31296_shake":
return "eFrodoKEM-976-SHAKE"
out = "eFrodoKEM-976-SHAKE"
if mode == "PQCkemKAT_43088":
return "eFrodoKEM-1344-AES"
out = "eFrodoKEM-1344-AES"
if mode == "PQCkemKAT_43088_shake":
return "eFrodoKEM-1344-SHAKE"
out = "eFrodoKEM-1344-SHAKE"

raise Exception('Unknown FrodoKEM mode', mode)
if out is None:
raise Exception('Unknown FrodoKEM mode', mode)

if is_ephemeral:
return out
else:
return out[1:] # remove 'e' to obtain 'FrodoKEM'

def main(args = None):
"""Set True for eFrodo, otherwise the non-ephemeral variant is assumed.
Necessary because the files have the same name for either variant."""
is_ephemeral = False

if args is None:
args = sys.argv

Expand All @@ -101,7 +112,7 @@ def main(args = None):
print("# See src/scripts/dev_tools/gen_frodo_kat.py\n", file=output)

for file in args[1:]:
mode = map_mode(os.path.basename(os.path.splitext(file)[0]))
mode = map_mode(os.path.basename(os.path.splitext(file)[0]))

reader = KatReader(open(file))

Expand Down
Loading

0 comments on commit fe72599

Please sign in to comment.