IBR-DTNSuite  0.10
gf128mul.h File Reference
#include <stdlib.h>
#include <string.h>
#include "mode_hdr.h"
Include dependency graph for gf128mul.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TABLES_8K
 
#define GF_BYTE_LEN   16
 
#define tab64k(x)   ((gf_t64k)x)
 
#define xor_64k(i, a, t, r)   xor_block_aligned(r, tab64k(t)[i][a[i]])
 
#define gf_mul_64k(a, t, r)
 
#define tab8k(x)   ((gf_t8k)x)
 
#define xor_8k(i, a, t, r)
 
#define gf_mul_8k(a, t, r)
 
#define tab4k(x)   ((gf_t4k)x)
 
#define xor_4k(i, a, t, r)   mul_x8(r); xor_block_aligned(r, tab4k(t)[a[i]])
 
#define gf_mul_4k(a, t, r)
 
#define tab256(t)   ((gf_t256)t)
 
#define xor_256(i, a, t, r)
 
#define gf_mul_256(a, t, r)
 

Typedefs

typedef uint_32t(* gf_t64k )[256][GF_BYTE_LEN >> 2]
 
typedef uint_32t(* gf_t8k )[16][GF_BYTE_LEN >> 2]
 
typedef uint_32t(* gf_t4k )[GF_BYTE_LEN >> 2]
 
typedef uint_32t(* gf_t256 )[GF_BYTE_LEN >> 2]
 

Functions

void gf_mul (void *a, const void *b)
 
void init_64k_table (unsigned char g[], void *t)
 
void init_8k_table (unsigned char g[], void *t)
 
void init_4k_table (unsigned char g[], void *t)
 
void init_256_table (unsigned char g[], void *t)
 

Variables

const unsigned short gf_tab [256]
 

Macro Definition Documentation

#define GF_BYTE_LEN   16
#define gf_mul_256 (   a,
  t,
 
)
Value:
do { int i = 15; \
move_block_aligned(r,tab256(t)[a[15] & 15]); mul_x4(r); \
xor_block_aligned(r, tab256(t)[a[15] >> 4]); \
while(i--) \
{ xor_256(i, a, t, r); \
} \
move_block_aligned(a, r); \
} while(0)

Definition at line 935 of file gf128mul.h.

#define gf_mul_4k (   a,
  t,
 
)
Value:
do { int i = 15; \
move_block_aligned(r,tab4k(t)[a[15]]); \
while(i--) \
{ xor_4k(i, a, t, r); \
} \
move_block_aligned(a, r); \
} while(0)

Definition at line 846 of file gf128mul.h.

#define gf_mul_64k (   a,
  t,
 
)
Value:
do { \
move_block_aligned(r, tab64k(t)[0][a[0]]); \
xor_64k( 1, a, t, r); \
xor_64k( 2, a, t, r); xor_64k( 3, a, t, r); \
xor_64k( 4, a, t, r); xor_64k( 5, a, t, r); \
xor_64k( 6, a, t, r); xor_64k( 7, a, t, r); \
xor_64k( 8, a, t, r); xor_64k( 9, a, t, r); \
xor_64k(10, a, t, r); xor_64k(11, a, t, r); \
xor_64k(12, a, t, r); xor_64k(13, a, t, r); \
xor_64k(14, a, t, r); xor_64k(15, a, t, r); \
move_block_aligned(a, r); \
} while(0)

Definition at line 672 of file gf128mul.h.

#define gf_mul_8k (   a,
  t,
 
)
Value:
do { int i; \
memcpy(r, tab8k(t)[0][a[0] & 15], GF_BYTE_LEN); \
xor_block_aligned(r, tab8k(t)[1][a[0] >> 4]); \
for(i = 1; i < GF_BYTE_LEN; ++i) \
{ xor_8k(i, a, t, r); \
} \
memcpy(a, r, GF_BYTE_LEN); \
} while(0)

Definition at line 765 of file gf128mul.h.

#define tab256 (   t)    ((gf_t256)t)

Definition at line 879 of file gf128mul.h.

#define tab4k (   x)    ((gf_t4k)x)

Definition at line 798 of file gf128mul.h.

#define tab64k (   x)    ((gf_t64k)x)

Definition at line 636 of file gf128mul.h.

#define tab8k (   x)    ((gf_t8k)x)

Definition at line 712 of file gf128mul.h.

Referenced by init_8k_table().

#define TABLES_8K

Definition at line 52 of file gf128mul.h.

#define xor_256 (   i,
  a,
  t,
 
)
Value:
mul_x4(r); xor_block_aligned(r, tab256(t)[a[i] & 15]); \
mul_x4(r); xor_block_aligned(r, tab256(t)[a[i] >> 4])

Definition at line 880 of file gf128mul.h.

#define xor_4k (   i,
  a,
  t,
 
)    mul_x8(r); xor_block_aligned(r, tab4k(t)[a[i]])

Definition at line 799 of file gf128mul.h.

#define xor_64k (   i,
  a,
  t,
 
)    xor_block_aligned(r, tab64k(t)[i][a[i]])

Definition at line 637 of file gf128mul.h.

#define xor_8k (   i,
  a,
  t,
 
)
Value:
xor_block_aligned(r, tab8k(t)[i + i][a[i] & 15]); \
xor_block_aligned(r, tab8k(t)[i + i + 1][a[i] >> 4])

Definition at line 713 of file gf128mul.h.

Typedef Documentation

typedef uint_32t(* gf_t256)[GF_BYTE_LEN >> 2]

Definition at line 878 of file gf128mul.h.

typedef uint_32t(* gf_t4k)[GF_BYTE_LEN >> 2]

Definition at line 797 of file gf128mul.h.

typedef uint_32t(* gf_t64k)[256][GF_BYTE_LEN >> 2]

Definition at line 635 of file gf128mul.h.

typedef uint_32t(* gf_t8k)[16][GF_BYTE_LEN >> 2]

Definition at line 711 of file gf128mul.h.

Function Documentation

void gf_mul ( void *  a,
const void *  b 
)

Definition at line 106 of file gf128mul.cpp.

References GF_BYTE_LEN, move_block_aligned(), and xor_block_aligned().

Referenced by gcm_compute_tag().

Here is the call graph for this function:

void init_256_table ( unsigned char  g[],
void *  t 
)

Referenced by gcm_init_and_key().

void init_4k_table ( unsigned char  g[],
void *  t 
)

Referenced by gcm_init_and_key().

void init_64k_table ( unsigned char  g[],
void *  t 
)

Referenced by gcm_init_and_key().

void init_8k_table ( unsigned char  g[],
void *  t 
)

Definition at line 175 of file gf128mul.cpp.

References GF_BYTE_LEN, and tab8k.

Referenced by gcm_init_and_key().

Variable Documentation

const unsigned short gf_tab[256]

Definition at line 104 of file gf128mul.cpp.