ECDHCC26X4_s.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Texas Instruments Incorporated - https://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 #ifndef ti_drivers_ecdh_ECDHCC26X4_s__include
34 #define ti_drivers_ecdh_ECDHCC26X4_s__include
35 
36 #include <stdint.h>
37 
39 #include <ti/drivers/ECDH.h>
40 
41 #include <ti/sysbios/psa/SecureCB.h>
42 
43 #include <third_party/tfm/interface/include/psa/crypto_types.h>
44 #include <third_party/tfm/interface/include/psa/service.h>
45 
46 #include "ti_drivers_config.h" /* Sysconfig generated header */
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /*
53  * ECDH secure message types
54  */
55 #define ECDH_S_MSG_TYPE_CONSTRUCT (CRYPTO_S_MSG_TYPE_INDEX_ECDH | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 0U)))
56 #define ECDH_S_MSG_TYPE_OPEN (CRYPTO_S_MSG_TYPE_INDEX_ECDH | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 1U)))
57 #define ECDH_S_MSG_TYPE_REGISTER_CALLBACK \
58  (CRYPTO_S_MSG_TYPE_INDEX_ECDH | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 2U)))
59 #define ECDH_S_MSG_TYPE_CLOSE (CRYPTO_S_MSG_TYPE_INDEX_ECDH | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 3U)))
60 #define ECDH_S_MSG_TYPE_GENERATE_PUBLIC_KEY \
61  (CRYPTO_S_MSG_TYPE_INDEX_ECDH | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 4U)))
62 #define ECDH_S_MSG_TYPE_COMPUTE_SHARED_SECRET \
63  (CRYPTO_S_MSG_TYPE_INDEX_ECDH | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 5U)))
64 #define ECDH_S_MSG_TYPE_CANCEL_OPERATION (CRYPTO_S_MSG_TYPE_INDEX_ECDH | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 6U)))
65 
66 /*
67  * Config pool size determines how many dynamic driver instances can be created
68  * by the non-secure client using ECDH_construct().
69  */
70 #ifndef CONFIG_ECDH_S_CONFIG_POOL_SIZE
71  #define CONFIG_ECDH_S_CONFIG_POOL_SIZE 1
72 #endif
73 
74 #define ECDH_SECURE_CALLBACK_COUNT (CONFIG_TI_DRIVERS_ECDH_COUNT + CONFIG_ECDH_S_CONFIG_POOL_SIZE)
75 
76 /*
77  * ========= ECDH Secure Callback struct =========
78  * Non-secure clients must register their callback after opening or
79  * constructing a driver instance with blocking or callback return behavior.
80  */
81 typedef struct
82 {
83  SecureCB_Object object;
84  /* ECDH callback fxn parameters */
86  int_fast16_t returnStatus;
90 
91 /*
92  * ========= ECDH Secure Message Structs =========
93  * These secure message structs correspond to the secure message types defined
94  * above. Together, they are used by non-secure client to make PSA calls to the
95  * ECDH secure service. There is a single input vector for the PSA call
96  * which is a pointer to secure message struct. If the underlying function
97  * has a return value, there is a single output vector which is a pointer to
98  * storage for the return value.
99  */
100 typedef struct
101 {
105 
106 typedef struct
107 {
108  uint_least8_t index;
111 
112 typedef struct
113 {
117 
118 typedef struct
119 {
122 
123 typedef struct
124 {
128 
129 typedef struct
130 {
134 
135 typedef struct
136 {
139 
150 psa_status_t ECDH_s_handlePsaMsg(psa_msg_t *msg);
151 
157 void ECDH_s_init(void);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* ti_drivers_ecdh_ECDHCC26X4_s__include */
ECDH_OperationType
Enum for the operation types supported by the driver.
Definition: ECDH.h:635
ECC Global configuration.
Definition: ECDH.h:510
ECDH_Handle handle
Definition: ECDHCC26X4_s.h:125
ECDH_Handle handle
Definition: ECDHCC26X4_s.h:131
ECDH_Handle handle
Definition: ECDHCC26X4_s.h:137
uint_least8_t index
Definition: ECDHCC26X4_s.h:108
int_fast16_t returnStatus
Definition: ECDHCC26X4_s.h:86
Definition: ECDHCC26X4_s.h:100
Struct containing the parameters required to compute the shared secret.
Definition: ECDH.h:600
ECDH_Handle handle
Definition: ECDHCC26X4_s.h:120
ECDH_OperationType operationType
Definition: ECDHCC26X4_s.h:88
Definition: ECDHCC26X4_s.h:81
Secure Crypto Service.
const ECDH_Params * params
Definition: ECDHCC26X4_s.h:109
TI Driver for Elliptic Curve Diffie-Hellman key agreement scheme.
Definition: ECDHCC26X4_s.h:106
ECC Parameters.
Definition: ECDH.h:672
ECDH_s_SecureCallback * callback
Definition: ECDHCC26X4_s.h:115
ECDH_Handle handle
Definition: ECDHCC26X4_s.h:114
void ECDH_s_init(void)
Initializes the ECDH secure driver.
SecureCB_Object object
Definition: ECDHCC26X4_s.h:83
Definition: ECDHCC26X4_s.h:118
Definition: ECDHCC26X4_s.h:135
const ECDH_Params * params
Definition: ECDHCC26X4_s.h:103
ECDH_OperationGeneratePublicKey * operation
Definition: ECDHCC26X4_s.h:126
Struct containing the parameters required to generate a public key.
Definition: ECDH.h:581
psa_status_t ECDH_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for ECDH secure driver.
Definition: ECDHCC26X4_s.h:129
Definition: ECDHCC26X4_s.h:123
ECDH_Config * config
Definition: ECDHCC26X4_s.h:102
ECDH_Operation operation
Definition: ECDHCC26X4_s.h:87
ECDH_OperationComputeSharedSecret * operation
Definition: ECDHCC26X4_s.h:132
Union containing pointers to all supported operation structs.
Definition: ECDH.h:625
Definition: ECDHCC26X4_s.h:112
ECDH_Handle handle
Definition: ECDHCC26X4_s.h:85
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale