TrustCore SDK NanoCrypto API reference  version 7.0
ecc_edwards_keys.h
Go to the documentation of this file.
1 /*
2  * ecc_edwards_keys.h
3  *
4  * Header for Edward's Curve key operations.
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
10 
29 /*------------------------------------------------------------------*/
30 
31 #ifndef __ECC_EDWARDS_KEYS_HEADER__
32 #define __ECC_EDWARDS_KEYS_HEADER__
33 
34 /* Macros for the desired sha output lengths */
35 #define MOC_EDDSA_SHA512_LEN 64
36 #define MOC_EDDSA_SHAKE256_LEN 114
37 
38 #include "../crypto/crypto.h"
39 #include "../common/random.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
52 typedef enum
53 {
54  curveX25519 = 0, /* edDH */
55  curveX448 = 1,
56  curveEd25519 = 2, /* edDSA */
57  curveEd448 = 3
58 
59 } edECCCurve;
60 
61 typedef struct edECCKey
62 {
63  intBoolean isPrivate;
64  ubyte *pPrivKey;
65  ubyte *pPubKey;
66  edECCCurve curve;
67 
68 } edECCKey;
69 
84 MOC_EXTERN MSTATUS edECC_newKey(edECCKey **ppKey, edECCCurve curve, void *pExtCtx);
85 
86 
100 MOC_EXTERN MSTATUS edECC_getKeyLen(edECCKey *pKey, ubyte4 *pKeyLen, void *pExtCtx);
101 
102 
117 MOC_EXTERN MSTATUS edECC_equalKey(edECCKey *pKey1, edECCKey *pKey2, byteBoolean *pMatch, void *pExtCtx);
118 
119 
133 MOC_EXTERN MSTATUS edECC_cloneKey(edECCKey **ppNew, edECCKey *pSrc, void *pExtCtx);
134 
151 MOC_EXTERN MSTATUS edECC_generateKeyPair(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, RNGFun rngFun, void *pRngArg, BulkHashAlgo *pShaSuite, void *pExtCtx);
152 
153 
176 MOC_EXTERN MSTATUS edECC_setKeyParameters(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, ubyte *pPubKey, ubyte4 pubKeyLen, ubyte *pPrivKey, ubyte4 privKeyLen, BulkHashAlgo *pShaSuite, void *pExtCtx);
177 
178 
198 MOC_EXTERN MSTATUS edECC_getKeyParametersAlloc(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, ubyte **ppPubKey, ubyte4 *pPubLen, ubyte **ppPrivKey, ubyte4 *pPrivLen, void *pExtCtx);
199 
200 
218 MOC_EXTERN MSTATUS edECC_validateKey(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, BulkHashAlgo *pShaSuite, void *pExtCtx);
219 
220 
234 MOC_EXTERN MSTATUS edECC_getPublicKey(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, ubyte *pOutBuffer, ubyte4 bufferLen, void *pExtCtx);
235 
252 MOC_EXTERN MSTATUS edECC_calculatePubFromPriv(MOC_ECC(hwAccelDescr hwAccelCtx) ubyte *pPub, ubyte *pPriv, edECCCurve curve, BulkHashAlgo *pShaSuite, byteBoolean isShaEvp);
253 
266 MOC_EXTERN MSTATUS edECC_deleteKey(edECCKey **ppKey, void *pExtCtx);
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif /* __ECC_EDWARDS_KEYS_HEADER__ */
MOC_EXTERN MSTATUS edECC_equalKey(edECCKey *pKey1, edECCKey *pKey2, byteBoolean *pMatch, void *pExtCtx)
Tests if two Edward's form keys have identical public keys.
Structure to hold function pointers to hashing or extenable output methods.
Definition: crypto.h:133
MOC_EXTERN MSTATUS edECC_cloneKey(edECCKey **ppNew, edECCKey *pSrc, void *pExtCtx)
Allocates and clones an Edward's form key.
MOC_EXTERN MSTATUS edECC_getPublicKey(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, ubyte *pOutBuffer, ubyte4 bufferLen, void *pExtCtx)
Gets the public key from an Edward's form key.
MOC_EXTERN MSTATUS edECC_deleteKey(edECCKey **ppKey, void *pExtCtx)
Deletes an Edward's form key.
MOC_EXTERN MSTATUS edECC_setKeyParameters(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, ubyte *pPubKey, ubyte4 pubKeyLen, ubyte *pPrivKey, ubyte4 privKeyLen, BulkHashAlgo *pShaSuite, void *pExtCtx)
Sets the key parameters in an Edward's form key.
edECCCurve
Identifiers for the Edward's form curves and algorithms.
Definition: ecc_edwards_keys.h:52
sbyte4(* RNGFun)(void *rngFunArg, ubyte4 length, ubyte *buffer)
Function pointer type for a method that produces (pseudo) random bytes.
Definition: random.h:98
MOC_EXTERN MSTATUS edECC_newKey(edECCKey **ppKey, edECCCurve curve, void *pExtCtx)
Creates a new Edward's curve form key.
MOC_EXTERN MSTATUS edECC_calculatePubFromPriv(MOC_ECC(hwAccelDescr hwAccelCtx) ubyte *pPub, ubyte *pPriv, edECCCurve curve, BulkHashAlgo *pShaSuite, byteBoolean isShaEvp)
Gets the raw public key from a raw private key.
MOC_EXTERN MSTATUS edECC_generateKeyPair(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, RNGFun rngFun, void *pRngArg, BulkHashAlgo *pShaSuite, void *pExtCtx)
Generates a new Edward's form private key pair.
MOC_EXTERN MSTATUS edECC_validateKey(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, BulkHashAlgo *pShaSuite, void *pExtCtx)
Validates an Edward's form key.
MOC_EXTERN MSTATUS edECC_getKeyLen(edECCKey *pKey, ubyte4 *pKeyLen, void *pExtCtx)
Gets the key length associated with the given key.
MOC_EXTERN MSTATUS edECC_getKeyParametersAlloc(MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, ubyte **ppPubKey, ubyte4 *pPubLen, ubyte **ppPrivKey, ubyte4 *pPrivLen, void *pExtCtx)
Gets the key parameters in an Edward's form key.