Add function to check if SIGs enabled

This commit is contained in:
Douglas Stebila 2019-07-30 21:32:06 -04:00
parent 792bf04d13
commit 2e0b6e443a
3 changed files with 132 additions and 0 deletions

View File

@ -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 1;
#else
return 0;
#endif{% endfor %}{% endfor %}

View File

@ -31,6 +31,122 @@ OQS_API int OQS_SIG_alg_count() {
return OQS_SIG_algs_length;
}
OQS_API int OQS_SIG_alg_is_enabled(const char *method_name) {
if (method_name == NULL) {
return 0;
}
if (0 == strcasecmp(method_name, OQS_SIG_alg_default)) {
return OQS_SIG_alg_is_enabled(OQS_SIG_DEFAULT);
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ENABLED_CASE_START
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_2)) {
#ifdef OQS_ENABLE_SIG_dilithium_2
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_3)) {
#ifdef OQS_ENABLE_SIG_dilithium_3
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_dilithium_4)) {
#ifdef OQS_ENABLE_SIG_dilithium_4
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_mqdss_31_48)) {
#ifdef OQS_ENABLE_SIG_mqdss_31_48
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_mqdss_31_64)) {
#ifdef OQS_ENABLE_SIG_mqdss_31_64
return 1;
#else
return 0;
#endif
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ENABLED_CASE_END
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic_L1_FS)) {
#ifdef OQS_ENABLE_SIG_picnic_L1_FS
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic_L1_UR)) {
#ifdef OQS_ENABLE_SIG_picnic_L1_UR
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic_L3_FS)) {
#ifdef OQS_ENABLE_SIG_picnic_L3_FS
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic_L3_UR)) {
#ifdef OQS_ENABLE_SIG_picnic_L3_UR
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic_L5_FS)) {
#ifdef OQS_ENABLE_SIG_picnic_L5_FS
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic_L5_UR)) {
#ifdef OQS_ENABLE_SIG_picnic_L5_UR
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic2_L1_FS)) {
#ifdef OQS_ENABLE_SIG_picnic2_L1_FS
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic2_L3_FS)) {
#ifdef OQS_ENABLE_SIG_picnic2_L3_FS
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_picnic2_L5_FS)) {
#ifdef OQS_ENABLE_SIG_picnic2_L5_FS
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_qTESLA_I)) {
#ifdef OQS_ENABLE_SIG_qTESLA_I
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_qTESLA_III_size)) {
#ifdef OQS_ENABLE_SIG_qTESLA_III_size
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_alg_qTESLA_III_speed)) {
#ifdef OQS_ENABLE_SIG_qTESLA_III_speed
return 1;
#else
return 0;
#endif
// EDIT-WHEN-ADDING-SIG
} else {
return 0;
}
}
OQS_API OQS_SIG *OQS_SIG_new(const char *method_name) {
if (method_name == NULL) {
return NULL;

View File

@ -184,6 +184,14 @@ OQS_API const char *OQS_SIG_alg_identifier(size_t i);
*/
OQS_API int OQS_SIG_alg_count();
/**
* Indicates whether the specified algorithm was enabled at compile-time or not.
*
* @param[in] method_name Name of the desired algorithm; one of the names in `OQS_SIG_algs`.
* @return 1 if enabled, 0 if disabled or not found
*/
OQS_API int OQS_SIG_alg_is_enabled(const char *method_name);
/**
* Signature schemes object
*/