blob: 9ea354deba91ea497c1c694891b3c91b47f9ee7f [file] [log] [blame]
Gilad Ben-Yossef033327a2019-05-15 09:24:04 +03001/*
2 * Copyright (c) 2017-2020 ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _BSV_CRYPTO_DEFS_H
8#define _BSV_CRYPTO_DEFS_H
9
10#ifdef __cplusplus
11extern "C"
12{
13#endif
14
15/*!
16@file
17@brief This file contains the definitions of the cryptographic ROM APIs.
18
19@defgroup cc_bsv_crypto_defs CryptoCell Boot Services cryptographic ROM API definitions
20@{
21@ingroup cc_bsv
22*/
23
24/*! AES supported HW key code table. */
25typedef enum {
26
27 CC_BSV_USER_KEY = 0, /*!< Definition for a user key. */
28 CC_BSV_HUK_KEY = 1, /*!< Definition for the HW unique key. */
29 CC_BSV_RTL_KEY = 2, /*!< Definition for the RTL key. */
30 CC_BSV_SESSION_KEY = 3, /*!< Definition for the Session key. */
31 CC_BSV_CE_KEY = 4, /*!< Definition for the Kce. */
32 CC_BSV_PLT_KEY = 5, /*!< Definition for the Platform key. */
33 CC_BSV_KCST_KEY = 6, /*!< Definition for Kcst. */
34 CC_BSV_ICV_PROV_KEY = 0xd, /*!< Definition for the Kpicv. */
35 CC_BSV_ICV_CE_KEY = 0xe, /*!< Definition for the Kceicv. */
36 CC_BSV_PROV_KEY = 0xf, /*!< Definition for the Kcp. */
37 CC_BSV_END_OF_KEY_TYPE = INT32_MAX, /*!< Reserved. */
38}CCBsvKeyType_t;
39
40/*! AES directions. */
41typedef enum bsvAesDirection {
42 BSV_AES_DIRECTION_ENCRYPT = 0, /*!< Encrypt.*/
43 BSV_AES_DIRECTION_DECRYPT = 1, /*!< Decrypt.*/
44 BSV_AES_NUM_OF_ENCRYPT_MODES, /*!< The maximal number of operations. */
45 BSV_AES_DIRECTION_RESERVE32B = INT32_MAX /*!< Reserved.*/
46}bsvAesDirection_t;
47
48/*! Definitions of the cryptographic flow supported as part of the Secure Boot. */
49typedef enum {
50 CC_BSV_CRYPTO_HASH_MODE = 0, /*!< Hash mode only. */
51 CC_BSV_CRYPTO_AES_CTR_AND_HASH_MODE = 1, /*!< Data goes into the AES and Hash engines. */
52 CC_BSV_CRYPTO_AES_CTR_TO_HASH_MODE = 2 /*!< Data goes into the AES and from the AES to the Hash engine. */
53}CCBsvflowMode_t;
54
55/*! CryptoImage HW completion sequence mode */
56typedef enum
57{
58 BSV_CRYPTO_COMPLETION_NO_WAIT = 0, /*!< The driver waits only before reading the output. */
59 BSV_CRYPTO_COMPLETION_WAIT_UPON_END = 1 /*!< The driver waits after each chunk of data. */
60}bsvCryptoCompletionMode_t;
61
62
63/*! AES-CMAC result size, in words. */
64#define CC_BSV_CMAC_RESULT_SIZE_IN_WORDS 4 /* 128b */
65/*! AES-CMAC result size, in bytes. */
66#define CC_BSV_CMAC_RESULT_SIZE_IN_BYTES 16 /* 128b */
67/*! AES-CCM 128bit key size, in bytes. */
68#define CC_BSV_CCM_KEY_SIZE_BYTES 16
69/*! AES-CCM 128bit key size, in words. */
70#define CC_BSV_CCM_KEY_SIZE_WORDS 4
71/*! AES-CCM NONCE size, in bytes. */
72#define CC_BSV_CCM_NONCE_SIZE_BYTES 12
73
74
75/*! AES-CMAC result buffer. */
76typedef uint32_t CCBsvCmacResult_t[CC_BSV_CMAC_RESULT_SIZE_IN_WORDS];
77/*! AES-CCM key buffer.*/
78typedef uint32_t CCBsvCcmKey_t[CC_BSV_CCM_KEY_SIZE_WORDS];
79/*! AES-CCM nonce buffer.*/
80typedef uint8_t CCBsvCcmNonce_t[CC_BSV_CCM_NONCE_SIZE_BYTES];
81/*! AES-CCM MAC buffer.*/
82typedef uint8_t CCBsvCcmMacRes_t[CC_BSV_CMAC_RESULT_SIZE_IN_BYTES];
83
84
85#ifdef __cplusplus
86}
87#endif
88
89#endif
90
91/**
92@}
93 */
94