CryptoKey.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2022, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, 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 Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software 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,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
81 #ifndef ti_drivers_cryptoutils_cyptokey_CryptoKey__include
82 #define ti_drivers_cryptoutils_cyptokey_CryptoKey__include
83 
84 #include <stdint.h>
85 #include <stdbool.h>
86 
87 #if (ENABLE_KEY_STORAGE == 1) || (SPE_ENABLED == 1)
89 #endif
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
117 #define CryptoKey_STATUS_RESERVED (-32)
118 
132 #define CryptoKey_STATUS_SUCCESS (0)
133 
140 #define CryptoKey_STATUS_ERROR (-1)
141 
148 #define CryptoKey_STATUS_UNDEFINED_ENCODING (-2)
149 
158 typedef uint8_t CryptoKey_Encoding;
159 static const CryptoKey_Encoding CryptoKey_PLAINTEXT = 0x02U;
160 static const CryptoKey_Encoding CryptoKey_BLANK_PLAINTEXT = 0x04U;
161 static const CryptoKey_Encoding CryptoKey_KEYSTORE = 0x08U;
162 static const CryptoKey_Encoding CryptoKey_BLANK_KEYSTORE = 0x10U;
163 
170 typedef struct
171 {
172  uint8_t *keyMaterial;
173  uint32_t keyLength;
175 
182 typedef struct
183 {
184  uint32_t keyLength;
185  uint32_t keyID;
186 #if (ENABLE_KEY_STORAGE == 1) || (SPE_ENABLED == 1)
187  KeyStore_PSA_KeyAttributes attributes;
188 #endif
190 
198 typedef struct
199 {
200  CryptoKey_Encoding encoding;
201  union
202  {
205  } u;
206 } CryptoKey;
207 
218 typedef struct CryptoKey_SecurityPolicy_ CryptoKey_SecurityPolicy;
219 
228 int_fast16_t CryptoKey_getCryptoKeyType(CryptoKey *keyHandle, CryptoKey_Encoding *keyType);
229 
238 int_fast16_t CryptoKey_isBlank(CryptoKey *keyHandle, bool *isBlank);
239 
249 int_fast16_t CryptoKey_markAsBlank(CryptoKey *keyHandle);
250 
261 
275 int_fast16_t CryptoKey_verifySecureInputKey(CryptoKey *secureKey);
276 
290 int_fast16_t CryptoKey_verifySecureOutputKey(CryptoKey *secureKey);
291 
292 #ifdef __cplusplus
293 }
294 #endif
295 
296 #endif /* ti_drivers_cryptoutils_cyptokey_CryptoKey__include */
CryptoKey_Plaintext plaintext
Definition: CryptoKey.h:203
static const CryptoKey_Encoding CryptoKey_KEYSTORE
Definition: CryptoKey.h:161
uint8_t CryptoKey_Encoding
List of the different types of CryptoKey.
Definition: CryptoKey.h:158
int_fast16_t CryptoKey_verifySecureOutputKey(CryptoKey *secureKey)
Function to verify a secure output CryptoKey.
static const CryptoKey_Encoding CryptoKey_BLANK_PLAINTEXT
Definition: CryptoKey.h:160
CryptoKeyKeyStore_PSA driver header.
CryptoKey datastructure.
Definition: CryptoKey.h:198
Key store CryptoKey datastructure.
Definition: CryptoKey.h:182
int_fast16_t CryptoKey_getCryptoKeyType(CryptoKey *keyHandle, CryptoKey_Encoding *keyType)
Gets the key type of the CryptoKey.
uint32_t keyID
Definition: CryptoKey.h:185
static const CryptoKey_Encoding CryptoKey_PLAINTEXT
Definition: CryptoKey.h:159
int_fast16_t CryptoKey_verifySecureInputKey(CryptoKey *secureKey)
Function to verify a secure CryptoKey.
uint32_t keyLength
Definition: CryptoKey.h:184
int_fast16_t CryptoKey_markAsBlank(CryptoKey *keyHandle)
Marks a CryptoKey as &#39;blank&#39;.
CryptoKey_Encoding encoding
Definition: CryptoKey.h:200
Plaintext CryptoKey datastructure.
Definition: CryptoKey.h:170
int_fast16_t CryptoKey_initSecurityPolicy(CryptoKey_SecurityPolicy *policy)
Function to initialize the CryptoKey_SecurityPolicy struct to its defaults.
int_fast16_t CryptoKey_isBlank(CryptoKey *keyHandle, bool *isBlank)
Wheather the CryptoKey is &#39;blank&#39; or represents valid keying material.
CryptoKey_KeyStore keyStore
Definition: CryptoKey.h:204
struct CryptoKey_SecurityPolicy_ CryptoKey_SecurityPolicy
Structure that specifies the restrictions on a CryptoKey.
Definition: CryptoKey.h:218
static const CryptoKey_Encoding CryptoKey_BLANK_KEYSTORE
Definition: CryptoKey.h:162
uint8_t * keyMaterial
Definition: CryptoKey.h:172
psa_key_attributes_t KeyStore_PSA_KeyAttributes
Definition: CryptoKeyKeyStore_PSA.h:866
uint32_t keyLength
Definition: CryptoKey.h:173
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale