1 /*
2  * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef CC3XX_AES_H
9 #define CC3XX_AES_H
10 
11 #include "cc3xx_error.h"
12 
13 #include <stdint.h>
14 #include <stddef.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 typedef enum {
21     CC3XX_AES_DIRECTION_ENCRYPT = 0b0U,
22     CC3XX_AES_DIRECTION_DECRYPT = 0b1U,
23 } cc3xx_aes_direction_t;
24 
25 typedef enum {
26     CC3XX_AES_MODE_ECB = 0b000U,
27     CC3XX_AES_MODE_CTR = 0b010U,
28 } cc3xx_aes_mode_t;
29 
30 typedef enum {
31     CC3XX_AES_KEYSIZE_128 = 0b00U,
32     CC3XX_AES_KEYSIZE_192 = 0b01U,
33     CC3XX_AES_KEYSIZE_256 = 0b10U,
34 } cc3xx_aes_keysize_t;
35 
36 typedef enum {
37     CC3XX_AES_KEY_ID_HUK      = 0x0U,  /*!< Hardware unique key. Also referred to as RKEK */
38     CC3XX_AES_KEY_ID_KRTL     = 0x1U,  /*!< RTL Key */
39     CC3XX_AES_KEY_ID_KCP      = 0x2U,  /*!< DM provisioning key */
40     CC3XX_AES_KEY_ID_KCE      = 0x3U,  /*!< DM code encryption key */
41     CC3XX_AES_KEY_ID_KPICV    = 0x4U,  /*!< CM provisioning key */
42     CC3XX_AES_KEY_ID_KCEICV   = 0x5U,  /*!< CM code encryption key */
43     CC3XX_AES_KEY_ID_GUK      = 0xFU,  /*!< Group unique key. See CCA spec for information */
44     CC3XX_AES_KEY_ID_USER_KEY = 0xFFU, /*!< Key input into registers manually */
45 } cc3xx_aes_key_id_t;
46 
47 cc3xx_err_t cc3xx_aes(cc3xx_aes_key_id_t key_id, const uint8_t *key,
48                     cc3xx_aes_keysize_t key_size, const uint8_t* in, size_t
49                     in_len, uint8_t* iv, uint8_t *out,
50                     cc3xx_aes_direction_t direction, cc3xx_aes_mode_t mode);
51 
52 #ifdef __cplusplus
53 }
54 #endif
55 
56 #endif /* CC3XX_AES_H */
57