Merge pull request #3 from lenerd/lenerd/fix-glibc-conflict

Fix multiple bugs
This commit is contained in:
Oleksandr Tkachenko 2019-04-09 17:41:15 +02:00 committed by GitHub
commit e5057094ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 52 additions and 17 deletions

View File

@ -155,6 +155,7 @@ void *gen_cuckoo_entries(void *ctx_void) {
for(i = ctx->startpos; i < ctx->endpos; i++, eleptr+=inbytelen) {
gen_cuckoo_entry(eleptr, ctx->cuckoo_entries + i, hs, i);
}
return NULL;
}

View File

@ -112,6 +112,7 @@ void *gen_entries(void *ctx_tmp) {
}
free(tmpbuf);
free(address);
return NULL;
}
inline void insert_element(sht_ctx* table, uint8_t* element, uint32_t* address, uint8_t* tmpbuf, hs_t* hs) {

View File

@ -587,6 +587,7 @@ void *otpsi_query_hash_table(void* ctx_tmp) {//GHashTable *map, uint8_t* element
free(matches);
//return size_intersect;
return NULL;
}
//TODO if this works correctly, combine with other find intersection methods and outsource to hashing_util.h
@ -717,6 +718,7 @@ void print_bin_content(uint8_t* hash_table, uint32_t nbins, uint32_t elebytelen,
void *receive_masks(void *ctx_tmp) {
mask_rcv_ctx* ctx = (mask_rcv_ctx*) ctx_tmp;
ctx->sock->Receive(ctx->rcv_buf, ctx->maskbytelen * ctx->nmasks);
return NULL;
}
uint32_t get_stash_size(uint32_t neles) {

View File

@ -17,6 +17,8 @@
#define DEFAULT_BITSIZE 128
typedef int BOOL; // as in Miracl
static const uint8_t REVERSE_NIBBLE_ORDER[16] =
{0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE, 0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF};

View File

@ -7,6 +7,10 @@
#include "ecc-pk-crypto.h"
#include "../../externals/miracl_lib/ecn.h"
#include "../../externals/miracl_lib/big.h"
#include "../../externals/miracl_lib/ec2.h"
char *ecx163 = (char *) "2fe13c0537bbc11acaa07d793de4e6d5e5c94eee8";
char *ecy163 = (char *) "289070fb05d38ff58321f2e800536d538ccdaa3d9";
@ -203,6 +207,13 @@ void ecc_fe::sample_fe_from_bytes(uint8_t* buf, uint32_t bytelen) {
}
void ecc_fe::print() {
cout << (*val) << endl;
}
void ecc_fe::init() {
val = new EC2();
}
ecc_num::ecc_num(ecc_field* fld) {
@ -245,20 +256,34 @@ void ecc_num::export_to_bytes(uint8_t* buf, uint32_t field_size_bytes) {
big_to_bytes ((int32_t) field_size_bytes, val->getbig(), (char*) buf, true);
}
void ecc_num::print() {
cout << (*val) << endl;
}
// ecc_brickexp methods
struct ecc_brickexp::ecc_brickexp_impl {
ebrick2 br;
};
ecc_brickexp::ecc_brickexp(fe* point, ecc_fparams* fparams) {
Big x, y;
fe2ec2(point)->getxy(x, y);
ebrick2_init(&br, x.getbig(), y.getbig(), fparams->BA->getbig(), fparams->BB->getbig(),
fparams->m, fparams->a, fparams->b, fparams->c, 8, fparams->secparam);
impl = std::make_unique<ecc_brickexp_impl>();
ebrick2_init(&impl->br, x.getbig(), y.getbig(), fparams->BA->getbig(),
fparams->BB->getbig(), fparams->m, fparams->a, fparams->b,
fparams->c, 8, fparams->secparam);
}
ecc_brickexp::~ecc_brickexp() {
ebrick2_end(&impl->br);
}
void ecc_brickexp::pow(fe* result, num* e)
{
Big xtmp, ytmp;
mul2_brick(&br, num2Big(e)->getbig(), xtmp.getbig(), ytmp.getbig());
mul2_brick(&impl->br, num2Big(e)->getbig(), xtmp.getbig(), ytmp.getbig());
*fe2ec2(result) = EC2(xtmp, ytmp);
}

View File

@ -9,10 +9,11 @@
#define ECC_PK_CRYPTO_H_
#include "pk-crypto.h"
#include <memory>
#include "../../externals/miracl_lib/ecn.h"
#include "../../externals/miracl_lib/big.h"
#include "../../externals/miracl_lib/ec2.h"
// forward declarations
class Big;
class EC2;
#define fe2ec2(fieldele) (((ecc_fe*) (fieldele))->get_val())
@ -94,7 +95,7 @@ public:
void export_to_bytes(uint8_t* buf, uint32_t field_size_bytes);
void import_from_bytes(uint8_t* buf, uint32_t field_size_bytes);
void set_rnd(uint32_t bits);
void print() {cout << (*val) << endl;};
void print();
private:
Big* val;
@ -118,11 +119,11 @@ public:
void import_from_bytes(uint8_t* buf);
void sample_fe_from_bytes(uint8_t* buf, uint32_t bytelen);
void print() {cout << (*val) << endl;};
void print();
private:
void init() {val = new EC2();};
void init();
EC2* val;
ecc_field* field;
};
@ -130,11 +131,12 @@ private:
class ecc_brickexp : public brickexp {
public:
ecc_brickexp(fe* point, ecc_fparams* fparams);
~ecc_brickexp() {ebrick2_end(&br);}
~ecc_brickexp();
void pow(fe* res, num* e);
private:
ebrick2 br;
struct ecc_brickexp_impl; // used to hide MIRACL's ebrick2 type in the implementation
std::unique_ptr<ecc_brickexp_impl> impl;
};
void point_to_byte(uint8_t* pBufIdx, uint32_t field_size_bytes, EC2* to_export);

View File

@ -18,7 +18,7 @@ class brickexp;
class pk_crypto {
public:
pk_crypto(seclvl sp, uint8_t* seed){};
~pk_crypto(){};
virtual ~pk_crypto(){};
virtual num* get_num() = 0;
virtual num* get_rnd_num(uint32_t bitlen=0) = 0;
virtual fe* get_fe() = 0;
@ -45,7 +45,7 @@ protected:
class num {
public:
num(){};
~num(){};
virtual ~num(){};
virtual void set(num* src) = 0;
virtual void set_si(int32_t src) = 0;
virtual void set_add(num* a, num* b) = 0;
@ -60,7 +60,7 @@ public:
class fe {
public:
fe(){};
~fe(){};
virtual ~fe(){};
virtual void set(fe* src) = 0;
virtual void set_mul(fe* a, fe* b) = 0;
virtual void set_pow(fe* b, num* e) = 0;
@ -78,7 +78,7 @@ protected:
class brickexp {
public:
brickexp(){};
~brickexp(){};
virtual ~brickexp(){};
virtual void pow(fe* result, num* e) = 0;
};

View File

@ -23,7 +23,7 @@ class BaseOT
{
public:
BaseOT(crypto* crypt, field_type ftype){m_cCrypto = crypt; m_cPKCrypto = crypt->gen_field(ftype); };
~BaseOT(){delete m_cPKCrypto; };
virtual ~BaseOT(){delete m_cPKCrypto; };
virtual void Sender(uint32_t nSndVals, uint32_t nOTs, CSocket* sock, uint8_t* ret) = 0;
virtual void Receiver(uint32_t nSndVals, uint32_t uint32_t, CBitVector& choices, CSocket* sock, uint8_t* ret) = 0;

View File

@ -1,5 +1,7 @@
#include "kk-ot-extension.h"
#define TRUE 1 // as in Miracl
/*
* ---------------------------------- OT Extension Sender Part --------------------------------------
*/

View File

@ -81,7 +81,7 @@ void NaorPinkas::Receiver(uint32_t nSndVals, uint32_t nOTs, CBitVector& choices,
delete bc;//BrickDelete(&bc);
delete bg;//BrickDelete(&bg);
delete [] pBuf;
free(pBuf);
free(PK_sigma);
free(pDec);
free(pC);