ECDSA.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2026, 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  */
457 #ifndef ti_drivers_ECDSA__include
458 #define ti_drivers_ECDSA__include
459 
460 #include <stdbool.h>
461 #include <stddef.h>
462 #include <stdint.h>
463 
466 
467 #ifdef __cplusplus
468 extern "C" {
469 #endif
470 
483 #define ECDSA_STATUS_RESERVED (-32)
484 
491 #define ECDSA_STATUS_SUCCESS (0)
492 
499 #define ECDSA_STATUS_ERROR (-1)
500 
510 #define ECDSA_STATUS_RESOURCE_UNAVAILABLE (-2)
511 
518 #define ECDSA_STATUS_R_LARGER_THAN_ORDER (-3)
519 
526 #define ECDSA_STATUS_S_LARGER_THAN_ORDER (-4)
527 
534 #define ECDSA_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-5)
535 
543 #define ECDSA_STATUS_PUBLIC_KEY_LARGER_THAN_PRIME (-6)
544 
550 #define ECDSA_STATUS_POINT_AT_INFINITY (-7)
551 
555 #define ECDSA_STATUS_CANCELED (-8)
556 
565 #define ECDSA_STATUS_INVALID_KEY_SIZE (-10)
566 
573 #define ECDSA_STATUS_KEYSTORE_ERROR (-11)
574 
586 typedef struct
587 {
589  void *object;
590 
592  void const *hwAttrs;
593 } ECDSA_Config;
594 
599 
622 typedef enum
623 {
639 
640 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX))
641 
644 typedef enum
645 {
654 
658 typedef enum
659 {
667 
671 typedef enum
672 {
678 #endif
679 
683 typedef struct
684 {
685 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX))
687  size_t hashLength;
688 #endif
693  const uint8_t *hash;
697  uint8_t *r;
703  uint8_t *s;
709 
713 typedef struct
714 {
715 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX))
717  size_t hashLength;
718 #else
719  const ECCParams_CurveParams *curve;
720 #endif
724  const uint8_t *hash;
728  const uint8_t *r;
734  const uint8_t *s;
741 
745 typedef union
746 {
750 
754 typedef enum
755 {
759 
779 typedef void (*ECDSA_CallbackFxn)(ECDSA_Handle handle,
780  int_fast16_t returnStatus,
781  ECDSA_Operation operation,
782  ECDSA_OperationType operationType);
783 
792 typedef struct
793 {
798  uint32_t timeout;
801  void *custom;
804 } ECDSA_Params;
805 
811 extern const ECDSA_Params ECDSA_defaultParams;
812 
821 void ECDSA_init(void);
822 
832 void ECDSA_close(ECDSA_Handle handle);
833 
851 ECDSA_Handle ECDSA_open(uint_least8_t index, const ECDSA_Params *params);
852 
865 void ECDSA_Params_init(ECDSA_Params *params);
866 
876 
886 
915 int_fast16_t ECDSA_sign(ECDSA_Handle handle, ECDSA_OperationSign *operation);
916 
944 int_fast16_t ECDSA_verify(ECDSA_Handle handle, ECDSA_OperationVerify *operation);
945 
959 int_fast16_t ECDSA_cancelOperation(ECDSA_Handle handle);
960 
985 ECDSA_Handle ECDSA_construct(ECDSA_Config *config, const ECDSA_Params *params);
986 
987 #ifdef __cplusplus
988 }
989 #endif
990 
991 #endif /* ti_drivers_ECDSA__include */
Definition: ECDSA.h:647
ECDSA_CurveType
Enum for the curve types supported by the driver.
Definition: ECDSA.h:644
ECDSA_ReturnBehavior
The way in which ECDSA function calls return after performing an encryption + authentication or decry...
Definition: ECDSA.h:622
Definition: ECDSA.h:650
uint8_t * s
Definition: ECDSA.h:703
The CryptoKey type is an opaque representation of a cryptographic key.
const CryptoKey * myPrivateKey
Definition: ECDSA.h:690
ECDSA_CurveType curveType
Definition: ECDSA.h:716
Definition: ECDSA.h:757
const uint8_t * hash
Definition: ECDSA.h:693
Definition: ECDSA.h:649
void ECDSA_OperationSign_init(ECDSA_OperationSign *operation)
Function to initialize an ECDSA_OperationSign struct to its defaults.
Definition: ECDSA.h:648
void const * hwAttrs
Definition: ECDSA.h:592
const CryptoKey * theirPublicKey
Definition: ECDSA.h:721
void(* ECDSA_CallbackFxn)(ECDSA_Handle handle, int_fast16_t returnStatus, ECDSA_Operation operation, ECDSA_OperationType operationType)
The definition of a callback function used by the ECDSA driver when used in ECDSA_RETURN_BEHAVIOR_CAL...
Definition: ECDSA.h:779
Definition: ECDSA.h:663
Definition: ECDSA.h:646
ECDSA_ReturnBehavior returnBehavior
Definition: ECDSA.h:794
const uint8_t * s
Definition: ECDSA.h:734
Definition: ECDSA.h:651
Definition: ECDSA.h:675
CryptoKey datastructure.
Definition: CryptoKey.h:211
ECDSA_DigestLength
Enum for the hash digest lengths in bits supported by the driver.
Definition: ECDSA.h:671
ECDSA Global configuration.
Definition: ECDSA.h:586
Definition: ECDSA.h:665
void ECDSA_close(ECDSA_Handle handle)
Function to close an ECDSA peripheral specified by the ECDSA handle.
void ECDSA_init(void)
This function initializes the ECDSA module.
Struct containing the parameters required for signing a message.
Definition: ECDSA.h:683
const ECDSA_Params ECDSA_defaultParams
Default ECDSA_Params structure.
Definition: ECDSA.h:661
size_t hashLength
Definition: ECDSA.h:687
Definition: ECDSA.h:674
ECDSA Parameters.
Definition: ECDSA.h:792
ECDSA_CurveLength
Enum for signature sizes in bits supported by the driver.
Definition: ECDSA.h:658
const ECCParams_CurveParams * curve
Definition: ECDSA.h:689
ECDSA_OperationType
Enum for the operation types supported by the driver.
Definition: ECDSA.h:754
Definition: ECDSA.h:664
void ECDSA_Params_init(ECDSA_Params *params)
Function to initialize the ECDSA_Params struct to its defaults.
const uint8_t * r
Definition: ECDSA.h:728
Union containing pointers to all supported operation structs.
Definition: ECDSA.h:745
Definition: ECDSA.h:660
Definition: ECDSA.h:634
int_fast16_t ECDSA_sign(ECDSA_Handle handle, ECDSA_OperationSign *operation)
Signs a hashed message.
void * custom
Definition: ECDSA.h:801
ECDSA_Config * ECDSA_Handle
A handle that is returned from an ECDSA_open() call.
Definition: ECDSA.h:598
uint8_t * r
Definition: ECDSA.h:697
int_fast16_t ECDSA_verify(ECDSA_Handle handle, ECDSA_OperationVerify *operation)
Verifies a received signature matches a hash and public key.
Struct containing the parameters required for verifying a message.
Definition: ECDSA.h:713
void * object
Definition: ECDSA.h:589
Definition: ECDSA.h:652
ECDSA_CallbackFxn callbackFxn
Definition: ECDSA.h:797
Definition: ECDSA.h:673
ECDSA_OperationVerify * verify
Definition: ECDSA.h:748
Definition: ECDSA.h:630
ECDSA_CurveType curveType
Definition: ECDSA.h:686
size_t hashLength
Definition: ECDSA.h:717
A structure containing the parameters of an elliptic curve.
Definition: ECCParams.h:145
Definition: ECDSA.h:624
const uint8_t * hash
Definition: ECDSA.h:724
ECDSA_Handle ECDSA_open(uint_least8_t index, const ECDSA_Params *params)
This function opens a given ECDSA peripheral.
Definition: ECDSA.h:676
Definition: ECDSA.h:756
ECDSA_OperationSign * sign
Definition: ECDSA.h:747
uint32_t timeout
Definition: ECDSA.h:798
Definition: ECDSA.h:662
ECDSA_Handle ECDSA_construct(ECDSA_Config *config, const ECDSA_Params *params)
Constructs a new ECDSA object.
void ECDSA_OperationVerify_init(ECDSA_OperationVerify *operation)
Function to initialize an ECDSA_OperationSign struct to its defaults.
int_fast16_t ECDSA_cancelOperation(ECDSA_Handle handle)
Cancels an ongoing ECDSA operation.
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale