ndn-lite
tc_aes.h
Go to the documentation of this file.
1 /* aes.h - TinyCrypt interface to an AES-128 implementation */
2 
3 /*
4  * Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * - Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * - Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * - Neither the name of Intel Corporation nor the names of its contributors
17  * may be used to endorse or promote products derived from this software
18  * without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
49 #ifndef __TC_AES_H__
50 #define __TC_AES_H__
51 
52 #include <stdint.h>
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #define Nb (4) /* number of columns (32-bit words) comprising the state */
59 #define Nk (4) /* number of 32-bit words comprising the key */
60 #define Nr (10) /* number of rounds */
61 #define TC_AES_BLOCK_SIZE (Nb*Nk)
62 #define TC_AES_KEY_SIZE (Nb*Nk)
63 
64 typedef struct tc_aes_key_sched_struct {
65  unsigned int words[Nb*(Nr+1)];
67 
79 int tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k);
80 
93 int tc_aes_encrypt(uint8_t *out, const uint8_t *in,
94  const TCAesKeySched_t s);
95 
110 int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k);
111 
123 int tc_aes_decrypt(uint8_t *out, const uint8_t *in,
124  const TCAesKeySched_t s);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* __TC_AES_H__ */
int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k)
Set the AES-128 decryption key Uses key k to initialize s.
Definition: tc_aes_decrypt.c:62
struct tc_aes_key_sched_struct * TCAesKeySched_t
int tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k)
Set AES-128 encryption key Uses key k to initialize s.
Definition: tc_aes_encrypt.c:70
#define Nb
Definition: tc_aes.h:58
int tc_aes_encrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s)
AES-128 Encryption procedure Encrypts contents of in buffer into out buffer under key; schedule s.
Definition: tc_aes_encrypt.c:158
int tc_aes_decrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s)
AES-128 Encryption procedure Decrypts in buffer into out buffer under key schedule s.
Definition: tc_aes_decrypt.c:129
unsigned int words[Nb *(Nr+1)]
Definition: tc_aes.h:65
#define Nr
Definition: tc_aes.h:60
Definition: tc_aes.h:64