From b917c0dd15778da97ad9e62c3bbe72e235e90147 Mon Sep 17 00:00:00 2001 From: Ivan Deniskin <ivanmordwin@yandex.ru> Date: Mon, 28 May 2018 13:37:48 +0300 Subject: [PATCH] Adaptation for qt projects --- client/client.pri | 15 +++++ core/core.pri | 11 ++++ crypto/crypto.pri | 49 +++++++++++++++ crypto/liboqs/common/common.h | 1 + crypto/liboqs/crypto/rand/rand.h | 9 +++ .../kex_rlwe_msrln16/kex_rlwe_msrln16.h | 8 +++ crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.c | 59 ------------------- http/http.pri | 15 +++++ libdap.pri | 7 +++ 9 files changed, 115 insertions(+), 59 deletions(-) create mode 100644 client/client.pri create mode 100644 core/core.pri create mode 100644 crypto/crypto.pri create mode 100644 http/http.pri create mode 100644 libdap.pri diff --git a/client/client.pri b/client/client.pri new file mode 100644 index 0000000..77b4320 --- /dev/null +++ b/client/client.pri @@ -0,0 +1,15 @@ +HEADERS += $$PWD/dap_client.h \ + $$PWD/dap_client_internal.h \ + $$PWD/dap_client_remote.h \ + $$PWD/sxmlc/sxmlc.h \ + $$PWD/sxmlc/sxmlsearch.h + + +SOURCES += $$PWD/dap_client.c \ + $$PWD/dap_client_internal.c \ + $$PWD/dap_client_remote.c \ + $$PWD/sxmlc/sxmlc.c \ + $$PWD/sxmlc/sxmlsearch.c + + +INCLUDEPATH += $$PWD diff --git a/core/core.pri b/core/core.pri new file mode 100644 index 0000000..3a669ec --- /dev/null +++ b/core/core.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/dap_common.h \ + $$PWD/dap_config.h \ + $$PWD/dap_math_ops.h \ + $$PWD/uthash.h \ + $$PWD/utlist.h \ + $$PWD/dap_math_ops.h + +SOURCES += $$PWD/dap_common.c \ + $$PWD/dap_config.c + +INCLUDEPATH += $$PWD diff --git a/crypto/crypto.pri b/crypto/crypto.pri new file mode 100644 index 0000000..1b1b486 --- /dev/null +++ b/crypto/crypto.pri @@ -0,0 +1,49 @@ +HEADERS += $$PWD/dap_enc.h \ + $$PWD/dap_enc_base64.h \ + $$PWD/dap_enc_aes.h \ + $$PWD/dap_enc_newhope.h \ + $$PWD/dap_enc_msrln16.h \ + $$PWD/dap_enc_key.h \ + $$PWD/dap_enc_sidh16.h \ + $$PWD/liboqs/kex_sidh_cln16/kex_sidh_cln16.h \ + $$PWD/liboqs/kex_sidh_cln16/SIDH.h \ + $$PWD/liboqs/kex_sidh_cln16/SIDH_internal.h \ + $$PWD/liboqs/kex_rlwe_msrln16/kex_rlwe_msrln16.h \ + $$PWD/liboqs/kex_rlwe_msrln16/LatticeCrypto_priv.h \ + $$PWD/liboqs/kex_rlwe_msrln16/LatticeCrypto.h \ + $$PWD/liboqs/crypto/sha3/sha3.h \ + $$PWD/liboqs/crypto/rand/rand.h \ + $$PWD/liboqs/crypto/rand_urandom_aesctr/rand_urandom_aesctr.h \ + $$PWD/liboqs/crypto/rand_urandom_chacha20/rand_urandom_chacha20.h \ + $$PWD/liboqs/crypto/aes/aes_local.h \ + $$PWD/liboqs/crypto/aes/aes.h + +SOURCES += $$PWD/dap_enc.c \ + $$PWD/dap_enc_base64.c \ + $$PWD/dap_enc_aes.c \ + $$PWD/dap_enc_newhope.c \ + $$PWD/dap_enc_msrln16.c \ + $$PWD/dap_enc_key.c \ + $$PWD/dap_enc_sidh16.c \ + $$PWD/liboqs/kex_sidh_cln16/kex_sidh_cln16.c \ + $$PWD/liboqs/kex_sidh_cln16/SIDH.c \ + $$PWD/liboqs/kex_sidh_cln16/SIDH_setup.c \ + $$PWD/liboqs/kex_sidh_cln16/sidh_kex.c \ + $$PWD/liboqs/kex_sidh_cln16/ec_isogeny.c \ + $$PWD/liboqs/kex_sidh_cln16/fpx.c \ + $$PWD/liboqs/kex_sidh_cln16/generic/fp_generic.c \ + $$PWD/liboqs/kex_rlwe_msrln16/generic/ntt.c \ + $$PWD/liboqs/kex_rlwe_msrln16/kex_rlwe_msrln16.c \ + $$PWD/liboqs/kex_rlwe_msrln16/LatticeCrypto_kex.c \ + $$PWD/liboqs/kex_rlwe_msrln16/ntt_constants.c \ + $$PWD/liboqs/crypto/sha3/sha3.c \ + $$PWD/liboqs/crypto/rand/rand.c \ + $$PWD/liboqs/crypto/rand_urandom_aesctr/rand_urandom_aesctr.c \ + $$PWD/liboqs/crypto/rand_urandom_chacha20/rand_urandom_chacha20.c \ + $$PWD/liboqs/crypto/aes/aes_c.c \ + $$PWD/liboqs/crypto/aes/aes_ni.c \ + $$PWD/liboqs/crypto/aes/aes.c + + + +INCLUDEPATH += $$PWD diff --git a/crypto/liboqs/common/common.h b/crypto/liboqs/common/common.h index 010d932..0eeeb95 100644 --- a/crypto/liboqs/common/common.h +++ b/crypto/liboqs/common/common.h @@ -2,6 +2,7 @@ #define __OQS_COMMON_H #include <stdlib.h> +#include <stdio.h> #define OQS_SUCCESS 1 #define OQS_ERROR 0 diff --git a/crypto/liboqs/crypto/rand/rand.h b/crypto/liboqs/crypto/rand/rand.h index 710e449..bf5af4e 100644 --- a/crypto/liboqs/crypto/rand/rand.h +++ b/crypto/liboqs/crypto/rand/rand.h @@ -9,6 +9,10 @@ #include <stddef.h> #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + enum OQS_RAND_alg_name { OQS_RAND_alg_default, OQS_RAND_alg_urandom_chacha20, @@ -95,4 +99,9 @@ double OQS_RAND_zscore_deviation_from_uniform(const unsigned long occurrences[25 void OQS_RAND_report_statistics(const unsigned long occurrences[256], const char *indent); int OQS_RAND_get_system_entropy(uint8_t *buf, size_t n); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/crypto/liboqs/kex_rlwe_msrln16/kex_rlwe_msrln16.h b/crypto/liboqs/kex_rlwe_msrln16/kex_rlwe_msrln16.h index 77613a4..08cd3ff 100644 --- a/crypto/liboqs/kex_rlwe_msrln16/kex_rlwe_msrln16.h +++ b/crypto/liboqs/kex_rlwe_msrln16/kex_rlwe_msrln16.h @@ -16,6 +16,10 @@ /*#include <oqs/kex.h> #include <oqs/rand.h>*/ +#ifdef __cplusplus +extern "C" { +#endif + OQS_KEX *OQS_KEX_rlwe_msrln16_new(OQS_RAND *rand); int OQS_KEX_rlwe_msrln16_alice_0(OQS_KEX *k, void **alice_priv, uint8_t **alice_msg, size_t *alice_msg_len); @@ -25,4 +29,8 @@ int OQS_KEX_rlwe_msrln16_alice_1(OQS_KEX *k, const void *alice_priv, const uint8 void OQS_KEX_rlwe_msrln16_alice_priv_free(OQS_KEX *k, void *alice_priv); void OQS_KEX_rlwe_msrln16_free(OQS_KEX *k); +#ifdef __cplusplus +} +#endif + #endif diff --git a/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.c b/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.c index 5151901..178f983 100644 --- a/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.c +++ b/crypto/liboqs/kex_sidh_cln16/kex_sidh_cln16.c @@ -241,66 +241,7 @@ cleanup: return ret; } -int OQS_KEX_sidh_cln16_alice_1(OQS_KEX *k, const void *alice_priv, const uint8_t *bob_msg, const size_t bob_msg_len, uint8_t **key, size_t *key_len) { - int ret; - // decompression values - unsigned char *R = NULL, *A = NULL; - - if (!k || !alice_priv || !bob_msg || !key || !key_len) { - return 0; - } - - *key = NULL; - - int compressed = isCompressed(k->named_parameters); - - *key = malloc(SIDH_SHAREDKEY_LEN); - if (*key == NULL) { - goto err; - } - *key_len = SIDH_SHAREDKEY_LEN; - - if (compressed) { - if (bob_msg_len != SIDH_COMPRESSED_PUBKEY_LEN) { - goto err; - } - A = malloc(SIDH_COMPRESSED_A_LEN); - if (A == NULL) { - goto err; - } - R = malloc(SIDH_COMPRESSED_R_LEN); - if (R == NULL) { - goto err; - } - // compute Alice's shared secret - oqs_sidh_cln16_PublicKeyBDecompression_A((unsigned char *) alice_priv, (unsigned char *) bob_msg, R, A, k->ctx); - if (oqs_sidh_cln16_EphemeralSecretAgreement_Compression_A((unsigned char *) alice_priv, R, A, (unsigned char *) *key, k->ctx) != SIDH_CRYPTO_SUCCESS) { - goto err; - } - } else { - if (bob_msg_len != SIDH_PUBKEY_LEN) { - goto err; - } - if (oqs_sidh_cln16_EphemeralSecretAgreement_A((unsigned char *) alice_priv, (unsigned char *) bob_msg, (unsigned char *) *key, k->ctx) != SIDH_CRYPTO_SUCCESS) { - goto err; - } - } - - ret = 1; - goto cleanup; - -err: - ret = 0; - free(*key); - *key = NULL; - -cleanup: - free(A); - free(R); - - return ret; -} void OQS_KEX_sidh_cln16_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) { if (alice_priv) { diff --git a/http/http.pri b/http/http.pri new file mode 100644 index 0000000..4c88864 --- /dev/null +++ b/http/http.pri @@ -0,0 +1,15 @@ +HEADERS += $$PWD/dap_http_client.h \ + $$PWD/dap_http_client_simple.h \ + $$PWD/dap_http_header.h + + +SOURCES += $$PWD/dap_http_client.c \ + $$PWD/dap_http_client_simple.c \ + $$PWD/dap_http_header.c + + +linux-* { + LIBS += -lcurl +} + +INCLUDEPATH += $$PWD diff --git a/libdap.pri b/libdap.pri new file mode 100644 index 0000000..eac25ba --- /dev/null +++ b/libdap.pri @@ -0,0 +1,7 @@ +include (client/client.pri) +include (core/core.pri) +include (crypto/crypto.pri) +include (http/http.pri) + + +INCLUDEPATH += $$PWD -- GitLab