Rizin
unix-like reverse engineering framework and cli tools
aes.h File Reference
#include "nettle-types.h"

Go to the source code of this file.

Classes

struct  aes128_ctx
 
struct  aes192_ctx
 
struct  aes256_ctx
 
struct  aes_ctx
 

Macros

#define aes_set_encrypt_key   nettle_aes_set_encrypt_key
 
#define aes_set_decrypt_key   nettle_aes_set_decrypt_key
 
#define aes_invert_key   nettle_aes_invert_key
 
#define aes_encrypt   nettle_aes_encrypt
 
#define aes_decrypt   nettle_aes_decrypt
 
#define aes128_set_encrypt_key   nettle_aes128_set_encrypt_key
 
#define aes128_set_decrypt_key   nettle_aes128_set_decrypt_key
 
#define aes128_invert_key   nettle_aes128_invert_key
 
#define aes128_encrypt   nettle_aes128_encrypt
 
#define aes128_decrypt   nettle_aes128_decrypt
 
#define aes192_set_encrypt_key   nettle_aes192_set_encrypt_key
 
#define aes192_set_decrypt_key   nettle_aes192_set_decrypt_key
 
#define aes192_invert_key   nettle_aes192_invert_key
 
#define aes192_encrypt   nettle_aes192_encrypt
 
#define aes192_decrypt   nettle_aes192_decrypt
 
#define aes256_set_encrypt_key   nettle_aes256_set_encrypt_key
 
#define aes256_set_decrypt_key   nettle_aes256_set_decrypt_key
 
#define aes256_invert_key   nettle_aes256_invert_key
 
#define aes256_encrypt   nettle_aes256_encrypt
 
#define aes256_decrypt   nettle_aes256_decrypt
 
#define AES_BLOCK_SIZE   16
 
#define AES128_KEY_SIZE   16
 
#define AES192_KEY_SIZE   24
 
#define AES256_KEY_SIZE   32
 
#define _AES128_ROUNDS   10
 
#define _AES192_ROUNDS   12
 
#define _AES256_ROUNDS   14
 
#define AES_MIN_KEY_SIZE   AES128_KEY_SIZE
 
#define AES_MAX_KEY_SIZE   AES256_KEY_SIZE
 
#define AES_KEY_SIZE   32
 

Functions

void aes128_set_encrypt_key (struct aes128_ctx *ctx, const uint8_t *key)
 
void aes128_set_decrypt_key (struct aes128_ctx *ctx, const uint8_t *key)
 
void aes128_invert_key (struct aes128_ctx *dst, const struct aes128_ctx *src)
 
void aes128_encrypt (const struct aes128_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
 
void aes128_decrypt (const struct aes128_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
 
void aes192_set_encrypt_key (struct aes192_ctx *ctx, const uint8_t *key)
 
void aes192_set_decrypt_key (struct aes192_ctx *ctx, const uint8_t *key)
 
void aes192_invert_key (struct aes192_ctx *dst, const struct aes192_ctx *src)
 
void aes192_encrypt (const struct aes192_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
 
void aes192_decrypt (const struct aes192_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
 
void aes256_set_encrypt_key (struct aes256_ctx *ctx, const uint8_t *key)
 
void aes256_set_decrypt_key (struct aes256_ctx *ctx, const uint8_t *key)
 
void aes256_invert_key (struct aes256_ctx *dst, const struct aes256_ctx *src)
 
void aes256_encrypt (const struct aes256_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
 
void aes256_decrypt (const struct aes256_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
 
void aes_set_encrypt_key (struct aes_ctx *ctx, size_t length, const uint8_t *key) _NETTLE_ATTRIBUTE_DEPRECATED
 
void aes_set_decrypt_key (struct aes_ctx *ctx, size_t length, const uint8_t *key) _NETTLE_ATTRIBUTE_DEPRECATED
 
void aes_invert_key (struct aes_ctx *dst, const struct aes_ctx *src) _NETTLE_ATTRIBUTE_DEPRECATED
 
void aes_encrypt (const struct aes_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src) _NETTLE_ATTRIBUTE_DEPRECATED
 
void aes_decrypt (const struct aes_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src) _NETTLE_ATTRIBUTE_DEPRECATED
 

Macro Definition Documentation

◆ _AES128_ROUNDS

#define _AES128_ROUNDS   10

Definition at line 73 of file aes.h.

◆ _AES192_ROUNDS

#define _AES192_ROUNDS   12

Definition at line 74 of file aes.h.

◆ _AES256_ROUNDS

#define _AES256_ROUNDS   14

Definition at line 75 of file aes.h.

◆ aes128_decrypt

#define aes128_decrypt   nettle_aes128_decrypt

Definition at line 56 of file aes.h.

◆ aes128_encrypt

#define aes128_encrypt   nettle_aes128_encrypt

Definition at line 55 of file aes.h.

◆ aes128_invert_key

#define aes128_invert_key   nettle_aes128_invert_key

Definition at line 54 of file aes.h.

◆ AES128_KEY_SIZE

#define AES128_KEY_SIZE   16

Definition at line 70 of file aes.h.

◆ aes128_set_decrypt_key

#define aes128_set_decrypt_key   nettle_aes128_set_decrypt_key

Definition at line 53 of file aes.h.

◆ aes128_set_encrypt_key

#define aes128_set_encrypt_key   nettle_aes128_set_encrypt_key

Definition at line 52 of file aes.h.

◆ aes192_decrypt

#define aes192_decrypt   nettle_aes192_decrypt

Definition at line 61 of file aes.h.

◆ aes192_encrypt

#define aes192_encrypt   nettle_aes192_encrypt

Definition at line 60 of file aes.h.

◆ aes192_invert_key

#define aes192_invert_key   nettle_aes192_invert_key

Definition at line 59 of file aes.h.

◆ AES192_KEY_SIZE

#define AES192_KEY_SIZE   24

Definition at line 71 of file aes.h.

◆ aes192_set_decrypt_key

#define aes192_set_decrypt_key   nettle_aes192_set_decrypt_key

Definition at line 58 of file aes.h.

◆ aes192_set_encrypt_key

#define aes192_set_encrypt_key   nettle_aes192_set_encrypt_key

Definition at line 57 of file aes.h.

◆ aes256_decrypt

#define aes256_decrypt   nettle_aes256_decrypt

Definition at line 66 of file aes.h.

◆ aes256_encrypt

#define aes256_encrypt   nettle_aes256_encrypt

Definition at line 65 of file aes.h.

◆ aes256_invert_key

#define aes256_invert_key   nettle_aes256_invert_key

Definition at line 64 of file aes.h.

◆ AES256_KEY_SIZE

#define AES256_KEY_SIZE   32

Definition at line 72 of file aes.h.

◆ aes256_set_decrypt_key

#define aes256_set_decrypt_key   nettle_aes256_set_decrypt_key

Definition at line 63 of file aes.h.

◆ aes256_set_encrypt_key

#define aes256_set_encrypt_key   nettle_aes256_set_encrypt_key

Definition at line 62 of file aes.h.

◆ AES_BLOCK_SIZE

#define AES_BLOCK_SIZE   16

Definition at line 68 of file aes.h.

◆ aes_decrypt

#define aes_decrypt   nettle_aes_decrypt

Definition at line 51 of file aes.h.

◆ aes_encrypt

#define aes_encrypt   nettle_aes_encrypt

Definition at line 50 of file aes.h.

◆ aes_invert_key

#define aes_invert_key   nettle_aes_invert_key

Definition at line 49 of file aes.h.

◆ AES_KEY_SIZE

#define AES_KEY_SIZE   32

Definition at line 148 of file aes.h.

◆ AES_MAX_KEY_SIZE

#define AES_MAX_KEY_SIZE   AES256_KEY_SIZE

Definition at line 146 of file aes.h.

◆ AES_MIN_KEY_SIZE

#define AES_MIN_KEY_SIZE   AES128_KEY_SIZE

Definition at line 145 of file aes.h.

◆ aes_set_decrypt_key

#define aes_set_decrypt_key   nettle_aes_set_decrypt_key

Definition at line 48 of file aes.h.

◆ aes_set_encrypt_key

#define aes_set_encrypt_key   nettle_aes_set_encrypt_key

Definition at line 47 of file aes.h.

Function Documentation

◆ aes128_decrypt()

void aes128_decrypt ( const struct aes128_ctx ctx,
size_t  length,
uint8_t dst,
const uint8_t src 
)

Referenced by aes_decrypt(), and decryptaes().

◆ aes128_encrypt()

void aes128_encrypt ( const struct aes128_ctx ctx,
size_t  length,
uint8_t dst,
const uint8_t src 
)

Referenced by aes_encrypt(), and encryptaes().

◆ aes128_invert_key()

void aes128_invert_key ( struct aes128_ctx dst,
const struct aes128_ctx src 
)

◆ aes128_set_decrypt_key()

void aes128_set_decrypt_key ( struct aes128_ctx ctx,
const uint8_t key 
)

Referenced by aes_cbc_set_key(), and aes_set_key().

◆ aes128_set_encrypt_key()

void aes128_set_encrypt_key ( struct aes128_ctx ctx,
const uint8_t key 
)

◆ aes192_decrypt()

void aes192_decrypt ( const struct aes192_ctx ctx,
size_t  length,
uint8_t dst,
const uint8_t src 
)

Referenced by aes_decrypt(), and decryptaes().

◆ aes192_encrypt()

void aes192_encrypt ( const struct aes192_ctx ctx,
size_t  length,
uint8_t dst,
const uint8_t src 
)

Referenced by aes_encrypt(), and encryptaes().

◆ aes192_invert_key()

void aes192_invert_key ( struct aes192_ctx dst,
const struct aes192_ctx src 
)

◆ aes192_set_decrypt_key()

void aes192_set_decrypt_key ( struct aes192_ctx ctx,
const uint8_t key 
)

Referenced by aes_cbc_set_key(), and aes_set_key().

◆ aes192_set_encrypt_key()

void aes192_set_encrypt_key ( struct aes192_ctx ctx,
const uint8_t key 
)

◆ aes256_decrypt()

void aes256_decrypt ( const struct aes256_ctx ctx,
size_t  length,
uint8_t dst,
const uint8_t src 
)

Referenced by aes_decrypt(), and decryptaes().

◆ aes256_encrypt()

void aes256_encrypt ( const struct aes256_ctx ctx,
size_t  length,
uint8_t dst,
const uint8_t src 
)

Referenced by aes_encrypt(), and encryptaes().

◆ aes256_invert_key()

void aes256_invert_key ( struct aes256_ctx dst,
const struct aes256_ctx src 
)

◆ aes256_set_decrypt_key()

void aes256_set_decrypt_key ( struct aes256_ctx ctx,
const uint8_t key 
)

Referenced by aes_cbc_set_key(), and aes_set_key().

◆ aes256_set_encrypt_key()

void aes256_set_encrypt_key ( struct aes256_ctx ctx,
const uint8_t key 
)

◆ aes_decrypt()

void aes_decrypt ( const struct aes_ctx ctx,
size_t  length,
uint8_t dst,
const uint8_t src 
)

Definition at line 46 of file aes-decrypt.c.

49 {
50  switch (ctx->key_size)
51  {
52  default: abort();
53  case AES128_KEY_SIZE:
54  aes128_decrypt(&ctx->u.ctx128, length, dst, src);
55  break;
56  case AES192_KEY_SIZE:
57  aes192_decrypt(&ctx->u.ctx192, length, dst, src);
58  break;
59  case AES256_KEY_SIZE:
60  aes256_decrypt(&ctx->u.ctx256, length, dst, src);
61  break;
62  }
63 }
void aes128_decrypt(const struct aes128_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
#define AES192_KEY_SIZE
Definition: aes.h:71
#define AES256_KEY_SIZE
Definition: aes.h:72
void aes256_decrypt(const struct aes256_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
#define AES128_KEY_SIZE
Definition: aes.h:70
void aes192_decrypt(const struct aes192_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
lzma_index * src
Definition: index.h:567
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 static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
char * dst
Definition: lz4.h:724

References aes128_decrypt(), AES128_KEY_SIZE, aes192_decrypt(), AES192_KEY_SIZE, aes256_decrypt(), AES256_KEY_SIZE, dst, length, and src.

◆ aes_encrypt()

void aes_encrypt ( const struct aes_ctx ctx,
size_t  length,
uint8_t dst,
const uint8_t src 
)

Definition at line 49 of file aes-encrypt.c.

52 {
53  switch (ctx->key_size)
54  {
55  default: abort();
56  case AES128_KEY_SIZE:
57  aes128_encrypt(&ctx->u.ctx128, length, dst, src);
58  break;
59  case AES192_KEY_SIZE:
60  aes192_encrypt(&ctx->u.ctx192, length, dst, src);
61  break;
62  case AES256_KEY_SIZE:
63  aes256_encrypt(&ctx->u.ctx256, length, dst, src);
64  break;
65  }
66 }
void aes128_encrypt(const struct aes128_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
void aes192_encrypt(const struct aes192_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
void aes256_encrypt(const struct aes256_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)

References aes128_encrypt(), AES128_KEY_SIZE, aes192_encrypt(), AES192_KEY_SIZE, aes256_encrypt(), AES256_KEY_SIZE, dst, length, and src.

◆ aes_invert_key()

void aes_invert_key ( struct aes_ctx dst,
const struct aes_ctx src 
)

Definition at line 51 of file aes-set-decrypt-key.c.

53 {
54  switch (src->key_size)
55  {
56  default: abort();
57  case AES128_KEY_SIZE:
58  aes128_invert_key(&dst->u.ctx128, &src->u.ctx128);
59  break;
60  case AES192_KEY_SIZE:
61  aes192_invert_key(&dst->u.ctx192, &src->u.ctx192);
62  break;
63  case AES256_KEY_SIZE:
64  aes256_invert_key(&dst->u.ctx256, &src->u.ctx256);
65  break;
66  }
67 
68  dst->key_size = src->key_size;
69 }
void aes192_invert_key(struct aes192_ctx *dst, const struct aes192_ctx *src)
void aes256_invert_key(struct aes256_ctx *dst, const struct aes256_ctx *src)
void aes128_invert_key(struct aes128_ctx *dst, const struct aes128_ctx *src)

References aes128_invert_key(), AES128_KEY_SIZE, aes192_invert_key(), AES192_KEY_SIZE, aes256_invert_key(), AES256_KEY_SIZE, dst, and src.

Referenced by aes_set_decrypt_key().

◆ aes_set_decrypt_key()

void aes_set_decrypt_key ( struct aes_ctx ctx,
size_t  length,
const uint8_t key 
)

Definition at line 72 of file aes-set-decrypt-key.c.

74 {
75  /* We first create subkeys for encryption,
76  * then modify the subkeys for decryption. */
77  aes_set_encrypt_key(ctx, keysize, key);
79 }
void aes_invert_key(struct aes_ctx *dst, const struct aes_ctx *src)
#define aes_set_encrypt_key
Definition: aes.h:47
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

References aes_invert_key(), aes_set_encrypt_key, and key.

◆ aes_set_encrypt_key()

void aes_set_encrypt_key ( struct aes_ctx ctx,
size_t  length,
const uint8_t key 
)

Definition at line 48 of file aes-set-encrypt-key.c.

50 {
51  switch (key_size)
52  {
53  default: abort();
54  case AES128_KEY_SIZE:
55  aes128_set_encrypt_key(&ctx->u.ctx128, key);
56  break;
57  case AES192_KEY_SIZE:
58  aes192_set_encrypt_key(&ctx->u.ctx192, key);
59  break;
60  case AES256_KEY_SIZE:
61  aes256_set_encrypt_key(&ctx->u.ctx256, key);
62  break;
63  }
64 
65  ctx->key_size = key_size;
66 }
void aes128_set_encrypt_key(struct aes128_ctx *ctx, const uint8_t *key)
void aes256_set_encrypt_key(struct aes256_ctx *ctx, const uint8_t *key)
void aes192_set_encrypt_key(struct aes192_ctx *ctx, const uint8_t *key)

References AES128_KEY_SIZE, aes128_set_encrypt_key(), AES192_KEY_SIZE, aes192_set_encrypt_key(), AES256_KEY_SIZE, aes256_set_encrypt_key(), and key.