mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-05 00:05:12 -04:00
Partial work on signature templating
This commit is contained in:
parent
fe6929dc61
commit
350880a2b8
17
Makefile.am
17
Makefile.am
@ -26,14 +26,11 @@ endif
|
||||
if ENABLE_SIG_QTESLA
|
||||
liboqs_la_LIBADD += src/sig/qtesla/libqtesla.la
|
||||
endif
|
||||
if ENABLE_SIG_DILITHIUM
|
||||
liboqs_la_LIBADD += src/sig/dilithium/libdilithium.la
|
||||
endif
|
||||
|
||||
if ENABLE_KEM_BIKE
|
||||
liboqs_la_LIBADD += src/kem/bike/libkembike.la
|
||||
endif
|
||||
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_IF_ENABLE_KEM_START
|
||||
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_IF_ENABLE_START
|
||||
if ENABLE_KEM_KYBER
|
||||
liboqs_la_LIBADD += src/kem/kyber/libkemkyber.la
|
||||
endif
|
||||
@ -43,7 +40,11 @@ endif
|
||||
if ENABLE_KEM_NTRU
|
||||
liboqs_la_LIBADD += src/kem/ntru/libkemntru.la
|
||||
endif
|
||||
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_IF_ENABLE_KEM_END
|
||||
|
||||
if ENABLE_SIG_DILITHIUM
|
||||
liboqs_la_LIBADD += src/sig/dilithium/libsigdilithium.la
|
||||
endif
|
||||
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_IF_ENABLE_END
|
||||
if ENABLE_KEM_FRODOKEM
|
||||
liboqs_la_LIBADD += src/kem/frodokem/libkemfrodokem.la
|
||||
endif
|
||||
@ -71,9 +72,9 @@ installheader_HEADERS= src/oqs.h \
|
||||
src/kem/frodokem/kem_frodokem.h \
|
||||
src/kem/sike/kem_sike.h \
|
||||
src/sig/sig.h \
|
||||
src/sig/dilithium/sig_dilithium.h \
|
||||
src/sig/picnic/sig_picnic.h \
|
||||
src/sig/qtesla/sig_qtesla.h \
|
||||
src/sig/dilithium/sig_dilithium.h
|
||||
src/sig/qtesla/sig_qtesla.h
|
||||
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_INSTALLHEADER_END
|
||||
|
||||
|
||||
@ -107,13 +108,13 @@ links:
|
||||
cp -f src/kem/kyber/kem_kyber.h include/oqs
|
||||
cp -f src/kem/newhope/kem_newhope.h include/oqs
|
||||
cp -f src/kem/ntru/kem_ntru.h include/oqs
|
||||
cp -f src/sig/dilithium/sig_dilithium.h include/oqs
|
||||
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_LINKS_END
|
||||
cp -f src/kem/frodokem/kem_frodokem.h include/oqs
|
||||
cp -f src/kem/sike/kem_sike.h include/oqs
|
||||
cp -f src/sig/sig.h include/oqs
|
||||
cp -f src/sig/picnic/sig_picnic.h include/oqs
|
||||
cp -f src/sig/qtesla/sig_qtesla.h include/oqs
|
||||
cp -f src/sig/dilithium/sig_dilithium.h include/oqs
|
||||
|
||||
clean-local:
|
||||
rm -rf include
|
||||
|
@ -47,6 +47,7 @@ AC_DEFUN([CONFIG_FEATURE_FLAGS],
|
||||
ARG_DISBL_SET_WRAP([kem-kyber], [kem_kyber], [ENABLE_KEM_KYBER], [src/kem/kyber])
|
||||
ARG_DISBL_SET_WRAP([kem-newhope], [kem_newhope], [ENABLE_KEM_NEWHOPE], [src/kem/newhope])
|
||||
ARG_DISBL_SET_WRAP([kem-ntru], [kem_ntru], [ENABLE_KEM_NTRU], [src/kem/ntru])
|
||||
ARG_DISBL_SET_WRAP([sig-dilithium], [sig_dilithium], [ENABLE_SIG_DILITHIUM], [src/sig/dilithium])
|
||||
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_ARG_DISBL_SET_WRAP_END
|
||||
ARG_DISBL_SET_WRAP([kem-frodokem], [kem_frodokem], [ENABLE_KEM_FRODOKEM], [src/kem/frodokem])
|
||||
ARG_DISBL_SET_WRAP([kem-sike], [kem_sike], [ENABLE_KEM_SIKE], [src/kem/sike])
|
||||
@ -55,8 +56,6 @@ AC_DEFUN([CONFIG_FEATURE_FLAGS],
|
||||
[ENABLE_SIG_PICNIC], [src/sig/picnic])
|
||||
ARG_DISBL_SET_WRAP([sig-qtesla], [sig_qtesla],
|
||||
[ENABLE_SIG_QTESLA], [src/sig/qtesla])
|
||||
ARG_DISBL_SET_WRAP([sig-dilithium], [sig_dilithium],
|
||||
[ENABLE_SIG_DILITHIUM], [src/sig/dilithium])
|
||||
]
|
||||
)
|
||||
|
||||
@ -100,6 +99,11 @@ AC_DEFUN([CONFIG_FEATURES],
|
||||
AC_DEFINE(OQS_ENABLE_KEM_ntru_hps4096821, 1, "Define to 1 when NTRU-HPS-4096-821 enabled")
|
||||
AC_DEFINE(OQS_ENABLE_KEM_ntru_hrss701, 1, "Define to 1 when NTRU-HRSS-701 enabled")
|
||||
])
|
||||
AM_COND_IF([ENABLE_SIG_DILITHIUM], [
|
||||
AC_DEFINE(OQS_ENABLE_SIG_dilithium_2, 1, "Define to 1 when DILITHIUM_2 enabled")
|
||||
AC_DEFINE(OQS_ENABLE_SIG_dilithium_3, 1, "Define to 1 when DILITHIUM_3 enabled")
|
||||
AC_DEFINE(OQS_ENABLE_SIG_dilithium_4, 1, "Define to 1 when DILITHIUM_4 enabled")
|
||||
])
|
||||
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_AM_COND_IF_END
|
||||
|
||||
AM_COND_IF([ENABLE_KEM_FRODOKEM], [
|
||||
@ -136,10 +140,5 @@ AC_DEFUN([CONFIG_FEATURES],
|
||||
AC_DEFINE(OQS_ENABLE_SIG_picnic2_L5_FS, 1, "Define to 1 when picnic2-L5-FS enabled")
|
||||
])
|
||||
|
||||
AM_COND_IF([ENABLE_SIG_DILITHIUM], [
|
||||
AC_DEFINE(OQS_ENABLE_SIG_dilithium_2, 1, "Define to 1 when DILITHIUM_2 enabled")
|
||||
AC_DEFINE(OQS_ENABLE_SIG_dilithium_3, 1, "Define to 1 when DILITHIUM_3 enabled")
|
||||
AC_DEFINE(OQS_ENABLE_SIG_dilithium_4, 1, "Define to 1 when DILITHIUM_4 enabled")
|
||||
])
|
||||
]
|
||||
)
|
||||
|
@ -2,4 +2,8 @@
|
||||
if ENABLE_KEM_{{ family['name']|upper }}
|
||||
liboqs_la_LIBADD += src/kem/{{ family['name'] }}/libkem{{ family['name'] }}.la
|
||||
endif{% endfor %}
|
||||
{% for family in instructions['sigs'] %}
|
||||
if ENABLE_SIG_{{ family['name']|upper }}
|
||||
liboqs_la_LIBADD += src/sig/{{ family['name'] }}/libsig{{ family['name'] }}.la
|
||||
endif{% endfor %}
|
||||
|
@ -12,7 +12,8 @@ installheader_HEADERS= src/oqs.h \
|
||||
src/kem/frodokem/kem_frodokem.h \
|
||||
src/kem/sike/kem_sike.h \
|
||||
src/sig/sig.h \
|
||||
{%- for family in instructions['sigs'] %}
|
||||
src/sig/{{ family['name'] }}/sig_{{ family['name'] }}.h \{% endfor %}
|
||||
src/sig/picnic/sig_picnic.h \
|
||||
src/sig/qtesla/sig_qtesla.h \
|
||||
src/sig/dilithium/sig_dilithium.h
|
||||
src/sig/qtesla/sig_qtesla.h
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
{% for family in instructions['kems'] %}
|
||||
cp -f src/kem/{{ family['name'] }}/kem_{{ family['name'] }}.h include/oqs{% endfor %}
|
||||
{%- for family in instructions['sigs'] %}
|
||||
cp -f src/sig/{{ family['name'] }}/sig_{{ family['name'] }}.h include/oqs{% endfor %}
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
{% for family in instructions['kems'] %}
|
||||
AM_COND_IF([ENABLE_KEM_{{ family['name']|upper }}], [{% for scheme in family['schemes'] %}
|
||||
AC_DEFINE(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}, 1, "Define to 1 when {{ scheme['pretty_name_full'] }} enabled"){% endfor %}
|
||||
]){% endfor %}{% for family in instructions['sigs'] %}
|
||||
AM_COND_IF([ENABLE_SIG_{{ family['name']|upper }}], [{% for scheme in family['schemes'] %}
|
||||
AC_DEFINE(OQS_ENABLE_SIG_{{ family['name'] }}_{{ scheme['scheme'] }}, 1, "Define to 1 when {{ scheme['pretty_name_full'] }} enabled"){% endfor %}
|
||||
]){% endfor %}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
{% for family in instructions['kems'] %}
|
||||
ARG_DISBL_SET_WRAP([kem-{{ family['name'] }}], [kem_{{ family['name'] }}], [ENABLE_KEM_{{ family['name']|upper }}], [src/kem/{{ family['name'] }}]){% endfor %}
|
||||
ARG_DISBL_SET_WRAP([kem-{{ family['name'] }}], [kem_{{ family['name'] }}], [ENABLE_KEM_{{ family['name']|upper }}], [src/kem/{{ family['name'] }}]){% endfor %}{% for family in instructions['sigs'] %}
|
||||
ARG_DISBL_SET_WRAP([sig-{{ family['name'] }}], [sig_{{ family['name'] }}], [ENABLE_SIG_{{ family['name']|upper }}], [src/sig/{{ family['name'] }}]){% endfor %}
|
||||
|
||||
|
@ -7,7 +7,8 @@ AC_CONFIG_FILES([Makefile
|
||||
src/sig/Makefile
|
||||
src/sig/picnic/Makefile
|
||||
src/sig/qtesla/Makefile
|
||||
src/sig/dilithium/Makefile
|
||||
{%- for family in instructions['sigs'] %}
|
||||
src/sig/{{ family['name'] }}/Makefile{% endfor %}
|
||||
src/kem/bike/Makefile
|
||||
{%- for family in instructions['kems'] %}
|
||||
src/kem/{{ family['name'] }}/Makefile{% endfor %}
|
||||
|
@ -61,6 +61,12 @@ def load_instructions():
|
||||
for scheme in family['schemes']:
|
||||
scheme['metadata'] = yaml.safe_load(file_get_contents(os.path.join(os.environ['PQCLEAN_DIR'], 'crypto_kem', scheme['pqclean_scheme'], 'META.yml')))
|
||||
scheme['metadata']['ind_cca'] = 'true'
|
||||
for family in instructions['sigs']:
|
||||
family['type'] = 'sig'
|
||||
family['family'] = family['name']
|
||||
for scheme in family['schemes']:
|
||||
scheme['metadata'] = yaml.safe_load(file_get_contents(os.path.join(os.environ['PQCLEAN_DIR'], 'crypto_sign', scheme['pqclean_scheme'], 'META.yml')))
|
||||
scheme['metadata']['euf_cma'] = 'true'
|
||||
return instructions
|
||||
|
||||
instructions = load_instructions()
|
||||
@ -109,6 +115,8 @@ replacer('configure.ac', instructions, '#####')
|
||||
replacer('Makefile.am', instructions, '#####')
|
||||
replacer('src/kem/kem.c', instructions, '/////')
|
||||
replacer('src/kem/kem.h', instructions, '/////')
|
||||
replacer('src/sig/sig.c', instructions, '/////')
|
||||
replacer('src/sig/sig.h', instructions, '/////')
|
||||
replacer('VisualStudio/winconfig.h', instructions, '/////')
|
||||
generator_all('VisualStudio/oqs/dll.def', instructions)
|
||||
unix2dos('VisualStudio/oqs/dll.def')
|
||||
|
@ -74,3 +74,29 @@ kems:
|
||||
implementation: clean
|
||||
sources: ['kem.c', 'owcpa.c', 'pack3.c', 'packq.c', 'poly.c', 'sample.c', 'verify.c']
|
||||
visual_studio_guid: 96485f85-7dd5-4df3-a1cd-769da06d3ada
|
||||
sigs:
|
||||
-
|
||||
name: dilithium
|
||||
visual_studio_guid: 2a035f7e-7c7e-4ca3-94ac-140aac970a73
|
||||
schemes:
|
||||
-
|
||||
scheme: 2
|
||||
pqclean_scheme: dilithium2
|
||||
pretty_name_full: DILITHIUM_2
|
||||
implementation: clean
|
||||
sources: ['sign.c', 'polyvec.c', 'poly.c', 'packing.c', 'ntt.c', 'reduce.c', 'rounding.c', 'symmetric.c']
|
||||
visual_studio_guid: 1f5e5dbe-8082-4756-9e90-c7d84198d682
|
||||
-
|
||||
scheme: 3
|
||||
pqclean_scheme: dilithium3
|
||||
pretty_name_full: DILITHIUM_3
|
||||
implementation: clean
|
||||
sources: ['sign.c', 'polyvec.c', 'poly.c', 'packing.c', 'ntt.c', 'reduce.c', 'rounding.c', 'symmetric.c']
|
||||
visual_studio_guid: 8a93b308-7b77-41e7-88a5-275994b62322
|
||||
-
|
||||
scheme: 4
|
||||
pqclean_scheme: dilithium4
|
||||
pretty_name_full: DILITHIUM_4
|
||||
implementation: clean
|
||||
sources: ['sign.c', 'polyvec.c', 'poly.c', 'packing.c', 'ntt.c', 'reduce.c', 'rounding.c', 'symmetric.c']
|
||||
visual_studio_guid: fb8c21f2-891b-46fb-8a45-17f69dfa31bd
|
||||
|
@ -0,0 +1,3 @@
|
||||
{% for family in instructions['sigs'] %}
|
||||
{% for scheme in family['schemes'] %} OQS_SIG_alg_{{ family['name'] }}_{{ scheme['scheme'] }},{% endfor %}{% endfor %}
|
||||
|
@ -0,0 +1,8 @@
|
||||
{% for family in instructions['sigs'] %}{% for scheme in family['schemes'] %}
|
||||
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_{{ family['name'] }}_{{ scheme['scheme'] }})) {
|
||||
#ifdef OQS_ENABLE_SIG_{{ family['name'] }}_{{ scheme['scheme'] }}
|
||||
return OQS_SIG_{{ family['name'] }}_{{ scheme['scheme'] }}_new();
|
||||
#else
|
||||
return NULL;
|
||||
#endif{% endfor %}{% endfor %}
|
||||
|
@ -0,0 +1,4 @@
|
||||
{% for family in instructions['sigs'] %}{% for scheme in family['schemes'] %}
|
||||
/** Algorithm identifier for {{ scheme['pretty_name_full'] }} */
|
||||
#define OQS_SIG_alg_{{ family['name'] }}_{{ scheme['scheme'] }} "{{ scheme['pretty_name_full'] }}"{% endfor %}{% endfor %}
|
||||
|
@ -0,0 +1,4 @@
|
||||
{% set unary %}{% for family in instructions['sigs'] %}{% for scheme in family['schemes'] %}1{% endfor %}{% endfor %}{% endset %}
|
||||
/** Number of algorithm identifiers above (including default). */
|
||||
#define OQS_SIG_algs_length {{ unary|length + 13 }}
|
||||
|
3
scripts/copy_from_pqclean/src/sig/sig.h/include.fragment
Normal file
3
scripts/copy_from_pqclean/src/sig/sig.h/include.fragment
Normal file
@ -0,0 +1,3 @@
|
||||
{% for family in instructions['sigs'] %}
|
||||
#include <oqs/sig_{{ family['name'] }}.h>{% endfor %}
|
||||
|
@ -12,21 +12,11 @@ OQS_API const char *OQS_SIG_alg_identifier(size_t i) {
|
||||
// EDIT-WHEN-ADDING-SIG
|
||||
const char *a[OQS_SIG_algs_length] = {
|
||||
OQS_SIG_alg_default,
|
||||
OQS_SIG_alg_picnic_L1_FS,
|
||||
OQS_SIG_alg_picnic_L1_UR,
|
||||
OQS_SIG_alg_picnic_L3_FS,
|
||||
OQS_SIG_alg_picnic_L3_UR,
|
||||
OQS_SIG_alg_picnic_L5_FS,
|
||||
OQS_SIG_alg_picnic_L5_UR,
|
||||
OQS_SIG_alg_picnic2_L1_FS,
|
||||
OQS_SIG_alg_picnic2_L3_FS,
|
||||
OQS_SIG_alg_picnic2_L5_FS,
|
||||
OQS_SIG_alg_qTESLA_I,
|
||||
OQS_SIG_alg_qTESLA_III_size,
|
||||
OQS_SIG_alg_qTESLA_III_speed,
|
||||
OQS_SIG_alg_dilithium_2,
|
||||
OQS_SIG_alg_dilithium_3,
|
||||
OQS_SIG_alg_dilithium_4};
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ALG_IDENTIFIER_START
|
||||
OQS_SIG_alg_dilithium_2, OQS_SIG_alg_dilithium_3, OQS_SIG_alg_dilithium_4,
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ALG_IDENTIFIER_END
|
||||
OQS_SIG_alg_picnic_L1_FS, OQS_SIG_alg_picnic_L1_UR, OQS_SIG_alg_picnic_L3_FS, OQS_SIG_alg_picnic_L3_UR, OQS_SIG_alg_picnic_L5_FS, OQS_SIG_alg_picnic_L5_UR, OQS_SIG_alg_picnic2_L1_FS, OQS_SIG_alg_picnic2_L3_FS, OQS_SIG_alg_picnic2_L5_FS,
|
||||
OQS_SIG_alg_qTESLA_I, OQS_SIG_alg_qTESLA_III_size, OQS_SIG_alg_qTESLA_III_speed};
|
||||
if (i >= OQS_SIG_algs_length) {
|
||||
return NULL;
|
||||
} else {
|
||||
@ -44,6 +34,26 @@ OQS_API OQS_SIG *OQS_SIG_new(const char *method_name) {
|
||||
}
|
||||
if (0 == strcasecmp(method_name, OQS_SIG_alg_default)) {
|
||||
return OQS_SIG_new(OQS_SIG_DEFAULT);
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_NEW_CASE_START
|
||||
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_2)) {
|
||||
#ifdef OQS_ENABLE_SIG_dilithium_2
|
||||
return OQS_SIG_dilithium_2_new();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_3)) {
|
||||
#ifdef OQS_ENABLE_SIG_dilithium_3
|
||||
return OQS_SIG_dilithium_3_new();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_4)) {
|
||||
#ifdef OQS_ENABLE_SIG_dilithium_4
|
||||
return OQS_SIG_dilithium_4_new();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_NEW_CASE_END
|
||||
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic_L1_FS)) {
|
||||
#ifdef OQS_ENABLE_SIG_picnic_L1_FS
|
||||
return OQS_SIG_picnic_L1_FS_new();
|
||||
@ -115,24 +125,6 @@ OQS_API OQS_SIG *OQS_SIG_new(const char *method_name) {
|
||||
return OQS_SIG_qTESLA_III_speed_new();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_2)) {
|
||||
#ifdef OQS_ENABLE_SIG_dilithium_2
|
||||
return OQS_SIG_dilithium_2_new();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_3)) {
|
||||
#ifdef OQS_ENABLE_SIG_dilithium_3
|
||||
return OQS_SIG_dilithium_3_new();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_4)) {
|
||||
#ifdef OQS_ENABLE_SIG_dilithium_4
|
||||
return OQS_SIG_dilithium_4_new();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
// EDIT-WHEN-ADDING-SIG
|
||||
} else {
|
||||
|
@ -55,16 +55,19 @@ extern "C" {
|
||||
#define OQS_SIG_alg_qTESLA_III_size "qTESLA_III_size"
|
||||
/** Algorithm identifier for qTESLA_III_speed */
|
||||
#define OQS_SIG_alg_qTESLA_III_speed "qTESLA_III_speed"
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ALG_IDENTIFIER_START
|
||||
/** Algorithm identifier for DILITHIUM_2 */
|
||||
#define OQS_SIG_alg_dilithium_2 "DILITHIUM_2"
|
||||
/** Algorithm identifier for DILITHIUM_3 */
|
||||
#define OQS_SIG_alg_dilithium_3 "DILITHIUM_3"
|
||||
/** Algorithm identifier for DILITHIUM_4 */
|
||||
#define OQS_SIG_alg_dilithium_4 "DILITHIUM_4"
|
||||
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ALG_IDENTIFIER_END
|
||||
// EDIT-WHEN-ADDING-SIG
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ALGS_LENGTH_START
|
||||
/** Number of algorithm identifiers above (including default). */
|
||||
#define OQS_SIG_algs_length 16
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ALGS_LENGTH_END
|
||||
|
||||
/**
|
||||
* Returns identifiers for available signature schemes in liboqs. Used with OQS_SIG_new.
|
||||
@ -226,7 +229,9 @@ OQS_API void OQS_SIG_free(OQS_SIG *sig);
|
||||
|
||||
#include <oqs/sig_picnic.h>
|
||||
#include <oqs/sig_qtesla.h>
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_INCLUDE_START
|
||||
#include <oqs/sig_dilithium.h>
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_INCLUDE_END
|
||||
// EDIT-WHEN-ADDING-SIG
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
Loading…
x
Reference in New Issue
Block a user