NXP Reader Library  v17.1.0.2535
Commands_ECC

Describes about the ASymmetric Crypto's ECC related commands. More...

Collaboration diagram for Commands_ECC:

Modules

 Defines
 Macro Definitions for ASymmetric Crypto's ECC interface support.
 

Functions

phStatus_t phCryptoASym_ECC_GenerateKeyPair (void *pDataParams, uint8_t bCurveID)
 Generates a ECC Private and Public Key pair based on the ECC Curve name specified. More...
 
phStatus_t phCryptoASym_ECC_ExportKey (void *pDataParams, uint16_t wOption, uint16_t wKeyBuffSize, uint8_t *pCurveID, uint8_t *pKey, uint16_t *pKeyLen)
 Exports the ECC Private or Public key based on the option provided. More...
 
phStatus_t phCryptoASym_ECC_LoadKey (void *pDataParams, uint16_t wOption, uint16_t wKeyNo, uint16_t wPos)
 Perform ECC Key Loading from KeyStore. More...
 
phStatus_t phCryptoASym_ECC_LoadKeyDirect (void *pDataParams, uint16_t wOption, uint8_t *pKey, uint16_t wKeyLen)
 Direct Loads a ECC private and Public Key. More...
 
phStatus_t phCryptoASym_ECC_Sign (void *pDataParams, uint16_t wOption, uint8_t bHashAlgo, uint8_t *pMessage, uint16_t wMsgLen, uint8_t *pSign, uint16_t *pSignLen)
 Signs the message. More...
 
phStatus_t phCryptoASym_ECC_Verify (void *pDataParams, uint16_t wOption, uint8_t bHashAlgo, uint8_t *pMessage, uint16_t wMsgLen, uint8_t *pSign, uint16_t wSignLen)
 Verifies the signature. More...
 
phStatus_t phCryptoASym_ECC_SharedSecret (void *pDataParams, uint16_t wOption, uint8_t *pPublicKey, uint16_t wPublicKeyLen, uint8_t *pSharedSecret, uint16_t *pSharedSecretLen)
 Computes the shared secret between current side private key and other side public key. More...
 

Detailed Description

Describes about the ASymmetric Crypto's ECC related commands.

Function Documentation

◆ phCryptoASym_ECC_GenerateKeyPair()

phStatus_t phCryptoASym_ECC_GenerateKeyPair ( void *  pDataParams,
uint8_t  bCurveID 
)

Generates a ECC Private and Public Key pair based on the ECC Curve name specified.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_UNSUPPORTED_CURVE_IDCurveID not supported. Refer bCurveID parameter description.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure
[in]bCurveID[In] The Curve ID's to be used for key generation.

◆ phCryptoASym_ECC_ExportKey()

phStatus_t phCryptoASym_ECC_ExportKey ( void *  pDataParams,
uint16_t  wOption,
uint16_t  wKeyBuffSize,
uint8_t pCurveID,
uint8_t pKey,
uint16_t pKeyLen 
)

Exports the ECC Private or Public key based on the option provided.

Note
This interface needs to be called post using one of the below mentioned interfaces,
Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_KEYKeyPair not loaded or generated. Refer description notes for more information.
PH_ERR_UNSUPPORTED_KEY_PAIR_TYPEExport Key pair type is not supported. Refer wOption parameter description.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure
[in]wOption[In] Combined values for Key to export, the format to be used and internal key context to be used while exporting the keys.
[in]wKeyBuffSize[In] Size of bytes allocated for pKey parameter description.
[out]pCurveID[Out] Curve ID of the key being exported.
[out]pKey[Out] The generated key based on the option provided. The keys will be exported from either of the below interfaces,
[out]pKeyLen[Out] Length of bytes in pKey buffer.

◆ phCryptoASym_ECC_LoadKey()

phStatus_t phCryptoASym_ECC_LoadKey ( void *  pDataParams,
uint16_t  wOption,
uint16_t  wKeyNo,
uint16_t  wPos 
)

Perform ECC Key Loading from KeyStore.

This function uses the key storage provided at component initialization to retrieve the key identified by wKeyNo. After retrieving the key is loaded into the internal key storage array to be prepared for subsequent crypto operations.

Note
  • Before calling this interface make sure the Private, Public Keys are loaded to KeyStore.
Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_KEYThe KeyType available in wKeyNo is not of ECC Key Type.
PH_ERR_UNSUPPORTED_KEY_PAIR_TYPELoad Key type is not supported. Refer wOption parameter description.
PH_ERR_UNSUPPORTED_CURVE_IDCurve ID not supported. Refer wOption parameter description.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Internal key context and Key-Pair to be used while loading the keys.
[in]wKeyNo[In] Key number in KeyStore to be loaded.
[in]wPos[In] Key Position in KeyStore to be loaded.

◆ phCryptoASym_ECC_LoadKeyDirect()

phStatus_t phCryptoASym_ECC_LoadKeyDirect ( void *  pDataParams,
uint16_t  wOption,
uint8_t pKey,
uint16_t  wKeyLen 
)

Direct Loads a ECC private and Public Key.

The key provided in the pKey parameter is loaded directly into the internal key context and will be utilized for subsequent crypto operations.

Note
  • This interface should be called more than ones to load Private or Public Key.
  • This interface supports loading of Private or Public Key separately.
  • This interface supports loading of Private or Public Key alone.
Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_UNSUPPORTED_KEY_PAIR_TYPELoad Key type is not supported. Refer wOption parameter description.
PH_ERR_UNSUPPORTED_CURVE_IDCurve ID not supported. Refer wOption parameter description.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Combined values for Key to load, the format to be used and internal context to be used while importing the keys.
[in]pKey[In] The Private or Public key to be loaded.
[in]wKeyLen[In] Length of bytes in pKey buffer.

◆ phCryptoASym_ECC_Sign()

phStatus_t phCryptoASym_ECC_Sign ( void *  pDataParams,
uint16_t  wOption,
uint8_t  bHashAlgo,
uint8_t pMessage,
uint16_t  wMsgLen,
uint8_t pSign,
uint16_t pSignLen 
)

Signs the message.

Note
Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_KEYKeyPair not loaded or generated. Refer description notes for more information.
PH_ERR_UNSUPPORTED_HASH_ALGOHashing algorithm not supported. Refer bHashAlgo parameter description.
PH_ERR_INVALID_PARAMETERIf Hashing algorithm is No-Hashing and buffering options is not PH_EXCHANGE_DEFAULT.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Buffering options combined with internal key context to use for signing.
[in]bHashAlgo[In] The hashing algorithm to be used. Refer Hash Algorithms for list for supported Algorithms.
[in]pMessage[In] Message to be signed.
[in]wMsgLen[In] Length of bytes in pMessage buffer.
[out]pSign[Out] The signature of the message. The Signature will be in R and S integer format. pSign = R data followed by S data.
Here R and S length should be based on the curve length.
Ex: If curve length is 256 bit then R and S length will be 32 bytes each.
[out]pSignLen[Out] Length of bytes in pSign buffer.

◆ phCryptoASym_ECC_Verify()

phStatus_t phCryptoASym_ECC_Verify ( void *  pDataParams,
uint16_t  wOption,
uint8_t  bHashAlgo,
uint8_t pMessage,
uint16_t  wMsgLen,
uint8_t pSign,
uint16_t  wSignLen 
)

Verifies the signature.

Note
Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_KEYKeyPair not loaded or generated. Refer description notes for more information.
PH_ERR_UNSUPPORTED_HASH_ALGOHashing algorithm not supported. Refer bHashAlgo parameter description.
PH_ERR_INVALID_PARAMETERIf Hashing algorithm is No-Hashing and buffering options is not PH_EXCHANGE_DEFAULT.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Buffering options combined with internal key context to use for verification.
  • PH_EXCHANGE_DEFAULT: Computes the Hash for the Message and provides the verification based on the Signature.
  • PH_EXCHANGE_BUFFER_FIRST: Computes the Hash and saves for completion. Here the Signature is not taken for verification.
  • PH_EXCHANGE_BUFFER_CONT: Computes the Hash along with the previous hash data and saves for completion. Here the Signature is not taken for verification.
  • PH_EXCHANGE_BUFFER_LAST: Computes the Hash along with the previous hash data. Here the Signature is taken for verification.
[in]bHashAlgo[In] The hashing algorithm to be used. Refer Hash Algorithms for list for supported Algorithms.
[in]pMessage[In] Message to be verified.
[in]wMsgLen[In] Length of bytes in pMessage buffer.
[in]pSign[In] The signature of the message. The Signature should be in R and S integer format. pSign = R data followed by S data.
Here R and S length should be based on the curve length.
Ex: If curve length is 256 bit then R and S length will be 32 bytes each.
[in]wSignLen[In] Length of bytes in pSign buffer.

◆ phCryptoASym_ECC_SharedSecret()

phStatus_t phCryptoASym_ECC_SharedSecret ( void *  pDataParams,
uint16_t  wOption,
uint8_t pPublicKey,
uint16_t  wPublicKeyLen,
uint8_t pSharedSecret,
uint16_t pSharedSecretLen 
)

Computes the shared secret between current side private key and other side public key.

The computation used ECDH algorithm.

Note
Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_KEYKeyPair not loaded or generated. Refer description notes for more information.
PH_ERR_UNSUPPORTED_CURVE_IDCurve ID not supported. Refer wOption parameter description.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] The CurveID of the key thats available in pPublicKey buffer combined with internal key context to use for shared secret computation.
  • Refer Curve ID for the Key to be loaded.
[in]pPublicKey[In] The other side's Public key.
[in]wPublicKeyLen[In] Length of bytes in pPublicKey buffer.
[out]pSharedSecret[Out] Shared secret between current side's private key and other side's public key.
[out]pSharedSecretLen[Out] Length of bytes in pSharedSecret buffer.