EDDSA.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-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  */
326 #ifndef ti_drivers_EDDSA__include
327 #define ti_drivers_EDDSA__include
328 
329 #include <stdbool.h>
330 #include <stddef.h>
331 #include <stdint.h>
332 
335 
336 #ifdef __cplusplus
337 extern "C" {
338 #endif
339 
352 #define EDDSA_STATUS_RESERVED (-32)
353 
360 #define EDDSA_STATUS_SUCCESS (0)
361 
368 #define EDDSA_STATUS_ERROR (-1)
369 
373 #define EDDSA_STATUS_CANCELED (-2)
374 
384 #define EDDSA_STATUS_HASH_UNAVAILABLE (-3)
385 
395 #define EDDSA_STATUS_PKA_UNAVAILABLE (-4)
396 
403 #define EDDSA_STATUS_POINT_AT_INFINITY (-5)
404 
410 #define EDDSA_STATUS_INVALID_PRIVATE_KEY_SIZE (-6)
411 
418 #define EDDSA_STATUS_INVALID_PUBLIC_KEY_SIZE (-7)
419 
426 #define EDDSA_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-8)
427 
434 #define EDDSA_STATUS_INVALID_R_SIZE (-9)
435 
441 #define EDDSA_STATUS_INVALID_S_SIZE (-10)
442 
450 #define EDDSA_STATUS_S_LARGER_THAN_ORDER (-11)
451 
458 #define EDDSA_STATUS_KEY_ID_PARAM_MISMATCH (-12)
459 
465 #define EDDSA_STATUS_KEYSTORE_INVALID_ID (-13)
466 
474 #define EDDSA_STATUS_KEYSTORE_GENERIC_FAILURE (-14)
475 
481 #define EDDSA_STATUS_SHA2_HASH_FAILURE (-15)
482 
494 typedef struct
495 {
497  void *object;
498 
500  void const *hwAttrs;
501 } EDDSA_Config;
502 
507 
530 typedef enum
531 {
552 
557 typedef struct
558 {
573 
578 typedef struct
579 {
593  const uint8_t *preHashedMessage;
601  uint8_t *R;
606  uint8_t *S;
612 
617 typedef struct
618 {
628  const uint8_t *preHashedMessage;
636  const uint8_t *R;
641  const uint8_t *S;
647 
651 typedef union
652 {
660 
664 typedef enum
665 {
670 
690 typedef void (*EDDSA_CallbackFxn)(EDDSA_Handle handle,
691  int_fast16_t returnStatus,
692  EDDSA_Operation operation,
693  EDDSA_OperationType operationType);
694 
703 typedef struct
704 {
711  uint32_t timeout;
714  void *custom;
717 } EDDSA_Params;
718 
727 void EDDSA_init(void);
728 
738 void EDDSA_close(EDDSA_Handle handle);
739 
757 EDDSA_Handle EDDSA_open(uint_least8_t index, const EDDSA_Params *params);
758 
772 
783 
794 
805 
843 int_fast16_t EDDSA_generatePublicKey(EDDSA_Handle handle, EDDSA_OperationGeneratePublicKey *operation);
844 
882 int_fast16_t EDDSA_sign(EDDSA_Handle handle, EDDSA_OperationSign *operation);
883 
923 int_fast16_t EDDSA_verify(EDDSA_Handle handle, EDDSA_OperationVerify *operation);
924 
943 int_fast16_t EDDSA_cancelOperation(EDDSA_Handle handle);
944 
969 EDDSA_Handle EDDSA_construct(EDDSA_Config *config, const EDDSA_Params *params);
970 
971 #ifdef __cplusplus
972 }
973 #endif
974 
975 #endif /* ti_drivers_EDDSA__include */
ADC_Params params
Definition: Driver_Init.h:11
void EDDSA_init(void)
This function initializes the EDDSA module.
const ECCParams_CurveParams * curve
Definition: EDDSA.h:559
EDDSA_OperationGeneratePublicKey * generatePublicKey
Definition: EDDSA.h:654
size_t preHashedMessageLength
Definition: EDDSA.h:598
The CryptoKey type is an opaque representation of a cryptographic key.
EDDSA_CallbackFxn callbackFxn
Definition: EDDSA.h:708
Definition: EDDSA.h:667
const ECCParams_CurveParams * curve
Definition: EDDSA.h:619
int_fast16_t EDDSA_generatePublicKey(EDDSA_Handle handle, EDDSA_OperationGeneratePublicKey *operation)
Generates an EdDSA private-public keypair.
void * object
Definition: EDDSA.h:497
EDDSA Global configuration.
Definition: EDDSA.h:494
void EDDSA_Params_init(EDDSA_Params *params)
Function to initialize the EDDSA_Params struct to its defaults.
EDDSA_ReturnBehavior returnBehavior
Definition: EDDSA.h:705
Definition: EDDSA.h:668
size_t preHashedMessageLength
Definition: EDDSA.h:633
Definition: EDDSA.h:545
Struct containing the parameters required for generating an EdDSA digital signature.
Definition: EDDSA.h:578
CryptoKey datastructure.
Definition: CryptoKey.h:198
Definition: EDDSA.h:539
int_fast16_t EDDSA_cancelOperation(EDDSA_Handle handle)
Cancels an ongoing EDDSA operation.
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:714
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:690
const uint8_t * preHashedMessage
Definition: EDDSA.h:628
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:557
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:617
EDDSA_OperationSign * sign
Definition: EDDSA.h:656
EDDSA Parameters.
Definition: EDDSA.h:703
void EDDSA_OperationVerify_init(EDDSA_OperationVerify *operation)
Function to initialize an EDDSA_OperationSign struct to its defaults.
const CryptoKey * myPrivateKey
Definition: EDDSA.h:583
const ECCParams_CurveParams * curve
Definition: EDDSA.h:580
EDDSA_Config * EDDSA_Handle
A handle that is returned from an EDDSA_open() call.
Definition: EDDSA.h:506
const uint8_t * S
Definition: EDDSA.h:641
const CryptoKey * myPublicKey
Definition: EDDSA.h:588
EDDSA_ReturnBehavior
The way in which EDDSA function calls return after performing an encryption + authentication or decry...
Definition: EDDSA.h:530
int_fast16_t EDDSA_sign(EDDSA_Handle handle, EDDSA_OperationSign *operation)
Generates an EdDSA signature.
uint32_t timeout
Definition: EDDSA.h:711
const uint8_t * preHashedMessage
Definition: EDDSA.h:593
const CryptoKey * myPrivateKey
Definition: EDDSA.h:562
const CryptoKey * theirPublicKey
Definition: EDDSA.h:622
uint8_t * S
Definition: EDDSA.h:606
EDDSA_OperationType
Enum for the operation types supported by the driver.
Definition: EDDSA.h:664
CryptoKey * myPublicKey
Definition: EDDSA.h:567
A structure containing the parameters of an elliptic curve.
Definition: ECCParams.h:140
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:636
void const * hwAttrs
Definition: EDDSA.h:500
uint8_t * R
Definition: EDDSA.h:601
Union containing pointers to all supported operation structs.
Definition: EDDSA.h:651
EDDSA_OperationVerify * verify
Definition: EDDSA.h:658
Definition: EDDSA.h:532
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale