Crypto - Platform
This module includes the platform abstraction for Crypto.
Summary
Enumerations |
|
---|---|
Anonymous Enum 17{
|
enum This enumeration defines the key usage flags. |
otCryptoKeyAlgorithm{
|
enum This enumeration defines the key algorithms. |
otCryptoKeyStorage{
|
enum This enumeration defines the key storage types. |
otCryptoKeyType{
|
enum This enumeration defines the key types. |
Typedefs |
|
---|---|
otCryptoContext
|
typedefstruct otCryptoContext
|
otCryptoKey
|
typedefstruct otCryptoKey
|
otCryptoKeyRef
|
typedefuint32_t
This datatype represents the key reference. |
Functions |
|
---|---|
otPlatCryptoAesEncrypt(otCryptoContext *aContext, const uint8_t *aInput, uint8_t *aOutput)
|
Encrypt the given data.
|
otPlatCryptoAesFree(otCryptoContext *aContext)
|
Free the AES context.
|
otPlatCryptoAesInit(otCryptoContext *aContext)
|
Initialise the AES operation.
|
otPlatCryptoAesSetKey(otCryptoContext *aContext, const otCryptoKey *aKey)
|
Set the key for AES operation.
|
otPlatCryptoDestroyKey(otCryptoKeyRef aKeyRef)
|
Destroy a key stored in PSA ITS.
|
otPlatCryptoExportKey(otCryptoKeyRef aKeyRef, uint8_t *aBuffer, size_t aBufferLen, size_t *aKeyLen)
|
Export a key stored in PSA ITS.
|
otPlatCryptoHasKey(otCryptoKeyRef aKeyRef)
|
bool
Check if the key ref passed has an associated key in PSA ITS.
|
otPlatCryptoHkdfDeinit(otCryptoContext *aContext)
|
Uninitialize the HKDF context.
|
otPlatCryptoHkdfExpand(otCryptoContext *aContext, const uint8_t *aInfo, uint16_t aInfoLength, uint8_t *aOutputKey, uint16_t aOutputKeyLength)
|
Perform HKDF Expand step.
|
otPlatCryptoHkdfExtract(otCryptoContext *aContext, const uint8_t *aSalt, uint16_t aSaltLength, const otCryptoKey *aInputKey)
|
Perform HKDF Extract step.
|
otPlatCryptoHkdfInit(otCryptoContext *aContext)
|
Initialise the HKDF context.
|
otPlatCryptoHmacSha256Deinit(otCryptoContext *aContext)
|
Uninitialize the HMAC operation.
|
otPlatCryptoHmacSha256Finish(otCryptoContext *aContext, uint8_t *aBuf, size_t aBufLength)
|
Complete the HMAC operation.
|
otPlatCryptoHmacSha256Init(otCryptoContext *aContext)
|
Initialize the HMAC operation.
|
otPlatCryptoHmacSha256Start(otCryptoContext *aContext, const otCryptoKey *aKey)
|
Start HMAC operation.
|
otPlatCryptoHmacSha256Update(otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength)
|
Update the HMAC operation with new input.
|
otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef, otCryptoKeyType aKeyType, otCryptoKeyAlgorithm aKeyAlgorithm, int aKeyUsage, otCryptoKeyStorage aKeyPersistence, const uint8_t *aKey, size_t aKeyLen)
|
Import a key into PSA ITS.
|
otPlatCryptoInit(void)
|
void
Initialize the Crypto module.
|
otPlatCryptoRandomDeinit(void)
|
void
Deinitialize cryptographically-secure pseudorandom number generator (CSPRNG).
|
otPlatCryptoRandomGet(uint8_t *aBuffer, uint16_t aSize)
|
Fills a given buffer with cryptographically secure random bytes.
|
otPlatCryptoRandomInit(void)
|
void
Initialize cryptographically-secure pseudorandom number generator (CSPRNG).
|
otPlatCryptoSha256Deinit(otCryptoContext *aContext)
|
Uninitialize the SHA-256 operation.
|
otPlatCryptoSha256Finish(otCryptoContext *aContext, uint8_t *aHash, uint16_t aHashSize)
|
Finish SHA-256 operation.
|
otPlatCryptoSha256Init(otCryptoContext *aContext)
|
Initialise the SHA-256 operation.
|
otPlatCryptoSha256Start(otCryptoContext *aContext)
|
Start SHA-256 operation.
|
otPlatCryptoSha256Update(otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength)
|
Update SHA-256 operation with new input.
|
Structs |
|
---|---|
otCryptoContext |
This structure stores the context object for platform APIs. |
otCryptoKey |
This structure represents the Key Material required for Crypto operations. |
Enumerations
Anonymous Enum 17
Anonymous Enum 17
This enumeration defines the key usage flags.
Properties | |
---|---|
OT_CRYPTO_KEY_USAGE_DECRYPT
|
Key Usage: AES ECB. |
OT_CRYPTO_KEY_USAGE_ENCRYPT
|
Key Usage: Encryption (vendor defined). |
OT_CRYPTO_KEY_USAGE_EXPORT
|
Key Usage: Key can be exported. |
OT_CRYPTO_KEY_USAGE_NONE
|
Key Usage: Key Usage is empty. |
OT_CRYPTO_KEY_USAGE_SIGN_HASH
|
Key Usage: HMAC SHA-256. |
otCryptoKeyAlgorithm
otCryptoKeyAlgorithm
This enumeration defines the key algorithms.
Properties | |
---|---|
OT_CRYPTO_KEY_ALG_AES_ECB
|
Key Algorithm: AES ECB. |
OT_CRYPTO_KEY_ALG_HMAC_SHA_256
|
Key Algorithm: HMAC SHA-256. |
OT_CRYPTO_KEY_ALG_VENDOR
|
Key Algorithm: Vendor Defined. |
otCryptoKeyStorage
otCryptoKeyStorage
This enumeration defines the key storage types.
Properties | |
---|---|
OT_CRYPTO_KEY_STORAGE_PERSISTENT
|
Key Persistence: Key is persistent. |
OT_CRYPTO_KEY_STORAGE_VOLATILE
|
Key Persistence: Key is volatile. |
otCryptoKeyType
otCryptoKeyType
This enumeration defines the key types.
Properties | |
---|---|
OT_CRYPTO_KEY_TYPE_AES
|
Key Type: AES. |
OT_CRYPTO_KEY_TYPE_HMAC
|
Key Type: HMAC. |
OT_CRYPTO_KEY_TYPE_RAW
|
Key Type: Raw Data. |
Typedefs
otCryptoContext
struct otCryptoContext otCryptoContext
otCryptoKey
struct otCryptoKey otCryptoKey
otCryptoKeyRef
uint32_t otCryptoKeyRef
This datatype represents the key reference.
Functions
otPlatCryptoAesEncrypt
otError otPlatCryptoAesEncrypt( otCryptoContext *aContext, const uint8_t *aInput, uint8_t *aOutput )
Encrypt the given data.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoAesFree
otError otPlatCryptoAesFree( otCryptoContext *aContext )
Free the AES context.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoAesInit
otError otPlatCryptoAesInit( otCryptoContext *aContext )
Initialise the AES operation.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otPlatCryptoAesSetKey
otError otPlatCryptoAesSetKey( otCryptoContext *aContext, const otCryptoKey *aKey )
Set the key for AES operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoDestroyKey
otError otPlatCryptoDestroyKey( otCryptoKeyRef aKeyRef )
Destroy a key stored in PSA ITS.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otPlatCryptoExportKey
otError otPlatCryptoExportKey( otCryptoKeyRef aKeyRef, uint8_t *aBuffer, size_t aBufferLen, size_t *aKeyLen )
Export a key stored in PSA ITS.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otPlatCryptoHasKey
bool otPlatCryptoHasKey( otCryptoKeyRef aKeyRef )
Check if the key ref passed has an associated key in PSA ITS.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otPlatCryptoHkdfDeinit
otError otPlatCryptoHkdfDeinit( otCryptoContext *aContext )
Uninitialize the HKDF context.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoHkdfExpand
otError otPlatCryptoHkdfExpand( otCryptoContext *aContext, const uint8_t *aInfo, uint16_t aInfoLength, uint8_t *aOutputKey, uint16_t aOutputKeyLength )
Perform HKDF Expand step.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Return Values |
|
otPlatCryptoHkdfExtract
otError otPlatCryptoHkdfExtract( otCryptoContext *aContext, const uint8_t *aSalt, uint16_t aSaltLength, const otCryptoKey *aInputKey )
Perform HKDF Extract step.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otPlatCryptoHkdfInit
otError otPlatCryptoHkdfInit( otCryptoContext *aContext )
Initialise the HKDF context.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoHmacSha256Deinit
otError otPlatCryptoHmacSha256Deinit( otCryptoContext *aContext )
Uninitialize the HMAC operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoHmacSha256Finish
otError otPlatCryptoHmacSha256Finish( otCryptoContext *aContext, uint8_t *aBuf, size_t aBufLength )
Complete the HMAC operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoHmacSha256Init
otError otPlatCryptoHmacSha256Init( otCryptoContext *aContext )
Initialize the HMAC operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoHmacSha256Start
otError otPlatCryptoHmacSha256Start( otCryptoContext *aContext, const otCryptoKey *aKey )
Start HMAC operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoHmacSha256Update
otError otPlatCryptoHmacSha256Update( otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength )
Update the HMAC operation with new input.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoImportKey
otError otPlatCryptoImportKey( otCryptoKeyRef *aKeyRef, otCryptoKeyType aKeyType, otCryptoKeyAlgorithm aKeyAlgorithm, int aKeyUsage, otCryptoKeyStorage aKeyPersistence, const uint8_t *aKey, size_t aKeyLen )
Import a key into PSA ITS.
If OT_CRYPTO_KEY_STORAGE_VOLATILE is passed for aKeyPersistence thenaKeyRef
is output, the initial value does not matter and platform API MUST update it to return the new key ref.
Details | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||||
Return Values |
|
This API is only used by OT core when OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
is enabled.
otPlatCryptoInit
void otPlatCryptoInit( void )
Initialize the Crypto module.
otPlatCryptoRandomDeinit
void otPlatCryptoRandomDeinit( void )
Deinitialize cryptographically-secure pseudorandom number generator (CSPRNG).
otPlatCryptoRandomGet
otError otPlatCryptoRandomGet( uint8_t *aBuffer, uint16_t aSize )
Fills a given buffer with cryptographically secure random bytes.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otPlatCryptoRandomInit
void otPlatCryptoRandomInit( void )
Initialize cryptographically-secure pseudorandom number generator (CSPRNG).
otPlatCryptoSha256Deinit
otError otPlatCryptoSha256Deinit( otCryptoContext *aContext )
Uninitialize the SHA-256 operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoSha256Finish
otError otPlatCryptoSha256Finish( otCryptoContext *aContext, uint8_t *aHash, uint16_t aHashSize )
Finish SHA-256 operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoSha256Init
otError otPlatCryptoSha256Init( otCryptoContext *aContext )
Initialise the SHA-256 operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoSha256Start
otError otPlatCryptoSha256Start( otCryptoContext *aContext )
Start SHA-256 operation.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otPlatCryptoSha256Update
otError otPlatCryptoSha256Update( otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength )
Update SHA-256 operation with new input.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
Resources
OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.