![]() |
MCUXpresso SDK API Reference Manual
Rev 2.16.000
NXP Semiconductors
|
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... | |
void | SHA_SetCallback (SHA_Type *base, sha_ctx_t *ctx, sha_callback_t callback, void *userData) |
Initializes the SHA handle for background hashing. More... | |
status_t | SHA_UpdateNonBlocking (SHA_Type *base, sha_ctx_t *ctx, const uint8_t *input, size_t inputSize) |
Create running hash on given data. More... | |
void | SHA_ClkInit (SHA_Type *base) |
Start SHA clock. More... | |
void | SHA_ClkDeinit (SHA_Type *base) |
Stop SHA clock. More... | |
status_t SHA_Init | ( | SHA_Type * | base, |
sha_ctx_t * | ctx, | ||
sha_algo_t | algo | ||
) |
This function initializes new hash context.
base | SHA peripheral base address | |
[out] | ctx | Output hash context |
algo | Underlaying algorithm to use for hash computation. Either SHA-1 or SHA-256. |
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.
base | SHA peripheral base address | |
[in,out] | ctx | HASH context |
message | Input message | |
messageSize | Size of input message in bytes |
Outputs the final hash and erases the context. SHA-1 or SHA-256 padding bits are automatically added by this function.
base | SHA peripheral base address | |
[in,out] | ctx | HASH context |
[out] | output | Output hash data |
[in,out] | outputSize | On input, determines the size of bytes of the output array. On output, tells how many bytes have been written to output. |
void SHA_SetCallback | ( | SHA_Type * | base, |
sha_ctx_t * | ctx, | ||
sha_callback_t | callback, | ||
void * | userData | ||
) |
This function initializes the hash context for background hashing (Non-blocking) APIs. This is less typical interface to hash function, but can be used for parallel processing, when main CPU has something else to do. Example is digital signature RSASSA-PKCS1-V1_5-VERIFY((n,e),M,S) algorithm, where background hashing of M can be started, then CPU can compute S^e mod n (in parallel with background hashing) and once the digest becomes available, CPU can proceed to comparison of EM with EM'.
base | SHA peripheral base address. | |
[out] | ctx | Hash context. |
callback | Callback function. | |
userData | User data (to be passed as an argument to callback function, once callback is invoked from isr). |
status_t SHA_UpdateNonBlocking | ( | SHA_Type * | base, |
sha_ctx_t * | ctx, | ||
const uint8_t * | input, | ||
size_t | inputSize | ||
) |
Configures the SHA to compute new running hash as AHB master and returns immediately. SHA AHB Master mode supports only aligned input
address and can be called only once per continuous block of data. Every call to this function must be preceded with SHA_Init() and finished with _SHA_Finish(). Once callback function is invoked by SHA isr, it should set a flag for the main application to finalize the hashing (padding) and to read out the final digest by calling SHA_Finish().
base | SHA peripheral base address |
ctx | Specifies callback. Last incomplete 512-bit block of the input is copied into clear buffer for padding. |
input | 32-bit word aligned pointer to Input data. |
inputSize | Size of input data in bytes (must be word aligned) |
void SHA_ClkInit | ( | SHA_Type * | base | ) |
Start SHA clock
base | SHA peripheral base address |
void SHA_ClkDeinit | ( | SHA_Type * | base | ) |
Stop SHA clock
base | SHA peripheral base address |