diff --git a/crypto/dap_enc_key.c b/crypto/dap_enc_key.c index a52d115122a84fb1a16459058109ed5f5d22f7e4..7175dbe0dce0241c846fdf69c123c88f848cdf13 100644 --- a/crypto/dap_enc_key.c +++ b/crypto/dap_enc_key.c @@ -25,6 +25,7 @@ #include "dap_enc_aes.h" #include "dap_enc_newhope.h" +#include "dap_enc_sidh16.h" #include "dap_enc_msrln16.h" #include "dap_enc_key.h" @@ -69,7 +70,16 @@ struct dap_enc_key_callbacks{ .key_public_raw_callback = dap_enc_newhope_key_public_raw, .new_from_data_public_callback = dap_enc_newhope_key_new_from_data_public }, - //MSRLN16 + [DAP_ENC_KEY_TYPE_SIDH_CLN16]={ + .name = "SIDHCLN16", + .size_max = 64, + .enc = dap_enc_sidh16_encode, + .dec = dap_enc_sidh16_decode, + .new_callback = NULL, + .delete_callback = NULL, + .new_generate_callback = dap_enc_sidh16_key_new_generate, + .new_from_data_callback = dap_enc_sidh16_key_new_from_data + }, [DAP_ENC_KEY_TYPE_RLWE_MSRLN16] = { .name = "MSRLN16", .size_max = 64, diff --git a/crypto/dap_enc_key.h b/crypto/dap_enc_key.h index 7cf6d7313d40f9d0ae4d1d548715e1f2233347e5..bb208aa29718fc9d392e51bd1ed81038d4f3fc58 100644 --- a/crypto/dap_enc_key.h +++ b/crypto/dap_enc_key.h @@ -112,7 +112,6 @@ typedef struct dap_enc_key{ dap_enc_callback_dataop_t enc; dap_enc_callback_dataop_t dec; dap_enc_callback_t delete_callback; - void * _inheritor; } dap_enc_key_t; diff --git a/crypto/dap_enc_sidh16.c b/crypto/dap_enc_sidh16.c index 8a8305bd0260343d85e6a58648a48ee9d966346b..e9f56af21cff59372e40c291a161ae747e15391a 100644 --- a/crypto/dap_enc_sidh16.c +++ b/crypto/dap_enc_sidh16.c @@ -5,12 +5,12 @@ #include <string.h> #include <stdbool.h> -#include "dap_common.h" #include "dap_enc_sidh16.h" -#include "kex_sidh_cln16.h" #include "dap_enc_key.h" -#include "SIDH.h" +#include <../libdap/core/dap_common.h> +#include <../libdap/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.h> +#include <../libdap/crypto/liboqs/kex_sidh_cln16/SIDH.h> static const char *P751 = "p751"; static const char *CompressedP751 = "compressedp751"; @@ -44,7 +44,7 @@ dap_enc_key_t *dap_enc_sidh16_key_new_generate(struct dap_enc_key *a_key, size_t oqs_sidh_cln16_curve_free(curveIsogeny); return NULL; } - k->data ; + k->data; k->data_size; k->type = DAP_ENC_KEY_TYPE_SIDH_CLN16; k->last_used_timestamp; @@ -139,7 +139,7 @@ size_t dap_enc_sidh16_encode(struct dap_enc_key *a_key, const void *a_in, size_t // int OQS_KEX_sidh_cln16_bob(OQS_KEX *k, const uint8_t *alice_msg, const size_t alice_msg_len, uint8_t **bob_msg, size_t *bob_msg_len, uint8_t **key, size_t *key_len) size_t dap_enc_sidh16_decode(struct dap_enc_key *a_key, const void *a_in, size_t a_in_size, void *a_out) { - int ret; + size_t ret; dap_enc_sidh16_key_t *sidh_a_key = DAP_ENC_SIDH16_KEY(a_key); uint8_t *bob_priv = NULL; // non-compressed public key diff --git a/crypto/dap_enc_sidh16.h b/crypto/dap_enc_sidh16.h index 606780b1243f3fc9996af4288535f93f92b5558d..169cea09bd92b0e12d1e0784f25c456431336bd6 100644 --- a/crypto/dap_enc_sidh16.h +++ b/crypto/dap_enc_sidh16.h @@ -10,19 +10,35 @@ #include "dap_common.h" #include "dap_enc_key.h" +#include <../libdap/crypto/liboqs/kex_sidh_cln16/SIDH.h> +#include <../libdap/crypto/liboqs/kex/kex.h> + -#include "SIDH.h" struct dap_enc_key; +extern bool dap_sidh16_CurveIsogenyStruct_isnull(PCurveIsogenyStruct pCurveIsogeny); + typedef struct dap_enc_sidh16_key{ OQS_RAND *rand; void * user_curveIsogeny; unsigned int alice_msg_len; unsigned int bob_msg_len; unsigned int key_len; + uint16_t estimated_classical_security; + uint16_t estimated_quantum_security; } dap_enc_sidh16_key_t; +struct dapenc_testcase { + enum OQS_KEX_alg_name alg_name; + unsigned char *seed; + size_t seed_len; + char *named_parameters; + char *id; + int run; + int iter; +}; + #define DAP_ENC_SIDH16_KEY(a) ((dap_enc_sidh16_key_t *)((a)->_inheritor)) dap_enc_key_t *dap_enc_sidh16_key_new_generate(struct dap_enc_key* a_key, size_t a_size); // new diff --git a/crypto/liboqs/kex/kex.h b/crypto/liboqs/kex/kex.h index 02ab71edb49357e65337560345625a965190c8b5..dba05f9a8754ebca21eeed9ae2347ba94be8b1d4 100644 --- a/crypto/liboqs/kex/kex.h +++ b/crypto/liboqs/kex/kex.h @@ -9,6 +9,10 @@ #include <stddef.h> #include <stdint.h> +#if !defined(WINDOWS) +//#include <oqs/config.h> +#include <../libdap/crypto/liboqs/config.h> +======= //#include <oqs/rand.h> //беда Ñ Ñимлинками, поÑему так пока #include "../crypto/rand/rand.h" @@ -95,7 +99,7 @@ typedef struct OQS_KEX { * @param alice_msg_len Alice's message length * @return 1 on success, or 0 on failure */ - int (*alice_0)(OQS_KEX *k, void **alive_priv, uint8_t **alice_msg, size_t *alice_msg_len); + int (*alice_0)(OQS_KEX *k, void **alice_priv, uint8_t **alice_msg, size_t *alice_msg_len); /** * Pointer to a function for shared key generation by Bob. diff --git a/crypto/liboqs/kex_sidh_cln16/SIDH.h b/crypto/liboqs/kex_sidh_cln16/SIDH.h index 762ea99b60e3704075d269f3f66f45e4f91e7934..5f0ba90b915a4fdc367fdcada502bb7a9d0917b4 100644 --- a/crypto/liboqs/kex_sidh_cln16/SIDH.h +++ b/crypto/liboqs/kex_sidh_cln16/SIDH.h @@ -17,7 +17,8 @@ extern "C" { #endif -#include <oqs/rand.h> +//#include <../libdap/crypto/rand.h> //<oqs/rand.h> +#include <../libdap/crypto/liboqs/crypto/rand/rand.h> #include <stdint.h> #include <stdbool.h> #include <stddef.h> diff --git a/crypto/liboqs/kex_sidh_cln16/SIDH_internal.h b/crypto/liboqs/kex_sidh_cln16/SIDH_internal.h index 82a4a101b9a157c777042b23a8ff5de58b587329..97fdde84c30f7752f74b9f457a0f97b1a5cc3d14 100644 --- a/crypto/liboqs/kex_sidh_cln16/SIDH_internal.h +++ b/crypto/liboqs/kex_sidh_cln16/SIDH_internal.h @@ -23,7 +23,7 @@ extern "C" { #define UNUSED __attribute__((unused)) #endif -#include "SIDH.h" +#include <../libdap/crypto/liboqs/kex_sidh_cln16/SIDH.h> // Basic constants diff --git a/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.h b/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.h index 4409db7a6f9f0292ac6343066fc755ff75db21f1..15385d6f9ae50fc315e0a00f5697aa57df1ca6a3 100644 --- a/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.h +++ b/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.h @@ -9,8 +9,10 @@ #include <stddef.h> #include <stdint.h> -#include <oqs/kex.h> -#include <oqs/rand.h> +//#include <oqs/kex.h> +#include <../libdap/crypto/liboqs/kex/kex.h> +//#include <oqs/rand.h> +#include <../libdap/crypto/liboqs/crypto/rand/rand.h> OQS_KEX *OQS_KEX_sidh_cln16_new(OQS_RAND *rand, const char *named_parameters);