Rizin
unix-like reverse engineering framework and cli tools
aes-invert-internal.c File Reference
#include "aes-internal.h"
#include "macros.h"

Go to the source code of this file.

Macros

#define MIX_COLUMN(T, key)
 
#define SWAP(a, b)   do { uint32_t t_swap = (a); (a) = (b); (b) = t_swap; } while(0)
 

Functions

void _nettle_aes_invert (unsigned rounds, uint32_t *dst, const uint32_t *src)
 

Variables

static const uint32_t mtable [0x100]
 

Macro Definition Documentation

◆ MIX_COLUMN

#define MIX_COLUMN (   T,
  key 
)
Value:
do { \
uint32_t _k, _nk, _t; \
_k = (key); \
_nk = T[_k & 0xff]; \
_k >>= 8; \
_t = T[_k & 0xff]; \
_nk ^= ROTL32(8, _t); \
_k >>= 8; \
_t = T[_k & 0xff]; \
_nk ^= ROTL32(16, _t); \
_k >>= 8; \
_t = T[_k & 0xff]; \
_nk ^= ROTL32(24, _t); \
(key) = _nk; \
} while(0)
#define T(op)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118
#define ROTL32(n, x)
Definition: macros.h:157

Definition at line 118 of file aes-invert-internal.c.

◆ SWAP

#define SWAP (   a,
  b 
)    do { uint32_t t_swap = (a); (a) = (b); (b) = t_swap; } while(0)

Definition at line 135 of file aes-invert-internal.c.

Function Documentation

◆ _nettle_aes_invert()

void _nettle_aes_invert ( unsigned  rounds,
uint32_t dst,
const uint32_t src 
)

Definition at line 139 of file aes-invert-internal.c.

140 {
141  unsigned i;
142 
143  /* Reverse the order of subkeys, in groups of 4. */
144  /* FIXME: Instead of reordering the subkeys, change the access order
145  of aes_decrypt, since it's a separate function anyway? */
146  if (src == dst)
147  {
148  unsigned j, k;
149 
150  for (i = 0, j = rounds * 4;
151  i < j;
152  i += 4, j -= 4)
153  for (k = 0; k<4; k++)
154  SWAP(dst[i+k], dst[j+k]);
155  }
156  else
157  {
158  unsigned k;
159 
160  for (i = 0; i <= rounds * 4; i += 4)
161  for (k = 0; k < 4; k++)
162  dst[i+k] = src[rounds * 4 - i + k];
163  }
164 
165  /* Transform all subkeys but the first and last. */
166  for (i = 4; i < 4 * rounds; i++)
167  MIX_COLUMN (mtable, dst[i]);
168 }
#define MIX_COLUMN(T, key)
static const uint32_t mtable[0x100]
#define SWAP(a, b)
lzma_index ** i
Definition: index.h:629
lzma_index * src
Definition: index.h:567
const char * k
Definition: dsignal.c:11
char * dst
Definition: lz4.h:724

References dst, i, k, MIX_COLUMN, mtable, src, and SWAP.

Referenced by nettle_aes128_invert_key(), nettle_aes192_invert_key(), and nettle_aes256_invert_key().

Variable Documentation

◆ mtable

const uint32_t mtable[0x100]
static

Definition at line 50 of file aes-invert-internal.c.

Referenced by _nettle_aes_invert().