EDDSA.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-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  */
363 #ifndef ti_drivers_EDDSA__include
364 #define ti_drivers_EDDSA__include
365 
366 #include <stdbool.h>
367 #include <stddef.h>
368 #include <stdint.h>
369 
372 
373 #ifdef __cplusplus
374 extern "C" {
375 #endif
376 
389 #define EDDSA_STATUS_RESERVED (-32)
390 
397 #define EDDSA_STATUS_SUCCESS (0)
398 
405 #define EDDSA_STATUS_ERROR (-1)
406 
410 #define EDDSA_STATUS_CANCELED (-2)
411 
421 #define EDDSA_STATUS_HASH_UNAVAILABLE (-3)
422 
432 #define EDDSA_STATUS_PKA_UNAVAILABLE (-4)
433 
440 #define EDDSA_STATUS_POINT_AT_INFINITY (-5)
441 
447 #define EDDSA_STATUS_INVALID_PRIVATE_KEY_SIZE (-6)
448 
455 #define EDDSA_STATUS_INVALID_PUBLIC_KEY_SIZE (-7)
456 
463 #define EDDSA_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-8)
464 
471 #define EDDSA_STATUS_INVALID_R_SIZE (-9)
472 
478 #define EDDSA_STATUS_INVALID_S_SIZE (-10)
479 
487 #define EDDSA_STATUS_S_LARGER_THAN_ORDER (-11)
488 
495 #define EDDSA_STATUS_KEY_ID_PARAM_MISMATCH (-12)
496 
502 #define EDDSA_STATUS_KEYSTORE_INVALID_ID (-13)
503 
511 #define EDDSA_STATUS_KEYSTORE_GENERIC_FAILURE (-14)
512 
518 #define EDDSA_STATUS_SHA2_HASH_FAILURE (-15)
519 
526 #define EDDSA_STATUS_KEYSTORE_ERROR (-16)
527 
534 #define EDDSA_STATUS_FEATURE_NOT_SUPPORTED (-17)
535 
547 typedef struct
548 {
550  void *object;
551 
553  void const *hwAttrs;
554 } EDDSA_Config;
555 
560 
583 typedef enum
584 {
605 
610 typedef struct
611 {
626 
631 typedef struct
632 {
646  const uint8_t *preHashedMessage;
654  uint8_t *R;
659  uint8_t *S;
665 
670 typedef struct
671 {
681  const uint8_t *preHashedMessage;
689  const uint8_t *R;
694  const uint8_t *S;
700 
704 typedef union
705 {
713 
717 typedef enum
718 {
723 
743 typedef void (*EDDSA_CallbackFxn)(EDDSA_Handle handle,
744  int_fast16_t returnStatus,
745  EDDSA_Operation operation,
746  EDDSA_OperationType operationType);
747 
756 typedef struct
757 {
764  uint32_t timeout;
767  void *custom;
770 } EDDSA_Params;
771 
777 extern const EDDSA_Params EDDSA_defaultParams;
778 
787 void EDDSA_init(void);
788 
798 void EDDSA_close(EDDSA_Handle handle);
799 
817 EDDSA_Handle EDDSA_open(uint_least8_t index, const EDDSA_Params *params);
818 
831 void EDDSA_Params_init(EDDSA_Params *params);
832 
843 
854 
865 
904 int_fast16_t EDDSA_generatePublicKey(EDDSA_Handle handle, EDDSA_OperationGeneratePublicKey *operation);
905 
944 int_fast16_t EDDSA_sign(EDDSA_Handle handle, EDDSA_OperationSign *operation);
945 
986 int_fast16_t EDDSA_verify(EDDSA_Handle handle, EDDSA_OperationVerify *operation);
987 
1006 int_fast16_t EDDSA_cancelOperation(EDDSA_Handle handle);
1007 
1032 EDDSA_Handle EDDSA_construct(EDDSA_Config *config, const EDDSA_Params *params);
1033 
1034 #ifdef __cplusplus
1035 }
1036 #endif
1037 
1038 #endif /* ti_drivers_EDDSA__include */
void EDDSA_init(void)
This function initializes the EDDSA module.
const ECCParams_CurveParams * curve
Definition: EDDSA.h:612
EDDSA_OperationGeneratePublicKey * generatePublicKey
Definition: EDDSA.h:707
size_t preHashedMessageLength
Definition: EDDSA.h:651
The CryptoKey type is an opaque representation of a cryptographic key.
EDDSA_CallbackFxn callbackFxn
Definition: EDDSA.h:761
Definition: EDDSA.h:720
const ECCParams_CurveParams * curve
Definition: EDDSA.h:672
int_fast16_t EDDSA_generatePublicKey(EDDSA_Handle handle, EDDSA_OperationGeneratePublicKey *operation)
Generates an EdDSA private-public keypair.
void * object
Definition: EDDSA.h:550
EDDSA Global configuration.
Definition: EDDSA.h:547
void EDDSA_Params_init(EDDSA_Params *params)
Function to initialize the EDDSA_Params struct to its defaults.
EDDSA_ReturnBehavior returnBehavior
Definition: EDDSA.h:758
Definition: EDDSA.h:721
size_t preHashedMessageLength
Definition: EDDSA.h:686
Definition: EDDSA.h:598
Struct containing the parameters required for generating an EdDSA digital signature.
Definition: EDDSA.h:631
CryptoKey datastructure.
Definition: CryptoKey.h:211
Definition: EDDSA.h:592
int_fast16_t EDDSA_cancelOperation(EDDSA_Handle handle)
Cancels an ongoing EDDSA operation.
const EDDSA_Params EDDSA_defaultParams
Default EDDSA_Params structure.
int_fast16_t EDDSA_verify(EDDSA_Handle handle, EDDSA_OperationVerify *operation)
Verifies a received EdDSA signature matches a hash and public key.
void * custom
Definition: EDDSA.h:767
EDDSA_Handle EDDSA_construct(EDDSA_Config *config, const EDDSA_Params *params)
Constructs a new EDDSA object.
void(* EDDSA_CallbackFxn)(EDDSA_Handle handle, int_fast16_t returnStatus, EDDSA_Operation operation, EDDSA_OperationType operationType)
The definition of a callback function used by the EDDSA driver when used in EDDSA_RETURN_BEHAVIOR_CAL...
Definition: EDDSA.h:743
const uint8_t * preHashedMessage
Definition: EDDSA.h:681
void EDDSA_OperationGeneratePublicKey_init(EDDSA_OperationGeneratePublicKey *operation)
Function to initialize an EDDSA_OperationGeneratePublicKey struct to its defaults.
Struct containing the parameters required for generating an EdDSA private-public keypair.
Definition: EDDSA.h:610
void EDDSA_close(EDDSA_Handle handle)
Function to close an EDDSA peripheral specified by the EDDSA handle.
Struct containing the parameters required for verifying an EdDSA digital signature.
Definition: EDDSA.h:670
EDDSA_OperationSign * sign
Definition: EDDSA.h:709
EDDSA Parameters.
Definition: EDDSA.h:756
void EDDSA_OperationVerify_init(EDDSA_OperationVerify *operation)
Function to initialize an EDDSA_OperationSign struct to its defaults.
const CryptoKey * myPrivateKey
Definition: EDDSA.h:636
const ECCParams_CurveParams * curve
Definition: EDDSA.h:633
EDDSA_Config * EDDSA_Handle
A handle that is returned from an EDDSA_open() call.
Definition: EDDSA.h:559
const uint8_t * S
Definition: EDDSA.h:694
const CryptoKey * myPublicKey
Definition: EDDSA.h:641
EDDSA_ReturnBehavior
The way in which EDDSA function calls return after performing an encryption + authentication or decry...
Definition: EDDSA.h:583
int_fast16_t EDDSA_sign(EDDSA_Handle handle, EDDSA_OperationSign *operation)
Generates an EdDSA signature.
uint32_t timeout
Definition: EDDSA.h:764
const uint8_t * preHashedMessage
Definition: EDDSA.h:646
const CryptoKey * myPrivateKey
Definition: EDDSA.h:615
const CryptoKey * theirPublicKey
Definition: EDDSA.h:675
uint8_t * S
Definition: EDDSA.h:659
EDDSA_OperationType
Enum for the operation types supported by the driver.
Definition: EDDSA.h:717
CryptoKey * myPublicKey
Definition: EDDSA.h:620
A structure containing the parameters of an elliptic curve.
Definition: ECCParams.h:143
void EDDSA_OperationSign_init(EDDSA_OperationSign *operation)
Function to initialize an EDDSA_OperationSign struct to its defaults.
EDDSA_Handle EDDSA_open(uint_least8_t index, const EDDSA_Params *params)
This function opens a given EDDSA peripheral.
const uint8_t * R
Definition: EDDSA.h:689
void const * hwAttrs
Definition: EDDSA.h:553
uint8_t * R
Definition: EDDSA.h:654
Union containing pointers to all supported operation structs.
Definition: EDDSA.h:704
EDDSA_OperationVerify * verify
Definition: EDDSA.h:711
Definition: EDDSA.h:585
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale