Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Support more NIDs in KEM table #313

Merged
merged 9 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 33 additions & 17 deletions oqs-template/generate-oid-nid-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
for fil in files:
with open(os.path.join(root, fil), mode='r', encoding='utf-8') as f:
alg_pretty_name = next(f).rstrip()
if alg_pretty_name.startswith("# "): alg_pretty_name = alg_pretty_name[1:].lstrip()
for line in f:
if line.startswith("- **Version**:"):
sig_to_impl_version[alg_pretty_name] = line.split(":")[1].rstrip()
Expand Down Expand Up @@ -70,14 +71,16 @@
for fil in files:
with open(os.path.join(root, fil), mode='r', encoding='utf-8') as f:
alg_pretty_name = next(f).rstrip()
if alg_pretty_name.startswith("# "): alg_pretty_name = alg_pretty_name[1:].lstrip()
for line in f:
if line.startswith("- **Version**:"):
kem_to_impl_version[alg_pretty_name] = line.split(":")[1].rstrip()
break
kem_to_impl_version['SIDH'] = kem_to_impl_version['SIKE']

table = [['Family', 'Implementation Version', 'Variant', 'Claimed NIST Level',
'PQ-only Code Point', 'Hybrid Elliptic Curve', 'Hybrid Code Point']]
table_header = ['Family', 'Implementation Version', 'Variant', 'Claimed NIST Level',
'Code Point', 'Hybrid Elliptic Curve (if any)']
table = []
hybrid_elliptic_curve = ''
for kem in sorted(config['kems'], key=lambda k: k['family']):
if kem['bit_security'] == 128:
Expand All @@ -92,22 +95,35 @@
else:
sys.exit("kem['bit_security'] value malformed.")

if kem['name_group'] == 'kyber512':
table.append([kem['family'], kem_to_impl_version[kem['family']],
kem['name_group'], claimed_nist_level, kem['nid'],
'x25519', '0x2F26'])
elif kem['name_group'] == 'sikep434':
table.append([kem['family'], kem_to_impl_version[kem['family']],
kem['name_group'], claimed_nist_level, kem['nid'],
'x25519', '0x2F27'])
elif kem['name_group'] == 'bike1l1fo':
table.append([kem['family'], kem_to_impl_version[kem['family']],
kem['name_group'], claimed_nist_level, kem['nid'],
'x25519', '0x2F28'])

table.append([kem['family'], kem_to_impl_version[kem['family']],
kem['name_group'], claimed_nist_level, kem['nid'],
hybrid_elliptic_curve, kem['nid_hybrid']])
kem['name_group'], claimed_nist_level,
kem['nid'], ""])
table.append([kem['family'], kem_to_impl_version[kem['family']],
kem['name_group'], claimed_nist_level,
kem['nid_hybrid'], hybrid_elliptic_curve])

if 'extra_nids' in kem:
if 'current' in kem['extra_nids']:
for entry in kem['extra_nids']['current']:
table.append([kem['family'], kem_to_impl_version[kem['family']],
kem['name_group'], claimed_nist_level,
kem['nid'], ""])
if 'previous' in kem['extra_nids']:
for entry in kem['extra_nids']['previous']:
if 'hybrid_group' in entry:
table.append([kem['family'], entry['implementation_version'],
kem['name_group'], claimed_nist_level,
entry['nid'], entry['hybrid_group']])
else:
table.append([kem['family'], entry['implementation_version'],
kem['name_group'], claimed_nist_level,
entry['nid'], ""])

# sort by: family, version, security level, variant, hybrid
table.sort(key = lambda row: "{:s}|{:s}|{:d}|{:s}|{:s}".format(row[0], row[1], row[3], row[2], row[5]))

table = [table_header] + table

with open('oqs-kem-info.md', mode='w', encoding='utf-8') as f:
f.write(tabulate(table, tablefmt="pipe", headers="firstrow"))
f.write("\n")
18 changes: 18 additions & 0 deletions oqs-template/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ kems:
nid_hybrid: '0x2F0F'
oqs_alg: 'OQS_KEM_alg_kyber_512'
bit_security: 128
extra_nids:
current:
- hybrid_group: "x25519"
nid: '0x2F26'
previous:
- implementation_version: NIST Round 2 submission
nid: '0x020F'
- implementation_version: NIST Round 2 submission
hybrid_group: secp256_r1
nid: '0x2F0F'
-
family: 'CRYSTALS-Kyber'
name_group: 'kyber768'
Expand Down Expand Up @@ -162,6 +172,10 @@ kems:
nid_hybrid: '0x2F1F'
oqs_alg: 'OQS_KEM_alg_sike_p434'
bit_security: 128
extra_nids:
current:
- hybrid_group: "x25519"
nid: '0x2F27'
-
family: 'SIKE'
name_group: 'sikep503'
Expand Down Expand Up @@ -190,6 +204,10 @@ kems:
nid_hybrid: '0x2F23'
oqs_alg: 'OQS_KEM_alg_bike1_l1_fo'
bit_security: 128
extra_nids:
current:
- hybrid_group: "x25519"
nid: '0x2F28'
-
family: 'BIKE'
name_group: 'bike1l3fo'
Expand Down
Loading