ECDH.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020, 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, key blob), 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 a blank CryptoKey with the same size as the previously initialized
121  * public key.
122  * - Initialize the ECDH_OperationComputeSharedSecret struct and then populate it. By
123  * default, octet string public keys will be assumed and octet string shared secrets
124  * will be generated.
125  * - If importing RFC 7748-style public keys, initialize the operation's public key
126  * data format to be ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY.
127  * - If generating RFC 7748-style shared secrets, initialize the operation's shared secret
128  * data format to be ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY.
129  * - Call ECDH_computeSharedSecret(). The shared secret will be copied to a location
130  * according to the shared secret CryptoKey passed to the function call. The driver
131  * will validate the supplied public key and reject invalid ones.
132  *
133  * ## Creating one or more symmetric keys from the shared secret #
134  * After calculating the shared secret between the application and the other party,
135  * the entropy in the shared secret must be evened out and stretched as needed. There are
136  * uncountable methods and algorithms to stretch an original seed entropy (the share secret)
137  * to generate symmetric keys.
138  * - Run the X coordinate of the resulting entropy through a key derivation function (KDF)
139  *
140  * ## After a key exchange #
141  * After the ECDH key exchange completes, the application should either start another operation
142  * or close the driver by calling ECDH_close()
143  *
144  * ## General usage #
145  * The API expects elliptic curves as defined in ti/drivers/cryptoutils/ecc/ECCParams.h.
146  * Several commonly used curves are provided. Check the device-specific ECDH documentation
147  * for curve type (short Weierstrass, Montgomery, Edwards) support for your device.
148  * ECDH support for a curve type on a device does not imply curve-type support for
149  * other ECC schemes.
150  *
151  * ## Key Formatting
152  * By default, the ECDH API expects the private and public keys to be formatted in octet
153  * string format. The details of octet string formatting can be found in
154  * SEC 1: Elliptic Curve Cryptography.
155  *
156  * Private keys are formatted as big-endian integers of the same length as the
157  * curve length.
158  *
159  * Public keys and shared secrets are points on an elliptic curve. These points can
160  * be expressed in several ways. The most common one is in affine coordinates as an
161  * X,Y pair.
162  * This API uses points expressed in uncompressed affine coordinates by default.
163  * The octet string format requires a formatting byte in the first byte of the
164  * public key. When using uncompressed affine coordinates, this is the value
165  * 0x04.
166  * The point itself is stored as a concatenated array of X followed by Y.
167  * X and Y are big-endian. Some implementations do not require or yield
168  * the Y coordinate for ECDH on certain curves. It is recommended that the full
169  * keying material buffer of twice the curve param length is used to facilitate
170  * code-reuse. Implementations that do not use the Y coordinate will zero-out
171  * the Y-coordinate whenever they write a point to the CryptoKey.
172  *
173  * If device-supported, Montgomery curves can be stored as their X-only format
174  * based on the RFC-7748 specification. Here, only the X coordinate is packed
175  * in little-endian integers of the same length as the curve length.
176  *
177  * This API accepts and returns the keying material of public keys according
178  * to the following table:
179  *
180  * | Curve Type | Keying Material Array | Array Length |
181  * |--------------------|-----------------------|----------------------------|
182  * | Short Weierstrass | [0x04, X, Y] | 1 + 2 * Curve Param Length |
183  * | Montgomery | [0x04, X, Y] | 1 + 2 * Curve Param Length |
184  * | Montgomery | [X] | Curve Param Length |
185  * | Edwards | [0x04, X, Y] | 1 + 2 * Curve Param Length |
186  *
187  * @anchor ti_drivers_ECDH_Synopsis
188  * ## Synopsis
189  * @anchor ti_drivers_ECDH_Synopsis_Code
190  * @code
191  * // Import ECDH Driver definitions
192  * #include <ti/drivers/ECDH.h>
193  *
194  * ECDH_init();
195  *
196  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
197  * ecdhHandle = ECDH_open(0, NULL);
198  *
199  * // Initialize myPrivateKey and myPublicKey
200  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
201  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
202  *
203  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
204  * operationGeneratePublicKey.curve = &ECCParams_NISTP256;
205  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
206  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
207  *
208  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
209  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
210  *
211  * // Now send the content of myPublicKeyingMaterial to the other party,
212  * // receive their public key, and copy their public keying material to theirPublicKeyingMaterial
213  *
214  * // Initialize their public CryptoKey and the shared secret CryptoKey
215  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
216  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
217  *
218  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific implementation
219  * ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
220  * operationComputeSharedSecret.curve = &ECCParams_NISTP256;
221  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
222  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
223  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
224  *
225  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
226  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
227  *
228  * // Close the driver
229  * ECDH_close(ecdhHandle);
230  *
231  * @endcode
232  *
233  * ## Synopsis for X25519 X-only key exchange
234  * @anchor ti_drivers_ECDH_X25519_Code
235  * @code
236  * // Import ECDH Driver definitions
237  * #include <ti/drivers/ECDH.h>
238  *
239  * ECDH_init();
240  *
241  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
242  * ecdhHandle = ECDH_open(0, NULL);
243  *
244  * // Initialize myPrivateKey and myPublicKey
245  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
246  * // Note that the public key size is only 32 bytes
247  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
248  *
249  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
250  * operationGeneratePublicKey.curve = &ECCParams_Curve25519;
251  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
252  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
253  * // If generating an RFC 7748 X-Only formatted key, we use the following public key data format:
254  * operationGeneratePublicKey.publicKeyDataFormat = ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY;
255  *
256  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
257  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
258  *
259  * // Now send the content of myPublicKeyingMaterial to the other party,
260  * // receive their public key, and copy their public keying material to theirPublicKeyingMaterial
261  *
262  * // Initialize their public CryptoKey and the shared secret CryptoKey
263  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
264  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
265  *
266  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific implementation
267  * ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
268  * operationComputeSharedSecret.curve = &ECCParams_Curve25519;
269  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
270  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
271  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
272  * // If receiving an RFC 7748 X-Only formatted key, we specify the input format:
273  * operationComputeSharedSecret.publicKeyDataFormat = ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY;
274  * // If agreeing on an RFC 7748 X-Only formatted shared secret, we specify the shared secret format
275  * operationComputeSharedSecret.sharedSecretDataFormat = ECDH_PUBLIC_KEY_DATA_FORMAT_MONTGOMERY_X_ONLY;
276  *
277  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
278  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
279  *
280  * // Close the driver
281  * ECDH_close(ecdhHandle);
282  *
283  * @endcode
284  *
285  * @anchor ti_drivers_ECDH_Examples
286  * # Examples #
287  *
288  * ## ECDH exchange with plaintext CryptoKeys #
289  *
290  * @code
291  *
292  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
293  * #include <ti/drivers/ECDH.h>
294  *
295  * #define CURVE_LENGTH 32
296  *
297  * ...
298  *
299  * // Our private key is 0x0000000000000000000000000000000000000000000000000000000000000001
300  * // In practice, this value should come from a TRNG, PRNG, PUF, or device-specific pre-seeded key
301  * uint8_t myPrivateKeyingMaterial[CURVE_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
302  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
303  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
304  * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
305  * uint8_t myPublicKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
306  * uint8_t theirPublicKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
307  * uint8_t sharedSecretKeyingMaterial[2 * CURVE_LENGTH + 1] = {0};
308  * uint8_t symmetricKeyingMaterial[16] = {0};
309  *
310  * CryptoKey myPrivateKey;
311  * CryptoKey myPublicKey;
312  * CryptoKey theirPublicKey;
313  * CryptoKey sharedSecret;
314  * CryptoKey symmetricKey;
315  *
316  * ECDH_Handle ecdhHandle;
317  *
318  * int_fast16_t operationResult;
319  *
320  * ECDH_OperationGeneratePublicKey operationGeneratePublicKey;
321  *
322  * // Since we are using default ECDH_Params, we just pass in NULL for that parameter.
323  * ecdhHandle = ECDH_open(0, NULL);
324  *
325  * if (!ecdhHandle) {
326  * // Handle error
327  * }
328  *
329  * // Initialize myPrivateKey and myPublicKey
330  * CryptoKeyPlaintext_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial));
331  * CryptoKeyPlaintext_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial));
332  *
333  * ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey);
334  * operationGeneratePublicKey.curve = &ECCParams_NISTP256;
335  * operationGeneratePublicKey.myPrivateKey = &myPrivateKey;
336  * operationGeneratePublicKey.myPublicKey = &myPublicKey;
337  *
338  * // Generate the keying material for myPublicKey and store it in myPublicKeyingMaterial
339  * operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey);
340  *
341  * if (operationResult != ECDH_STATUS_SUCCESS) {
342  * // Handle error
343  * }
344  *
345  * // Now send the content of myPublicKeyingMaterial to the other party,
346  * // receive their public key, and copy their public keying material and the
347  * // 0x04 byte to theirPublicKeyingMaterial
348  *
349  * // Initialise their public CryptoKey and the shared secret CryptoKey
350  * CryptoKeyPlaintext_initKey(&theirPublicKey, theirPublicKeyingMaterial, sizeof(theirPublicKeyingMaterial));
351  * CryptoKeyPlaintext_initBlankKey(&sharedSecret, sharedSecretKeyingMaterial, sizeof(sharedSecretKeyingMaterial));
352  *
353  * // The ECC_NISTP256 struct is provided in ti/drivers/types/EccParams.h and the corresponding device-specific implementation
354  * ECDH_OperationComputeSharedSecret_init(&operationComputeSharedSecret);
355  * operationComputeSharedSecret.curve = &ECCParams_NISTP256;
356  * operationComputeSharedSecret.myPrivateKey = &myPrivateKey;
357  * operationComputeSharedSecret.theirPublicKey = &theirPublicKey;
358  * operationComputeSharedSecret.sharedSecret = &sharedSecret;
359  *
360  * // Compute the shared secret and copy it to sharedSecretKeyingMaterial
361  * operationResult = ECDH_computeSharedSecret(ecdhHandle, &operationComputeSharedSecret);
362  *
363  * if (operationResult != ECDH_STATUS_SUCCESS) {
364  * // Handle error
365  * }
366  *
367  * CryptoKeyPlaintext_initBlankKey(&symmetricKey, symmetricKeyingMaterial, sizeof(symmetricKeyingMaterial));
368  *
369  * // Set up a KDF such as HKDF and open the requisite cryptographic primitive driver to implement it
370  * // HKDF and SHA2 were chosen as an example and may not be available directly
371  *
372  * // At this point, you and the other party have both created the content within symmetricKeyingMaterial without
373  * // someone else listening to your communication channel being able to do so
374  *
375  * @endcode
376  *
377  *
378  */
379 
380 
381 #ifndef ti_drivers_ECDH__include
382 #define ti_drivers_ECDH__include
383 
384 #include <stdbool.h>
385 #include <stddef.h>
386 #include <stdint.h>
387 
390 
391 #ifdef __cplusplus
392 extern "C" {
393 #endif
394 
407 #define ECDH_STATUS_RESERVED (-32)
408 
415 #define ECDH_STATUS_SUCCESS (0)
416 
423 #define ECDH_STATUS_ERROR (-1)
424 
433 #define ECDH_STATUS_RESOURCE_UNAVAILABLE (-2)
434 
441 #define ECDH_STATUS_POINT_AT_INFINITY (-3)
442 
449 #define ECDH_STATUS_PRIVATE_KEY_LARGER_EQUAL_ORDER (-4)
450 
457 #define ECDH_STATUS_PRIVATE_KEY_ZERO (-5)
458 
465 #define ECDH_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-6)
466 
474 #define ECDH_STATUS_PUBLIC_KEY_LARGER_THAN_PRIME (-7)
475 
479 #define ECDH_STATUS_CANCELED (-8)
480 
489 #define ECDH_STATUS_INVALID_KEY_SIZE (-9)
490 
502 typedef struct {
504  void *object;
505 
507  void const *hwAttrs;
508 } ECDH_Config;
509 
514 
536 typedef enum {
552 
553 
554 typedef enum {
562 
563 
567 typedef struct {
579 
583 typedef struct {
601 
605 typedef union {
609 
613 typedef enum {
617 
636 typedef void (*ECDH_CallbackFxn) (ECDH_Handle handle,
637  int_fast16_t returnStatus,
638  ECDH_Operation operation,
639  ECDH_OperationType operationType);
640 
649 typedef struct {
652  uint32_t timeout;
653  void *custom;
656 } ECDH_Params;
657 
663 extern const ECDH_Params ECDH_defaultParams;
664 
673 void ECDH_init(void);
674 
688 
706 ECDH_Handle ECDH_open(uint_least8_t index, const ECDH_Params *params);
707 
717 void ECDH_close(ECDH_Handle handle);
718 
728 
738 
761 int_fast16_t ECDH_generatePublicKey(ECDH_Handle handle, ECDH_OperationGeneratePublicKey *operation);
762 
782 int_fast16_t ECDH_computeSharedSecret(ECDH_Handle handle, ECDH_OperationComputeSharedSecret *operation);
783 
797 int_fast16_t ECDH_cancelOperation(ECDH_Handle handle);
798 
822 ECDH_Handle ECDH_construct(ECDH_Config *config, const ECDH_Params *params);
823 
824 #ifdef __cplusplus
825 }
826 #endif
827 
828 #endif /* ti_drivers_ECDH__include */
ECDH_OperationType
Enum for the operation types supported by the driver.
Definition: ECDH.h:613
ADC_Params params
Definition: Driver_Init.h:11
ECC Global configuration.
Definition: ECDH.h:502
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:513
ECDH_ReturnBehavior returnBehavior
Definition: ECDH.h:650
void ECDH_OperationGeneratePublicKey_init(ECDH_OperationGeneratePublicKey *operation)
Function to initialize an ECDH_OperationGeneratePublicKey struct to its defaults. ...
ECDH_OperationComputeSharedSecret * computeSharedSecret
Definition: ECDH.h:607
int_fast16_t ECDH_cancelOperation(ECDH_Handle handle)
Cancels an ongoing ECDH operation.
Definition: ECDH.h:547
void * object
Definition: ECDH.h:504
void * custom
Definition: ECDH.h:653
Struct containing the parameters required to compute the shared secret.
Definition: ECDH.h:583
CryptoKey datastructure.
Definition: CryptoKey.h:209
const CryptoKey * theirPublicKey
Definition: ECDH.h:590
ECDH_CallbackFxn callbackFxn
Definition: ECDH.h:651
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:636
void ECDH_OperationComputeSharedSecret_init(ECDH_OperationComputeSharedSecret *operation)
Function to initialize an ECDH_OperationComputeSharedSecret struct to its defaults.
ECDH_OperationGeneratePublicKey * generatePublicKey
Definition: ECDH.h:606
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:569
const CryptoKey * myPrivateKey
Definition: ECDH.h:587
const ECCParams_CurveParams * curve
Definition: ECDH.h:584
void ECDH_init(void)
This function initializes the ECC module.
ECC Parameters.
Definition: ECDH.h:649
Definition: ECDH.h:543
ECDH_Handle ECDH_open(uint_least8_t index, const ECDH_Params *params)
This function opens a given ECC peripheral.
ECDH_PublicKeyDataFormat publicKeyDataFormat
Definition: ECDH.h:577
uint32_t timeout
Definition: ECDH.h:652
CryptoKey * sharedSecret
Definition: ECDH.h:593
ECDH_ReturnBehavior
The way in which ECC function calls return after performing an encryption + authentication or decrypt...
Definition: ECDH.h:536
ECDH_PublicKeyDataFormat
Definition: ECDH.h:554
int_fast16_t ECDH_computeSharedSecret(ECDH_Handle handle, ECDH_OperationComputeSharedSecret *operation)
Computes a shared secret.
Struct containing the parameters required to generate a public key.
Definition: ECDH.h:567
void ECDH_close(ECDH_Handle handle)
Function to close an ECC peripheral specified by the ECC handle.
const ECCParams_CurveParams * curve
Definition: ECDH.h:568
A structure containing the parameters of an elliptic curve in short Weierstrass form.
Definition: ECCParams.h:120
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:507
CryptoKey * myPublicKey
Definition: ECDH.h:572
ECDH_PublicKeyDataFormat publicKeyDataFormat
Definition: ECDH.h:598
ECDH_PublicKeyDataFormat sharedSecretDataFormat
Definition: ECDH.h:599
Union containing pointers to all supported operation structs.
Definition: ECDH.h:605
Definition: ECDH.h:537
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale