ECJPAKE.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2018, 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  */
529 #ifndef ti_drivers_ECJPAKE__include
530 #define ti_drivers_ECJPAKE__include
531 
532 #ifdef __cplusplus
533 extern "C" {
534 #endif
535 
536 #include <stdbool.h>
537 #include <stddef.h>
538 #include <stdint.h>
539 
542 
560 #define ECJPAKE_CMD_RESERVED (32)
561 
574 #define ECJPAKE_STATUS_RESERVED (-32)
575 
589 #define ECJPAKE_STATUS_SUCCESS (0)
590 
597 #define ECJPAKE_STATUS_ERROR (-1)
598 
606 #define ECJPAKE_STATUS_UNDEFINEDCMD (-2)
607 
616 #define ECJPAKE_STATUS_RESOURCE_UNAVAILABLE (-3)
617 
623 #define ECJPAKE_STATUS_INVALID_PUBLIC_KEY (-4)
624 
631 #define ECJPAKE_STATUS_PUBLIC_KEY_NOT_ON_CURVE (-5)
632 
640 #define ECJPAKE_STATUS_PUBLIC_KEY_LARGER_THAN_PRIME (-6)
641 
648 #define ECJPAKE_STATUS_POINT_AT_INFINITY (-7)
649 
656 #define ECJPAKE_STATUS_INVALID_PRIVATE_KEY (-8)
657 
664 #define ECJPAKE_STATUS_INVALID_PRIVATE_V (-9)
665 
666 
677 /* Add ECJPAKE_CMD_<commands> here */
678 
687 
725 
737 typedef struct ECJPAKE_Config_ {
739  void *object;
740 
742  void const *hwAttrs;
744 
803 
820  const uint8_t *hash;
824  uint8_t *r;
828 
849  const uint8_t *hash;
852  const uint8_t *r;
856 
926 
954 
955 
959 typedef union ECJPAKE_Operation_ {
966 
977 
996 typedef void (*ECJPAKE_CallbackFxn) (ECJPAKE_Handle handle,
997  int_fast16_t returnStatus,
998  ECJPAKE_Operation operation,
999  ECJPAKE_OperationType operationType);
1000 
1009 typedef struct ECJPAKE_Params_ {
1012  uint32_t timeout;
1015  void *custom;
1018 } ECJPAKE_Params;
1019 
1028 void ECJPAKE_init(void);
1029 
1039 
1049 
1059 
1069 
1070 
1080 
1090 void ECJPAKE_close(ECJPAKE_Handle handle);
1091 
1129 int_fast16_t ECJPAKE_control(ECJPAKE_Handle handle, uint32_t cmd, void *args);
1130 
1148 ECJPAKE_Handle ECJPAKE_open(uint_least8_t index, ECJPAKE_Params *params);
1149 
1162 void ECJPAKE_Params_init(ECJPAKE_Params *params);
1163 
1181 int_fast16_t ECJPAKE_roundOneGenerateKeys(ECJPAKE_Handle handle, ECJPAKE_OperationRoundOneGenerateKeys *operation);
1182 
1209 int_fast16_t ECJPAKE_generateZKP(ECJPAKE_Handle handle, ECJPAKE_OperationGenerateZKP *operation);
1210 
1227 int_fast16_t ECJPAKE_verifyZKP(ECJPAKE_Handle handle, ECJPAKE_OperationVerifyZKP *operation);
1228 
1246 int_fast16_t ECJPAKE_roundTwoGenerateKeys(ECJPAKE_Handle handle, ECJPAKE_OperationRoundTwoGenerateKeys *operation);
1247 
1268 int_fast16_t ECJPAKE_computeSharedSecret(ECJPAKE_Handle handle, ECJPAKE_OperationComputeSharedSecret *operation);
1269 
1270 
1271 
1272 
1273 
1274 #ifdef __cplusplus
1275 }
1276 #endif
1277 
1278 #endif /* ti_drivers_ECJPAKE__include */
const CryptoKey * myPrivateKey2
Definition: ECJPAKE.h:864
enum ECJPAKE_OperationType_ ECJPAKE_OperationType
Enum for the operation types supported by the driver.
CryptoKey * myPrivateV
Definition: ECJPAKE.h:909
ECJPAKE_OperationComputeSharedSecret * computeSharedSecret
Definition: ECJPAKE.h:964
ECJPAKE_OperationRoundOneGenerateKeys * generateRoundOneKeys
Definition: ECJPAKE.h:960
const CryptoKey * theirPublicKey2
Definition: ECJPAKE.h:941
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:833
The CryptoKey type is an opaque representation of a cryptographic key.
const uint8_t * hash
Definition: ECJPAKE.h:820
void * custom
Definition: ECJPAKE.h:1015
CryptoKey * myCombinedPrivateKey
Definition: ECJPAKE.h:901
Struct containing the parameters required to generate a ZKP.
Definition: ECJPAKE.h:807
int_fast16_t ECJPAKE_computeSharedSecret(ECJPAKE_Handle handle, ECJPAKE_OperationComputeSharedSecret *operation)
Computes the shared secret.
void ECJPAKE_OperationVerifyZKP_init(ECJPAKE_OperationVerifyZKP *operation)
Function to initialize an ECJPAKE_OperationVerifyZKP struct to its defaults.
void ECJPAKE_close(ECJPAKE_Handle handle)
Function to close an ECJPAKE peripheral specified by the ECJPAKE handle.
struct ECJPAKE_OperationComputeSharedSecret_ ECJPAKE_OperationComputeSharedSecret
Struct containing the parameters required to compute the shared secret.
void ECJPAKE_OperationRoundOneGenerateKeys_init(ECJPAKE_OperationRoundOneGenerateKeys *operation)
Function to initialize an ECJPAKE_OperationRoundOneGenerateKeys struct to its defaults.
CryptoKey * myPublicV2
Definition: ECJPAKE.h:793
CryptoKey datastructure.
Definition: CryptoKey.h:210
Definition: ECJPAKE.h:720
struct ECJPAKE_OperationGenerateZKP_ ECJPAKE_OperationGenerateZKP
Struct containing the parameters required to generate a ZKP.
int_fast16_t ECJPAKE_roundTwoGenerateKeys(ECJPAKE_Handle handle, ECJPAKE_OperationRoundTwoGenerateKeys *operation)
Generates all public and private keying material for the first round of the EC-JPAKE scheme...
struct ECJPAKE_Config_ ECJPAKE_Config
ECJPAKE Global configuration.
void ECJPAKE_OperationRoundTwoGenerateKeys_init(ECJPAKE_OperationRoundTwoGenerateKeys *operation)
Function to initialize an ECJPAKE_OperationRoundTwoGenerateKeys struct to its defaults.
const CryptoKey * myPublicKey1
Definition: ECJPAKE.h:868
const CryptoKey * myPrivateKey
Definition: ECJPAKE.h:811
CryptoKey * myPublicKey1
Definition: ECJPAKE.h:760
const CryptoKey * theirGenerator
Definition: ECJPAKE.h:836
ECJPAKE_OperationType_
Enum for the operation types supported by the driver.
Definition: ECJPAKE.h:970
ECJPAKE Parameters.
Definition: ECJPAKE.h:1009
int_fast16_t ECJPAKE_control(ECJPAKE_Handle handle, uint32_t cmd, void *args)
Function performs implementation specific features on a given ECJPAKE_Handle.
CryptoKey * myPublicV1
Definition: ECJPAKE.h:784
union ECJPAKE_Operation_ ECJPAKE_Operation
Union containing pointers to all supported operation structs.
const uint8_t * hash
Definition: ECJPAKE.h:849
void * object
Definition: ECJPAKE.h:739
CryptoKey * myPrivateV2
Definition: ECJPAKE.h:777
A structure containing the parameters of an elliptic curve in short Weierstrass form.
Definition: ECCParams.h:111
void(* ECJPAKE_CallbackFxn)(ECJPAKE_Handle handle, int_fast16_t returnStatus, ECJPAKE_Operation operation, ECJPAKE_OperationType operationType)
The definition of a callback function used by the ECJPAKE driver when used in ECJPAKE_RETURN_BEHAVIOR...
Definition: ECJPAKE.h:996
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:808
CryptoKey * myNewGenerator
Definition: ECJPAKE.h:895
uint32_t timeout
Definition: ECJPAKE.h:1012
CryptoKey * theirNewGenerator
Definition: ECJPAKE.h:889
int_fast16_t ECJPAKE_verifyZKP(ECJPAKE_Handle handle, ECJPAKE_OperationVerifyZKP *operation)
Verifies a Schnorr Zero-Knowledge Proof (ZKP) signature.
void ECJPAKE_init(void)
This function initializes the ECJPAKE module.
Definition: ECJPAKE.h:716
CryptoKey * myCombinedPublicKey
Definition: ECJPAKE.h:906
uint8_t * r
Definition: ECJPAKE.h:824
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:931
Definition: ECJPAKE.h:710
struct ECJPAKE_OperationRoundOneGenerateKeys_ ECJPAKE_OperationRoundOneGenerateKeys
Struct containing the parameters required to generate the first round of keys.
int_fast16_t ECJPAKE_generateZKP(ECJPAKE_Handle handle, ECJPAKE_OperationGenerateZKP *operation)
Generates the r component of a Schnorr Zero-Knowledge Proof (ZKP) signature.
ECJPAKE Global configuration.
Definition: ECJPAKE.h:737
void const * hwAttrs
Definition: ECJPAKE.h:742
const CryptoKey * theirPublicKey1
Definition: ECJPAKE.h:874
const CryptoKey * preSharedSecret
Definition: ECJPAKE.h:880
const CryptoKey * myCombinedPrivateKey
Definition: ECJPAKE.h:934
Struct containing the parameters required to generate the second round keys.
Definition: ECJPAKE.h:860
const CryptoKey * myPrivateV
Definition: ECJPAKE.h:815
Struct containing the parameters required to compute the shared secret.
Definition: ECJPAKE.h:930
void ECJPAKE_Params_init(ECJPAKE_Params *params)
Function to initialize the ECJPAKE_Params struct to its defaults.
ECJPAKE_OperationVerifyZKP * verifyZKP
Definition: ECJPAKE.h:962
ECJPAKE_CallbackFxn callbackFxn
Definition: ECJPAKE.h:1011
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:861
ECJPAKE_OperationRoundTwoGenerateKeys * generateRoundTwoKeys
Definition: ECJPAKE.h:963
Struct containing the parameters required to verify a ZKP.
Definition: ECJPAKE.h:832
ECJPAKE_ReturnBehavior_
The way in which ECJPAKE function calls return after performing an encryption + authentication or dec...
Definition: ECJPAKE.h:709
CryptoKey * myPublicKey2
Definition: ECJPAKE.h:765
int_fast16_t ECJPAKE_roundOneGenerateKeys(ECJPAKE_Handle handle, ECJPAKE_OperationRoundOneGenerateKeys *operation)
Generates all public and private keying material for the first round of the EC-JPAKE scheme...
enum ECJPAKE_ReturnBehavior_ ECJPAKE_ReturnBehavior
The way in which ECJPAKE function calls return after performing an encryption + authentication or dec...
struct ECJPAKE_OperationVerifyZKP_ ECJPAKE_OperationVerifyZKP
Struct containing the parameters required to verify a ZKP.
const uint8_t * r
Definition: ECJPAKE.h:852
const CryptoKey * myPublicKey2
Definition: ECJPAKE.h:871
Definition: ECJPAKE.h:973
struct ECJPAKE_Config_ * ECJPAKE_Handle
A handle that is returned from an ECJPAKE_open() call.
Definition: ECJPAKE.h:686
struct ECJPAKE_Params_ ECJPAKE_Params
ECJPAKE Parameters.
ECJPAKE_ReturnBehavior returnBehavior
Definition: ECJPAKE.h:1010
const CryptoKey * myPrivateKey2
Definition: ECJPAKE.h:946
CryptoKey * sharedSecret
Definition: ECJPAKE.h:950
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:749
ECJPAKE_OperationGenerateZKP * generateZKP
Definition: ECJPAKE.h:961
Union containing pointers to all supported operation structs.
Definition: ECJPAKE.h:959
const CryptoKey * theirPublicKey2
Definition: ECJPAKE.h:877
CryptoKey * myPublicV
Definition: ECJPAKE.h:916
const CryptoKey * theirCombinedPublicKey
Definition: ECJPAKE.h:938
const CryptoKey * theirPublicV
Definition: ECJPAKE.h:846
const CryptoKey * theirPublicKey
Definition: ECJPAKE.h:842
CryptoKey * myPrivateKey1
Definition: ECJPAKE.h:752
Struct containing the parameters required to generate the first round of keys.
Definition: ECJPAKE.h:748
struct ECJPAKE_OperationRoundTwoGenerateKeys_ ECJPAKE_OperationRoundTwoGenerateKeys
Struct containing the parameters required to generate the second round keys.
CryptoKey * myPrivateKey2
Definition: ECJPAKE.h:756
CryptoKey * myPrivateV1
Definition: ECJPAKE.h:770
ECJPAKE_Handle ECJPAKE_open(uint_least8_t index, ECJPAKE_Params *params)
This function opens a given ECJPAKE peripheral.
void ECJPAKE_OperationGenerateZKP_init(ECJPAKE_OperationGenerateZKP *operation)
Function to initialize an ECJPAKE_OperationGenerateZKP struct to its defaults.
Definition: ECJPAKE.h:972
void ECJPAKE_OperationComputeSharedSecret_init(ECJPAKE_OperationComputeSharedSecret *operation)
Function to initialize an ECJPAKE_OperationComputeSharedSecret struct to its defaults.
Copyright 2018, Texas Instruments Incorporated