cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
Macros
aesopt.h File Reference
#include "crypt/aes.h"
#include "crypt/brg_endian.h"

Go to the source code of this file.

Macros

#define ENCRYPTION_IN_C   1
 
#define DECRYPTION_IN_C   2
 
#define ENC_KEYING_IN_C   4
 
#define DEC_KEYING_IN_C   8
 
#define NO_TABLES   0
 
#define ONE_TABLE   1
 
#define FOUR_TABLES   4
 
#define NONE   0
 
#define PARTIAL   1
 
#define FULL   2
 
#define ALGORITHM_BYTE_ORDER   PLATFORM_BYTE_ORDER
 
#define SAFE_IO
 
#define ENC_UNROLL   FULL
 
#define DEC_UNROLL   FULL
 
#define FF_TABLES
 
#define ARRAYS
 
#define FIXED_TABLES
 
#define to_byte(x)   ((x) & 0xff)
 
#define ENC_ROUND   FOUR_TABLES
 
#define LAST_ENC_ROUND   FOUR_TABLES
 
#define DEC_ROUND   FOUR_TABLES
 
#define LAST_DEC_ROUND   FOUR_TABLES
 
#define KEY_SCHED   FOUR_TABLES
 
#define s(x, c)   x[c]
 
#define EFUNCS_IN_C   0
 
#define DFUNCS_IN_C   0
 
#define FUNCS_IN_C   ( EFUNCS_IN_C | DFUNCS_IN_C )
 
#define RC_LENGTH   (5 * (AES_BLOCK_SIZE / 4 - 2))
 
#define brot(x, n)   (((uint_32t)(x) << n) | ((uint_32t)(x) >> (32 - n)))
 
#define aes_sw32(x)   ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00))
 
#define upr(x, n)   (((uint_32t)(x) << (8 * (n))) | ((uint_32t)(x) >> (32 - 8 * (n))))
 
#define ups(x, n)   ((uint_32t) (x) << (8 * (n)))
 
#define bval(x, n)   to_byte((x) >> (8 * (n)))
 
#define bytes2word(b0, b1, b2, b3)   (((uint_32t)(b3) << 24) | ((uint_32t)(b2) << 16) | ((uint_32t)(b1) << 8) | (b0))
 
#define upr(x, n)   (((uint_32t)(x) >> (8 * (n))) | ((uint_32t)(x) << (32 - 8 * (n))))
 
#define ups(x, n)   ((uint_32t) (x) >> (8 * (n)))
 
#define bval(x, n)   to_byte((x) >> (24 - 8 * (n)))
 
#define bytes2word(b0, b1, b2, b3)   (((uint_32t)(b0) << 24) | ((uint_32t)(b1) << 16) | ((uint_32t)(b2) << 8) | (b3))
 
#define word_in(x, c)
 
#define word_out(x, c, v)
 
#define WPOLY   0x011b
 
#define BPOLY   0x1b
 
#define m1   0x80808080
 
#define m2   0x7f7f7f7f
 
#define gf_mulx(x)   ((((x) & m2) << 1) ^ ((((x) & m1) >> 7) * BPOLY))
 
#define no_table(x, box, vf, rf, c)
 
#define one_table(x, op, tab, vf, rf, c)
 
#define four_tables(x, tab, vf, rf, c)
 
#define vf1(x, r, c)   (x)
 
#define rf1(r, c)   (r)
 
#define rf2(r, c)   ((8+r-c)&3)
 
#define dec_fmvars   uint_32t g2
 
#define fwd_mcol(x)   (g2 = gf_mulx(x), g2 ^ upr((x) ^ g2, 3) ^ upr((x), 2) ^ upr((x), 1))
 
#define dec_imvars   uint_32t g2, g4, g9
 
#define inv_mcol(x)
 
#define ls_box(x, c)   no_table(x,t_use(s,box),vf1,rf2,c)
 

Macro Definition Documentation

#define aes_sw32 (   x)    ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00))

Definition at line 555 of file aesopt.h.

#define ALGORITHM_BYTE_ORDER   PLATFORM_BYTE_ORDER

Definition at line 198 of file aesopt.h.

#define ARRAYS

Definition at line 340 of file aesopt.h.

#define BPOLY   0x1b

Definition at line 607 of file aesopt.h.

#define brot (   x,
  n 
)    (((uint_32t)(x) << n) | ((uint_32t)(x) >> (32 - n)))

Definition at line 554 of file aesopt.h.

#define bval (   x,
  n 
)    to_byte((x) >> (8 * (n)))

Definition at line 580 of file aesopt.h.

#define bval (   x,
  n 
)    to_byte((x) >> (24 - 8 * (n)))

Definition at line 580 of file aesopt.h.

#define bytes2word (   b0,
  b1,
  b2,
  b3 
)    (((uint_32t)(b3) << 24) | ((uint_32t)(b2) << 16) | ((uint_32t)(b1) << 8) | (b0))

Definition at line 581 of file aesopt.h.

#define bytes2word (   b0,
  b1,
  b2,
  b3 
)    (((uint_32t)(b0) << 24) | ((uint_32t)(b1) << 16) | ((uint_32t)(b2) << 8) | (b3))

Definition at line 581 of file aesopt.h.

#define dec_fmvars   uint_32t g2

Definition at line 735 of file aesopt.h.

#define dec_imvars   uint_32t g2, g4, g9

Definition at line 744 of file aesopt.h.

#define DEC_KEYING_IN_C   8

Definition at line 155 of file aesopt.h.

#define DEC_ROUND   FOUR_TABLES

Definition at line 414 of file aesopt.h.

#define DEC_UNROLL   FULL

Definition at line 316 of file aesopt.h.

#define DECRYPTION_IN_C   2

Definition at line 153 of file aesopt.h.

#define DFUNCS_IN_C   0

Definition at line 505 of file aesopt.h.

#define EFUNCS_IN_C   0

Definition at line 494 of file aesopt.h.

#define ENC_KEYING_IN_C   4

Definition at line 154 of file aesopt.h.

#define ENC_ROUND   FOUR_TABLES

Definition at line 398 of file aesopt.h.

#define ENC_UNROLL   FULL

Definition at line 308 of file aesopt.h.

#define ENCRYPTION_IN_C   1

Definition at line 152 of file aesopt.h.

#define FF_TABLES

Definition at line 329 of file aesopt.h.

#define FIXED_TABLES

Definition at line 350 of file aesopt.h.

#define FOUR_TABLES   4

Definition at line 159 of file aesopt.h.

#define four_tables (   x,
  tab,
  vf,
  rf,
 
)
Value:
( tab[0][bval(vf(x,0,c),rf(0,c))] \
^ tab[1][bval(vf(x,1,c),rf(1,c))] \
^ tab[2][bval(vf(x,2,c),rf(2,c))] \
^ tab[3][bval(vf(x,3,c),rf(3,c))])

Definition at line 717 of file aesopt.h.

#define FULL   2

Definition at line 162 of file aesopt.h.

#define FUNCS_IN_C   ( EFUNCS_IN_C | DFUNCS_IN_C )

Definition at line 515 of file aesopt.h.

#define fwd_mcol (   x)    (g2 = gf_mulx(x), g2 ^ upr((x) ^ g2, 3) ^ upr((x), 2) ^ upr((x), 1))

Definition at line 736 of file aesopt.h.

#define gf_mulx (   x)    ((((x) & m2) << 1) ^ ((((x) & m1) >> 7) * BPOLY))

Definition at line 613 of file aesopt.h.

#define inv_mcol (   x)
Value:
(g2 = gf_mulx(x), g4 = gf_mulx(g2), g9 = (x) ^ gf_mulx(g4), g4 ^= g9, \
(x) ^ g2 ^ g4 ^ upr(g2 ^ g9, 3) ^ upr(g4, 2) ^ upr(g9, 1))

Definition at line 745 of file aesopt.h.

#define KEY_SCHED   FOUR_TABLES

Definition at line 434 of file aesopt.h.

#define LAST_DEC_ROUND   FOUR_TABLES

Definition at line 422 of file aesopt.h.

#define LAST_ENC_ROUND   FOUR_TABLES

Definition at line 406 of file aesopt.h.

#define ls_box (   x,
 
)    no_table(x,t_use(s,box),vf1,rf2,c)

Definition at line 758 of file aesopt.h.

#define m1   0x80808080

Definition at line 611 of file aesopt.h.

#define m2   0x7f7f7f7f

Definition at line 612 of file aesopt.h.

#define no_table (   x,
  box,
  vf,
  rf,
 
)
Value:
box[bval(vf(x,0,c),rf(0,c))], \
box[bval(vf(x,1,c),rf(1,c))], \
box[bval(vf(x,2,c),rf(2,c))], \
box[bval(vf(x,3,c),rf(3,c))])

Definition at line 705 of file aesopt.h.

#define NO_TABLES   0

Definition at line 157 of file aesopt.h.

#define NONE   0

Definition at line 160 of file aesopt.h.

#define ONE_TABLE   1

Definition at line 158 of file aesopt.h.

#define one_table (   x,
  op,
  tab,
  vf,
  rf,
 
)
Value:
( tab[bval(vf(x,0,c),rf(0,c))] \
^ op(tab[bval(vf(x,1,c),rf(1,c))],1) \
^ op(tab[bval(vf(x,2,c),rf(2,c))],2) \
^ op(tab[bval(vf(x,3,c),rf(3,c))],3))

Definition at line 711 of file aesopt.h.

#define PARTIAL   1

Definition at line 161 of file aesopt.h.

#define RC_LENGTH   (5 * (AES_BLOCK_SIZE / 4 - 2))

Definition at line 519 of file aesopt.h.

#define rf1 (   r,
 
)    (r)

Definition at line 724 of file aesopt.h.

#define rf2 (   r,
 
)    ((8+r-c)&3)

Definition at line 725 of file aesopt.h.

#define s (   x,
 
)    x[c]

Definition at line 482 of file aesopt.h.

#define SAFE_IO

Definition at line 293 of file aesopt.h.

#define to_byte (   x)    ((x) & 0xff)

Definition at line 361 of file aesopt.h.

#define upr (   x,
  n 
)    (((uint_32t)(x) << (8 * (n))) | ((uint_32t)(x) >> (32 - 8 * (n))))

Definition at line 578 of file aesopt.h.

#define upr (   x,
  n 
)    (((uint_32t)(x) >> (8 * (n))) | ((uint_32t)(x) << (32 - 8 * (n))))

Definition at line 578 of file aesopt.h.

#define ups (   x,
  n 
)    ((uint_32t) (x) << (8 * (n)))

Definition at line 579 of file aesopt.h.

#define ups (   x,
  n 
)    ((uint_32t) (x) >> (8 * (n)))

Definition at line 579 of file aesopt.h.

#define vf1 (   x,
  r,
 
)    (x)

Definition at line 723 of file aesopt.h.

#define word_in (   x,
 
)
Value:
bytes2word(((const uint_8t*)(x)+4*c)[0], ((const uint_8t*)(x)+4*c)[1], \
((const uint_8t*)(x)+4*c)[2], ((const uint_8t*)(x)+4*c)[3])

Definition at line 587 of file aesopt.h.

#define word_out (   x,
  c,
 
)
Value:
{ ((uint_8t*)(x)+4*c)[0] = bval(v,0); ((uint_8t*)(x)+4*c)[1] = bval(v,1); \
((uint_8t*)(x)+4*c)[2] = bval(v,2); ((uint_8t*)(x)+4*c)[3] = bval(v,3); }

Definition at line 589 of file aesopt.h.

#define WPOLY   0x011b

Definition at line 606 of file aesopt.h.