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 {
496  void *object;
497 
499  void const *hwAttrs;
500 } EDDSA_Config;
501 
506 
529 typedef enum {
550 
555 typedef struct {
570 
575 typedef struct {
589  const uint8_t *preHashedMessage;
597  uint8_t *R;
602  uint8_t *S;
608 
613 typedef struct {
623  const uint8_t *preHashedMessage;
631  const uint8_t *R;
636  const uint8_t *S;
642 
646 typedef union {
654 
658 typedef enum {
663 
683 typedef void (*EDDSA_CallbackFxn) (EDDSA_Handle handle,
684  int_fast16_t returnStatus,
685  EDDSA_Operation operation,
686  EDDSA_OperationType operationType);
687 
696 typedef struct {
703  uint32_t timeout;
707  void *custom;
710 } EDDSA_Params;
711 
720 void EDDSA_init(void);
721 
731 void EDDSA_close(EDDSA_Handle handle);
732 
750 EDDSA_Handle EDDSA_open(uint_least8_t index, const EDDSA_Params *params);
751 
765 
776  *operation);
777 
788 
799 
837 int_fast16_t EDDSA_generatePublicKey(EDDSA_Handle handle,
839 
877 int_fast16_t EDDSA_sign(EDDSA_Handle handle, EDDSA_OperationSign *operation);
878 
918 int_fast16_t EDDSA_verify(EDDSA_Handle handle,
919  EDDSA_OperationVerify *operation);
920 
939 int_fast16_t EDDSA_cancelOperation(EDDSA_Handle handle);
940 
965 EDDSA_Handle EDDSA_construct(EDDSA_Config *config, const EDDSA_Params *params);
966 
967 #ifdef __cplusplus
968 }
969 #endif
970 
971 #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:556
EDDSA_OperationGeneratePublicKey * generatePublicKey
Definition: EDDSA.h:648
size_t preHashedMessageLength
Definition: EDDSA.h:594
The CryptoKey type is an opaque representation of a cryptographic key.
EDDSA_CallbackFxn callbackFxn
Definition: EDDSA.h:700
Definition: EDDSA.h:660
const ECCParams_CurveParams * curve
Definition: EDDSA.h:614
int_fast16_t EDDSA_generatePublicKey(EDDSA_Handle handle, EDDSA_OperationGeneratePublicKey *operation)
Generates an EdDSA private-public keypair.
void * object
Definition: EDDSA.h:496
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:697
Definition: EDDSA.h:661
size_t preHashedMessageLength
Definition: EDDSA.h:628
Definition: EDDSA.h:543
Struct containing the parameters required for generating an EdDSA digital signature.
Definition: EDDSA.h:575
CryptoKey datastructure.
Definition: CryptoKey.h:209
Definition: EDDSA.h:537
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:707
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:683
const uint8_t * preHashedMessage
Definition: EDDSA.h:623
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:555
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:613
EDDSA_OperationSign * sign
Definition: EDDSA.h:650
EDDSA Parameters.
Definition: EDDSA.h:696
void EDDSA_OperationVerify_init(EDDSA_OperationVerify *operation)
Function to initialize an EDDSA_OperationSign struct to its defaults.
const CryptoKey * myPrivateKey
Definition: EDDSA.h:579
const ECCParams_CurveParams * curve
Definition: EDDSA.h:576
EDDSA_Config * EDDSA_Handle
A handle that is returned from an EDDSA_open() call.
Definition: EDDSA.h:505
const uint8_t * S
Definition: EDDSA.h:636
const CryptoKey * myPublicKey
Definition: EDDSA.h:584
EDDSA_ReturnBehavior
The way in which EDDSA function calls return after performing an encryption + authentication or decry...
Definition: EDDSA.h:529
int_fast16_t EDDSA_sign(EDDSA_Handle handle, EDDSA_OperationSign *operation)
Generates an EdDSA signature.
uint32_t timeout
Definition: EDDSA.h:703
const uint8_t * preHashedMessage
Definition: EDDSA.h:589
const CryptoKey * myPrivateKey
Definition: EDDSA.h:559
const CryptoKey * theirPublicKey
Definition: EDDSA.h:617
uint8_t * S
Definition: EDDSA.h:602
EDDSA_OperationType
Enum for the operation types supported by the driver.
Definition: EDDSA.h:658
CryptoKey * myPublicKey
Definition: EDDSA.h:564
A structure containing the parameters of an elliptic curve in short Weierstrass form.
Definition: ECCParams.h:120
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:631
void const * hwAttrs
Definition: EDDSA.h:499
uint8_t * R
Definition: EDDSA.h:597
Union containing pointers to all supported operation structs.
Definition: EDDSA.h:646
EDDSA_OperationVerify * verify
Definition: EDDSA.h:652
Definition: EDDSA.h:530
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale