ECDH.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2018, 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  */
295 #ifndef ti_drivers_ECDH__include
296 #define ti_drivers_ECDH__include
297 
298 #ifdef __cplusplus
299 extern "C" {
300 #endif
301 
302 #include <stdbool.h>
303 #include <stddef.h>
304 #include <stdint.h>
305 
308 
326 #define ECDH_CMD_RESERVED (32)
327 
340 #define ECDH_STATUS_RESERVED (-32)
341 
355 #define ECDH_STATUS_SUCCESS (0)
356 
363 #define ECDH_STATUS_ERROR (-1)
364 
372 #define ECDH_STATUS_UNDEFINEDCMD (-2)
373 
382 #define ECDH_STATUS_RESOURCE_UNAVAILABLE (-3)
383 
390 #define ECDH_STATUS_POINT_AT_INFINITY (-4)
391 
398 #define ECDH_STATUS_PRIVATE_KEY_LARGER_EQUAL_ORDER (-5)
399 
406 #define ECDH_STATUS_PRIVATE_KEY_ZERO (-6)
407 
408 
415 #define ECDH_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-7)
416 
424 #define ECDH_STATUS_PUBLIC_KEY_LARGER_THAN_PRIME (-8)
425 
438 /* Add ECDH_CMD_<commands> here */
439 
447 typedef struct ECDH_Config_ *ECDH_Handle;
448 
470 typedef enum ECDH_ReturnBehavior_ {
486 
487 
499 typedef struct ECDH_Config_ {
501  void *object;
502 
504  void const *hwAttrs;
505 } ECDH_Config;
506 
519 
537 
541 typedef union ECDH_Operation_ {
545 
549 typedef enum ECDH_OperationType_ {
553 
572 typedef void (*ECDH_CallbackFxn) (ECDH_Handle handle,
573  int_fast16_t returnStatus,
574  ECDH_Operation operation,
575  ECDH_OperationType operationType);
576 
585 typedef struct ECDH_Params_ {
588  uint32_t timeout;
589  void *custom;
592 } ECDH_Params;
593 
599 extern const ECDH_Params ECDH_defaultParams;
600 
609 void ECDH_init(void);
610 
623 void ECDH_Params_init(ECDH_Params *params);
624 
642 ECDH_Handle ECDH_open(uint_least8_t index, ECDH_Params *params);
643 
653 void ECDH_close(ECDH_Handle handle);
654 
692 int_fast16_t ECDH_control(ECDH_Handle handle, uint32_t cmd, void *args);
693 
703 
713 
729 int_fast16_t ECDH_generatePublicKey(ECDH_Handle handle, ECDH_OperationGeneratePublicKey *operation);
730 
744 int_fast16_t ECDH_computeSharedSecret(ECDH_Handle handle, ECDH_OperationComputeSharedSecret *operation);
745 
746 #ifdef __cplusplus
747 }
748 #endif
749 
750 #endif /* ti_drivers_ECDH__include */
const CryptoKey * myPrivateKey
Definition: ECDH.h:527
const CryptoKey * myPrivateKey
Definition: ECDH.h:512
ECDH_ReturnBehavior_
The way in which ECC function calls return after performing an encryption + authentication or decrypt...
Definition: ECDH.h:470
The CryptoKey type is an opaque representation of a cryptographic key.
union ECDH_Operation_ ECDH_Operation
Union containing pointers to all supported operation structs.
ECDH_Handle ECDH_open(uint_least8_t index, ECDH_Params *params)
This function opens a given ECC peripheral.
ECC Parameters.
Definition: ECDH.h:585
void * custom
Definition: ECDH.h:589
void ECDH_OperationGeneratePublicKey_init(ECDH_OperationGeneratePublicKey *operation)
Function to initialize an ECDH_OperationGeneratePublicKey struct to its defaults. ...
struct ECDH_Params_ ECDH_Params
ECC Parameters.
ECDH_ReturnBehavior returnBehavior
Definition: ECDH.h:586
int_fast16_t ECDH_control(ECDH_Handle handle, uint32_t cmd, void *args)
Function performs implementation specific features on a given ECDH_Handle.
ECDH_CallbackFxn callbackFxn
Definition: ECDH.h:587
CryptoKey datastructure.
Definition: CryptoKey.h:210
struct ECDH_OperationComputeSharedSecret_ ECDH_OperationComputeSharedSecret
Struct containing the parameters required to compute the shared secret.
Struct containing the parameters required to generate a public key.
Definition: ECDH.h:510
A structure containing the parameters of an elliptic curve in short Weierstrass form.
Definition: ECCParams.h:111
void * object
Definition: ECDH.h:501
struct ECDH_OperationGeneratePublicKey_ ECDH_OperationGeneratePublicKey
Struct containing the parameters required to generate a public key.
Definition: ECDH.h:481
Definition: ECDH.h:477
const ECDH_Params ECDH_defaultParams
Default ECDH_Params structure.
Definition: ECDH.h:471
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:572
const CryptoKey * theirPublicKey
Definition: ECDH.h:530
void ECDH_OperationComputeSharedSecret_init(ECDH_OperationComputeSharedSecret *operation)
Function to initialize an ECDH_OperationComputeSharedSecret struct to its defaults.
int_fast16_t ECDH_generatePublicKey(ECDH_Handle handle, ECDH_OperationGeneratePublicKey *operation)
Generates a public key for use in key agreement.
CryptoKey * sharedSecret
Definition: ECDH.h:533
void ECDH_init(void)
This function initializes the ECC module.
Union containing pointers to all supported operation structs.
Definition: ECDH.h:541
enum ECDH_OperationType_ ECDH_OperationType
Enum for the operation types supported by the driver.
void const * hwAttrs
Definition: ECDH.h:504
ECDH_OperationComputeSharedSecret * computeSharedSecret
Definition: ECDH.h:543
struct ECDH_Config_ ECDH_Config
ECC Global configuration.
int_fast16_t ECDH_computeSharedSecret(ECDH_Handle handle, ECDH_OperationComputeSharedSecret *operation)
Computes a shared secret.
ECC Global configuration.
Definition: ECDH.h:499
void ECDH_close(ECDH_Handle handle)
Function to close an ECC peripheral specified by the ECC handle.
struct ECDH_Config_ * ECDH_Handle
A handle that is returned from an ECDH_open() call.
Definition: ECDH.h:447
void ECDH_Params_init(ECDH_Params *params)
Function to initialize the ECDH_Params struct to its defaults.
uint32_t timeout
Definition: ECDH.h:588
ECDH_OperationGeneratePublicKey * generatePublicKey
Definition: ECDH.h:542
CryptoKey * myPublicKey
Definition: ECDH.h:515
ECDH_OperationType_
Enum for the operation types supported by the driver.
Definition: ECDH.h:549
const ECCParams_CurveParams * curve
Definition: ECDH.h:524
Struct containing the parameters required to compute the shared secret.
Definition: ECDH.h:523
const ECCParams_CurveParams * curve
Definition: ECDH.h:511
enum ECDH_ReturnBehavior_ ECDH_ReturnBehavior
The way in which ECC function calls return after performing an encryption + authentication or decrypt...
Copyright 2018, Texas Instruments Incorporated