ECDH.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-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  * @file ECDH.h
34  *
35  * @brief TI Driver for Elliptic Curve Diffie-Hellman key agreement scheme.
36  *
37  * @anchor ti_drivers_ECDH_Overview
38  * # Overview #
39  *
40  * Elliptic Curve Diffie-Hellman (ECDH) is a key agreement scheme between
41  * two parties based on the Diffie-Hellman key exchange protocol.
42  *
43  * It provides a means of generating a shared secret and derived symmetric key
44  * between the two parties over an insecure channel.
45  *
46  * It does not provide authentication. As such, it does not guarantee that the
47  * party you are exchanging keys with is truly the party you wish to establish a
48  * secured channel with.
49  *
50  * The two parties each generate a private key and a public key. The private key
51  * is a random integer in the interval [1, n - 1], where n is the order of a
52  * previously agreed upon curve. The public key is generated
53  * by multiplying the private key by the generator point of a previously agreed
54  * upon elliptic curve such as NISTP256 or Curve 25519. The public key is itself
55  * a point upon the elliptic curve. Each public key is then transmitted to the
56  * other party over a potentially insecure channel. The other party's public key
57  * is then multiplied with the private key, generating a shared secret. This
58  * shared secret is also a point on the curve. However, the entropy in the secret
59  * is not spread evenly throughout the shared secret. In order to generate one or more
60  * shared symmetric keys, the shared secret must be run through a key derivation
61  * function (KDF) that was previously agreed upon. Usually, only the X coordinate
62  * is processed in this way as it contains all the entropy of the shared secret and
63  * some curve implementations only provide the X coordinate. The key derivation function
64  * can take many forms, from simply hashing the X coordinate of the shared secret
65  * with SHA2 and truncating the result to generating multiple symmetric keys with
66  * HKDF, an HMAC based KDF.
67  *
68  * Key derivation functions in the context of symmetric key generation after
69  * elliptic curve based key exchange differ from KDFs used to generate keys from
70  * passwords a user provides in a login. Those KDFs such as bcrypt purposefully
71  * add additional computation to increase a system's resistance against brute
72  * force or dictionary attacks.
73  *
74  * @anchor ti_drivers_ECDH_Usage
75  * # Usage #
76  *
77  * ## Before starting an ECDH operation #
78  *
79  * Before starting an ECDH operation, the application must do the following:
80  * - Call ECDH_init() to initialize the driver
81  * - Call ECDH_Params_init() to initialize the ECDH_Params to default values.
82  * - Modify the ECDH_Params as desired
83  * - Call ECDH_open() to open an instance of the driver
84  *
85  * ## Generating your public-private key pair #
86  * To generate a public-private key pair for an agreed upon curve, the application
87  * must do the following:
88  * - Generate the keying material for the private key. This keying material must
89  * be an integer in the interval [1, n - 1], where n is the order of the curve.
90  * It can be stored in big-endian or little-endian format.
91  * The array should be the same length as the curve parameters of the curve used.
92  * The driver validates private keys against the provided curve by default.
93  * - Initialize the private key CryptoKey. CryptoKeys are opaque data structures and representations
94  * of keying material and its storage. Depending on how the keying material
95  * is stored (RAM or flash, key store), the CryptoKey must be
96  * initialized differently. The ECDH API can handle all types of CryptoKey.
97  * However, not all device-specific implementations support all types of CryptoKey.
98  * Devices without a key store will not support CryptoKeys with keying material
99  * stored in a key store for example.
100  * All devices support plaintext CryptoKeys.
101  * - Initialize a blank CryptoKey for the public key. The CryptoKey will keep track
102  * of where the keying material for the public key should be copied and how
103  * long it is. SEC 1-based big-endian format public keys should have key material twice the length
104  * of the private key plus one. Little-endian format public keys should have key material the
105  * length of the private key for Montgomery curve X-only public keys or have key material twice
106  * the length of the private for other curves
107  * - Initialize the ECDH_OperationGeneratePublicKey struct and then populate it. By
108  * default, big-endian public keys will be generated.
109  * - If using RFC 7748-style public keys, initialize the operation's public key
110  * data format to be ECDH_LITTLE_ENDIAN_KEY.
111  * - Call ECDH_generatePublicKey(). The generated keying material will be copied
112  * according the the CryptoKey passed in as the public key parameter. The CryptoKey
113  * will no longer be considered 'blank' after the operation.
114  *
115  * ## Calculating a shared secret #
116  * After trading public keys with the other party, the application should do the following
117  * to calculate the shared secret:
118  * - Initialize a CryptoKey as public key with the keying material received from the other
119  * party.
120  * - Initialize the private key CryptoKey with the key used to generate your
121  * public key. CryptoKeys are opaque data structures and representations
122  * of keying material and its storage. Depending on how the keying material
123  * is stored (RAM or flash, key store), the CryptoKey must be
124  * initialized differently. The ECDH API can handle all types of CryptoKey.
125  * However, not all device-specific implementations support all types of CryptoKey.
126  * Devices without a key store will not support CryptoKeys with keying material
127  * stored in a key store for example.
128  * All devices support plaintext CryptoKeys.
129  * - Initialize a blank CryptoKey with the same size as the previously initialized
130  * public key.
131  * - Initialize the ECDH_OperationComputeSharedSecret struct and then populate it. By
132  * default, big-endian input keys will be assumed and big-endian shared secrets
133  * will be generated.
134  * - If importing RFC 7748-style public keys, initialize the operation's key material
135  * endianess to be ECDH_LITTLE_ENDIAN_KEY.
136  * - Call ECDH_computeSharedSecret(). The shared secret will be copied to a location
137  * according to the shared secret CryptoKey passed to the function call. The driver
138  * will validate the supplied public key and reject invalid ones.
139  *
140  * ## Creating one or more symmetric keys from the shared secret #
141  * After calculating the shared secret between the application and the other party,
142  * the entropy in the shared secret must be evened out and stretched as needed. There are
143  * uncountable methods and algorithms to stretch an original seed entropy (the share secret)
144  * to generate symmetric keys.
145  * - Run the X coordinate of the resulting entropy through a key derivation function (KDF)
146  *
147  * ## After a key exchange #
148  * After the ECDH key exchange completes, the application should either start another operation
149  * or close the driver by calling ECDH_close()
150  *
151  * ## General usage #
152  * The API expects elliptic curves as defined in ti/drivers/cryptoutils/ecc/ECCParams.h.
153  * Several commonly used curves are provided. Check the device-specific ECDH documentation
154  * for curve type (short Weierstrass, Montgomery, Edwards) support for your device.
155  * ECDH support for a curve type on a device does not imply curve-type support for
156  * other ECC schemes.
157  *
158  * ## Key Formatting
159  * By default, the ECDH API expects the private and public keys to be formatted in
160  * big-endian format. The details of octet string formatting can be found in
161  * SEC 1: Elliptic Curve Cryptography.
162  *
163  * ## Limitations #
164  * For CC27XX devices, the ECDH driver cannot accept private keys with a
165  * value of 0x01 (entire value is 0x01).
166  *
167  * Private keys can be formatted as big-endian or little-endian integers of the same
168  * length as the curve length.
169  *
170  * Public keys and shared secrets are points on an elliptic curve. These points can
171  * be expressed in several ways. The most common one is in affine coordinates as an
172  * X,Y pair.
173  * This API uses points expressed in uncompressed affine coordinates by default.
174  * The big-endian format requires a formatting byte in the first byte of the
175  * public key. When using uncompressed affine coordinates, this is the value
176  * 0x04.
177  * The point itself is stored as a concatenated array of X followed by Y.
178  * X and Y maybe in big-endian or little-endian. Some implementations do not require or
179  * yield the Y coordinate for ECDH on certain curves. It is recommended that the full
180  * keying material buffer of twice the curve param length is used to facilitate
181  * code-reuse. Implementations that do not use the Y coordinate will zero-out
182  * the Y-coordinate whenever they write a point to the CryptoKey.
183  *
184  * If device-supported, Montgomery curves can be stored as their X-only format
185  * based on the RFC-7748 specification. Here, only the X coordinate is packed
186  * in little-endian integers of the same length as the curve length.
187  *
188  * This API accepts and returns the keying material of public keys according
189  * to the following table:
190  *
191  * | Curve Type | Keying Material Array | Array Length |
192  * |--------------------|-----------------------|----------------------------|
193  * | Short Weierstrass | [0x04, X, Y] | 1 + 2 * Curve Param Length |
194  * | Montgomery | [0x04, X, Y] | 1 + 2 * Curve Param Length |
195  * | Montgomery | [X] | Curve Param Length |
196  * | Edwards | [0x04, X, Y] | 1 + 2 * Curve Param Length |
197  *
198  * Note: This driver will automatically prune the private key according to
199  * RFC 7748 for the following curve:
200  * X25519
201  *
202  * @anchor ti_drivers_ECDH_Synopsis
203  * ## Synopsis
204  * @anchor ti_drivers_ECDH_Synopsis_Code
205  * @code
206  * // Import ECDH Driver definitions
207  * #include <ti/drivers/ECDH.h>
208  *
209  * ECDH_init();
210  *
211  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
212  * ecdhHandle = ECDH_open(0, NULL);
213  *
214  * // Initialize myPrivateKey and myPublicKey
215  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
216  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
217  *
218  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
219  * operationGeneratePublicKey.curve = &ECCParams_NISTP256;
220  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
221  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
222  *
223  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
224  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
225  *
226  * // Now send the content of myPublicKeyingMaterial to the other party,
227  * // receive their public key, and copy their public keying material to theirPublicKeyingMaterial
228  *
229  * // Initialize their public CryptoKey and the shared secret CryptoKey
230  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
231  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
232  *
233  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific
234  * implementation ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
235  * operationComputeSharedSecret.curve = &ECCParams_NISTP256;
236  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
237  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
238  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
239  *
240  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
241  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
242  *
243  * // Close the driver
244  * ECDH_close(ecdhHandle);
245  *
246  * @endcode
247  *
248  * ## Synopsis for X25519 X-only key exchange
249  * @anchor ti_drivers_ECDH_X25519_Code
250  * @code
251  * // Import ECDH Driver definitions
252  * #include <ti/drivers/ECDH.h>
253  *
254  * ECDH_init();
255  *
256  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
257  * ecdhHandle = ECDH_open(0, NULL);
258  *
259  * // For CC27XX devices only,
260  * // Since the ECDH driver for CC27XX relies on one HW engine (the HSM) for all of its operations
261  * // If the HSM boot up sequence fails, ECDH_open() will return NULL.
262  * if (!ecdhHandle) {
263  * // Handle error
264  * }
265  *
266  *
267  * // Initialize myPrivateKey and myPublicKey
268  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
269  * // Note that the public key size is only 32 bytes
270  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
271  *
272  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
273  * operationGeneratePublicKey.curve = &ECCParams_Curve25519;
274  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
275  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
276  * // If generating public key in little-endian format, we use the following format:
277  * operationGeneratePublicKey.keyMaterialEndianness = ECDH_LITTLE_ENDIAN_KEY;
278  *
279  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
280  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
281  *
282  * // Now send the content of myPublicKeyingMaterial to the other party,
283  * // receive their public key, and copy their public keying material to theirPublicKeyingMaterial
284  *
285  * // Initialize their public CryptoKey and the shared secret CryptoKey
286  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
287  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
288  *
289  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific
290  * implementation ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
291  * operationComputeSharedSecret.curve = &ECCParams_Curve25519;
292  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
293  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
294  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
295  * // If receiving and generating keys in little-endian format, we use the following format:
296  * operationComputeSharedSecret.keyMaterialEndianness = ECDH_LITTLE_ENDIAN_KEY;
297  *
298  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
299  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
300  *
301  * // Close the driver
302  * ECDH_close(ecdhHandle);
303  *
304  * @endcode
305  *
306  * @anchor ti_drivers_ECDH_Examples
307  * # Examples #
308  *
309  * ## ECDH exchange with plaintext CryptoKeys #
310  *
311  * @code
312  *
313  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
314  * #include <ti/drivers/ECDH.h>
315  *
316  * #define CURVE_LENGTH 32
317  *
318  * ...
319  *
320  * // Our private key is 0x0000000000000000000000000000000000000000000000000000000000000001
321  * // In practice, this value should come from a TRNG, PRNG, PUF, or device-specific pre-seeded key
322  * uint8_t myPrivateKeyingMaterial[CURVE_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
323  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
324  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
325  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
326  * uint8_t myPublicKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
327  * uint8_t theirPublicKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
328  * uint8_t sharedSecretKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
329  * uint8_t symmetricKeyingMaterial[16] = {0};
330  *
331  * CryptoKey myPrivateKey;
332  * CryptoKey myPublicKey;
333  * CryptoKey theirPublicKey;
334  * CryptoKey sharedSecret;
335  * CryptoKey symmetricKey;
336  *
337  * ECDH_Handle ecdhHandle;
338  *
339  * int_fast16_t operationResult;
340  *
341  * ECDH_OperationGeneratePublicKey operationGeneratePublicKey;
342  *
343  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
344  * ecdhHandle = ECDH_open(0, NULL);
345  *
346  * if (!ecdhHandle) {
347  * // Handle error
348  * }
349  *
350  * // Initialize myPrivateKey and myPublicKey
351  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
352  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
353  *
354  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
355  * operationGeneratePublicKey.curve = &ECCParams_NISTP256;
356  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
357  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
358  *
359  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
360  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
361  *
362  * if (operationResult != ECDH_STATUS_SUCCESS) {
363  * // Handle error
364  * }
365  *
366  * // Now send the content of myPublicKeyingMaterial to the other party,
367  * // receive their public key, and copy their public keying material and the
368  * // 0x04 byte to theirPublicKeyingMaterial
369  *
370  * // Initialise their public CryptoKey and the shared secret CryptoKey
371  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
372  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
373  *
374  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific
375  * implementation ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
376  * operationComputeSharedSecret.curve = &ECCParams_NISTP256;
377  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
378  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
379  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
380  *
381  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
382  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
383  *
384  * if (operationResult != ECDH_STATUS_SUCCESS) {
385  * // Handle error
386  * }
387  *
388  * CryptoKeyPlaintext_initBlankKey(&symmetricKey, symmetricKeyingMaterial, sizeof(symmetricKeyingMaterial));
389  *
390  * // Set up a KDF such as HKDF and open the requisite cryptographic primitive driver to implement it
391  * // HKDF and SHA2 were chosen as an example and may not be available directly
392  *
393  * // At this point, you and the other party have both created the content within symmetricKeyingMaterial without
394  * // someone else listening to your communication channel being able to do so
395  *
396  * @endcode
397  *
398  *
399  */
400 
401 #ifndef ti_drivers_ECDH__include
402 #define ti_drivers_ECDH__include
403 
404 #include <stdbool.h>
405 #include <stddef.h>
406 #include <stdint.h>
407 
410 
411 #ifdef __cplusplus
412 extern "C" {
413 #endif
414 
427 #define ECDH_STATUS_RESERVED (-32)
428 
435 #define ECDH_STATUS_SUCCESS (0)
436 
443 #define ECDH_STATUS_ERROR (-1)
444 
453 #define ECDH_STATUS_RESOURCE_UNAVAILABLE (-2)
454 
461 #define ECDH_STATUS_POINT_AT_INFINITY (-3)
462 
469 #define ECDH_STATUS_PRIVATE_KEY_LARGER_EQUAL_ORDER (-4)
470 
477 #define ECDH_STATUS_PRIVATE_KEY_ZERO (-5)
478 
485 #define ECDH_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-6)
486 
494 #define ECDH_STATUS_PUBLIC_KEY_LARGER_THAN_PRIME (-7)
495 
499 #define ECDH_STATUS_CANCELED (-8)
500 
509 #define ECDH_STATUS_INVALID_KEY_SIZE (-9)
510 
517 #define ECDH_STATUS_KEYSTORE_ERROR (-10)
518 
530 typedef struct
531 {
533  void *object;
534 
536  void const *hwAttrs;
537 } ECDH_Config;
538 
543 
570 typedef enum
571 {
587 
588 typedef enum
589 {
597 
598 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX)
599 
602 typedef enum
603 {
613 
617 typedef enum
618 {
627 #endif
628 
632 typedef struct
633 {
634 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX)
636 #endif
650 
654 typedef struct
655 {
656 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX)
658 #endif
678 
682 typedef union
683 {
689 
693 typedef enum
694 {
698 
717 typedef void (*ECDH_CallbackFxn)(ECDH_Handle handle,
718  int_fast16_t returnStatus,
719  ECDH_Operation operation,
720  ECDH_OperationType operationType);
721 
730 typedef struct
731 {
734  uint32_t timeout;
735  void *custom;
738 } ECDH_Params;
739 
745 extern const ECDH_Params ECDH_defaultParams;
746 
755 void ECDH_init(void);
756 
769 void ECDH_Params_init(ECDH_Params *params);
770 
788 ECDH_Handle ECDH_open(uint_least8_t index, const ECDH_Params *params);
789 
799 void ECDH_close(ECDH_Handle handle);
800 
810 
820 
846 int_fast16_t ECDH_generatePublicKey(ECDH_Handle handle, ECDH_OperationGeneratePublicKey *operation);
847 
869 int_fast16_t ECDH_computeSharedSecret(ECDH_Handle handle, ECDH_OperationComputeSharedSecret *operation);
870 
884 int_fast16_t ECDH_cancelOperation(ECDH_Handle handle);
885 
909 ECDH_Handle ECDH_construct(ECDH_Config *config, const ECDH_Params *params);
910 
911 #ifdef __cplusplus
912 }
913 #endif
914 
915 #endif /* ti_drivers_ECDH__include */
ECDH_OperationType
Enum for the operation types supported by the driver.
Definition: ECDH.h:693
Definition: ECDH.h:621
ECDH_CurveType
Enum for the curve types supported by the driver.
Definition: ECDH.h:602
ECC Global configuration.
Definition: ECDH.h:530
The CryptoKey type is an opaque representation of a cryptographic key.
ECDH_Config * ECDH_Handle
A handle that is returned from an ECDH_open() call.
Definition: ECDH.h:542
ECDH_KeyMaterialEndianness keyMaterialEndianness
Definition: ECDH.h:646
Definition: ECDH.h:619
Definition: ECDH.h:607
ECDH_ReturnBehavior returnBehavior
Definition: ECDH.h:732
void ECDH_OperationGeneratePublicKey_init(ECDH_OperationGeneratePublicKey *operation)
Function to initialize an ECDH_OperationGeneratePublicKey struct to its defaults. ...
ECDH_OperationComputeSharedSecret * computeSharedSecret
Definition: ECDH.h:685
int_fast16_t ECDH_cancelOperation(ECDH_Handle handle)
Cancels an ongoing ECDH operation.
Definition: ECDH.h:582
void * object
Definition: ECDH.h:533
void * custom
Definition: ECDH.h:735
Struct containing the parameters required to compute the shared secret.
Definition: ECDH.h:654
Definition: ECDH.h:620
CryptoKey datastructure.
Definition: CryptoKey.h:211
const CryptoKey * theirPublicKey
Definition: ECDH.h:665
Definition: ECDH.h:604
ECDH_CallbackFxn callbackFxn
Definition: ECDH.h:733
Definition: ECDH.h:624
const ECDH_Params ECDH_defaultParams
Default ECDH_Params structure.
void(* ECDH_CallbackFxn)(ECDH_Handle handle, int_fast16_t returnStatus, ECDH_Operation operation, ECDH_OperationType operationType)
The definition of a callback function used by the ECDH driver when used in ECDH_RETURN_BEHAVIOR_CALLB...
Definition: ECDH.h:717
void ECDH_OperationComputeSharedSecret_init(ECDH_OperationComputeSharedSecret *operation)
Function to initialize an ECDH_OperationComputeSharedSecret struct to its defaults.
ECDH_OperationGeneratePublicKey * generatePublicKey
Definition: ECDH.h:684
int_fast16_t ECDH_generatePublicKey(ECDH_Handle handle, ECDH_OperationGeneratePublicKey *operation)
Generates a public key for use in key agreement.
Definition: ECDH.h:609
const CryptoKey * myPrivateKey
Definition: ECDH.h:638
const CryptoKey * myPrivateKey
Definition: ECDH.h:662
ECDH_KeyMaterialEndianness
Definition: ECDH.h:588
Definition: ECDH.h:623
const ECCParams_CurveParams * curve
Definition: ECDH.h:659
void ECDH_init(void)
This function initializes the ECC module.
ECDH_CurveType curveType
Definition: ECDH.h:657
ECC Parameters.
Definition: ECDH.h:730
Definition: ECDH.h:578
ECDH_Handle ECDH_open(uint_least8_t index, const ECDH_Params *params)
This function opens a given ECC peripheral.
Definition: ECDH.h:625
Definition: ECDH.h:590
uint32_t timeout
Definition: ECDH.h:734
CryptoKey * sharedSecret
Definition: ECDH.h:668
Definition: ECDH.h:606
Definition: ECDH.h:611
ECDH_ReturnBehavior
The way in which ECDH function calls return after performing a public key generation or shared secret...
Definition: ECDH.h:570
Definition: ECDH.h:605
int_fast16_t ECDH_computeSharedSecret(ECDH_Handle handle, ECDH_OperationComputeSharedSecret *operation)
Computes a shared secret.
Definition: ECDH.h:622
ECDH_KeyMaterialEndianness keyMaterialEndianness
Definition: ECDH.h:673
Struct containing the parameters required to generate a public key.
Definition: ECDH.h:632
void ECDH_close(ECDH_Handle handle)
Function to close an ECC peripheral specified by the ECC handle.
ECDH_CurveLength
Enum for signature sizes in bits supported by the driver.
Definition: ECDH.h:617
const ECCParams_CurveParams * curve
Definition: ECDH.h:637
A structure containing the parameters of an elliptic curve.
Definition: ECCParams.h:143
ECDH_Handle ECDH_construct(ECDH_Config *config, const ECDH_Params *params)
Constructs a new ECDH object.
void ECDH_Params_init(ECDH_Params *params)
Function to initialize the ECDH_Params struct to its defaults.
ECDH_CurveType curveType
Definition: ECDH.h:635
void const * hwAttrs
Definition: ECDH.h:536
Definition: ECDH.h:608
Definition: ECDH.h:593
CryptoKey * myPublicKey
Definition: ECDH.h:641
Definition: ECDH.h:610
Union containing pointers to all supported operation structs.
Definition: ECDH.h:682
Definition: ECDH.h:572
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale