Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update oqs_template #107

Merged
merged 2 commits into from
Dec 4, 2023
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
34 changes: 17 additions & 17 deletions oqs_template/generate.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,87 @@ kems:
family: 'FrodoKEM'
name: 'frodo640aes'
nid: '0x0200'
mix_with: [{'name': 'p256', 'mix_nid':'0x2F00', 'nid':'SSL_CURVE_SECP256R1'}]
mix_with: [{'name': 'p256', 'mix_nid':'0x2F00', 'nid':'SSL_GROUP_SECP256R1'}]
use_as_default_with: 'p256'
oqs_meth: 'OQS_KEM_alg_frodokem_640_aes'
-
family: 'FrodoKEM'
name: 'frodo640shake'
nid: '0x0201'
mix_with: [{'name': 'p256', 'mix_nid':'0x2F01', 'nid':'SSL_CURVE_SECP256R1'}]
mix_with: [{'name': 'p256', 'mix_nid':'0x2F01', 'nid':'SSL_GROUP_SECP256R1'}]
oqs_meth: 'OQS_KEM_alg_frodokem_640_shake'
-
family: 'FrodoKEM'
name: 'frodo976aes'
nid: '0x0202'
mix_with: [{'name': 'p384', 'mix_nid':'0x2F02', 'nid':'SSL_CURVE_SECP384R1'}]
mix_with: [{'name': 'p384', 'mix_nid':'0x2F02', 'nid':'SSL_GROUP_SECP384R1'}]
oqs_meth: 'OQS_KEM_alg_frodokem_976_aes'
-
family: 'FrodoKEM'
name: 'frodo976shake'
nid: '0x0203'
mix_with: [{'name': 'p384', 'mix_nid':'0x2F03', 'nid':'SSL_CURVE_SECP384R1'}]
mix_with: [{'name': 'p384', 'mix_nid':'0x2F03', 'nid':'SSL_GROUP_SECP384R1'}]
oqs_meth: 'OQS_KEM_alg_frodokem_976_shake'
-
family: 'FrodoKEM'
name: 'frodo1344aes'
nid: '0x0204'
mix_with: [{'name': 'p521', 'mix_nid':'0x2F04', 'nid':'SSL_CURVE_SECP521R1'}]
mix_with: [{'name': 'p521', 'mix_nid':'0x2F04', 'nid':'SSL_GROUP_SECP521R1'}]
oqs_meth: 'OQS_KEM_alg_frodokem_1344_aes'
-
family: 'FrodoKEM'
name: 'frodo1344shake'
nid: '0x0205'
mix_with: [{'name': 'p521', 'mix_nid':'0x2F05', 'nid':'SSL_CURVE_SECP521R1'}]
mix_with: [{'name': 'p521', 'mix_nid':'0x2F05', 'nid':'SSL_GROUP_SECP521R1'}]
oqs_meth: 'OQS_KEM_alg_frodokem_1344_shake'
-
family: 'BIKE'
name: 'bikel1'
nid: '0x0241'
mix_with: [{'name': 'p256', 'mix_nid':'0x2F41', 'nid':'SSL_CURVE_SECP256R1'}]
mix_with: [{'name': 'p256', 'mix_nid':'0x2F41', 'nid':'SSL_GROUP_SECP256R1'}]
use_as_default_with: 'p256'
oqs_meth: 'OQS_KEM_alg_bike_l1'
-
family: 'BIKE'
name: 'bikel3'
nid: '0x0242'
mix_with: [{'name': 'p384', 'mix_nid':'0x2F42', 'nid':'SSL_CURVE_SECP384R1'}]
mix_with: [{'name': 'p384', 'mix_nid':'0x2F42', 'nid':'SSL_GROUP_SECP384R1'}]
oqs_meth: 'OQS_KEM_alg_bike_l3'
-
family: 'CRYSTALS-Kyber'
name: 'kyber512'
nid: '0x023A'
mix_with: [{'name': 'p256', 'mix_nid':'0x2F3A', 'nid':'SSL_CURVE_SECP256R1'}]
mix_with: [{'name': 'p256', 'mix_nid':'0x2F3A', 'nid':'SSL_GROUP_SECP256R1'}]
oqs_meth: 'OQS_KEM_alg_kyber_512'
-
family: 'CRYSTALS-Kyber'
name: 'kyber768'
nid: '0x023C'
mix_with: [{'name': 'p384', 'mix_nid':'0x2F3C', 'nid':'SSL_CURVE_SECP384R1'}]
mix_with: [{'name': 'p384', 'mix_nid':'0x2F3C', 'nid':'SSL_GROUP_SECP384R1'}]
oqs_meth: 'OQS_KEM_alg_kyber_768'
-
family: 'CRYSTALS-Kyber'
name: 'kyber1024'
nid: '0x023D'
mix_with: [{'name': 'p521', 'mix_nid':'0x2F3D', 'nid':'SSL_CURVE_SECP521R1'}]
mix_with: [{'name': 'p521', 'mix_nid':'0x2F3D', 'nid':'SSL_GROUP_SECP521R1'}]
oqs_meth: 'OQS_KEM_alg_kyber_1024'
-
family: 'HQC'
name: 'hqc128'
nid: '0x022C'
mix_with: [{'name': 'p256', 'mix_nid':'0x2F2C', 'nid':'SSL_CURVE_SECP256R1'}]
nid: '0x0244'
mix_with: [{'name': 'p256', 'mix_nid':'0x2F44', 'nid':'SSL_GROUP_SECP256R1'}]
oqs_meth: 'OQS_KEM_alg_hqc_128'
-
family: 'HQC'
name: 'hqc192'
nid: '0x022D'
mix_with: [{'name': 'p384', 'mix_nid':'0x2F2D', 'nid':'SSL_CURVE_SECP384R1'}]
nid: '0x0245'
mix_with: [{'name': 'p384', 'mix_nid':'0x2F45', 'nid':'SSL_GROUP_SECP384R1'}]
oqs_meth: 'OQS_KEM_alg_hqc_192'
-
family: 'HQC'
name: 'hqc256'
nid: '0x022E'
mix_with: [{'name': 'p521', 'mix_nid':'0x2F2E', 'nid':'SSL_CURVE_SECP521R1'}]
nid: '0x0246'
mix_with: [{'name': 'p521', 'mix_nid':'0x2F46', 'nid':'SSL_GROUP_SECP521R1'}]
oqs_meth: 'OQS_KEM_alg_hqc_256'


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% for kem in config['kems'] %}
#define SSL_CURVE_{{ kem['name']|upper }} {{ kem['nid']|int(base=16) }}
#define SSL_GROUP_{{ kem['name']|upper }} {{ kem['nid']|int(base=16) }}
{%- for classical_alg in kem['mix_with'] %}
#define SSL_CURVE_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }} {{ classical_alg['mix_nid']|int(base=16) }}
#define SSL_GROUP_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }} {{ classical_alg['mix_nid']|int(base=16) }}
{%- endfor %}
{%- endfor %}

4 changes: 2 additions & 2 deletions oqs_template/ssl/extensions.cc/add_all_kems.fragment
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% for kem in config['kems'] %}
{%- for classical_alg in kem['mix_with'] %}
SSL_CURVE_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }},
SSL_GROUP_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }},
{%- endfor %}
SSL_CURVE_{{ kem['name']|upper }},
SSL_GROUP_{{ kem['name']|upper }},
{%- endfor %}

2 changes: 1 addition & 1 deletion oqs_template/ssl/extensions.cc/add_default_kems.fragment
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% for kem in config['kems'] %}
{%- if kem['use_as_default_with'] %}
SSL_CURVE_{{ kem['use_as_default_with']|upper }}_{{ kem['name']|upper }},
SSL_GROUP_{{ kem['use_as_default_with']|upper }}_{{ kem['name']|upper }},
{%- endif -%}
{%- endfor %}

6 changes: 4 additions & 2 deletions oqs_template/ssl/extensions.cc/add_pq_groups.fragment
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{% for kem in config['kems'] %}
id == SSL_CURVE_{{ kem['name']|upper }} ||
case SSL_GROUP_{{ kem['name']|upper }}:
return true;
{%- set last_kem = loop.last -%}
{%- for classical_alg in kem['mix_with'] %}
{%- set last_hybrid = loop.last %}
id == SSL_CURVE_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }} {%- if not (last_kem and last_hybrid) %} || {%- else -%};{%- endif -%}
case SSL_GROUP_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }}:
return true;
{%- endfor %}
{%- endfor %}

9 changes: 0 additions & 9 deletions oqs_template/ssl/s3_both.cc/list_curves.fragment

This file was deleted.

4 changes: 2 additions & 2 deletions oqs_template/ssl/ssl_key_share.cc/def_namedgroups.fragment
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% for kem in config['kems'] %}
{NID_{{ kem['name'] }}, SSL_CURVE_{{ kem['name']|upper }}, "{{ kem['name'] }}", "{{ kem['name'] }}"},
{NID_{{ kem['name'] }}, SSL_GROUP_{{ kem['name']|upper }}, "{{ kem['name'] }}", "{{ kem['name'] }}"},
{%- for classical_alg in kem['mix_with'] %}
{NID_{{ classical_alg['name'] }}_{{ kem['name'] }}, SSL_CURVE_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }}, "{{ classical_alg['name'] }}_{{ kem['name'] }}", "{{ classical_alg['name'] }}_{{ kem['name'] }}"},
{NID_{{ classical_alg['name'] }}_{{ kem['name'] }}, SSL_GROUP_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }}, "{{ classical_alg['name'] }}_{{ kem['name'] }}", "{{ classical_alg['name'] }}_{{ kem['name'] }}"},
{%- endfor %}
{%- endfor %}

14 changes: 4 additions & 10 deletions oqs_template/ssl/ssl_key_share.cc/handle_group_ids.fragment
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
{% for kem in config['kems'] %}
case SSL_CURVE_{{ kem['name']|upper }}:
if(OQS_KEM_alg_is_enabled({{ kem['oqs_meth'] }}))
return UniquePtr<SSLKeyShare>(New<OQSKeyShare>(SSL_CURVE_{{ kem['name']|upper }}, {{ kem['oqs_meth'] }}));
else
return nullptr;
case SSL_GROUP_{{ kem['name']|upper }}:
return MakeUnique<OQSKeyShare>(SSL_GROUP_{{ kem['name']|upper }}, {{ kem['oqs_meth'] }});
{%- for classical_alg in kem['mix_with'] %}
case SSL_CURVE_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }}:
if(OQS_KEM_alg_is_enabled({{ kem['oqs_meth'] }}))
return UniquePtr<SSLKeyShare>(New<ClassicalWithOQSKeyShare>(SSL_CURVE_{{ classical_alg['name']|upper}}_{{ kem['name']|upper }}, {{ classical_alg['nid'] }}, {{ kem['oqs_meth'] }}));
else
return nullptr;
case SSL_GROUP_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }}:
return MakeUnique<ClassicalWithOQSKeyShare>(SSL_GROUP_{{ classical_alg['name']|upper}}_{{ kem['name']|upper }}, {{ classical_alg['nid'] }}, {{ kem['oqs_meth'] }});
{%- endfor %}
{%- endfor %}

4 changes: 2 additions & 2 deletions oqs_template/ssl/ssl_test.cc/add_curvetest.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{{ classical_alg['name'] }}_{{ kem['name'] }}{%- if not loop.last -%}: {%- endif -%}
{%- endfor -%}",
{
SSL_CURVE_{{ kem['name']|upper }},
SSL_GROUP_{{ kem['name']|upper }},
{%- for classical_alg in kem['mix_with'] %}
SSL_CURVE_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }},
SSL_GROUP_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }},
{%- endfor %}
},
},
Expand Down
4 changes: 2 additions & 2 deletions oqs_template/ssl/ssl_test.cc/list_all_oqs_kems.fragment
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%- for kem in config['kems'] if kem['family'] != 'HQC' %}
{NID_{{ kem['name'] }}, SSL_CURVE_{{ kem['name']|upper }}},
{NID_{{ kem['name'] }}, SSL_GROUP_{{ kem['name']|upper }}},
{%- for classical_alg in kem['mix_with'] %}
{NID_{{ classical_alg['name'] }}_{{ kem['name'] }}, SSL_CURVE_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }}},
{NID_{{ classical_alg['name'] }}_{{ kem['name'] }}, SSL_GROUP_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }}},
{%- endfor %}
{%- endfor %}

9 changes: 9 additions & 0 deletions oqs_template/ssl/test/fuzzer.h/list_groups.fragment
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% for kem in config['kems'] %}
SSL_GROUP_{{ kem['name']|upper }},
{%- set last_kem = loop.last -%}
{%- for classical_alg in kem['mix_with'] %}
{%- set last_hybrid = loop.last %}
SSL_GROUP_{{ classical_alg['name']|upper }}_{{ kem['name']|upper }}{%- if not (last_kem and last_hybrid) %},{%- endif -%}
{%- endfor %}
{%- endfor %}

6 changes: 0 additions & 6 deletions oqs_template/ssl/test/fuzzer.h/list_nids.fragment

This file was deleted.

11 changes: 0 additions & 11 deletions oqs_template/ssl/test/test_config.cc/add_nids.fragment

This file was deleted.