aesopt.h File Reference
`#include "aes.h"`
`#include "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 | ENC_KS_UNROLL
#define | DEC_KS_UNROLL
#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 | AES_REV_DKS
#define | s(x, c) x[c]
#define | EFUNCS_IN_C ( ENCRYPTION_IN_C | ENC_KEYING_IN_C )
#define | DFUNCS_IN_C ( DECRYPTION_IN_C | DEC_KEYING_IN_C )
#define | FUNCS_IN_C ( EFUNCS_IN_C | DFUNCS_IN_C )
#define | RC_LENGTH (5 * (AES_BLOCK_SIZE / 4 - 2))
#define | brot(x, n) (((uint32_t)(x) << n) | ((uint32_t)(x) >> (32 - n)))
#define | aes_sw32(x) ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00))
#define | word_in(x, c)
#define | word_out(x, c, v)
#define | WPOLY 0x011b
#define | BPOLY 0x1b
#define | gf_c1 0x80808080
#define | gf_c2 0x7f7f7f7f
#define | gf_mulx(x) ((((x) & gf_c2) << 1) ^ ((((x) & gf_c1) >> 7) * BPOLY))
#define | FT4_SET
#define | FL4_SET
#define | IT4_SET
#define | IL4_SET
#define | IM4_SET
#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 uint32_t g2
#define | fwd_mcol(x) (g2 = gf_mulx(x), g2 ^ upr((x) ^ g2, 3) ^ upr((x), 2) ^ upr((x), 1))
#define | inv_mcol(x) four_tables(x,t_use(i,m),vf1,rf1,0)
#define | ls_box(x, c) four_tables(x,t_use(f,l),vf1,rf2,c)

## Macro Definition Documentation

## AES_REV_DKS

#define AES_REV_DKS

## aes_sw32

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

## ALGORITHM_BYTE_ORDER

#define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER

## ARRAYS

#define ARRAYS

## BPOLY

#define BPOLY 0x1b

## brot

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

## dec_fmvars

#define dec_fmvars uint32_t g2

## DEC_KEYING_IN_C

#define DEC_KEYING_IN_C 8

## DEC_KS_UNROLL

#define DEC_KS_UNROLL

## DEC_ROUND

#define DEC_ROUND FOUR_TABLES

## DEC_UNROLL

#define DEC_UNROLL FULL

## DECRYPTION_IN_C

#define DECRYPTION_IN_C 2

## DFUNCS_IN_C

#define DFUNCS_IN_C ( DECRYPTION_IN_C | DEC_KEYING_IN_C )

## EFUNCS_IN_C

#define EFUNCS_IN_C ( ENCRYPTION_IN_C | ENC_KEYING_IN_C )

## ENC_KEYING_IN_C

#define ENC_KEYING_IN_C 4

## ENC_KS_UNROLL

#define ENC_KS_UNROLL

## ENC_ROUND

#define ENC_ROUND FOUR_TABLES

## ENC_UNROLL

#define ENC_UNROLL FULL

## ENCRYPTION_IN_C

#define ENCRYPTION_IN_C 1

## FF_TABLES

#define FF_TABLES

## FIXED_TABLES

#define FIXED_TABLES

## FL4_SET

#define FL4_SET

## FOUR_TABLES

#define FOUR_TABLES 4

## four_tables

#define four_tables | ( |  | x,
|  |  | tab,
|  |  | vf,
|  |  | rf,
|  |  | c
| ) |  |

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))])

## FT4_SET

#define FT4_SET

## FULL

#define FULL 2

## FUNCS_IN_C

#define FUNCS_IN_C ( EFUNCS_IN_C | DFUNCS_IN_C )

## fwd_mcol

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

## gf_c1

#define gf_c1 0x80808080

## gf_c2

#define gf_c2 0x7f7f7f7f

## gf_mulx

#define gf_mulx | ( |  | x | ) | ((((x) & gf_c2) << 1) ^ ((((x) & gf_c1) >> 7) * BPOLY))

## IL4_SET

#define IL4_SET

## IM4_SET

#define IM4_SET

## inv_mcol

#define inv_mcol | ( |  | x | ) | four_tables(x,t_use(i,m),vf1,rf1,0)

## IT4_SET

#define IT4_SET

## KEY_SCHED

#define KEY_SCHED FOUR_TABLES

## LAST_DEC_ROUND

#define LAST_DEC_ROUND FOUR_TABLES

## LAST_ENC_ROUND

#define LAST_ENC_ROUND FOUR_TABLES

## ls_box

#define ls_box | ( |  | x,
|  |  | c
| ) |  | four_tables(x,t_use(f,l),vf1,rf2,c)

## no_table

#define no_table | ( |  | x,
|  |  | box,
|  |  | vf,
|  |  | rf,
|  |  | c
| ) |  |

Value:
bytes2word( \
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))])

## NO_TABLES

#define NO_TABLES 0

## NONE

#define NONE 0

## ONE_TABLE

#define ONE_TABLE 1

## one_table

#define one_table | ( |  | x,
|  |  | op,
|  |  | tab,
|  |  | vf,
|  |  | rf,
|  |  | c
| ) |  |

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))

## PARTIAL

#define PARTIAL 1

## RC_LENGTH

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

## rf1

#define rf1 | ( |  | r,
|  |  | c
| ) |  | (r)

## rf2

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

## s

#define s | ( |  | x,
|  |  | c
| ) |  | x[c]

## SAFE_IO

#define SAFE_IO

## to_byte

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

## vf1

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

## word_in

#define word_in | ( |  | x,
|  |  | c
| ) |  |

Value:
bytes2word(((const uint8_t*)(x)+4*c)[0], ((const uint8_t*)(x)+4*c)[1], \
((const uint8_t*)(x)+4*c)[2], ((const uint8_t*)(x)+4*c)[3])

## word_out

#define word_out | ( |  | x,
|  |  | c,
|  |  | v
| ) |  |

Value:
{ ((uint8_t*)(x)+4*c)[0] = bval(v,0); ((uint8_t*)(x)+4*c)[1] = bval(v,1); \
((uint8_t*)(x)+4*c)[2] = bval(v,2); ((uint8_t*)(x)+4*c)[3] = bval(v,3); }
v
#define v(n, i)
Definition: aeskey.c:224

## WPOLY

#define WPOLY 0x011b