Photo

Algorithmic Cryptanalysis

External Links

  • Libraries & Programs
  • Readings
  • IACR
  • Cryptographer's world
  • CRC Press
  • Book on CRC Press
  • Author's home page
  • Other Links
Mon Dec 17 04:05:32 2018

Algorithmic Cryptanalysis (View it on amazon.com)

A CRC Press Book by Antoine Joux

Program 3.3: Matrix multiplication with fast scalar product

Creative Commons License
Algorithmic cryptanalysis codes by Antoine Joux are licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
void Mul(WORD res[DIM], WORD mat1[DIM], WORD mat2[DIM])
{

  int l,c,k;
  WORD val,mask;
  for (l=0;l<DIM;l++) res[l]=0;

  for (c=0;c<DIM;c++) { mask=0;

    for (k=0;k<DIM;k++) {
      mask^=(bit(mat2,k,c)<<k);
    }

    for (l=0;l<DIM;l++) {
      val=mat1[l]&mask;

      val^=(val>>16); val^=(val>>8);
      val^=(val>>4);  val^=(val>>2);

      val^=(val>>1);
      if (val&1) flipbit(res,l,c); 
    }
  }
}

Credits for page styles: Dynamic Drive CSS Library