This section describes the programming interface of the DCP HASH driver.
|
status_t | DCP_HASH_Init (DCP_Type *base, dcp_handle_t *handle, dcp_hash_ctx_t *ctx, dcp_hash_algo_t algo) |
| Initialize HASH context. More...
|
|
status_t | DCP_HASH_Update (DCP_Type *base, dcp_hash_ctx_t *ctx, const uint8_t *input, size_t inputSize) |
| Add data to current HASH. More...
|
|
status_t | DCP_HASH_Finish (DCP_Type *base, dcp_hash_ctx_t *ctx, uint8_t *output, size_t *outputSize) |
| Finalize hashing. More...
|
|
status_t | DCP_HASH (DCP_Type *base, dcp_handle_t *handle, dcp_hash_algo_t algo, const uint8_t *input, size_t inputSize, uint8_t *output, size_t *outputSize) |
| Create HASH on given data. More...
|
|
#define DCP_SHA_BLOCK_SIZE 128 |
internal buffer block size
#define DCP_HASH_CTX_SIZE 58 |
Enumerator |
---|
kDCP_Sha1 |
SHA_1.
|
kDCP_Sha256 |
SHA_256.
|
kDCP_Crc32 |
CRC_32.
|
This function initializes the HASH.
- Parameters
-
| base | DCP peripheral base address |
| handle | Specifies the DCP channel used for hashing. |
[out] | ctx | Output hash context |
| algo | Underlaying algorithm to use for hash computation. |
- Returns
- Status of initialization
status_t DCP_HASH_Update |
( |
DCP_Type * |
base, |
|
|
dcp_hash_ctx_t * |
ctx, |
|
|
const uint8_t * |
input, |
|
|
size_t |
inputSize |
|
) |
| |
Add data to current HASH. This can be called repeatedly with an arbitrary amount of data to be hashed. The functions blocks. If it returns kStatus_Success, the running hash has been updated (DCP has processed the input data), so the memory at input pointer can be released back to system. The DCP context buffer is updated with the running hash and with all necessary information to support possible context switch.
- Parameters
-
| base | DCP peripheral base address |
[in,out] | ctx | HASH context |
| input | Input data |
| inputSize | Size of input data in bytes |
- Returns
- Status of the hash update operation
status_t DCP_HASH_Finish |
( |
DCP_Type * |
base, |
|
|
dcp_hash_ctx_t * |
ctx, |
|
|
uint8_t * |
output, |
|
|
size_t * |
outputSize |
|
) |
| |
Outputs the final hash (computed by DCP_HASH_Update()) and erases the context.
- Parameters
-
[in,out] | ctx | Input hash context |
[out] | output | Output hash data |
[in,out] | outputSize | Optional parameter (can be passed as NULL). On function entry, it specifies the size of output[] buffer. On function return, it stores the number of updated output bytes. |
- Returns
- Status of the hash finish operation
status_t DCP_HASH |
( |
DCP_Type * |
base, |
|
|
dcp_handle_t * |
handle, |
|
|
dcp_hash_algo_t |
algo, |
|
|
const uint8_t * |
input, |
|
|
size_t |
inputSize, |
|
|
uint8_t * |
output, |
|
|
size_t * |
outputSize |
|
) |
| |
Perform the full SHA or CRC32 in one function call. The function is blocking.
- Parameters
-
| base | DCP peripheral base address |
| handle | Handle used for the request. |
| algo | Underlaying algorithm to use for hash computation. |
| input | Input data |
| inputSize | Size of input data in bytes |
[out] | output | Output hash data |
[out] | outputSize | Output parameter storing the size of the output hash in bytes |
- Returns
- Status of the one call hash operation.