Photo

Algorithmic Cryptanalysis

External Links

  • Libraries & Programs
  • Readings
  • IACR
  • Cryptographer's world
  • CRC Press
  • Book on CRC Press
  • Author's home page
  • Other Links
Fri Nov 22 02:43:33 2024

Algorithmic Cryptanalysis (View it on amazon.com)

A CRC Press Book by Antoine Joux

Program 3.7: Elementary matrix multiplication over GF(p)

Creative Commons License
Algorithmic cryptanalysis codes by Antoine Joux are licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
#include <stdio.h>
#include <stdlib.h>

#define TYPE unsigned short
#define MODULO 46337 /* Also works with primes up to 65521*/
#define access(M,i,j,size) M[(i)+((j)*(size))]

void matmul(TYPE * A, TYPE * B, TYPE *Res, int size) {

  int i,j,k;
  unsigned int tmp;
  
  for(i=0;i<size;i++) 
    for(j=0;j<size;j++) {

      tmp=0;
      for(k=0;k<size;k++) {

        tmp=(tmp+access(A,i,k,size)*access(B,k,j,size))%MODULO;
      }

      access(Res,i,j,size)=tmp;
    }
}

Credits for page styles: Dynamic Drive CSS Library