Monero
Loading...
Searching...
No Matches
aesb.c File Reference
#include <stdint.h>
#include "int-util.h"
Include dependency graph for aesb.c:

Macros

#define TABLE_ALIGN   32
#define WPOLY   0x011b
#define N_COLS   4
#define AES_BLOCK_SIZE   16
#define RC_LENGTH   (5 * (AES_BLOCK_SIZE / 4 - 2))
#define LOCAL_ALIGN
#define rf1(r, c)
#define word_in(x, c)
#define word_out(x, c, v)
#define s(x, c)
#define si(y, x, c)
#define so(y, x, c)
#define state_in(y, x)
#define state_out(y, x)
#define round(rm, y, x, k)
#define to_byte(x)
#define bval(x, n)
#define fwd_var(x, r, c)
#define fwd_rnd(y, x, k, c)
#define sb_data(w)
#define rc_data(w)
#define bytes2word(b0, b1, b2, b3)
#define h0(x)
#define w0(p)
#define w1(p)
#define w2(p)
#define w3(p)
#define u0(p)
#define u1(p)
#define u2(p)
#define u3(p)
#define v0(p)
#define v1(p)
#define v2(p)
#define v3(p)
#define f2(x)
#define f4(x)
#define f8(x)
#define f3(x)
#define f9(x)
#define fb(x)
#define fd(x)
#define fe(x)
#define t_dec(m, n)
#define t_set(m, n)
#define t_use(m, n)
#define d_4(t, n, b, e, f, g, h)
#define four_tables(x, tab, vf, rf, c)
#define STATIC
#define INLINE

Functions

 d_4 (uint32_t, t_dec(f, n), sb_data, u0, u1, u2, u3)
STATIC INLINE void aesb_single_round (const uint8_t *in, uint8_t *out, uint8_t *expandedKey)
STATIC INLINE void aesb_pseudo_round (const uint8_t *in, uint8_t *out, uint8_t *expandedKey)

Macro Definition Documentation

◆ AES_BLOCK_SIZE

#define AES_BLOCK_SIZE   16

◆ bval

#define bval ( x,
n )
Value:
to_byte(SWAP32LE(x) >> (8 * (n)))
#define to_byte(x)
Definition aesb.c:53
#define SWAP32LE
Definition int-util.h:277

◆ bytes2word

#define bytes2word ( b0,
b1,
b2,
b3 )
Value:
(((uint32_t)(b3) << 24) | \
((uint32_t)(b2) << 16) | ((uint32_t)(b1) << 8) | (b0))
unsigned int uint32_t
Definition stdint.h:126

◆ d_4

#define d_4 ( t,
n,
b,
e,
f,
g,
h )
Value:
LOCAL_ALIGN const t n[4][256] = { b(e), b(f), b(g), b(h) }
#define LOCAL_ALIGN
Definition aesb.c:40
cryptonote::block b
Definition block.cpp:40
static uint64_t h
Definition blockchain_stats.cpp:55

◆ f2

#define f2 ( x)
Value:
((x<<1) ^ (((x>>7) & 1) * WPOLY))
#define WPOLY
Definition aesb.c:30

◆ f3

#define f3 ( x)
Value:
(f2(x) ^ x)
#define f2(x)
Definition aesb.c:121

◆ f4

#define f4 ( x)
Value:
((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY))

◆ f8

#define f8 ( x)
Value:
((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) ^ (((x>>5) & 4) * WPOLY))

◆ f9

#define f9 ( x)
Value:
(f8(x) ^ x)
#define f8(x)
Definition aesb.c:123

◆ fb

#define fb ( x)
Value:
(f8(x) ^ f2(x) ^ x)

◆ fd

#define fd ( x)
Value:
(f8(x) ^ f4(x) ^ x)
#define f4(x)
Definition aesb.c:122

◆ fe

#define fe ( x)
Value:
(f8(x) ^ f4(x) ^ f2(x))

◆ 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))])
#define bval(x, n)
Definition aesb.c:54

◆ fwd_rnd

#define fwd_rnd ( y,
x,
k,
c )
Value:
(s(y,c) = (k)[c] ^ SWAP32LE(four_tables(x,t_use(f,n),fwd_var,rf1,c)))
#define s(x, c)
Definition aesb.c:47
#define four_tables(x, tab, vf, rf, c)
Definition aesb.c:136
#define rf1(r, c)
Definition aesb.c:43
#define t_use(m, n)
Definition aesb.c:132
#define fwd_var(x, r, c)
Definition aesb.c:56

◆ fwd_var

#define fwd_var ( x,
r,
c )
Value:
( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\
: r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\
: r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\
: ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2)))

◆ h0

#define h0 ( x)
Value:
(x)

◆ INLINE

#define INLINE

◆ LOCAL_ALIGN

#define LOCAL_ALIGN

◆ N_COLS

#define N_COLS   4

◆ rc_data

#define rc_data ( w)
Value:
{\
w(0x01), w(0x02), w(0x04), w(0x08), w(0x10),w(0x20), w(0x40), w(0x80),\
w(0x1b), w(0x36) }

◆ RC_LENGTH

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

◆ rf1

#define rf1 ( r,
c )
Value:
(r)

◆ round

#define round ( rm,
y,
x,
k )
Value:
rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3)

◆ s

#define s ( x,
c )
Value:
x[c]

◆ sb_data

#define sb_data ( w)

◆ si

#define si ( y,
x,
c )
Value:
(s(y,c) = word_in(x, c))
#define word_in(x, c)
Definition aesb.c:44

◆ so

#define so ( y,
x,
c )
Value:
word_out(y, c, s(x,c))
#define word_out(x, c, v)
Definition aesb.c:45

◆ state_in

#define state_in ( y,
x )
Value:
si(y,x,0); si(y,x,1); si(y,x,2); si(y,x,3)
#define si(y, x, c)
Definition aesb.c:48

◆ state_out

#define state_out ( y,
x )
Value:
so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3)
#define so(y, x, c)
Definition aesb.c:49

◆ STATIC

#define STATIC

◆ t_dec

#define t_dec ( m,
n )
Value:
t_##m##n

◆ t_set

#define t_set ( m,
n )
Value:
t_##m##n

◆ t_use

#define t_use ( m,
n )
Value:
t_##m##n

◆ TABLE_ALIGN

#define TABLE_ALIGN   32

◆ to_byte

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

◆ u0

#define u0 ( p)
Value:
bytes2word(f2(p), p, p, f3(p))
#define bytes2word(b0, b1, b2, b3)
Definition aesb.c:102
#define f3(x)
Definition aesb.c:124

◆ u1

#define u1 ( p)
Value:
bytes2word(f3(p), f2(p), p, p)

◆ u2

#define u2 ( p)
Value:
bytes2word(p, f3(p), f2(p), p)

◆ u3

#define u3 ( p)
Value:
bytes2word(p, p, f3(p), f2(p))

◆ v0

#define v0 ( p)
Value:
bytes2word(fe(p), f9(p), fd(p), fb(p))
#define f9(x)
Definition aesb.c:125
#define fb(x)
Definition aesb.c:126
#define fe(x)
Definition aesb.c:128
#define fd(x)
Definition aesb.c:127

◆ v1

#define v1 ( p)
Value:
bytes2word(fb(p), fe(p), f9(p), fd(p))

◆ v2

#define v2 ( p)
Value:
bytes2word(fd(p), fb(p), fe(p), f9(p))

◆ v3

#define v3 ( p)
Value:
bytes2word(f9(p), fd(p), fb(p), fe(p))

◆ w0

#define w0 ( p)
Value:
bytes2word(p, 0, 0, 0)

◆ w1

#define w1 ( p)
Value:
bytes2word(0, p, 0, 0)

◆ w2

#define w2 ( p)
Value:
bytes2word(0, 0, p, 0)

◆ w3

#define w3 ( p)
Value:
bytes2word(0, 0, 0, p)

◆ word_in

#define word_in ( x,
c )
Value:
(*((uint32_t*)(x)+(c)))

◆ word_out

#define word_out ( x,
c,
v )
Value:
(*((uint32_t*)(x)+(c)) = (v))

◆ WPOLY

#define WPOLY   0x011b

Function Documentation

◆ aesb_pseudo_round()

STATIC INLINE void aesb_pseudo_round ( const uint8_t * in,
uint8_t * out,
uint8_t * expandedKey )

◆ aesb_single_round()

STATIC INLINE void aesb_single_round ( const uint8_t * in,
uint8_t * out,
uint8_t * expandedKey )

◆ d_4()

d_4 ( uint32_t ,
t_dec(f, n) ,
sb_data ,
u0 ,
u1 ,
u2 ,
u3  )