Skip to content

Commit

Permalink
added composite to generate.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
feventura committed Dec 12, 2023
1 parent c72ccc5 commit b5365ae
Show file tree
Hide file tree
Showing 25 changed files with 1,161 additions and 947 deletions.
80 changes: 80 additions & 0 deletions oqs-template/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,21 @@ sigs:
# 'pretty_name': 'RSA3072',
# 'oid': '1.3.9999.1.3',
# 'code_point': '0xfe02'}]
# composite:[{'name': 'p256',
# 'pretty_name': 'ECDSA p256',
# 'security': '128',
# 'oid': '2.16.840.1.114027.80.1.8'}]
-
# OID scheme for composite variants:
# (2)
# (16)
# (840)
# (1)
# (114027)
# (80)
# (7)
# (1)
# -
# OID scheme for hybrid variants of Dilithium:
# iso (1)
# identified-organization (3)
Expand All @@ -398,6 +412,8 @@ sigs:
# IBM (2)
# qsc (267)
# Dilithium-r3 (7)


family: 'CRYSTALS-Dilithium'
variants:
-
Expand All @@ -416,6 +432,26 @@ sigs:
'pretty_name': 'RSA3072',
'oid': '1.3.9999.2.7.2',
'code_point': '0xfea2'}]
composite: [{'name': 'pss2048',
'pretty_name': 'RSA PSS 2048',
'security': '112',
'oid': '2.16.840.1.114027.80.7.1.1'},
{'name': 'rsa2048',
'pretty_name': 'RSA2028',
'security': '112',
'oid': '2.16.840.1.114027.80.7.1.2'},
{'name': 'ed25519',
'pretty_name': 'ED25519',
'security': '128',
'oid': '2.16.840.1.114027.80.7.1.3'},
{'name': 'p256',
'pretty_name': 'ECDSA p256',
'security': '128',
'oid': '2.16.840.1.114027.80.7.1.4'},
{'name': 'bp256',
'pretty_name': 'ECDSA brainpoolP256r1',
'security': '256',
'oid': '2.16.840.1.114027.80.7.1.5'}]
-
name: 'dilithium3'
pretty_name: 'Dilithium3'
Expand All @@ -428,6 +464,26 @@ sigs:
'pretty_name': 'ECDSA p384',
'oid': '1.3.9999.2.7.3',
'code_point': '0xfea4'}]
composite: [{'name': 'pss3072',
'pretty_name': 'RSA PSS 3072',
'security': '128',
'oid': '2.16.840.1.114027.80.7.1.6'},
{'name': 'rsa3072',
'pretty_name': 'RSA 3072',
'security': '128',
'oid': '2.16.840.1.114027.80.7.1.7'},
{'name': 'p256',
'pretty_name': 'ECDSA p256',
'security': '128',
'oid': '2.16.840.1.114027.80.7.1.8'},
{'name': 'bp256',
'pretty_name': 'ECDSA brainpoolP256r1',
'security': '256',
'oid': '2.16.840.1.114027.80.7.1.9'},
{'name': 'ed25519',
'pretty_name': 'ED25519',
'security': '128',
'oid': '2.16.840.1.114027.80.7.1.10'}]
-
name: 'dilithium5'
pretty_name: 'Dilithium5'
Expand All @@ -440,6 +496,18 @@ sigs:
'pretty_name': 'ECDSA p521',
'oid': '1.3.9999.2.7.4',
'code_point': '0xfea6'}]
composite: [{'name': 'p384',
'pretty_name': 'ECDSA p384',
'security': '192',
'oid': '2.16.840.1.114027.80.7.1.11'},
{'name': 'bp384',
'pretty_name': 'ECDSA brainpoolP384r1',
'security': '384',
'oid': '2.16.840.1.114027.80.7.1.12'},
{'name': 'ed448',
'pretty_name': 'ED448',
'security': '192',
'oid': '2.16.840.1.114027.80.7.1.13'}]
-
name: 'dilithium2_aes'
pretty_name: 'Dilithium2_AES'
Expand Down Expand Up @@ -512,6 +580,18 @@ sigs:
'pretty_name': 'RSA3072',
'oid': '1.3.9999.3.8',
'code_point': '0xfeb0'}]
composite: [{'name': 'p256',
'pretty_name': 'ECDSA p256',
'security': '128',
'oid': '2.16.840.1.114027.80.7.1.14'},
{'name': 'bp256',
'pretty_name': 'ECDSA brainpoolP256r1',
'security': '256',
'oid': '2.16.840.1.114027.80.7.1.15'},
{'name': 'ed25519',
'pretty_name': 'ED25519',
'security': '128',
'oid': '2.16.840.1.114027.80.7.1.16'}]
extra_nids:
old:
- implementation_version: NIST Round 3 submission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ MAKE_DECODER(, "{{ variant['name'] }}", {{ variant['name'] }}, oqsx, SubjectPubl
MAKE_DECODER(, "{{ classical_alg['name'] }}_{{ variant['name'] }}", {{ classical_alg['name'] }}_{{ variant['name'] }}, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "{{ classical_alg['name'] }}_{{ variant['name'] }}", {{ classical_alg['name'] }}_{{ variant['name'] }}, oqsx, SubjectPublicKeyInfo);
{%- endfor -%}
{%- for composite_alg in variant['composite'] %}
MAKE_DECODER(, "{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}, oqsx, SubjectPublicKeyInfo);
{%- endfor -%}
{%- endfor %}
{%- endfor %}

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ MAKE_ENCODER(, {{ classical_alg['name'] }}_{{ variant['name'] }}, oqsx, SubjectP
MAKE_ENCODER(, {{ classical_alg['name'] }}_{{ variant['name'] }}, oqsx, SubjectPublicKeyInfo, pem);
MAKE_TEXT_ENCODER(, {{ classical_alg['name'] }}_{{ variant['name'] }});
{%- endfor -%}
{%- for composite_alg in variant['composite'] %}
MAKE_ENCODER(, {{ variant['name'] }}_{{ composite_alg['name'] }}, oqsx, EncryptedPrivateKeyInfo, der);
MAKE_ENCODER(, {{ variant['name'] }}_{{ composite_alg['name'] }}, oqsx, EncryptedPrivateKeyInfo, pem);
MAKE_ENCODER(, {{ variant['name'] }}_{{ composite_alg['name'] }}, oqsx, PrivateKeyInfo, der);
MAKE_ENCODER(, {{ variant['name'] }}_{{ composite_alg['name'] }}, oqsx, PrivateKeyInfo, pem);
MAKE_ENCODER(, {{ variant['name'] }}_{{ composite_alg['name'] }}, oqsx, SubjectPublicKeyInfo, der);
MAKE_ENCODER(, {{ variant['name'] }}_{{ composite_alg['name'] }}, oqsx, SubjectPublicKeyInfo, pem);
MAKE_TEXT_ENCODER(, {{ variant['name'] }}_{{ composite_alg['name'] }});
{%- endfor -%}
{%- endfor %}
{%- endfor %}

13 changes: 13 additions & 0 deletions oqs-template/oqsprov/oqs_kmgmt.c/keymgmt_constructors.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ static void *{{ classical_alg['name'] }}_{{variant['name']}}_gen_init(void *prov
return oqsx_gen_init(provctx, selection, {{variant['oqs_meth']}}, "{{ classical_alg['name'] }}_{{variant['name']}}", KEY_TYPE_HYB_SIG, {{variant['security']}}, {{ count.val }});
}

{%- endfor -%}
{%- for composite_alg in variant['composite'] %}
{%- set count.val = count.val + 1 %}
static void *{{ variant['name'] }}_{{ composite_alg['name'] }}_new_key(void *provctx)
{
return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), {{variant['oqs_meth']}}, "{{ variant['name'] }}_{{ composite_alg['name'] }}", KEY_TYPE_CMP_SIG, NULL, {{composite_alg['security']}}, {{ count.val }});
}

static void *{{ variant['name'] }}_{{ composite_alg['name'] }}_gen_init(void *provctx, int selection)
{
return oqsx_gen_init(provctx, selection, {{variant['oqs_meth']}}, "{{ variant['name'] }}_{{ composite_alg['name'] }}", KEY_TYPE_CMP_SIG, {{composite_alg['security']}}, {{ count.val }});
}

{%- endfor -%}
{%- endfor %}
{% endfor %}
Expand Down
3 changes: 3 additions & 0 deletions oqs-template/oqsprov/oqs_kmgmt.c/keymgmt_functions.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ MAKE_SIG_KEYMGMT_FUNCTIONS({{variant['name']}})
{%- for classical_alg in variant['mix_with'] %}
MAKE_SIG_KEYMGMT_FUNCTIONS({{ classical_alg['name'] }}_{{variant['name']}})
{%- endfor -%}
{%- for composite_alg in variant['composite'] %}
MAKE_SIG_KEYMGMT_FUNCTIONS({{variant['name']}}_{{ composite_alg['name'] }})
{%- endfor -%}
{%- endfor %}
{%- endfor %}
{% for kem in config['kems'] %}
Expand Down
3 changes: 3 additions & 0 deletions oqs-template/oqsprov/oqs_prov.h/alg_functions.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_keymgmt_functions[];
{%- for classical_alg in variant['mix_with'] -%}
extern const OSSL_DISPATCH oqs_{{ classical_alg['name'] }}_{{ variant['name'] }}_keymgmt_functions[];
{%- endfor -%}
{%- for composite_alg in variant['composite'] -%}
extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_{{ composite_alg['name'] }}_keymgmt_functions[];
{%- endfor -%}
{%- endfor %}
{%- endfor %}
{% for kem in config['kems'] %}
Expand Down
11 changes: 11 additions & 0 deletions oqs-template/oqsprov/oqs_prov.h/endecoder_functions.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ extern const OSSL_DISPATCH oqs_{{ classical_alg['name'] }}_{{ variant['name'] }}
extern const OSSL_DISPATCH oqs_PrivateKeyInfo_der_to_{{ classical_alg['name'] }}_{{ variant['name'] }}_decoder_functions[];
extern const OSSL_DISPATCH oqs_SubjectPublicKeyInfo_der_to_{{ classical_alg['name'] }}_{{ variant['name'] }}_decoder_functions[];
{%- endfor -%}
{%- for composite_alg in variant['composite'] -%}
extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_{{ composite_alg['name'] }}_to_PrivateKeyInfo_der_encoder_functions[];
extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_{{ composite_alg['name'] }}_to_PrivateKeyInfo_pem_encoder_functions[];
extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_{{ composite_alg['name'] }}_to_EncryptedPrivateKeyInfo_der_encoder_functions[];
extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_{{ composite_alg['name'] }}_to_EncryptedPrivateKeyInfo_pem_encoder_functions[];
extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_{{ composite_alg['name'] }}_to_SubjectPublicKeyInfo_der_encoder_functions[];
extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_{{ composite_alg['name'] }}_to_SubjectPublicKeyInfo_pem_encoder_functions[];
extern const OSSL_DISPATCH oqs_{{ variant['name'] }}_{{ composite_alg['name'] }}_to_text_encoder_functions[];
extern const OSSL_DISPATCH oqs_PrivateKeyInfo_der_to_{{ variant['name'] }}_{{ composite_alg['name'] }}_decoder_functions[];
extern const OSSL_DISPATCH oqs_SubjectPublicKeyInfo_der_to_{{ variant['name'] }}_{{ composite_alg['name'] }}_decoder_functions[];
{%- endfor -%}
{%- endfor %}
{%- endfor %}

4 changes: 4 additions & 0 deletions oqs-template/oqsprov/oqsdecoders.inc/make.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ DECODER_w_structure("{{ variant['name'] }}", der, SubjectPublicKeyInfo, {{ varia
DECODER_w_structure("{{ classical_alg['name'] }}_{{ variant['name'] }}", der, PrivateKeyInfo, {{ classical_alg['name'] }}_{{ variant['name'] }}),
DECODER_w_structure("{{ classical_alg['name'] }}_{{ variant['name'] }}", der, SubjectPublicKeyInfo, {{ classical_alg['name'] }}_{{ variant['name'] }}),
{%- endfor %}
{%- for composite_alg in variant['composite'] -%}
DECODER_w_structure("{{ variant['name'] }}_{{ composite_alg['name'] }}", der, PrivateKeyInfo, {{ variant['name'] }}_{{ composite_alg['name'] }}),
DECODER_w_structure("{{ variant['name'] }}_{{ composite_alg['name'] }}", der, SubjectPublicKeyInfo, {{ variant['name'] }}_{{ composite_alg['name'] }}),
{%- endfor %}
#endif
{%- endfor %}
{%- endfor %}
Expand Down
9 changes: 9 additions & 0 deletions oqs-template/oqsprov/oqsencoders.inc/make.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ ENCODER_w_structure("{{ classical_alg['name'] }}_{{ variant['name'] }}", {{ clas
ENCODER_w_structure("{{ classical_alg['name'] }}_{{ variant['name'] }}", {{ classical_alg['name'] }}_{{ variant['name'] }}, pem, SubjectPublicKeyInfo),
ENCODER_TEXT("{{ classical_alg['name'] }}_{{ variant['name'] }}", {{ classical_alg['name'] }}_{{ variant['name'] }}),
{% endfor -%}
{% for composite_alg in variant['composite'] -%}
ENCODER_w_structure("{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}, der, PrivateKeyInfo),
ENCODER_w_structure("{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}, pem, PrivateKeyInfo),
ENCODER_w_structure("{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}, der, EncryptedPrivateKeyInfo),
ENCODER_w_structure("{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}, pem, EncryptedPrivateKeyInfo),
ENCODER_w_structure("{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}, der, SubjectPublicKeyInfo),
ENCODER_w_structure("{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}, pem, SubjectPublicKeyInfo),
ENCODER_TEXT("{{ variant['name'] }}_{{ composite_alg['name'] }}", {{ variant['name'] }}_{{ composite_alg['name'] }}),
{% endfor -%}
#endif
{%- endfor %}
{%- endfor %}
Expand Down
6 changes: 6 additions & 0 deletions oqs-template/oqsprov/oqsprov.c/assign_sig_oids.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
{%- for variant in sig['variants'] %}
{%- set count.val = count.val + 1 -%}
{%- for classical_alg in variant['mix_with'] %}
{%- set count.val = count.val + 1 -%}
{%- endfor %}
{%- for composite_alg in variant['composite'] %}
{%- set count.val = count.val + 1 -%}
{%- endfor %}
{%- endfor %}
Expand Down Expand Up @@ -40,6 +43,9 @@ const char* oqs_oid_alg_list[OQS_OID_CNT] =
{%- for classical_alg in variant['mix_with'] %}
"{{ classical_alg['oid'] }}" , "{{ classical_alg['name'] }}_{{ variant['name'] }}",
{%- endfor %}
{%- for composite_alg in variant['composite'] %}
"{{ composite_alg['oid'] }}" , "{{ variant['name'] }}_{{ composite_alg['name'] }}",
{%- endfor %}
{%- endfor %}
{%- endfor %}

5 changes: 5 additions & 0 deletions oqs-template/oqsprov/oqsprov.c/encoding_patching.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
if (getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}")) oqs_alg_encoding_list[{{ cnt.val }}] = getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}");
if (getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}_ALGNAME")) oqs_alg_encoding_list[{{ cnt.val + 1 }}] = getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}_ALGNAME");
{%- endfor %}
{%- for composite_alg in variant['composite'] %}
{%- set cnt.val = cnt.val + 2 %}
if (getenv("OQS_ENCODING_{{variant['name']|upper}}_{{ composite_alg['name']|upper }}")) oqs_alg_encoding_list[{{ cnt.val }}] = getenv("OQS_ENCODING_{{variant['name']|upper}}_{{ composite_alg['name']|upper }}");
if (getenv("OQS_ENCODING_{{variant['name']|upper}}_{{ composite_alg['name']|upper }}_ALGNAME")) oqs_alg_encoding_list[{{ cnt.val + 1 }}] = getenv("OQS_ENCODING_{{variant['name']|upper}}_{{ composite_alg['name']|upper }}_ALGNAME");
{%- endfor %}
{%- endfor %}
{%- endfor %}

3 changes: 3 additions & 0 deletions oqs-template/oqsprov/oqsprov.c/keymgmt_functions.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
{%- for classical_alg in variant['mix_with'] %}
SIGALG("{{ classical_alg['name'] }}_{{variant['name']}}", {{variant['security']}}, oqs_{{ classical_alg['name'] }}_{{ variant['name'] }}_keymgmt_functions),
{%- endfor %}
{%- for composite_alg in variant['composite'] %}
SIGALG("{{variant['name']}}_{{ composite_alg['name'] }}", {{composite_alg['security']}}, oqs_{{variant['name']}}_{{ composite_alg['name'] }}_keymgmt_functions),
{%- endfor %}
#endif
{%- endfor %}
{%- endfor %}
Expand Down
3 changes: 3 additions & 0 deletions oqs-template/oqsprov/oqsprov.c/sig_functions.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{%- for classical_alg in variant['mix_with'] %}
SIGALG("{{ classical_alg['name'] }}_{{variant['name']}}", {{variant['security']}}, oqs_signature_functions),
{%- endfor %}
{%- for composite_alg in variant['composite'] %}
SIGALG("{{variant['name']}}_{{ composite_alg['name'] }}", {{composite_alg['security']}}, oqs_signature_functions),
{%- endfor %}
#endif
{%- endfor %}
{%- endfor %}
Expand Down
6 changes: 6 additions & 0 deletions oqs-template/oqsprov/oqsprov_keys.c/oqsnames.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
{%- for classical_alg in variant['mix_with'] %}
{%- set count.val = count.val + 1 -%}
{%- endfor -%}
{%- for composite_alg in variant['composite'] %}
{%- set count.val = count.val + 1 -%}
{%- endfor -%}
{%- endfor -%}
{%- endfor %}

Expand All @@ -41,6 +44,9 @@ static oqs_nid_name_t nid_names[NID_TABLE_LEN] = {
{%- for classical_alg in variant['mix_with'] %}
{ 0, "{{ classical_alg['name'] }}_{{variant['name']}}", {{variant['oqs_meth']}}, KEY_TYPE_HYB_SIG, {{variant['security']}} },
{%- endfor %}
{%- for composite_alg in variant['composite'] %}
{ 0, "{{variant['name']}}_{{ composite_alg['name'] }}", {{variant['oqs_meth']}}, KEY_TYPE_CMP_SIG, {{composite_alg['security']}} },
{%- endfor %}
{%- endfor %}
{%- endfor %}

8 changes: 7 additions & 1 deletion oqs-template/scripts/common.py/sig_algs.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@
'{{ classical_alg['name'] }}_{{ variant['name'] }}',
{%- endfor -%}
{%- endfor %} {%- endfor %}

# post-quantum + classical signatures (COMPOSITE)
{% for sig in config['sigs'] -%}
{%- for variant in sig['variants'] -%}
{%- for composite_alg in variant['composite'] -%}
'{{ variant['name'] }}_{{ composite_alg['name'] }}',
{%- endfor -%}
{%- endfor %} {%- endfor %}
Loading

0 comments on commit b5365ae

Please sign in to comment.