aes.h File Reference

Headers for the implementation of the AES cipher-algorithm. More...

Detailed Description

Headers for the implementation of the AES cipher-algorithm.

Author
Freie Universitaet Berlin, Computer Systems & Telematics
Nicolai Schmittberger nicol.nosp@m.ai.s.nosp@m.chmit.nosp@m.tber.nosp@m.ger@f.nosp@m.u-be.nosp@m.rlin..nosp@m.de
Fabrice Bellard
Zakaria Kasmi zkasm.nosp@m.i@in.nosp@m.f.fu-.nosp@m.berl.nosp@m.in.de

Definition in file aes.h.

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include "crypto/ciphers.h"
+ Include dependency graph for aes.h:

Go to the source code of this file.

Data Structures

struct  aes_key_st
 AES key. More...
 
struct  aes_context_t
 the cipher_context_t-struct adapted for AES More...
 
#define GETU32(pt)
 
#define PUTU32(ct, st)
 
#define AES_MAXNR   14
 
#define AES_BLOCK_SIZE   16
 
#define AES_KEY_SIZE   16
 
typedef uint32_t u32
 
typedef uint16_t u16
 
typedef uint8_t u8
 
typedef struct aes_key_st AES_KEY
 
int aes_init (cipher_context_t *context, const uint8_t *key, uint8_t keySize)
 initializes the AES Cipher-algorithm with the passed parameters More...
 
int aes_encrypt (const cipher_context_t *context, const uint8_t *plain_block, uint8_t *cipher_block)
 encrypts one plainBlock-block and saves the result in cipherblock. More...
 
int aes_decrypt (const cipher_context_t *context, const uint8_t *cipher_block, uint8_t *plain_block)
 decrypts one cipher-block and saves the plain-block in plainBlock. More...
 

Macro Definition Documentation

◆ GETU32

#define GETU32 (   pt)
Value:
(((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))

Definition at line 43 of file aes.h.

◆ PUTU32

#define PUTU32 (   ct,
  st 
)
Value:
{ (ct)[0] = (u8)((st) >> 24); \
(ct)[1] = (u8)((st) >> 16); \
(ct)[2] = (u8)((st) >> 8); \
(ct)[3] = (u8)(st); }

Definition at line 45 of file aes.h.

Function Documentation

◆ aes_decrypt()

int aes_decrypt ( const cipher_context_t context,
const uint8_t *  cipher_block,
uint8_t *  plain_block 
)

decrypts one cipher-block and saves the plain-block in plainBlock.

decrypts one blocksize long block of ciphertext pointed to by cipherBlock to one blocksize long block of plaintext and stores the plaintext in the memory-area pointed to by plainBlock

Parameters
contextthe cipher_context_t-struct to use for this decryption
cipher_blocka pointer to the ciphertext-block (of size blocksize) to be decrypted
plain_blocka pointer to the place where the decrypted plaintext will be stored
Returns
1 or negative value if cipher key cannot be expanded into decryption key schedule

◆ aes_encrypt()

int aes_encrypt ( const cipher_context_t context,
const uint8_t *  plain_block,
uint8_t *  cipher_block 
)

encrypts one plainBlock-block and saves the result in cipherblock.

encrypts one blocksize long block of plaintext pointed to by plainBlock to one blocksize long block of ciphertext which will be written to the the memory-area pointed to by cipherBlock

Parameters
contextthe cipher_context_t-struct to use for this encryption
plain_blocka pointer to the plaintext-block (of size blocksize)
cipher_blocka pointer to the place where the ciphertext will be stored
Returns
1 or result of aes_set_encrypt_key if it failed

◆ aes_init()

int aes_init ( cipher_context_t context,
const uint8_t *  key,
uint8_t  keySize 
)

initializes the AES Cipher-algorithm with the passed parameters

Parameters
contextthe cipher_context_t-struct to save the initialization of the cipher in
keySizethe size of the key
keya pointer to the key
Returns
CIPHER_INIT_SUCCESS if the initialization was successful. The command may be unsuccessful if the key size is not valid. CIPHER_ERR_BAD_CONTEXT_SIZE if CIPHER_MAX_CONTEXT_SIZE has not been defined (which means that the cipher has not been included in the build)