Exemplo n.º 1
0
void F512(uint32_t *h, uint32_t *m) {
  int i;
  uint32_t roundConstantAddingValue;
  uint32_t roundConstant;
  uint32_t x[2*COLS512];


  for (i = 0; i < 2*COLS512; i++) {
    x[i] = h[i]^m[i];
  }

  roundConstantAddingValue = 0x01010101;
  roundConstant = 0;

  for(i=0;i<10;i++)
  {
  	RND512Q(m, roundConstant);
  	roundConstant += roundConstantAddingValue;
  }

  roundConstant = 0;

  for(i=0;i<10;i++)
  {
  	RND512P(x, roundConstant);
  	roundConstant += roundConstantAddingValue;
  }
				  
  for (i = 0; i < 2*COLS512; i++) {
    h[i] ^= x[i]^m[i];
  }
}
Exemplo n.º 2
0
/* compute compression function (short variants) */
static void F512(uint32_t *h, const uint32_t *m) {
  int i;
  uint32_t Ptmp[2*COLS512];
  uint32_t Qtmp[2*COLS512];
  uint32_t y[2*COLS512];
  uint32_t z[2*COLS512];

  for (i = 0; i < 2*COLS512; i++) {
    z[i] = m[i];
    Ptmp[i] = h[i]^m[i];
  }

  /* compute Q(m) */
  RND512Q((uint8_t*)z, y, 0x00000000);
  RND512Q((uint8_t*)y, z, 0x01000000);
  RND512Q((uint8_t*)z, y, 0x02000000);
  RND512Q((uint8_t*)y, z, 0x03000000);
  RND512Q((uint8_t*)z, y, 0x04000000);
  RND512Q((uint8_t*)y, z, 0x05000000);
  RND512Q((uint8_t*)z, y, 0x06000000);
  RND512Q((uint8_t*)y, z, 0x07000000);
  RND512Q((uint8_t*)z, y, 0x08000000);
  RND512Q((uint8_t*)y, Qtmp, 0x09000000);

  /* compute P(h+m) */
  RND512P((uint8_t*)Ptmp, y, 0x00000000);
  RND512P((uint8_t*)y, z, 0x00000001);
  RND512P((uint8_t*)z, y, 0x00000002);
  RND512P((uint8_t*)y, z, 0x00000003);
  RND512P((uint8_t*)z, y, 0x00000004);
  RND512P((uint8_t*)y, z, 0x00000005);
  RND512P((uint8_t*)z, y, 0x00000006);
  RND512P((uint8_t*)y, z, 0x00000007);
  RND512P((uint8_t*)z, y, 0x00000008);
  RND512P((uint8_t*)y, Ptmp, 0x00000009);

  /* compute P(h+m) + Q(m) + h */
  for (i = 0; i < 2*COLS512; i++) {
    h[i] ^= Ptmp[i]^Qtmp[i];
  }
}
Exemplo n.º 3
0
void Q(uint32_t *h, uint32_t *m)
{
  int i;
  uint32_t roundConstantAddingValue;
  uint32_t roundConstant;

  roundConstantAddingValue = 0x01010101;
  roundConstant = 0;

  for(i=0;i<10;i++)
  {
  	RND512Q(m, roundConstant);
  	roundConstant += roundConstantAddingValue;
  }

  for (i = 0; i < 2*COLS512; i++) {
    h[i] ^= m[i];
  }
}
Exemplo n.º 4
0
/* the compression function (short variants) */
inline void F512(u64 *h, const u64 *m, u64 *c) {		//modified

  u64 y[COLS512] __attribute__((aligned(16)));
  u64 z[COLS512] __attribute__((aligned(16)));
  u64 outQ[COLS512] __attribute__((aligned(16)));
  u64 inP[COLS512] __attribute__((aligned(16)));
  int i,j=0;

//ADDED By Gurpreet
  u64 ml[COLS512] __attribute__((aligned(16)));		//msg_left
  u64 mr[COLS512] __attribute__((aligned(16)));		//msg_right


j=0;
/*divide msg into two 512 blocks*/
      for (i = 0; i < COLS1024; i++) {		//modified
	if(i<COLS512){
    		ml[i] = m[i];
		}
	else {
		mr[j] = m[i];
		j++;
	     }
      }
//---------------
  /* compute c+ml 
             h+mr */
  for (i = 0; i < COLS512; i++) {
    inP[i] = c[i] ^ ml[i];
    z[i] = h[i]^mr[i];
  }

  /* compute Q(h+mr) */
  RND512Q(z,y,U64BIG(0x0000000000000000ull));
  RND512Q(y,z,U64BIG(0x0000000000000001ull));
  RND512Q(z,y,U64BIG(0x0000000000000002ull));
  RND512Q(y,z,U64BIG(0x0000000000000003ull));
  RND512Q(z,y,U64BIG(0x0000000000000004ull));
  RND512Q(y,z,U64BIG(0x0000000000000005ull));
  RND512Q(z,y,U64BIG(0x0000000000000006ull));
  RND512Q(y,z,U64BIG(0x0000000000000007ull));
  RND512Q(z,y,U64BIG(0x0000000000000008ull));
  RND512Q(y,outQ,U64BIG(0x0000000000000009ull));
	
  /* compute P(c+ml) */
  RND512P(inP,y,U64BIG(0x0000000000000000ull));
  RND512P(y,z,  U64BIG(0x0100000000000000ull));
  RND512P(z,y,  U64BIG(0x0200000000000000ull));
  RND512P(y,z,  U64BIG(0x0300000000000000ull));
  RND512P(z,y,  U64BIG(0x0400000000000000ull));
  RND512P(y,z,  U64BIG(0x0500000000000000ull));
  RND512P(z,y,  U64BIG(0x0600000000000000ull));
  RND512P(y,z,  U64BIG(0x0700000000000000ull));
  RND512P(z,y,  U64BIG(0x0800000000000000ull));
  RND512P(y,inP,  U64BIG(0x0900000000000000ull));
	
//ADDED by GURPREET 
  /* compute P(c+ml) + Q(h+mr) */
  for (i = 0; i < COLS512; i++) {
    inP[i] = inP[i]^outQ[i];
  }

  /* compute P(P(h+ml) + Q(h+mr)) */
  RND512P(inP,z,U64BIG(0x0000000000000000ull));
  RND512P(z,y,  U64BIG(0x0100000000000000ull));
  RND512P(y,z,  U64BIG(0x0200000000000000ull));
  RND512P(z,y,  U64BIG(0x0300000000000000ull));
  RND512P(y,z,  U64BIG(0x0400000000000000ull));
  RND512P(z,y,  U64BIG(0x0500000000000000ull));
  RND512P(y,z,  U64BIG(0x0600000000000000ull));
  RND512P(z,y,  U64BIG(0x0700000000000000ull));
  RND512P(y,z,  U64BIG(0x0800000000000000ull));
  RND512P(z,inP,  U64BIG(0x0900000000000000ull));

  /* compute P(P(h+ml) + Q(h+mr)) + Q(h+mr) + h */
#pragma vector aligned
  for (i = 0; i < COLS512; i++) {
    h[i] ^= inP[i] ^ outQ[i];
  }
}