-
Notifications
You must be signed in to change notification settings - Fork 95
Home
WANG,Xiao edited this page Jul 18, 2017
·
3 revisions
PRG is implemented as AES-NI in the CTR mode. Usage is presented as the following code sample.
PRG prg;//using a secure random seed
int rand_int, rand_ints[100];
block rand_block[3];
mpz_t integ;mpz_init(integ);
prg.random_data(&rand_int, sizeof(rand_int)); //fill rand_int with 32 random bits
prg.random_block(rand_block, 3); //fill rand_block with 128*3 random bits
prg.reseed(&rand_block[1]); //reset the seed and counter in prg
prg.random_data_unaligned(rand_ints+2, sizeof(int)*98); //when the array is not 128-bit-aligned
prg.random_mpz(integ, 1024); //random number with 1024 bits.
Implemented based on AES-NI. Code sample:
PRP prp();//using a public, fixed seed by default
block rand_block[3], b3[3];
int rand_ints[100];
prp.permute_block(rand_block, 3);//applying pi on each block of data
prp.permute_data(rand_ints, sizeof(int)*100);
block b2 = prp.H(rand_block[1], 1); //b2 = pi(r)\xor r, where r = doubling(random_block)\xor 1
prp.H<3>(b3, rand_block, 0);