ECJPAKE.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, 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  */
517 #ifndef ti_drivers_ECJPAKE__include
518 #define ti_drivers_ECJPAKE__include
519 
520 #ifdef __cplusplus
521 extern "C" {
522 #endif
523 
524 #include <stdbool.h>
525 #include <stddef.h>
526 #include <stdint.h>
527 
530 
548 #define ECJPAKE_CMD_RESERVED (32)
549 
562 #define ECJPAKE_STATUS_RESERVED (-32)
563 
577 #define ECJPAKE_STATUS_SUCCESS (0)
578 
585 #define ECJPAKE_STATUS_ERROR (-1)
586 
594 #define ECJPAKE_STATUS_UNDEFINEDCMD (-2)
595 
604 #define ECJPAKE_STATUS_RESOURCE_UNAVAILABLE (-3)
605 
612 #define ECJPAKE_STATUS_INVALID_PUBLIC_KEY (-4)
613 
614 
625 /* Add ECJPAKE_CMD_<commands> here */
626 
635 
673 
685 typedef struct ECJPAKE_Config_ {
687  void *object;
688 
690  void const *hwAttrs;
692 
751 
768  const uint8_t *hash;
772  uint8_t *r;
776 
797  const uint8_t *hash;
800  const uint8_t *r;
804 
876 
904 
905 
909 typedef union ECJPAKE_Operation_ {
916 
927 
946 typedef void (*ECJPAKE_CallbackFxn) (ECJPAKE_Handle handle,
947  int_fast16_t returnStatus,
948  ECJPAKE_Operation operation,
949  ECJPAKE_OperationType operationType);
950 
959 typedef struct ECJPAKE_Params_ {
962  uint32_t timeout;
965  void *custom;
969 
978 void ECJPAKE_init(void);
979 
989 
999 
1009 
1019 
1020 
1030 
1040 void ECJPAKE_close(ECJPAKE_Handle handle);
1041 
1079 int_fast16_t ECJPAKE_control(ECJPAKE_Handle handle, uint32_t cmd, void *args);
1080 
1098 ECJPAKE_Handle ECJPAKE_open(uint_least8_t index, ECJPAKE_Params *params);
1099 
1112 void ECJPAKE_Params_init(ECJPAKE_Params *params);
1113 
1131 int_fast16_t ECJPAKE_roundOneGenerateKeys(ECJPAKE_Handle handle, ECJPAKE_OperationRoundOneGenerateKeys *operation);
1132 
1159 int_fast16_t ECJPAKE_generateZKP(ECJPAKE_Handle handle, ECJPAKE_OperationGenerateZKP *operation);
1160 
1177 int_fast16_t ECJPAKE_verifyZKP(ECJPAKE_Handle handle, ECJPAKE_OperationVerifyZKP *operation);
1178 
1196 int_fast16_t ECJPAKE_roundTwoGenerateKeys(ECJPAKE_Handle handle, ECJPAKE_OperationRoundTwoGenerateKeys *operation);
1197 
1218 int_fast16_t ECJPAKE_computeSharedSecret(ECJPAKE_Handle handle, ECJPAKE_OperationComputeSharedSecret *operation);
1219 
1220 
1221 
1222 
1223 
1224 #ifdef __cplusplus
1225 }
1226 #endif
1227 
1228 #endif /* ti_drivers_ECJPAKE__include */
const CryptoKey * myPrivateKey2
Definition: ECJPAKE.h:812
enum ECJPAKE_OperationType_ ECJPAKE_OperationType
Enum for the operation types supported by the driver.
CryptoKey * myPrivateV
Definition: ECJPAKE.h:859
ECJPAKE_OperationComputeSharedSecret * computeSharedSecret
Definition: ECJPAKE.h:914
ECJPAKE_OperationRoundOneGenerateKeys * generateRoundOneKeys
Definition: ECJPAKE.h:910
const CryptoKey * theirPublicKey2
Definition: ECJPAKE.h:891
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:781
The CryptoKey type is an opaque representation of a cryptographic key.
const uint8_t * hash
Definition: ECJPAKE.h:768
void * custom
Definition: ECJPAKE.h:965
CryptoKey * myCombinedPrivateKey
Definition: ECJPAKE.h:849
Struct containing the parameters required to generate a ZKP.
Definition: ECJPAKE.h:755
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 a ECJPAKE_OperationVerifyZKP struct to its defaults.
void ECJPAKE_close(ECJPAKE_Handle handle)
Function to close a 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 a ECJPAKE_OperationRoundOneGenerateKeys struct to its defaults.
CryptoKey * myPublicV2
Definition: ECJPAKE.h:741
CryptoKey datastructure.
Definition: CryptoKey.h:210
Definition: ECJPAKE.h:668
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 a ECJPAKE_OperationRoundTwoGenerateKeys struct to its defaults.
const CryptoKey * myPublicKey1
Definition: ECJPAKE.h:816
const CryptoKey * myPrivateKey
Definition: ECJPAKE.h:759
CryptoKey * myPublicKey1
Definition: ECJPAKE.h:708
const CryptoKey * theirGenerator
Definition: ECJPAKE.h:784
ECJPAKE_OperationType_
Enum for the operation types supported by the driver.
Definition: ECJPAKE.h:920
ECJPAKE Parameters.
Definition: ECJPAKE.h:959
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:732
union ECJPAKE_Operation_ ECJPAKE_Operation
Union containing pointers to all supported operation structs.
const uint8_t * hash
Definition: ECJPAKE.h:797
void * object
Definition: ECJPAKE.h:687
CryptoKey * myPrivateV2
Definition: ECJPAKE.h:725
A structure containing the parameters of an elliptic curve in short Weierstrass form.
Definition: ECCParams.h:70
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:946
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:756
CryptoKey * myNewGenerator
Definition: ECJPAKE.h:843
uint32_t timeout
Definition: ECJPAKE.h:962
CryptoKey * theirNewGenerator
Definition: ECJPAKE.h:837
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:664
CryptoKey * myCombinedPublicKey
Definition: ECJPAKE.h:854
uint8_t * r
Definition: ECJPAKE.h:772
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:881
Definition: ECJPAKE.h:658
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:685
void const * hwAttrs
Definition: ECJPAKE.h:690
const CryptoKey * theirPublicKey1
Definition: ECJPAKE.h:822
const CryptoKey * preSharedSecret
Definition: ECJPAKE.h:828
const CryptoKey * myCombinedPrivateKey
Definition: ECJPAKE.h:884
Struct containing the parameters required to generate the second round keys.
Definition: ECJPAKE.h:808
const CryptoKey * myPrivateV
Definition: ECJPAKE.h:763
Struct containing the parameters required to compute the shared secret.
Definition: ECJPAKE.h:880
void ECJPAKE_Params_init(ECJPAKE_Params *params)
Function to initialize the ECJPAKE_Params struct to its defaults.
ECJPAKE_OperationVerifyZKP * verifyZKP
Definition: ECJPAKE.h:912
ECJPAKE_CallbackFxn callbackFxn
Definition: ECJPAKE.h:961
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:809
ECJPAKE_OperationRoundTwoGenerateKeys * generateRoundTwoKeys
Definition: ECJPAKE.h:913
Struct containing the parameters required to verify a ZKP.
Definition: ECJPAKE.h:780
ECJPAKE_ReturnBehavior_
The way in which ECJPAKE function calls return after performing an encryption + authentication or dec...
Definition: ECJPAKE.h:657
CryptoKey * myPublicKey2
Definition: ECJPAKE.h:713
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:800
const CryptoKey * myPublicKey2
Definition: ECJPAKE.h:819
Definition: ECJPAKE.h:923
struct ECJPAKE_Config_ * ECJPAKE_Handle
A handle that is returned from an ECJPAKE_open() call.
Definition: ECJPAKE.h:634
struct ECJPAKE_Params_ ECJPAKE_Params
ECJPAKE Parameters.
ECJPAKE_ReturnBehavior returnBehavior
Definition: ECJPAKE.h:960
const CryptoKey * myPrivateKey2
Definition: ECJPAKE.h:896
CryptoKey * sharedSecret
Definition: ECJPAKE.h:900
const ECCParams_CurveParams * curve
Definition: ECJPAKE.h:697
ECJPAKE_OperationGenerateZKP * generateZKP
Definition: ECJPAKE.h:911
Union containing pointers to all supported operation structs.
Definition: ECJPAKE.h:909
const CryptoKey * theirPublicKey2
Definition: ECJPAKE.h:825
CryptoKey * myPublicV
Definition: ECJPAKE.h:866
const CryptoKey * theirCombinedPublicKey
Definition: ECJPAKE.h:888
const CryptoKey * theirPublicV
Definition: ECJPAKE.h:794
const CryptoKey * theirPublicKey
Definition: ECJPAKE.h:790
CryptoKey * myPrivateKey1
Definition: ECJPAKE.h:700
Struct containing the parameters required to generate the first round of keys.
Definition: ECJPAKE.h:696
struct ECJPAKE_OperationRoundTwoGenerateKeys_ ECJPAKE_OperationRoundTwoGenerateKeys
Struct containing the parameters required to generate the second round keys.
CryptoKey * myPrivateKey2
Definition: ECJPAKE.h:704
CryptoKey * myPrivateV1
Definition: ECJPAKE.h:718
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 a ECJPAKE_OperationGenerateZKP struct to its defaults.
Definition: ECJPAKE.h:922
void ECJPAKE_OperationComputeSharedSecret_init(ECJPAKE_OperationComputeSharedSecret *operation)
Function to initialize a ECJPAKE_OperationComputeSharedSecret struct to its defaults.
Copyright 2017, Texas Instruments Incorporated