int main() { initHash(num_page); //init hash function char Target[800]="A"; int Threshold=4; time_t Start1,End1; //time_t Start2,End2; //initFreebase(); time(&Start1); join1(Target,Threshold); time(&End1); printf("Join 1 Used Time is:%d\n",(int)difftime(End1,Start1)); /*time(&Start2); join2(Target,Threshold); time(&End2); printf("Join 2 Used Time is:%d\n",(int)difftime(End2,Start2));*/ return 0; }
int keccak(char **in_e, int inlen, uint8_t **md, int rsiz) { __m128i aux[10]; int i; const ALIGN uint64_t RC[100] = { 0x0000000000000001,0x0000000000000001, 0x0000000000008082,0x0000000000008082, 0x800000000000808A,0x800000000000808A, 0x8000000080008000,0x8000000080008000, 0x000000000000808B,0x000000000000808B, 0x0000000080000001,0x0000000080000001, 0x8000000080008081,0x8000000080008081, 0x8000000000008009,0x8000000000008009, 0x000000000000008A,0x000000000000008A, 0x0000000000000088,0x0000000000000088, 0x0000000080008009,0x0000000080008009, 0x000000008000000A,0x000000008000000A, 0x000000008000808B,0x000000008000808B, 0x800000000000008B,0x800000000000008B, 0x8000000000008089,0x8000000000008089, 0x8000000000008003,0x8000000000008003, 0x8000000000008002,0x8000000000008002, 0x8000000000000080,0x8000000000000080, 0x000000000000800A,0x000000000000800A, 0x800000008000000A,0x800000008000000A, 0x8000000080008081,0x8000000080008081, 0x8000000000008080,0x8000000000008080, 0x0000000080000001,0x0000000080000001, 0x8000000080008008,0x8000000080008008 }; ALIGN uint8_t temp[2][144]; int j,l=0,it=0; __m128i s[28],ain[8]; __m128i auxl[5]; char* con[32]; char* in[2]; int t,g,gf; in[0]=in_e[0]; in[1]=in_e[1]; init_S_zeros(j); if(inlen >= rsiz ){ it = inlen / rsiz; } switch (rsiz){ case 136: t = 8; g = 128; gf = 144; break; case 104: t = 6; g = 96; gf = 112; break; case 72: t = 4; g = 64; gf = 80; break; } for(i=0;i<it/2;i++){ join1(in,j,t); keccakf(s,j); in[0] += g; in[1] += g; join2(in,j,t); keccakf(s,j); in[0] += gf; in[1] += gf; } if(it%2 != 0 ){ join1(in,j,t); keccakf(s,j); in[0] += rsiz; in[1] += rsiz; } inlen = inlen - it * rsiz; for(i=0;i<2;i++){ memset(temp[i], 0, 144*sizeof(uint8_t)); memcpy(temp[i], in[i], inlen); temp[i][inlen] = 0x06; inlen++; temp[i][rsiz - 1] |= 0x80; } join_last(j,t); keccakf(s,j); switch (rsiz){ case 136: back(j,1); store(md[0],0,s[0]); store(md[0],1,s[2]); store(md[1],0,s[1]); store(md[1],1,s[3]); break; case 104: back(j,2); store(md[0],0,s[0]); store(md[0],1,s[2]); store(md[1],0,s[1]); store(md[1],1,s[3]); store(md[0],2,s[4]); store(md[0],3,s[6]); store(md[1],2,s[5]); store(md[1],3,s[7]); break; case 72: back(j,2); store(md[0],0,s[0]); store(md[0],1,s[2]); store(md[1],0,s[1]); store(md[1],1,s[3]); store(md[0],2,s[4]); store(md[0],3,s[6]); store(md[1],2,s[5]); store(md[1],3,s[7]); break; } return 0; }