CryptoKeyKeyStore_PSA_s.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2025, Texas Instruments Incorporated - http://www.ti.com
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_s.h
35  * @brief Secure Crypto Service
36  *
37  * @anchor ti_drivers_cryptoutils_cryptokey_CryptoKeyKeyStore_PSA_s_Overview
38  * # Overview
39  * The Secure KeyStore driver is used to access all KeyStore functions
40  * when using the TF-M.
41  *
42  *******************************************************************************
43  */
44 #ifndef ti_drivers_cryptoutils_cryptokey_CryptoKeyKeyStore_PSA_s__include
45 #define ti_drivers_cryptoutils_cryptokey_CryptoKeyKeyStore_PSA_s__include
46 
47 #include <stdint.h>
48 
50 
51 #include <ti/devices/DeviceFamily.h>
52 
53 #include <third_party/tfm/interface/include/psa/crypto.h>
54 #include <third_party/tfm/interface/include/psa/service.h>
55 
56 /* For client side key attribute structure */
57 #include <third_party/tfm/interface/include/psa/crypto_client_struct.h>
58 
59 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4)
60  #include <ti/drivers/crypto/CryptoCC26X4_s.h>
61  /*
62  * Crypto Key Store secure message types
63  */
64  #define KEYSTORE_PSA_S_MSG_TYPE_GET_KEY KEYSTORE_PSA_S_MSG_TYPE(0U)
65  #define KEYSTORE_PSA_S_MSG_TYPE_GENERATE_KEY KEYSTORE_PSA_S_MSG_TYPE(1U)
66  #define KEYSTORE_PSA_S_MSG_TYPE_EXPORT_PUBLIC_KEY KEYSTORE_PSA_S_MSG_TYPE(2U)
67  #define KEYSTORE_PSA_S_MSG_TYPE_EXPORT_KEY KEYSTORE_PSA_S_MSG_TYPE(3U)
68  #define KEYSTORE_PSA_S_MSG_TYPE_DESTROY_KEY KEYSTORE_PSA_S_MSG_TYPE(4U)
69  #define KEYSTORE_PSA_S_MSG_TYPE_IMPORT_KEY KEYSTORE_PSA_S_MSG_TYPE(5U)
70  #define KEYSTORE_PSA_S_MSG_TYPE_PURGE_KEY KEYSTORE_PSA_S_MSG_TYPE(6U)
71  #define KEYSTORE_PSA_S_MSG_TYPE_GET_KEY_ATTRIBUTES KEYSTORE_PSA_S_MSG_TYPE(7U)
72  #define KEYSTORE_PSA_S_MSG_TYPE_RESET_KEY_ATTRIBUTES KEYSTORE_PSA_S_MSG_TYPE(8U)
73 #endif
74 
75 /*
76  * ============ KeyStore driver Secure Message Structs =========
77  * These secure message structs correspond to the secure message types defined
78  * above. Together, they are used by non-secure client to make PSA calls to the
79  * KeyStore secure service. There is a single input vector for the PSA call
80  * which is a pointer to secure message struct. If the underlying function
81  * has a return value, there is a single output vector which is a pointer to
82  * storage for the return value.
83  */
84 typedef struct
85 {
86  uint32_t key;
87  uint8_t *data;
88  size_t dataSize;
89  size_t *dataLength;
93 
94 typedef struct
95 {
96  struct psa_client_key_attributes_s *attributes;
99 
100 /* Msg for KeyStore_PSA_exportKey() and KeyStore_PSA_exportPublicKey() */
101 typedef struct
102 {
103  uint32_t key;
104  uint8_t *data;
105  size_t dataSize;
106  size_t *dataLength;
108 
109 typedef struct
110 {
111  struct psa_client_key_attributes_s *attributes;
112  uint8_t *data;
113  size_t dataLength;
114  uint32_t *key;
116 
117 /* Msg for KeyStore_PSA_destroyKey() and KeyStore_PSA_purgeKey() */
118 typedef struct
119 {
120  uint32_t key;
122 
123 typedef struct
124 {
125  uint32_t key;
126  struct psa_client_key_attributes_s *attributes;
128 
129 typedef struct
130 {
131  struct psa_client_key_attributes_s *attributes;
133 
144 psa_status_t KeyStore_s_handlePsaMsg(psa_msg_t *msg);
145 
151 void KeyStore_s_init(void);
152 
164 psa_status_t KeyStore_s_copyKeyAttributesFromClient(struct psa_client_key_attributes_s *clientKeyAttr,
165  int32_t clientId,
166  psa_key_attributes_t *keyAttributes);
167 
176 void KeyStore_s_copyKeyIDFromClient(KeyStore_PSA_KeyFileId *keyID, int32_t clientId, uint32_t *clientKeyID);
177 #endif /* ti_drivers_cryptoutils_cryptokey_CryptoKeyKeyStore_PSA_s__include */
Definition: CryptoKeyKeyStore_PSA_s.h:109
size_t dataSize
Definition: CryptoKeyKeyStore_PSA_s.h:105
psa_key_usage_t KeyStore_PSA_KeyUsage
Encoding of permitted usage on a key.
Definition: CryptoKeyKeyStore_PSA.h:133
uint32_t key
Definition: CryptoKeyKeyStore_PSA_s.h:86
uint32_t * key
Definition: CryptoKeyKeyStore_PSA_s.h:114
KeyStore_PSA_Algorithm alg
Definition: CryptoKeyKeyStore_PSA_s.h:90
uint32_t key
Definition: CryptoKeyKeyStore_PSA_s.h:125
CryptoKeyKeyStore_PSA driver header.
psa_status_t KeyStore_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for KeyStore secure driver.
KeyStore_PSA_KeyUsage usage
Definition: CryptoKeyKeyStore_PSA_s.h:91
mbedtls_svc_key_id_t KeyStore_PSA_KeyFileId
Definition: CryptoKeyKeyStore_PSA.h:1206
struct psa_client_key_attributes_s * attributes
Definition: CryptoKeyKeyStore_PSA_s.h:126
Definition: CryptoKeyKeyStore_PSA_s.h:84
uint8_t * data
Definition: CryptoKeyKeyStore_PSA_s.h:104
uint32_t key
Definition: CryptoKeyKeyStore_PSA_s.h:103
uint8_t * data
Definition: CryptoKeyKeyStore_PSA_s.h:112
Definition: CryptoKeyKeyStore_PSA_s.h:94
size_t * dataLength
Definition: CryptoKeyKeyStore_PSA_s.h:89
KeyStore_PSA_KeyFileId * key
Definition: CryptoKeyKeyStore_PSA_s.h:97
void KeyStore_s_copyKeyIDFromClient(KeyStore_PSA_KeyFileId *keyID, int32_t clientId, uint32_t *clientKeyID)
Copies client key ID from non-secure side to secure side.
uint32_t key
Definition: CryptoKeyKeyStore_PSA_s.h:120
Definition: CryptoKeyKeyStore_PSA_s.h:101
size_t dataLength
Definition: CryptoKeyKeyStore_PSA_s.h:113
psa_algorithm_t KeyStore_PSA_Algorithm
Encoding of a cryptographic algorithm.
Definition: CryptoKeyKeyStore_PSA.h:575
psa_status_t KeyStore_s_copyKeyAttributesFromClient(struct psa_client_key_attributes_s *clientKeyAttr, int32_t clientId, psa_key_attributes_t *keyAttributes)
Gets key attributes from client key attributes. Follows tfm_crypto_key_attributes_from_client() ...
struct psa_client_key_attributes_s * attributes
Definition: CryptoKeyKeyStore_PSA_s.h:131
Definition: CryptoKeyKeyStore_PSA_s.h:123
size_t dataSize
Definition: CryptoKeyKeyStore_PSA_s.h:88
struct psa_client_key_attributes_s * attributes
Definition: CryptoKeyKeyStore_PSA_s.h:111
Definition: CryptoKeyKeyStore_PSA_s.h:129
struct psa_client_key_attributes_s * attributes
Definition: CryptoKeyKeyStore_PSA_s.h:96
size_t * dataLength
Definition: CryptoKeyKeyStore_PSA_s.h:106
uint8_t * data
Definition: CryptoKeyKeyStore_PSA_s.h:87
Definition: CryptoKeyKeyStore_PSA_s.h:118
void KeyStore_s_init(void)
Initializes the KeyStore secure driver.
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale