MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

SHA Algorithm API.

SHA Functional Operation

status_t SHA_Init (SHA_Type *base, sha_ctx_t *ctx, sha_algo_t algo)
 Initialize HASH context. More...
 
status_t SHA_Update (SHA_Type *base, sha_ctx_t *ctx, const uint8_t *message, size_t messageSize)
 Add data to current HASH. More...
 
status_t SHA_Finish (SHA_Type *base, sha_ctx_t *ctx, uint8_t *output, size_t *outputSize)
 Finalize hashing. More...
 

Function Documentation

status_t SHA_Init ( SHA_Type *  base,
sha_ctx_t ctx,
sha_algo_t  algo 
)

This function initializes new hash context.

Parameters
baseSHA peripheral base address
[out]ctxOutput hash context
algoUnderlaying algorithm to use for hash computation. Either SHA-1 or SHA-256.
Returns
Status of initialization
status_t SHA_Update ( SHA_Type *  base,
sha_ctx_t ctx,
const uint8_t *  message,
size_t  messageSize 
)

Add data to current HASH. This can be called repeatedly with an arbitrary amount of data to be hashed.

Parameters
baseSHA peripheral base address
[in,out]ctxHASH context
messageInput message
messageSizeSize of input message in bytes
Returns
Status of the hash update operation
status_t SHA_Finish ( SHA_Type *  base,
sha_ctx_t ctx,
uint8_t *  output,
size_t *  outputSize 
)

Outputs the final hash and erases the context. SHA-1 or SHA-256 padding bits are automatically added by this function.

Parameters
baseSHA peripheral base address
[in,out]ctxHASH context
[out]outputOutput hash data
[in,out]outputSizeOn input, determines the size of bytes of the output array. On output, tells how many bytes have been written to output.
Returns
Status of the hash finish operation