Loading...
Searching...
No Matches
aes.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Freie Universität Berlin, Computer Systems & Telematics
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
30#ifndef CRYPTO_AES_H
31#define CRYPTO_AES_H
32
33#include <stdint.h>
34#include "crypto/ciphers.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40typedef uint32_t u32;
41typedef uint16_t u16;
42typedef uint8_t u8;
43
44# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
45 ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
46# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); \
47 (ct)[1] = (u8)((st) >> 16); \
48 (ct)[2] = (u8)((st) >> 8); \
49 (ct)[3] = (u8)(st); }
50
51#define AES_MAXNR 14
52#define AES_BLOCK_SIZE 16
53
58#define AES_KEY_SIZE_128 16
59#define AES_KEY_SIZE_192 24
60#define AES_KEY_SIZE_256 32
66typedef struct {
68 uint32_t context[(4 * (AES_MAXNR + 1)) + 1];
70
86int aes_init(cipher_context_t *context, const uint8_t *key, uint8_t keySize);
87
105int aes_encrypt(const cipher_context_t *context, const uint8_t *plain_block,
106 uint8_t *cipher_block);
107
125int aes_decrypt(const cipher_context_t *context, const uint8_t *cipher_block,
126 uint8_t *plain_block);
127
128#ifdef __cplusplus
129}
130#endif
131
133#endif /* CRYPTO_AES_H */
int aes_init(cipher_context_t *context, const uint8_t *key, uint8_t keySize)
initializes the AES Cipher-algorithm with the passed parameters
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.
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.
Headers for the packet encryption class.
the cipher_context_t-struct adapted for AES
Definition aes.h:66
the context for cipher-operations
Definition ciphers.h:78