Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
internal-aes.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef LW_INTERNAL_AES_H
24 #define LW_INTERNAL_AES_H
25 
40 #include "internal-util.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
49 #define AES_BLOCK_SIZE 16
50 
54 #define AES128_KEY_SIZE 16
55 
59 #define AES192_KEY_SIZE 24
60 
64 #define AES256_KEY_SIZE 32
65 
72 #define AES_ROUND_KEYS 60
73 
77 typedef struct
78 {
80  uint32_t k[AES_ROUND_KEYS];
81 
83  uint32_t rounds;
84 
86 
93 void aes_128_init(aes_key_schedule_t *ks, const unsigned char *key);
94 
101 void aes_192_init(aes_key_schedule_t *ks, const unsigned char *key);
102 
109 void aes_256_init(aes_key_schedule_t *ks, const unsigned char *key);
110 
121 void aes_ecb_encrypt
122  (const aes_key_schedule_t *ks, unsigned char *output,
123  const unsigned char *input);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif
void aes_128_init(aes_key_schedule_t *ks, const unsigned char *key)
Initializes the key schedule for AES-128.
Definition: internal-aes.c:318
Structure of the key schedule for AES.
Definition: internal-aes.h:77
#define AES_ROUND_KEYS
Number of round keys for the AES key schedule.
Definition: internal-aes.h:72
void aes_256_init(aes_key_schedule_t *ks, const unsigned char *key)
Initializes the key schedule for AES-256.
Definition: internal-aes.c:386
void aes_192_init(aes_key_schedule_t *ks, const unsigned char *key)
Initializes the key schedule for AES-192.
Definition: internal-aes.c:351
void aes_ecb_encrypt(const aes_key_schedule_t *ks, unsigned char *output, const unsigned char *input)
Encrypts a 128-bit block with AES in ECB mode.
Definition: internal-aes.c:428
uint32_t rounds
Definition: internal-aes.h:83