mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-11-29 00:03:48 -05:00
Add function to check if KEMs enabled
This commit is contained in:
parent
379a76e378
commit
792bf04d13
@ -0,0 +1,8 @@
|
||||
{% for family in instructions['kems'] %}{% for scheme in family['schemes'] %}
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_{{ family['name'] }}_{{ scheme['scheme'] }})) {
|
||||
#ifdef OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif{% endfor %}{% endfor %}
|
||||
|
||||
224
src/kem/kem.c
224
src/kem/kem.c
@ -33,6 +33,230 @@ OQS_API int OQS_KEM_alg_count() {
|
||||
return OQS_KEM_algs_length;
|
||||
}
|
||||
|
||||
OQS_API int OQS_KEM_alg_is_enabled(const char *method_name) {
|
||||
if (method_name == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (0 == strcasecmp(method_name, OQS_KEM_alg_default)) {
|
||||
return OQS_KEM_alg_is_enabled(OQS_KEM_DEFAULT);
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike1_l1)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike1_l1
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike1_l3)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike1_l3
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike1_l5)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike1_l5
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike2_l1)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike2_l1
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike2_l3)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike2_l3
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike2_l5)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike2_l5
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike3_l1)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike3_l1
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike3_l3)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike3_l3
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike3_l5)) {
|
||||
#ifdef OQS_ENABLE_KEM_bike3_l5
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ENABLED_CASE_START
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_512)) {
|
||||
#ifdef OQS_ENABLE_KEM_kyber_512
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_768)) {
|
||||
#ifdef OQS_ENABLE_KEM_kyber_768
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_1024)) {
|
||||
#ifdef OQS_ENABLE_KEM_kyber_1024
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_newhope_512cca)) {
|
||||
#ifdef OQS_ENABLE_KEM_newhope_512cca
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_newhope_1024cca)) {
|
||||
#ifdef OQS_ENABLE_KEM_newhope_1024cca
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps2048509)) {
|
||||
#ifdef OQS_ENABLE_KEM_ntru_hps2048509
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps2048677)) {
|
||||
#ifdef OQS_ENABLE_KEM_ntru_hps2048677
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps4096821)) {
|
||||
#ifdef OQS_ENABLE_KEM_ntru_hps4096821
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hrss701)) {
|
||||
#ifdef OQS_ENABLE_KEM_ntru_hrss701
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_lightsaber)) {
|
||||
#ifdef OQS_ENABLE_KEM_saber_lightsaber
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_saber)) {
|
||||
#ifdef OQS_ENABLE_KEM_saber_saber
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_firesaber)) {
|
||||
#ifdef OQS_ENABLE_KEM_saber_firesaber
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
///// OQS_COPY_FROM_PQCLEAN_FRAGMENT_ENABLED_CASE_END
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_640_aes)) {
|
||||
#ifdef OQS_ENABLE_KEM_frodokem_640_aes
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_640_shake)) {
|
||||
#ifdef OQS_ENABLE_KEM_frodokem_640_shake
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_976_aes)) {
|
||||
#ifdef OQS_ENABLE_KEM_frodokem_976_aes
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_976_shake)) {
|
||||
#ifdef OQS_ENABLE_KEM_frodokem_976_shake
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_1344_aes)) {
|
||||
#ifdef OQS_ENABLE_KEM_frodokem_1344_aes
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_1344_shake)) {
|
||||
#ifdef OQS_ENABLE_KEM_frodokem_1344_shake
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p434)) {
|
||||
#ifdef OQS_ENABLE_KEM_sidh_p434
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p503)) {
|
||||
#ifdef OQS_ENABLE_KEM_sidh_p503
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p610)) {
|
||||
#ifdef OQS_ENABLE_KEM_sidh_p610
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p751)) {
|
||||
#ifdef OQS_ENABLE_KEM_sidh_p751
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p434)) {
|
||||
#ifdef OQS_ENABLE_KEM_sike_p434
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p503)) {
|
||||
#ifdef OQS_ENABLE_KEM_sike_p503
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p610)) {
|
||||
#ifdef OQS_ENABLE_KEM_sike_p610
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p751)) {
|
||||
#ifdef OQS_ENABLE_KEM_sike_p751
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
// EDIT-WHEN-ADDING-KEM
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
OQS_API OQS_KEM *OQS_KEM_new(const char *method_name) {
|
||||
if (method_name == NULL) {
|
||||
return NULL;
|
||||
|
||||
@ -130,6 +130,14 @@ OQS_API const char *OQS_KEM_alg_identifier(size_t i);
|
||||
*/
|
||||
OQS_API int OQS_KEM_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_KEM_algs`.
|
||||
* @return 1 if enabled, 0 if disabled or not found
|
||||
*/
|
||||
OQS_API int OQS_KEM_alg_is_enabled(const char *method_name);
|
||||
|
||||
/**
|
||||
* Key encapsulation mechanism object
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user