ECDH.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021, 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 should be stored in an array with the least significant byte of the integer
91  * hex representation stored in the highest address of the array (big-endian).
92  * The array should be the same length as the curve parameters of the curve used.
93  * The driver validates private keys against the provided curve by default.
94  * - Initialize the private key CryptoKey. CryptoKeys are opaque data structures and representations
95  * of keying material and its storage. Depending on how the keying material
96  * is stored (RAM or flash, key store), the CryptoKey must be
97  * initialized differently. The ECDH API can handle all types of CryptoKey.
98  * However, not all device-specific implementations support all types of CryptoKey.
99  * Devices without a key store will not support CryptoKeys with keying material
100  * stored in a key store for example.
101  * All devices support plaintext CryptoKeys.
102  * - Initialize a blank CryptoKey for the public key. The CryptoKey will keep track
103  * of where the keying material for the public key should be copied and how
104  * long it is. It should have twice the length of the private key plus one
105  * for SEC 1-based octet string format public keys or the length of the private
106  * key for RFC 7748 Montgomery curve X-only public keys.
107  * - Initialize the ECDH_OperationGeneratePublicKey struct and then populate it. By
108  * default, octet string 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_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY.
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, octet string public keys will be assumed and octet string shared secrets
133  * will be generated.
134  * - If importing RFC 7748-style public keys, initialize the operation's public key
135  * data format to be ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY.
136  * - If generating RFC 7748-style shared secrets, initialize the operation's shared secret
137  * data format to be ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY.
138  * - Call ECDH_computeSharedSecret(). The shared secret will be copied to a location
139  * according to the shared secret CryptoKey passed to the function call. The driver
140  * will validate the supplied public key and reject invalid ones.
141  *
142  * ## Creating one or more symmetric keys from the shared secret #
143  * After calculating the shared secret between the application and the other party,
144  * the entropy in the shared secret must be evened out and stretched as needed. There are
145  * uncountable methods and algorithms to stretch an original seed entropy (the share secret)
146  * to generate symmetric keys.
147  * - Run the X coordinate of the resulting entropy through a key derivation function (KDF)
148  *
149  * ## After a key exchange #
150  * After the ECDH key exchange completes, the application should either start another operation
151  * or close the driver by calling ECDH_close()
152  *
153  * ## General usage #
154  * The API expects elliptic curves as defined in ti/drivers/cryptoutils/ecc/ECCParams.h.
155  * Several commonly used curves are provided. Check the device-specific ECDH documentation
156  * for curve type (short Weierstrass, Montgomery, Edwards) support for your device.
157  * ECDH support for a curve type on a device does not imply curve-type support for
158  * other ECC schemes.
159  *
160  * ## Key Formatting
161  * By default, the ECDH API expects the private and public keys to be formatted in octet
162  * string format. The details of octet string formatting can be found in
163  * SEC 1: Elliptic Curve Cryptography.
164  *
165  * Private keys are formatted as big-endian integers of the same length as the
166  * curve length.
167  *
168  * Public keys and shared secrets are points on an elliptic curve. These points can
169  * be expressed in several ways. The most common one is in affine coordinates as an
170  * X,Y pair.
171  * This API uses points expressed in uncompressed affine coordinates by default.
172  * The octet string format requires a formatting byte in the first byte of the
173  * public key. When using uncompressed affine coordinates, this is the value
174  * 0x04.
175  * The point itself is stored as a concatenated array of X followed by Y.
176  * X and Y are big-endian. Some implementations do not require or yield
177  * the Y coordinate for ECDH on certain curves. It is recommended that the full
178  * keying material buffer of twice the curve param length is used to facilitate
179  * code-reuse. Implementations that do not use the Y coordinate will zero-out
180  * the Y-coordinate whenever they write a point to the CryptoKey.
181  *
182  * If device-supported, Montgomery curves can be stored as their X-only format
183  * based on the RFC-7748 specification. Here, only the X coordinate is packed
184  * in little-endian integers of the same length as the curve length.
185  *
186  * This API accepts and returns the keying material of public keys according
187  * to the following table:
188  *
189  * | Curve Type | Keying Material Array | Array Length |
190  * |--------------------|-----------------------|----------------------------|
191  * | Short Weierstrass | [0x04, X, Y] | 1 + 2 * Curve Param Length |
192  * | Montgomery | [0x04, X, Y] | 1 + 2 * Curve Param Length |
193  * | Montgomery | [X] | Curve Param Length |
194  * | Edwards | [0x04, X, Y] | 1 + 2 * Curve Param Length |
195  *
196  * Note: This driver will automatically prune the private key according to
197  * RFC 7748 for the following curve:
198  * X25519
199  *
200  * @anchor ti_drivers_ECDH_Synopsis
201  * ## Synopsis
202  * @anchor ti_drivers_ECDH_Synopsis_Code
203  * @code
204  * // Import ECDH Driver definitions
205  * #include <ti/drivers/ECDH.h>
206  *
207  * ECDH_init();
208  *
209  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
210  * ecdhHandle = ECDH_open(0, NULL);
211  *
212  * // Initialize myPrivateKey and myPublicKey
213  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
214  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
215  *
216  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
217  * operationGeneratePublicKey.curve = &ECCParams_NISTP256;
218  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
219  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
220  *
221  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
222  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
223  *
224  * // Now send the content of myPublicKeyingMaterial to the other party,
225  * // receive their public key, and copy their public keying material to theirPublicKeyingMaterial
226  *
227  * // Initialize their public CryptoKey and the shared secret CryptoKey
228  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
229  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
230  *
231  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific implementation
232  * ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
233  * operationComputeSharedSecret.curve = &ECCParams_NISTP256;
234  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
235  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
236  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
237  *
238  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
239  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
240  *
241  * // Close the driver
242  * ECDH_close(ecdhHandle);
243  *
244  * @endcode
245  *
246  * ## Synopsis for X25519 X-only key exchange
247  * @anchor ti_drivers_ECDH_X25519_Code
248  * @code
249  * // Import ECDH Driver definitions
250  * #include <ti/drivers/ECDH.h>
251  *
252  * ECDH_init();
253  *
254  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
255  * ecdhHandle = ECDH_open(0, NULL);
256  *
257  * // Initialize myPrivateKey and myPublicKey
258  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
259  * // Note that the public key size is only 32 bytes
260  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
261  *
262  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
263  * operationGeneratePublicKey.curve = &ECCParams_Curve25519;
264  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
265  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
266  * // If generating an RFC 7748 X-Only formatted key, we use the following public key data format:
267  * operationGeneratePublicKey.publicKeyDataFormat = ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY;
268  *
269  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
270  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
271  *
272  * // Now send the content of myPublicKeyingMaterial to the other party,
273  * // receive their public key, and copy their public keying material to theirPublicKeyingMaterial
274  *
275  * // Initialize their public CryptoKey and the shared secret CryptoKey
276  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
277  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
278  *
279  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific implementation
280  * ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
281  * operationComputeSharedSecret.curve = &ECCParams_Curve25519;
282  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
283  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
284  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
285  * // If receiving an RFC 7748 X-Only formatted key, we specify the input format:
286  * operationComputeSharedSecret.publicKeyDataFormat = ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY;
287  * // If agreeing on an RFC 7748 X-Only formatted shared secret, we specify the shared secret format
288  * operationComputeSharedSecret.sharedSecretDataFormat = ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY;
289  *
290  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
291  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
292  *
293  * // Close the driver
294  * ECDH_close(ecdhHandle);
295  *
296  * @endcode
297  *
298  * @anchor ti_drivers_ECDH_Examples
299  * # Examples #
300  *
301  * ## ECDH exchange with plaintext CryptoKeys #
302  *
303  * @code
304  *
305  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
306  * #include <ti/drivers/ECDH.h>
307  *
308  * #define CURVE_LENGTH 32
309  *
310  * ...
311  *
312  * // Our private key is 0x0000000000000000000000000000000000000000000000000000000000000001
313  * // In practice, this value should come from a TRNG, PRNG, PUF, or device-specific pre-seeded key
314  * uint8_t myPrivateKeyingMaterial[CURVE_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
315  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
316  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
317  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
318  * uint8_t myPublicKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
319  * uint8_t theirPublicKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
320  * uint8_t sharedSecretKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
321  * uint8_t symmetricKeyingMaterial[16] = {0};
322  *
323  * CryptoKey myPrivateKey;
324  * CryptoKey myPublicKey;
325  * CryptoKey theirPublicKey;
326  * CryptoKey sharedSecret;
327  * CryptoKey symmetricKey;
328  *
329  * ECDH_Handle ecdhHandle;
330  *
331  * int_fast16_t operationResult;
332  *
333  * ECDH_OperationGeneratePublicKey operationGeneratePublicKey;
334  *
335  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
336  * ecdhHandle = ECDH_open(0, NULL);
337  *
338  * if (!ecdhHandle) {
339  * // Handle error
340  * }
341  *
342  * // Initialize myPrivateKey and myPublicKey
343  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
344  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
345  *
346  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
347  * operationGeneratePublicKey.curve = &ECCParams_NISTP256;
348  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
349  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
350  *
351  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
352  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
353  *
354  * if (operationResult != ECDH_STATUS_SUCCESS) {
355  * // Handle error
356  * }
357  *
358  * // Now send the content of myPublicKeyingMaterial to the other party,
359  * // receive their public key, and copy their public keying material and the
360  * // 0x04 byte to theirPublicKeyingMaterial
361  *
362  * // Initialise their public CryptoKey and the shared secret CryptoKey
363  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
364  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
365  *
366  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific implementation
367  * ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
368  * operationComputeSharedSecret.curve = &ECCParams_NISTP256;
369  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
370  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
371  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
372  *
373  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
374  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
375  *
376  * if (operationResult != ECDH_STATUS_SUCCESS) {
377  * // Handle error
378  * }
379  *
380  * CryptoKeyPlaintext_initBlankKey(&symmetricKey, symmetricKeyingMaterial, sizeof(symmetricKeyingMaterial));
381  *
382  * // Set up a KDF such as HKDF and open the requisite cryptographic primitive driver to implement it
383  * // HKDF and SHA2 were chosen as an example and may not be available directly
384  *
385  * // At this point, you and the other party have both created the content within symmetricKeyingMaterial without
386  * // someone else listening to your communication channel being able to do so
387  *
388  * @endcode
389  *
390  *
391  */
392 
393 
394 #ifndef ti_drivers_ECDH__include
395 #define ti_drivers_ECDH__include
396 
397 #include <stdbool.h>
398 #include <stddef.h>
399 #include <stdint.h>
400 
403 
404 #ifdef __cplusplus
405 extern "C" {
406 #endif
407 
420 #define ECDH_STATUS_RESERVED (-32)
421 
428 #define ECDH_STATUS_SUCCESS (0)
429 
436 #define ECDH_STATUS_ERROR (-1)
437 
446 #define ECDH_STATUS_RESOURCE_UNAVAILABLE (-2)
447 
454 #define ECDH_STATUS_POINT_AT_INFINITY (-3)
455 
462 #define ECDH_STATUS_PRIVATE_KEY_LARGER_EQUAL_ORDER (-4)
463 
470 #define ECDH_STATUS_PRIVATE_KEY_ZERO (-5)
471 
478 #define ECDH_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-6)
479 
487 #define ECDH_STATUS_PUBLIC_KEY_LARGER_THAN_PRIME (-7)
488 
492 #define ECDH_STATUS_CANCELED (-8)
493 
502 #define ECDH_STATUS_INVALID_KEY_SIZE (-9)
503 
515 typedef struct {
517  void *object;
518 
520  void const *hwAttrs;
521 } ECDH_Config;
522 
527 
554 typedef enum {
570 
571 typedef enum {
579 
583 typedef struct {
597 
601 typedef struct {
620 
624 typedef union {
628 
632 typedef enum {
636 
655 typedef void (*ECDH_CallbackFxn) (ECDH_Handle handle,
656  int_fast16_t returnStatus,
657  ECDH_Operation operation,
658  ECDH_OperationType operationType);
659 
668 typedef struct {
671  uint32_t timeout;
672  void *custom;
675 } ECDH_Params;
676 
682 extern const ECDH_Params ECDH_defaultParams;
683 
692 void ECDH_init(void);
693 
707 
725 ECDH_Handle ECDH_open(uint_least8_t index, const ECDH_Params *params);
726 
736 void ECDH_close(ECDH_Handle handle);
737 
747 
757 
781 int_fast16_t ECDH_generatePublicKey(ECDH_Handle handle, ECDH_OperationGeneratePublicKey *operation);
782 
802 int_fast16_t ECDH_computeSharedSecret(ECDH_Handle handle, ECDH_OperationComputeSharedSecret *operation);
803 
817 int_fast16_t ECDH_cancelOperation(ECDH_Handle handle);
818 
842 ECDH_Handle ECDH_construct(ECDH_Config *config, const ECDH_Params *params);
843 
844 #ifdef __cplusplus
845 }
846 #endif
847 
848 #endif /* ti_drivers_ECDH__include */
ECDH_OperationType
Enum for the operation types supported by the driver.
Definition: ECDH.h:632
ADC_Params params
Definition: Driver_Init.h:11
ECC Global configuration.
Definition: ECDH.h:515
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:526
ECDH_KeyMaterialEndianness keyMaterialEndianness
Definition: ECDH.h:593
ECDH_ReturnBehavior returnBehavior
Definition: ECDH.h:669
void ECDH_OperationGeneratePublicKey_init(ECDH_OperationGeneratePublicKey *operation)
Function to initialize an ECDH_OperationGeneratePublicKey struct to its defaults. ...
ECDH_OperationComputeSharedSecret * computeSharedSecret
Definition: ECDH.h:626
int_fast16_t ECDH_cancelOperation(ECDH_Handle handle)
Cancels an ongoing ECDH operation.
Definition: ECDH.h:565
void * object
Definition: ECDH.h:517
void * custom
Definition: ECDH.h:672
Struct containing the parameters required to compute the shared secret.
Definition: ECDH.h:601
CryptoKey datastructure.
Definition: CryptoKey.h:192
const CryptoKey * theirPublicKey
Definition: ECDH.h:608
ECDH_CallbackFxn callbackFxn
Definition: ECDH.h:670
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:655
void ECDH_OperationComputeSharedSecret_init(ECDH_OperationComputeSharedSecret *operation)
Function to initialize an ECDH_OperationComputeSharedSecret struct to its defaults.
ECDH_OperationGeneratePublicKey * generatePublicKey
Definition: ECDH.h:625
int_fast16_t ECDH_generatePublicKey(ECDH_Handle handle, ECDH_OperationGeneratePublicKey *operation)
Generates a public key for use in key agreement.
const CryptoKey * myPrivateKey
Definition: ECDH.h:585
const CryptoKey * myPrivateKey
Definition: ECDH.h:605
ECDH_KeyMaterialEndianness
Definition: ECDH.h:571
const ECCParams_CurveParams * curve
Definition: ECDH.h:602
void ECDH_init(void)
This function initializes the ECC module.
ECC Parameters.
Definition: ECDH.h:668
Definition: ECDH.h:561
ECDH_Handle ECDH_open(uint_least8_t index, const ECDH_Params *params)
This function opens a given ECC peripheral.
Definition: ECDH.h:572
uint32_t timeout
Definition: ECDH.h:671
CryptoKey * sharedSecret
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:554
int_fast16_t ECDH_computeSharedSecret(ECDH_Handle handle, ECDH_OperationComputeSharedSecret *operation)
Computes a shared secret.
ECDH_KeyMaterialEndianness keyMaterialEndianness
Definition: ECDH.h:616
Struct containing the parameters required to generate a public key.
Definition: ECDH.h:583
void ECDH_close(ECDH_Handle handle)
Function to close an ECC peripheral specified by the ECC handle.
const ECCParams_CurveParams * curve
Definition: ECDH.h:584
A structure containing the parameters of an elliptic curve in short Weierstrass form.
Definition: ECCParams.h:116
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.
void const * hwAttrs
Definition: ECDH.h:520
Definition: ECDH.h:575
CryptoKey * myPublicKey
Definition: ECDH.h:588
Union containing pointers to all supported operation structs.
Definition: ECDH.h:624
Definition: ECDH.h:555
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale