mirror of
https://github.com/encryptogroup/PSI.git
synced 2024-03-22 13:30:44 +08:00
Various changes
This commit is contained in:
parent
f1d6cb10a1
commit
0deb7637c6
|
@ -45,20 +45,24 @@ void crypto::init(uint32_t symsecbits, uint8_t* seed) {
|
|||
aes_hash_buf_y1 = (uint8_t*) malloc(AES_BYTES);
|
||||
aes_hash_buf_y2 = (uint8_t*) malloc(AES_BYTES);
|
||||
|
||||
sha_hash_buf = (uint8_t*) malloc((secparam.symbits >> 3 ) * 2);
|
||||
|
||||
if(secparam.symbits == ST.symbits) {
|
||||
if (secparam.symbits == ST.symbits) {
|
||||
hash_routine = &sha1_hash;
|
||||
} else if(secparam.symbits == MT.symbits) {
|
||||
sha_hash_buf = (uint8_t*) malloc(SHA1_OUT_BYTES);
|
||||
} else if (secparam.symbits == MT.symbits) {
|
||||
hash_routine = &sha256_hash;
|
||||
} else if(secparam.symbits == LT.symbits) {
|
||||
sha_hash_buf = (uint8_t*) malloc(SHA256_OUT_BYTES);
|
||||
} else if (secparam.symbits == LT.symbits) {
|
||||
hash_routine = &sha256_hash;
|
||||
} else if(secparam.symbits == XLT.symbits) {
|
||||
sha_hash_buf = (uint8_t*) malloc(SHA256_OUT_BYTES);
|
||||
} else if (secparam.symbits == XLT.symbits) {
|
||||
hash_routine = &sha512_hash;
|
||||
} else if(secparam.symbits == XXLT.symbits) {
|
||||
sha_hash_buf = (uint8_t*) malloc(SHA512_OUT_BYTES);
|
||||
} else if (secparam.symbits == XXLT.symbits) {
|
||||
hash_routine = &sha512_hash;
|
||||
sha_hash_buf = (uint8_t*) malloc(SHA512_OUT_BYTES);
|
||||
} else {
|
||||
hash_routine = &sha256_hash;
|
||||
sha_hash_buf = (uint8_t*) malloc(SHA256_OUT_BYTES);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#define AES_BYTES 16
|
||||
#define AES_BITS AES_BYTES*8
|
||||
|
||||
#define SHA1_OUT_BYTES 20
|
||||
#define SHA256_OUT_BYTES 32
|
||||
#define SHA512_OUT_BYTES 64
|
||||
|
||||
const uint8_t ZERO_IV[AES_BYTES]={0};
|
||||
|
||||
const uint8_t const_seed[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
|
||||
|
@ -133,7 +137,7 @@ static void InitAndReadCodeWord(REGISTER_SIZE*** codewords) {
|
|||
uint32_t ncodewords = m_nCodeWordBits;
|
||||
uint32_t ncwintlen = 8;
|
||||
*codewords = (REGISTER_SIZE**) malloc(sizeof(REGISTER_SIZE*) * ncodewords);
|
||||
for(uint32_t i = 0; i < m_nCodewords; i++) {
|
||||
for(uint32_t i = 0; i < ncodewords; i++) {
|
||||
(*codewords)[i] = (REGISTER_SIZE*) malloc(sizeof(REGISTER_SIZE) * ((ncwintlen * sizeof(uint32_t)) / sizeof(REGISTER_SIZE)));
|
||||
}
|
||||
readCodeWords(*codewords);
|
||||
|
|
|
@ -186,7 +186,7 @@ void prime_field::init(seclvl sp, uint8_t* seed) {
|
|||
mpz_init(rnd_seed);
|
||||
secparam = sp;
|
||||
|
||||
mpz_import(rnd_seed, secparam.symbits, 1, sizeof((seed)[0]), 0, 0, seed);
|
||||
mpz_import(rnd_seed, ceil_divide(secparam.symbits, 8), 1, sizeof((seed)[0]), 0, 0, seed);
|
||||
|
||||
if (secparam.ifcbits == ST.ifcbits) {
|
||||
mpz_set_str(p, ifcp1024, 16);
|
||||
|
@ -204,7 +204,7 @@ void prime_field::init(seclvl sp, uint8_t* seed) {
|
|||
{
|
||||
mpz_set_str(p, ifcp3072, 10);
|
||||
mpz_set_str(g, ifcg3072, 10);
|
||||
mpz_set_str(q, ifcq1024, 10);
|
||||
mpz_set_str(q, ifcq3072, 10);
|
||||
}
|
||||
|
||||
//TODO it would be better not to GMP's internal random generator, since it is not secure
|
||||
|
|
Loading…
Reference in New Issue
Block a user