Crypto - Platform

This module includes the platform abstraction for Crypto.

Classes

struct  otCryptoKey
 This structure represents the Key Material required for Crypto operations.
 
struct  otCryptoContext
 This structure stores the context object for platform APIs.
 
struct  otPlatCryptoSha256Hash
 This structure represents a SHA-256 hash.
 
struct  otPlatCryptoEcdsaKeyPair
 This structure represents an ECDSA key pair (public and private keys).
 
struct  otPlatCryptoEcdsaPublicKey
 This struct represents a ECDSA public key.
 
struct  otPlatCryptoEcdsaSignature
 This struct represents an ECDSA signature.

Macros

#define OT_CRYPTO_SHA256_HASH_SIZE   32
 Length of SHA256 hash (in bytes).
 
#define OT_CRYPTO_ECDSA_MAX_DER_SIZE   125
 Max buffer size (in bytes) for representing the EDCSA key-pair in DER format.
 
#define OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE   64
 Buffer size (in bytes) for representing the EDCSA public key.
 
#define OT_CRYPTO_ECDSA_SIGNATURE_SIZE   64
 Buffer size (in bytes) for representing the EDCSA signature.

Typedefs

typedef uint32_t otCryptoKeyRef
 This datatype represents the key reference.
 
typedef struct otCryptoKey otCryptoKey
 
typedef struct otCryptoContext otCryptoContext
 
typedef struct otPlatCryptoSha256Hash otPlatCryptoSha256Hash
 This structure represents a SHA-256 hash.
 
typedef struct otPlatCryptoEcdsaKeyPair otPlatCryptoEcdsaKeyPair
 
typedef struct otPlatCryptoEcdsaPublicKey otPlatCryptoEcdsaPublicKey
 
typedef struct otPlatCryptoEcdsaSignature otPlatCryptoEcdsaSignature

Enumerations

enum  otCryptoKeyType {
  OT_CRYPTO_KEY_TYPE_RAW,
  OT_CRYPTO_KEY_TYPE_AES,
  OT_CRYPTO_KEY_TYPE_HMAC
}
 This enumeration defines the key types.
 
enum  otCryptoKeyAlgorithm {
  OT_CRYPTO_KEY_ALG_VENDOR,
  OT_CRYPTO_KEY_ALG_AES_ECB,
  OT_CRYPTO_KEY_ALG_HMAC_SHA_256
}
 This enumeration defines the key algorithms.
 
enum  {
  OT_CRYPTO_KEY_USAGE_NONE = 0,
  OT_CRYPTO_KEY_USAGE_EXPORT = 1 << 0,
  OT_CRYPTO_KEY_USAGE_ENCRYPT = 1 << 1,
  OT_CRYPTO_KEY_USAGE_DECRYPT = 1 << 2,
  OT_CRYPTO_KEY_USAGE_SIGN_HASH = 1 << 3
}
 This enumeration defines the key usage flags.
 
enum  otCryptoKeyStorage {
  OT_CRYPTO_KEY_STORAGE_VOLATILE,
  OT_CRYPTO_KEY_STORAGE_PERSISTENT
}
 This enumeration defines the key storage types.

Functions

void otPlatCryptoInit (void)
 Initialize the Crypto module.
 
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.
 
otError otPlatCryptoExportKey (otCryptoKeyRef aKeyRef, uint8_t *aBuffer, size_t aBufferLen, size_t *aKeyLen)
 Export a key stored in PSA ITS.
 
otError otPlatCryptoDestroyKey (otCryptoKeyRef aKeyRef)
 Destroy a key stored in PSA ITS.
 
bool otPlatCryptoHasKey (otCryptoKeyRef aKeyRef)
 Check if the key ref passed has an associated key in PSA ITS.
 
otError otPlatCryptoHmacSha256Init (otCryptoContext *aContext)
 Initialize the HMAC operation.
 
otError otPlatCryptoHmacSha256Deinit (otCryptoContext *aContext)
 Uninitialize the HMAC operation.
 
otError otPlatCryptoHmacSha256Start (otCryptoContext *aContext, const otCryptoKey *aKey)
 Start HMAC operation.
 
otError otPlatCryptoHmacSha256Update (otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength)
 Update the HMAC operation with new input.
 
otError otPlatCryptoHmacSha256Finish (otCryptoContext *aContext, uint8_t *aBuf, size_t aBufLength)
 Complete the HMAC operation.
 
otError otPlatCryptoAesInit (otCryptoContext *aContext)
 Initialise the AES operation.
 
otError otPlatCryptoAesSetKey (otCryptoContext *aContext, const otCryptoKey *aKey)
 Set the key for AES operation.
 
otError otPlatCryptoAesEncrypt (otCryptoContext *aContext, const uint8_t *aInput, uint8_t *aOutput)
 Encrypt the given data.
 
otError otPlatCryptoAesFree (otCryptoContext *aContext)
 Free the AES context.
 
otError otPlatCryptoHkdfInit (otCryptoContext *aContext)
 Initialise the HKDF context.
 
otError otPlatCryptoHkdfExpand (otCryptoContext *aContext, const uint8_t *aInfo, uint16_t aInfoLength, uint8_t *aOutputKey, uint16_t aOutputKeyLength)
 Perform HKDF Expand step.
 
otError otPlatCryptoHkdfExtract (otCryptoContext *aContext, const uint8_t *aSalt, uint16_t aSaltLength, const otCryptoKey *aInputKey)
 Perform HKDF Extract step.
 
otError otPlatCryptoHkdfDeinit (otCryptoContext *aContext)
 Uninitialize the HKDF context.
 
otError otPlatCryptoSha256Init (otCryptoContext *aContext)
 Initialise the SHA-256 operation.
 
otError otPlatCryptoSha256Deinit (otCryptoContext *aContext)
 Uninitialize the SHA-256 operation.
 
otError otPlatCryptoSha256Start (otCryptoContext *aContext)
 Start SHA-256 operation.
 
otError otPlatCryptoSha256Update (otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength)
 Update SHA-256 operation with new input.
 
otError otPlatCryptoSha256Finish (otCryptoContext *aContext, uint8_t *aHash, uint16_t aHashSize)
 Finish SHA-256 operation.
 
void otPlatCryptoRandomInit (void)
 Initialize cryptographically-secure pseudorandom number generator (CSPRNG).
 
void otPlatCryptoRandomDeinit (void)
 Deinitialize cryptographically-secure pseudorandom number generator (CSPRNG).
 
otError otPlatCryptoRandomGet (uint8_t *aBuffer, uint16_t aSize)
 Fills a given buffer with cryptographically secure random bytes.
 
otError otPlatCryptoEcdsaGenerateKey (otPlatCryptoEcdsaKeyPair *aKeyPair)
 Generate and populate the output buffer with a new ECDSA key-pair.
 
otError otPlatCryptoEcdsaGetPublicKey (const otPlatCryptoEcdsaKeyPair *aKeyPair, otPlatCryptoEcdsaPublicKey *aPublicKey)
 Get the associated public key from the input context.
 
otError otPlatCryptoEcdsaSign (const otPlatCryptoEcdsaKeyPair *aKeyPair, const otPlatCryptoSha256Hash *aHash, otPlatCryptoEcdsaSignature *aSignature)
 Calculate the ECDSA signature for a hashed message using the private key from the input context.
 
otError otPlatCryptoEcdsaVerify (const otPlatCryptoEcdsaPublicKey *aPublicKey, const otPlatCryptoSha256Hash *aHash, const otPlatCryptoEcdsaSignature *aSignature)
 Use the key from the input context to verify the ECDSA signature of a hashed message.

Variables

OT_TOOL_PACKED_BEGIN struct otPlatCryptoSha256Hash OT_TOOL_PACKED_END

Detailed Description

This module includes the platform abstraction for Crypto.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

This enumeration defines the key usage flags.

Enumerator
OT_CRYPTO_KEY_USAGE_NONE 

Key Usage: Key Usage is empty.

OT_CRYPTO_KEY_USAGE_EXPORT 

Key Usage: Key can be exported.

OT_CRYPTO_KEY_USAGE_ENCRYPT 

Key Usage: Encryption (vendor defined).

OT_CRYPTO_KEY_USAGE_DECRYPT 

Key Usage: AES ECB.

OT_CRYPTO_KEY_USAGE_SIGN_HASH 

Key Usage: HMAC SHA-256.

◆ otCryptoKeyAlgorithm

This enumeration defines the key algorithms.

Enumerator
OT_CRYPTO_KEY_ALG_VENDOR 

Key Algorithm: Vendor Defined.

OT_CRYPTO_KEY_ALG_AES_ECB 

Key Algorithm: AES ECB.

OT_CRYPTO_KEY_ALG_HMAC_SHA_256 

Key Algorithm: HMAC SHA-256.

◆ otCryptoKeyStorage

This enumeration defines the key storage types.

Enumerator
OT_CRYPTO_KEY_STORAGE_VOLATILE 

Key Persistence: Key is volatile.

OT_CRYPTO_KEY_STORAGE_PERSISTENT 

Key Persistence: Key is persistent.

◆ otCryptoKeyType

This enumeration defines the key types.

Enumerator
OT_CRYPTO_KEY_TYPE_RAW 

Key Type: Raw Data.

OT_CRYPTO_KEY_TYPE_AES 

Key Type: AES.

OT_CRYPTO_KEY_TYPE_HMAC 

Key Type: HMAC.

Function Documentation

◆ otPlatCryptoAesEncrypt()

otError otPlatCryptoAesEncrypt ( otCryptoContext aContext,
const uint8_t *  aInput,
uint8_t *  aOutput 
)

Encrypt the given data.

Parameters
[in]aContextContext for AES operation.
[in]aInputPointer to the input buffer.
[in]aOutputPointer to the output buffer.
Return values
OT_ERROR_NONESuccessfully encrypted aInput.
OT_ERROR_FAILEDFailed to encrypt aInput.
OT_ERROR_INVALID_ARGSaContext or aKey or aOutput were NULL

◆ otPlatCryptoAesFree()

otError otPlatCryptoAesFree ( otCryptoContext aContext)

Free the AES context.

Parameters
[in]aContextContext for AES operation.
Return values
OT_ERROR_NONESuccessfully freed AES context.
OT_ERROR_FAILEDFailed to free AES context.
OT_ERROR_INVALID_ARGSaContext was NULL

◆ otPlatCryptoAesInit()

otError otPlatCryptoAesInit ( otCryptoContext aContext)

Initialise the AES operation.

Parameters
[in]aContextContext for AES operation.
Return values
OT_ERROR_NONESuccessfully Initialised AES operation.
OT_ERROR_FAILEDFailed to Initialise AES operation.
OT_ERROR_INVALID_ARGSaContext was NULL
OT_ERROR_NO_BUFSCannot allocate the context.
Note
The platform driver shall point the context to the correct object such as psa_key_id or mbedtls_aes_context_t.

◆ otPlatCryptoAesSetKey()

otError otPlatCryptoAesSetKey ( otCryptoContext aContext,
const otCryptoKey aKey 
)

Set the key for AES operation.

Parameters
[in]aContextContext for AES operation.
[out]aKeyKey to use for AES operation.
Return values
OT_ERROR_NONESuccessfully set the key for AES operation.
OT_ERROR_FAILEDFailed to set the key for AES operation.
OT_ERROR_INVALID_ARGSaContext or aKey was NULL

◆ otPlatCryptoDestroyKey()

otError otPlatCryptoDestroyKey ( otCryptoKeyRef  aKeyRef)

Destroy a key stored in PSA ITS.

Parameters
[in]aKeyRefThe key ref to be destroyed
Return values
OT_ERROR_NONESuccessfully destroyed the key.
OT_ERROR_FAILEDFailed to destroy the key.
Note
This API is only used by OT core when OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE is enabled.

◆ otPlatCryptoEcdsaGenerateKey()

otError otPlatCryptoEcdsaGenerateKey ( otPlatCryptoEcdsaKeyPair aKeyPair)

Generate and populate the output buffer with a new ECDSA key-pair.

Parameters
[out]aKeyPairA pointer to an ECDSA key-pair structure to store the generated key-pair.
Return values
OT_ERROR_NONEA new key-pair was generated successfully.
OT_ERROR_NO_BUFSFailed to allocate buffer for key generation.
OT_ERROR_NOT_CAPABLEFeature not supported.
OT_ERROR_FAILEDFailed to generate key-pair.

◆ otPlatCryptoEcdsaGetPublicKey()

otError otPlatCryptoEcdsaGetPublicKey ( const otPlatCryptoEcdsaKeyPair aKeyPair,
otPlatCryptoEcdsaPublicKey aPublicKey 
)

Get the associated public key from the input context.

Parameters
[in]aKeyPairA pointer to an ECDSA key-pair structure where the key-pair is stored.
[out]aPublicKeyA pointer to an ECDSA public key structure to store the public key.
Return values
OT_ERROR_NONEPublic key was retrieved successfully, and aBuffer is updated.
OT_ERROR_PARSEThe key-pair DER format could not be parsed (invalid format).
OT_ERROR_INVALID_ARGSThe aContext is NULL.

◆ otPlatCryptoEcdsaSign()

otError otPlatCryptoEcdsaSign ( const otPlatCryptoEcdsaKeyPair aKeyPair,
const otPlatCryptoSha256Hash aHash,
otPlatCryptoEcdsaSignature aSignature 
)

Calculate the ECDSA signature for a hashed message using the private key from the input context.

This method uses the deterministic digital signature generation procedure from RFC 6979.

Parameters
[in]aKeyPairA pointer to an ECDSA key-pair structure where the key-pair is stored.
[in]aHashA pointer to a SHA-256 hash structure where the hash value for signature calculation is stored.
[out]aSignatureA pointer to an ECDSA signature structure to output the calculated signature.
Return values
OT_ERROR_NONEThe signature was calculated successfully, aSignature was updated.
OT_ERROR_PARSEThe key-pair DER format could not be parsed (invalid format).
OT_ERROR_NO_BUFSFailed to allocate buffer for signature calculation.
OT_ERROR_INVALID_ARGSThe aContext is NULL.

◆ otPlatCryptoEcdsaVerify()

otError otPlatCryptoEcdsaVerify ( const otPlatCryptoEcdsaPublicKey aPublicKey,
const otPlatCryptoSha256Hash aHash,
const otPlatCryptoEcdsaSignature aSignature 
)

Use the key from the input context to verify the ECDSA signature of a hashed message.

Parameters
[in]aPublicKeyA pointer to an ECDSA public key structure where the public key for signature verification is stored.
[in]aHashA pointer to a SHA-256 hash structure where the hash value for signature verification is stored.
[in]aSignatureA pointer to an ECDSA signature structure where the signature value to be verified is stored.
Return values
OT_ERROR_NONEThe signature was verified successfully.
OT_ERROR_SECURITYThe signature is invalid.
OT_ERROR_INVALID_ARGSThe key or hash is invalid.
OT_ERROR_NO_BUFSFailed to allocate buffer for signature verification.

◆ otPlatCryptoExportKey()

otError otPlatCryptoExportKey ( otCryptoKeyRef  aKeyRef,
uint8_t *  aBuffer,
size_t  aBufferLen,
size_t *  aKeyLen 
)

Export a key stored in PSA ITS.

Parameters
[in]aKeyRefThe key ref to be used for crypto operations.
[out]aBufferPointer to the buffer where key needs to be exported.
[in]aBufferLenLength of the buffer passed to store the exported key.
[out]aKeyLenPointer to return the length of the exported key.
Return values
OT_ERROR_NONESuccessfully exported aKeyRef.
OT_ERROR_FAILEDFailed to export aKeyRef.
OT_ERROR_INVALID_ARGSaBuffer was NULL
Note
This API is only used by OT core when OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE is enabled.

◆ otPlatCryptoHasKey()

bool otPlatCryptoHasKey ( otCryptoKeyRef  aKeyRef)

Check if the key ref passed has an associated key in PSA ITS.

Parameters
[in]aKeyRefThe Key Ref to check.
Return values
TRUEThere is an associated key with aKeyRef.
FALSEThere is no associated key with aKeyRef.
Note
This API is only used by OT core when OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE is enabled.

◆ otPlatCryptoHkdfDeinit()

otError otPlatCryptoHkdfDeinit ( otCryptoContext aContext)

Uninitialize the HKDF context.

Parameters
[in]aContextContext for HKDF operation.
Return values
OT_ERROR_NONESuccessfully un-initialised HKDF operation.
OT_ERROR_FAILEDFailed to un-initialised HKDF operation.
OT_ERROR_INVALID_ARGSaContext was NULL

◆ otPlatCryptoHkdfExpand()

otError otPlatCryptoHkdfExpand ( otCryptoContext aContext,
const uint8_t *  aInfo,
uint16_t  aInfoLength,
uint8_t *  aOutputKey,
uint16_t  aOutputKeyLength 
)

Perform HKDF Expand step.

Parameters
[in]aContextOperation context for HKDF operation.
[in]aInfoPointer to the Info sequence.
[in]aInfoLengthLength of the Info sequence.
[out]aOutputKeyPointer to the output Key.
[in]aOutputKeyLengthSize of the output key buffer.
Return values
OT_ERROR_NONEHKDF Expand was successful.
OT_ERROR_FAILEDHKDF Expand failed.
OT_ERROR_INVALID_ARGSaContext was NULL

◆ otPlatCryptoHkdfExtract()

otError otPlatCryptoHkdfExtract ( otCryptoContext aContext,
const uint8_t *  aSalt,
uint16_t  aSaltLength,
const otCryptoKey aInputKey 
)

Perform HKDF Extract step.

Parameters
[in]aContextOperation context for HKDF operation.
[in]aSaltPointer to the Salt for HKDF.
[in]aSaltLengthLength of Salt.
[in]aInputKeyPointer to the input key.
Return values
OT_ERROR_NONEHKDF Extract was successful.
OT_ERROR_FAILEDHKDF Extract failed.

◆ otPlatCryptoHkdfInit()

otError otPlatCryptoHkdfInit ( otCryptoContext aContext)

Initialise the HKDF context.

Parameters
[in]aContextContext for HKDF operation.
Return values
OT_ERROR_NONESuccessfully Initialised AES operation.
OT_ERROR_FAILEDFailed to Initialise AES operation.
OT_ERROR_INVALID_ARGSaContext was NULL
Note
The platform driver shall point the context to the correct object such as psa_key_derivation_operation_t or HmacSha256::Hash

◆ otPlatCryptoHmacSha256Deinit()

otError otPlatCryptoHmacSha256Deinit ( otCryptoContext aContext)

Uninitialize the HMAC operation.

Parameters
[in]aContextContext for HMAC operation.
Return values
OT_ERROR_NONESuccessfully uninitialized HMAC operation.
OT_ERROR_FAILEDFailed to uninitialized HMAC operation.
OT_ERROR_INVALID_ARGSaContext was NULL

◆ otPlatCryptoHmacSha256Finish()

otError otPlatCryptoHmacSha256Finish ( otCryptoContext aContext,
uint8_t *  aBuf,
size_t  aBufLength 
)

Complete the HMAC operation.

Parameters
[in]aContextContext for HMAC operation.
[out]aBufA pointer to the output buffer.
[in]aBufLengthThe length of aBuf in bytes.
Return values
OT_ERROR_NONESuccessfully completed HMAC operation.
OT_ERROR_FAILEDFailed to complete HMAC operation.
OT_ERROR_INVALID_ARGSaContext or aBuf was NULL

◆ otPlatCryptoHmacSha256Init()

otError otPlatCryptoHmacSha256Init ( otCryptoContext aContext)

Initialize the HMAC operation.

Parameters
[in]aContextContext for HMAC operation.
Return values
OT_ERROR_NONESuccessfully initialized HMAC operation.
OT_ERROR_FAILEDFailed to initialize HMAC operation.
OT_ERROR_INVALID_ARGSaContext was NULL
Note
The platform driver shall point the context to the correct object such as psa_mac_operation_t or mbedtls_md_context_t.

◆ otPlatCryptoHmacSha256Start()

otError otPlatCryptoHmacSha256Start ( otCryptoContext aContext,
const otCryptoKey aKey 
)

Start HMAC operation.

Parameters
[in]aContextContext for HMAC operation.
[in]aKeyKey material to be used for for HMAC operation.
Return values
OT_ERROR_NONESuccessfully started HMAC operation.
OT_ERROR_FAILEDFailed to start HMAC operation.
OT_ERROR_INVALID_ARGSaContext or aKey was NULL

◆ otPlatCryptoHmacSha256Update()

otError otPlatCryptoHmacSha256Update ( otCryptoContext aContext,
const void *  aBuf,
uint16_t  aBufLength 
)

Update the HMAC operation with new input.

Parameters
[in]aContextContext for HMAC operation.
[in]aBufA pointer to the input buffer.
[in]aBufLengthThe length of aBuf in bytes.
Return values
OT_ERROR_NONESuccessfully updated HMAC with new input operation.
OT_ERROR_FAILEDFailed to update HMAC operation.
OT_ERROR_INVALID_ARGSaContext or aBuf was NULL

◆ 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.

Parameters
[in,out]aKeyRefPointer to the key ref to be used for crypto operations.
[in]aKeyTypeKey Type encoding for the key.
[in]aKeyAlgorithmKey algorithm encoding for the key.
[in]aKeyUsageKey Usage encoding for the key (combinations of OT_CRYPTO_KEY_USAGE_*).
[in]aKeyPersistenceKey Persistence for this key
[in]aKeyActual key to be imported.
[in]aKeyLenLength of the key to be imported.
Return values
OT_ERROR_NONESuccessfully imported the key.
OT_ERROR_FAILEDFailed to import the key.
OT_ERROR_INVALID_ARGSaKey was set to NULL.
Note
If OT_CRYPTO_KEY_STORAGE_PERSISTENT is passed for aKeyPersistence then aKeyRef is input and platform should use the given aKeyRef and MUST not change it.

If OT_CRYPTO_KEY_STORAGE_VOLATILE is passed for aKeyPersistence then aKeyRef is output, the initial value does not matter and platform API MUST update it to return the new key ref.

This API is only used by OT core when OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE is enabled.

◆ otPlatCryptoRandomGet()

otError otPlatCryptoRandomGet ( uint8_t *  aBuffer,
uint16_t  aSize 
)

Fills a given buffer with cryptographically secure random bytes.

Parameters
[out]aBufferA pointer to a buffer to fill with the random bytes.
[in]aSizeSize of buffer (number of bytes to fill).
Return values
OT_ERROR_NONESuccessfully filled buffer with random values.
OT_ERROR_FAILEDOperation failed.

◆ otPlatCryptoSha256Deinit()

otError otPlatCryptoSha256Deinit ( otCryptoContext aContext)

Uninitialize the SHA-256 operation.

Parameters
[in]aContextContext for SHA-256 operation.
Return values
OT_ERROR_NONESuccessfully un-initialised SHA-256 operation.
OT_ERROR_FAILEDFailed to un-initialised SHA-256 operation.
OT_ERROR_INVALID_ARGSaContext was NULL

◆ otPlatCryptoSha256Finish()

otError otPlatCryptoSha256Finish ( otCryptoContext aContext,
uint8_t *  aHash,
uint16_t  aHashSize 
)

Finish SHA-256 operation.

Parameters
[in]aContextContext for SHA-256 operation.
[in]aHashA pointer to the output buffer, where hash needs to be stored.
[in]aHashSizeThe length of aHash in bytes.
Return values
OT_ERROR_NONESuccessfully completed the SHA-256 operation.
OT_ERROR_FAILEDFailed to complete SHA-256 operation.
OT_ERROR_INVALID_ARGSaContext or aHash was NULL

◆ otPlatCryptoSha256Init()

otError otPlatCryptoSha256Init ( otCryptoContext aContext)

Initialise the SHA-256 operation.

Parameters
[in]aContextContext for SHA-256 operation.
Return values
OT_ERROR_NONESuccessfully initialised SHA-256 operation.
OT_ERROR_FAILEDFailed to initialise SHA-256 operation.
OT_ERROR_INVALID_ARGSaContext was NULL
Note
The platform driver shall point the context to the correct object such as psa_hash_operation_t or mbedtls_sha256_context.

◆ otPlatCryptoSha256Start()

otError otPlatCryptoSha256Start ( otCryptoContext aContext)

Start SHA-256 operation.

Parameters
[in]aContextContext for SHA-256 operation.
Return values
OT_ERROR_NONESuccessfully started SHA-256 operation.
OT_ERROR_FAILEDFailed to start SHA-256 operation.
OT_ERROR_INVALID_ARGSaContext was NULL

◆ otPlatCryptoSha256Update()

otError otPlatCryptoSha256Update ( otCryptoContext aContext,
const void *  aBuf,
uint16_t  aBufLength 
)

Update SHA-256 operation with new input.

Parameters
[in]aContextContext for SHA-256 operation.
[in]aBufA pointer to the input buffer.
[in]aBufLengthThe length of aBuf in bytes.
Return values
OT_ERROR_NONESuccessfully updated SHA-256 with new input operation.
OT_ERROR_FAILEDFailed to update SHA-256 operation.
OT_ERROR_INVALID_ARGSaContext or aBuf was NULL