1 /*
2   ROM functions for hardware AES support.
3 
4   It is not recommended to use these functions directly,
5   use the wrapper functions in hwcrypto/aes.h instead.
6 
7  */
8 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 
14 //     http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 
22 #pragma once
23 
24 #include <stdint.h>
25 #include <stdbool.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define AES_BLOCK_SIZE 16
32 
33 enum AES_TYPE {
34     AES_ENC,
35     AES_DEC,
36 };
37 
38 enum AES_BITS {
39     AES128,
40     AES192,
41     AES256
42 };
43 
44 void ets_aes_enable(void);
45 
46 void ets_aes_disable(void);
47 
48 void ets_aes_set_endian(bool key_word_swap, bool key_byte_swap,
49                         bool in_word_swap, bool in_byte_swap,
50                         bool out_word_swap, bool out_byte_swap);
51 
52 int ets_aes_setkey(enum AES_TYPE type, const void *key, enum AES_BITS bits);
53 
54 int ets_aes_setkey_enc(const void *key, enum AES_BITS bits);
55 
56 int ets_aes_setkey_dec(const void *key, enum AES_BITS bits);
57 
58 void ets_aes_block(const void *input, void *output);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63