ECDSA.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019, 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  */
349 #ifndef ti_drivers_ECDSA__include
350 #define ti_drivers_ECDSA__include
351 
352 #include <stdbool.h>
353 #include <stddef.h>
354 #include <stdint.h>
355 
358 
359 #ifdef __cplusplus
360 extern "C" {
361 #endif
362 
375 #define ECDSA_STATUS_RESERVED (-32)
376 
383 #define ECDSA_STATUS_SUCCESS (0)
384 
391 #define ECDSA_STATUS_ERROR (-1)
392 
402 #define ECDSA_STATUS_RESOURCE_UNAVAILABLE (-2)
403 
410 #define ECDSA_STATUS_R_LARGER_THAN_ORDER (-3)
411 
418 #define ECDSA_STATUS_S_LARGER_THAN_ORDER (-4)
419 
426 #define ECDSA_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-5)
427 
435 #define ECDSA_STATUS_PUBLIC_KEY_LARGER_THAN_PRIME (-6)
436 
442 #define ECDSA_STATUS_POINT_AT_INFINITY (-7)
443 
447 #define ECDSA_STATUS_CANCELED (-8)
448 
457 #define ECDSA_STATUS_INVALID_KEY_SIZE (-10)
458 
470 typedef struct {
472  void *object;
473 
475  void const *hwAttrs;
476 } ECDSA_Config;
477 
482 
505 typedef enum {
521 
525 typedef struct {
530  const uint8_t *hash;
534  uint8_t *r;
540  uint8_t *s;
546 
550 typedef struct {
555  const uint8_t *hash;
559  const uint8_t *r;
565  const uint8_t *s;
572 
576 typedef union {
580 
584 typedef enum {
588 
608 typedef void (*ECDSA_CallbackFxn) (ECDSA_Handle handle,
609  int_fast16_t returnStatus,
610  ECDSA_Operation operation,
611  ECDSA_OperationType operationType);
612 
621 typedef struct {
626  uint32_t timeout;
629  void *custom;
632 } ECDSA_Params;
633 
642 void ECDSA_init(void);
643 
653 void ECDSA_close(ECDSA_Handle handle);
654 
672 ECDSA_Handle ECDSA_open(uint_least8_t index, const ECDSA_Params *params);
673 
686 void ECDSA_Params_init(ECDSA_Params *params);
687 
697 
707 
727 int_fast16_t ECDSA_sign(ECDSA_Handle handle, ECDSA_OperationSign *operation);
728 
752 int_fast16_t ECDSA_verify(ECDSA_Handle handle, ECDSA_OperationVerify *operation);
753 
767 int_fast16_t ECDSA_cancelOperation(ECDSA_Handle handle);
768 
793 ECDSA_Handle ECDSA_construct(ECDSA_Config *config, const ECDSA_Params *params);
794 
795 #ifdef __cplusplus
796 }
797 #endif
798 
799 #endif /* ti_drivers_ECDSA__include */
ECDSA_ReturnBehavior
The way in which ECDSA function calls return after performing an encryption + authentication or decry...
Definition: ECDSA.h:505
uint8_t * s
Definition: ECDSA.h:540
The CryptoKey type is an opaque representation of a cryptographic key.
const CryptoKey * myPrivateKey
Definition: ECDSA.h:527
Definition: ECDSA.h:586
const uint8_t * hash
Definition: ECDSA.h:530
void ECDSA_OperationSign_init(ECDSA_OperationSign *operation)
Function to initialize an ECDSA_OperationSign struct to its defaults.
void const * hwAttrs
Definition: ECDSA.h:475
const CryptoKey * theirPublicKey
Definition: ECDSA.h:552
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:608
ECDSA_ReturnBehavior returnBehavior
Definition: ECDSA.h:622
const uint8_t * s
Definition: ECDSA.h:565
CryptoKey datastructure.
Definition: CryptoKey.h:209
ECDSA Global configuration.
Definition: ECDSA.h:470
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:525
ECDSA Parameters.
Definition: ECDSA.h:621
const ECCParams_CurveParams * curve
Definition: ECDSA.h:526
ECDSA_OperationType
Enum for the operation types supported by the driver.
Definition: ECDSA.h:584
void ECDSA_Params_init(ECDSA_Params *params)
Function to initialize the ECDSA_Params struct to its defaults.
const uint8_t * r
Definition: ECDSA.h:559
Union containing pointers to all supported operation structs.
Definition: ECDSA.h:576
Definition: ECDSA.h:516
int_fast16_t ECDSA_sign(ECDSA_Handle handle, ECDSA_OperationSign *operation)
Signs a hashed message.
void * custom
Definition: ECDSA.h:629
ECDSA_Config * ECDSA_Handle
A handle that is returned from an ECDSA_open() call.
Definition: ECDSA.h:481
uint8_t * r
Definition: ECDSA.h:534
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:550
void * object
Definition: ECDSA.h:472
ECDSA_CallbackFxn callbackFxn
Definition: ECDSA.h:625
ECDSA_OperationVerify * verify
Definition: ECDSA.h:578
Definition: ECDSA.h:512
A structure containing the parameters of an elliptic curve in short Weierstrass form.
Definition: ECCParams.h:120
Definition: ECDSA.h:506
const uint8_t * hash
Definition: ECDSA.h:555
ECDSA_Handle ECDSA_open(uint_least8_t index, const ECDSA_Params *params)
This function opens a given ECDSA peripheral.
Definition: ECDSA.h:585
const ECCParams_CurveParams * curve
Definition: ECDSA.h:551
ECDSA_OperationSign * sign
Definition: ECDSA.h:577
uint32_t timeout
Definition: ECDSA.h:626
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-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale