CryptoKeyKeyStore_PSA_helpers.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2025, 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  */
32 
33 /*!*****************************************************************************
34  * @file CryptoKeyKeyStore_PSA_helpers.h
35  * @brief CryptoKeyKeyStore driver header
36  *
37  * @anchor ti_drivers_cryptoutils_cryptokey_CryptoKeyKeyStore_PSA_helpers_Overview
38  * # Overview
39  * The CryptoKeyKeyStore driver provides API to initialize keys and get plaintext
40  * keys from KeyStore. This file provides definitions that are only available to the
41  * the secure side, in both TF-M disabled and TF-M enabled environments.
42  *
43  *******************************************************************************
44  */
45 
46 #ifndef ti_drivers_cryptoutils_cryptokey_CryptoKeyKeyStore_PSA_helpers__include
47 #define ti_drivers_cryptoutils_cryptokey_CryptoKeyKeyStore_PSA_helpers__include
48 
49 #include <stddef.h>
50 #include <stdint.h>
51 
53 
54 #include <ti/drivers/dpl/SemaphoreP.h>
55 #include <ti/devices/DeviceFamily.h>
56 
57 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4)
58  #include <third_party/mbedtls/library/psa_crypto_core.h>
59  #include <third_party/mbedtls/library/psa_crypto_slot_management.h>
60  #include <third_party/mbedtls/library/psa_crypto_storage.h>
61 #elif ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX))
63 #else
64  #error "Unsupported DeviceFamily_Parent for CryptoKeyKeyStore_PSA_helpers"
65 #endif
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
76 typedef struct
77 {
78  SemaphoreP_Struct KeyStore_accessSemaphore;
80  bool isAcquired;
82 
84 
85 #define FLETCHER_CHECKSUM_ALGORITHM 32 /* FLETCHER-32 */
86 
120  uint8_t *data,
121  size_t dataSize,
122  size_t *dataLength,
124  KeyStore_PSA_KeyUsage usage);
125 
126 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX))
127 
138 bool KeyStore_acquireLock(void);
139 
147 void KeyStore_releaseLock(void);
148 
184 int_fast16_t KeyStore_PSA_retrieveFromKeyStore(const CryptoKey *key,
185  uint8_t *keyBuffer,
186  size_t keyBufferSize,
187  uint32_t *keyAssetID,
188  KeyStore_PSA_Algorithm targetAlg,
189  KeyStore_PSA_KeyUsage targetUsage);
190 
225  uint32_t *const pAssetId,
226  KeyStore_PSA_Algorithm targetAlg,
227  KeyStore_PSA_KeyUsage targetUsage);
228 
262 int_fast16_t KeyStore_PSA_assetPostProcessing(KeyStore_PSA_KeyFileId key);
264 #endif /* #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == \
265  DeviceFamily_PARENT_CC35XX)) */
266 
282 int_fast16_t KeyStore_PSA_init(void);
283 
284 #ifdef __cplusplus
285 }
286 #endif
287 
288 #endif /* ti_drivers_cryptoutils_cryptokey_CryptoKeyKeyStore_PSA_helpers__include */
psa_key_usage_t KeyStore_PSA_KeyUsage
Encoding of permitted usage on a key.
Definition: CryptoKeyKeyStore_PSA.h:133
The CryptoKey type is an opaque representation of a cryptographic key.
Definition: CryptoKeyKeyStore_PSA_helpers.h:76
CryptoKeyKeyStore_PSA driver header.
CryptoKey datastructure.
Definition: CryptoKey.h:211
KeyStore_accessSemaphoreObject KeyStore_semaphoreObject
mbedtls_svc_key_id_t KeyStore_PSA_KeyFileId
Definition: CryptoKeyKeyStore_PSA.h:1182
bool KeyStore_acquireLock(void)
Attempt to acquire lock to access KeyStore. This function is used to synchronize drivers and the appl...
psa_algorithm_t KeyStore_PSA_Algorithm
Encoding of a cryptographic algorithm.
Definition: CryptoKeyKeyStore_PSA.h:575
SemaphoreP_Struct KeyStore_accessSemaphore
Definition: CryptoKeyKeyStore_PSA_helpers.h:78
int_fast16_t KeyStore_PSA_getKey(KeyStore_PSA_KeyFileId key, uint8_t *data, size_t dataSize, size_t *dataLength, KeyStore_PSA_Algorithm alg, KeyStore_PSA_KeyUsage usage)
Get the plaintext key in binary format.
int_fast16_t KeyStore_PSA_getKeyAssetId(KeyStore_PSA_KeyFileId key, uint32_t *const pAssetId, KeyStore_PSA_Algorithm targetAlg, KeyStore_PSA_KeyUsage targetUsage)
Get the asset ID for a given key ID.
bool isAcquired
Definition: CryptoKeyKeyStore_PSA_helpers.h:80
bool isInitialized
Definition: CryptoKeyKeyStore_PSA_helpers.h:79
int_fast16_t KeyStore_PSA_retrieveFromKeyStore(const CryptoKey *key, uint8_t *keyBuffer, size_t keyBufferSize, uint32_t *keyAssetID, KeyStore_PSA_Algorithm targetAlg, KeyStore_PSA_KeyUsage targetUsage)
Retrieve the key in either plaintext format or as an Asset ID.
int_fast16_t KeyStore_PSA_init(void)
Initialize the Key Store.
void KeyStore_releaseLock(void)
Release lock to access KeyStore.
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale