Skip to content

Commit

Permalink
Convert oqs-kem-info.md code points to hex (open-quantum-safe#188)
Browse files Browse the repository at this point in the history
* Convert Kyber768 code points to hex

* Fix generate.py duplicate hybrid NID warning

It appears that the erroneous warning message motivating this commit is
due to some vestigial code special-casing x-curves. The
`nid_ecx_hyybrid` kem field was only used to generate the duplicate ecx
nid warning message, so we track duplicates in a local `set` instead.
Additionally, we expand the warning message to all curve NIDs, not just
x-curves and treat duplicates as fatal because extra curve NIDs should
be unique for each KEM.

* Update contributors section of README

Signed-off-by: Felipe Ventura <felipe.ventura@entrust.com>
  • Loading branch information
WillChilds-Klein authored and feventura committed Mar 13, 2024
1 parent eecc084 commit 20d9a0b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ALGORITHMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ As standardization for these algorithms within TLS is not done, all TLS code poi
| kyber768 | 0x023C | Yes | OQS_CODEPOINT_KYBER768 |
| p384_kyber768 | 0x2F3C | Yes | OQS_CODEPOINT_P384_KYBER768 |
| x448_kyber768 | 0x2F90 | Yes | OQS_CODEPOINT_X448_KYBER768 |
| x25519_kyber768 | 25497 | Yes | OQS_CODEPOINT_X25519_KYBER768 |
| p256_kyber768 | 25498 | Yes | OQS_CODEPOINT_P256_KYBER768 |
| x25519_kyber768 | 0x6399 | Yes | OQS_CODEPOINT_X25519_KYBER768 |
| p256_kyber768 | 0x639A | Yes | OQS_CODEPOINT_P256_KYBER768 |
| kyber1024 | 0x023D | Yes | OQS_CODEPOINT_KYBER1024 |
| p521_kyber1024 | 0x2F3D | Yes | OQS_CODEPOINT_P521_KYBER1024 |
| bikel1 | 0x0241 | Yes | OQS_CODEPOINT_BIKEL1 |
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ Contributors to the `oqsprovider` include:
- Basil Hess
- Julian Segeth
- Alex Zaslavsky
- Will Childs-Klein

Acknowledgments
---------------
Expand Down
38 changes: 19 additions & 19 deletions oqs-template/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,25 +193,25 @@ def load_config(include_disabled_sigs=False):

for kem in config['kems']:
kem['hybrids'] = []
try:
for extra_nid_current in kem['extra_nids']['current']:
extra_hybrid = extra_nid_current
if extra_nid_current['hybrid_group'] == "x25519" or extra_nid_current['hybrid_group'] == "p256":
extra_hybrid['bit_security']=128
if extra_nid_current['hybrid_group'] == "x448" or extra_nid_current['hybrid_group'] == "p384":
extra_hybrid['bit_security']=192
if extra_nid_current['hybrid_group'] == "p521":
extra_hybrid['bit_security']=256
kem['hybrids'].append(extra_hybrid)
if 'hybrid_group' in extra_nid_current and extra_nid_current['hybrid_group'] in ["x25519", "x448"]:
extra_hyb_nid = extra_nid_current['nid']
if 'nid_ecx_hybrid' in kem:
print("Warning, duplicate nid_ecx_hybrid for",
kem['name_group'], ":", extra_hyb_nid, "in generate.yml,",
kem['nid_ecx_hybrid'], "in generate_extras.yml, using generate.yml entry.")
kem['nid_ecx_hybrid'] = extra_hyb_nid
except KeyError as ke:
pass
if 'extra_nids' not in kem or 'current' not in kem['extra_nids']:
continue
hybrid_nids = set()
for extra_hybrid in kem['extra_nids']['current']:
if extra_hybrid['hybrid_group'] == "x25519" or extra_hybrid['hybrid_group'] == "p256":
extra_hybrid['bit_security'] = 128
if extra_hybrid['hybrid_group'] == "x448" or extra_hybrid['hybrid_group'] == "p384":
extra_hybrid['bit_security'] = 192
if extra_hybrid['hybrid_group'] == "p521":
extra_hybrid['bit_security'] = 256
kem['hybrids'].append(extra_hybrid)
if 'hybrid_group' in extra_hybrid:
extra_hybrid_nid = extra_hybrid['nid']
if extra_hybrid_nid in hybrid_nids:
print("ERROR: duplicate hybrid NID for", kem['name_group'],
":", extra_hybrid_nid, "in generate.yml.",
"Curve NIDs may only be specified once per KEM.")
exit(1)
hybrid_nids.add(extra_hybrid_nid)
return config

# extend config with "hybrid_groups" array:
Expand Down
4 changes: 2 additions & 2 deletions oqs-template/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ kems:
- hybrid_group: "x448"
nid: '0x2F90'
- hybrid_group: "x25519"
nid: '25497'
nid: '0x6399'
- hybrid_group: "p256"
nid: '25498'
nid: '0x639A'
old:
- implementation_version: NIST Round 2 submission
nist-round: 2
Expand Down
4 changes: 2 additions & 2 deletions oqs-template/oqs-kem-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
| CRYSTALS-Kyber | NIST Round 3 submission | kyber768 | 3 | 3 | 0x023C | |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber768 | 3 | 3 | 0x2F3C | secp384_r1 |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber768 | 3 | 3 | 0x2F90 | x448 |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber768 | 3 | 3 | 25497 | x25519 |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber768 | 3 | 3 | 25498 | p256 |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber768 | 3 | 3 | 0x6399 | x25519 |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber768 | 3 | 3 | 0x639A | p256 |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber90s1024 | 3 | 5 | 0x0240 | |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber90s1024 | 3 | 5 | 0x2F40 | secp521_r1 |
| CRYSTALS-Kyber | NIST Round 3 submission | kyber90s512 | 3 | 1 | 0x023E | |
Expand Down
2 changes: 2 additions & 0 deletions oqs-template/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Jinja2==3.0.3
MarkupSafe==2.1.3
PyYAML==6.0
tabulate==0.9.0
4 changes: 2 additions & 2 deletions oqsprov/oqsprov_capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ static OQS_GROUP_CONSTANTS oqs_group_list[] = {

{ 0x2F3C, 192, TLS1_3_VERSION, 0, -1, -1, 1 },
{ 0x2F90, 192, TLS1_3_VERSION, 0, -1, -1, 1 },
{ 25497, 192, TLS1_3_VERSION, 0, -1, -1, 1 },
{ 25498, 192, TLS1_3_VERSION, 0, -1, -1, 1 },
{ 0x6399, 192, TLS1_3_VERSION, 0, -1, -1, 1 },
{ 0x639A, 192, TLS1_3_VERSION, 0, -1, -1, 1 },
{ 0x023D, 256, TLS1_3_VERSION, 0, -1, -1, 1 },

{ 0x2F3D, 256, TLS1_3_VERSION, 0, -1, -1, 1 },
Expand Down

0 comments on commit 20d9a0b

Please sign in to comment.