![]() |
TrustCore SDK NanoCrypto API reference
version 7.0
|
Header for curve25519 and curve448 key related methods. More...
Go to the source code of this file.
Enumerations | |
enum | edECCCurve { curveX25519 = 0, curveX448 = 1, curveEd25519 = 2, curveEd448 = 3 } |
Identifiers for the Edward's form curves and algorithms. More... | |
Functions | |
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. More... | |
MOC_EXTERN MSTATUS | edECC_cloneKey (edECCKey **ppNew, edECCKey *pSrc, void *pExtCtx) |
Allocates and clones an Edward's form key. More... | |
MOC_EXTERN MSTATUS | edECC_deleteKey (edECCKey **ppKey, void *pExtCtx) |
Deletes an Edward's form key. More... | |
MOC_EXTERN MSTATUS | edECC_equalKey (edECCKey *pKey1, edECCKey *pKey2, byteBoolean *pMatch, void *pExtCtx) |
Tests if two Edward's form keys have identical public keys. More... | |
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. More... | |
MOC_EXTERN MSTATUS | edECC_getKeyLen (edECCKey *pKey, ubyte4 *pKeyLen, void *pExtCtx) |
Gets the key length associated with the given key. More... | |
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. More... | |
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. More... | |
MOC_EXTERN MSTATUS | edECC_newKey (edECCKey **ppKey, edECCCurve curve, void *pExtCtx) |
Creates a new Edward's curve form key. More... | |
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. More... | |
MOC_EXTERN MSTATUS | edECC_validateKey (MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey *pKey, BulkHashAlgo *pShaSuite, void *pExtCtx) |
Validates an Edward's form key. More... | |
Documentation file for curve25519 and curve448 key related methods.
To enable the methods in this file one must define
__ENABLE_MOCANA_ECC__
and at least one or more of the following flags__ENABLE_MOCANA_ECC_EDDH_25519__
__ENABLE_MOCANA_ECC_EDDSA_25519__
__ENABLE_MOCANA_ECC_EDDH_448__
__ENABLE_MOCANA_ECC_EDDSA_448__
enum edECCCurve |
Identifiers for the Edward's form curves and algorithms. Note we need an algorithm specifier too because the key form and even curve form is actually different for EdDH vs that of EdDSA.
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.
pPub | Buffer to hold the resulting public key. |
pPriv | Buffer holding the input private key. |
curve | The curve/alg in use. |
pShaSuite | For EdDSA private keys, the SHA suite used by the EdDSA algorithm. This must be SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448. This param should be NULL for EdDH keys or public keys |
isShaEvp | TRUE if the pShaSuite contains init/update/final EVP style methods. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS edECC_cloneKey | ( | edECCKey ** | ppNew, |
edECCKey * | pSrc, | ||
void * | pExtCtx | ||
) |
Allocates and clones an Edward's form key. Be sure to call edECC_deleteKey
to free the newly allocated key when done with it.
ppNew | Pointer that will receive the location of the newly allocated key. |
pSrc | Pointer to the existing key to be cloned. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS edECC_deleteKey | ( | edECCKey ** | ppKey, |
void * | pExtCtx | ||
) |
Deletes an Edward's form key. This consists of zeroing sensative data and freeing allocated memory.
ppKey | Pointer that holds the location of the key to be deleted. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS edECC_equalKey | ( | edECCKey * | pKey1, |
edECCKey * | pKey2, | ||
byteBoolean * | pMatch, | ||
void * | pExtCtx | ||
) |
Tests if two Edward's form keys have identical public keys. This may be used on private keys but only the curves and public keys are compared.
pKey1 | Pointer to the first key. |
pKey2 | Pointer to the second key. |
pMatch | Contents will be set to TRUE if the public keys are identical. FALSE otherwise. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h 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.
pKey | Pointer to a previously allocated key. |
rngFun | Function pointer callback to a method that will provide random entropy. |
pRngArg | Optional argument that may be needed by the rngFun provided. |
pShaSuite | For EdDSA keys only, the SHA suite used by the EdDSA algorithm. This must be SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448. This param should be NULL for EdDH keys. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS edECC_getKeyLen | ( | edECCKey * | pKey, |
ubyte4 * | pKeyLen, | ||
void * | pExtCtx | ||
) |
Gets the key length associated with the given key.
pKey | Pointer to the input key. |
pKeyLen | Contents will be set to the length of the key in bytes. Note that a public key is the same length as a private key. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h 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. This may be used for a public key or a private key. This method allocates new buffers to hold the key values. Be sure to FREE them when done with them.
pKey | Pointer to a an exising key. |
ppPubKey | Pointer to the newly allocated buffer that will hold the resulting public key. |
pPubLen | Contents will be set to the length of the public key in bytes. |
ppPrivKey | Pointer to the newly allocated buffer that will hold the resulting private key. This will be NULL for pKey a public key. |
pPrivLen | Contents will be set to the length of the private key in bytes. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h 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 private or public key.
pKey | Pointer to a an exising key. |
pOutBuffer | Buffer that will hold the output public key. |
bufferLen | The length of the pOutBuffer in bytes. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS edECC_newKey | ( | edECCKey ** | ppKey, |
edECCCurve | curve, | ||
void * | pExtCtx | ||
) |
Creates a new Edward's curve form key. The key will be allocated and be sure to call edECC_deleteKey
to free the memory when done with the key.
ppKey | Pointer that will receive the location of the newly allocated key. |
curve | The curve and algorithm to associate with the new key. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h 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. This may be used to set a public key or a private key. If setting a private key without a public key value input, the public key value will be generated.
pKey | Pointer to a previously allocated key. |
pPubKey | Buffer holding the public key value to be set. This may be NULL for setting a private key, in which case the public value will be computed. |
pubKeyLen | The length of the public key in bytes. |
pPrivKey | Buffer holding the private key value to be set. This must be NULL when setting just a public key. |
privKeyLen | The length of the private key in bytes. |
pShaSuite | For EdDSA private keys when pPubKey is NULL, the SHA suite used by the EdDSA algorithm. This must be SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448. This param should be NULL for EdDH keys. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS edECC_validateKey | ( | MOC_ECC(hwAccelDescr hwAccelCtx) edECCKey * | pKey, |
BulkHashAlgo * | pShaSuite, | ||
void * | pExtCtx | ||
) |
Validates an Edward's form key. For private keys this consists of validating that the public key is correctly associated with the private key. For EdDSA public keys validation consists of validiting that it is a properly encoded point. For EdDH public keys no validation is needed and this method will always result in OK
.
pKey | Pointer to the key to be validated. This may be public or private. |
pShaSuite | For EdDSA private keys, the SHA suite used by the EdDSA algorithm. This must be SHA2-512 for curve25519 and SHA3-SHAKE256 for curve448. This param should be NULL for EdDH keys or public keys. |
pExtCtx | An extended context reserved for future use. |
OK
(0) if successful and the key is valid, otherwise a negative number error code from merrors.h