SHA256#
SHA-256 Cryptography Library.
This file includes an alternative implementation of the standard mbed TLS SHA using hardware accelerator incorporated in MCU devices from Silicon Labs.
Modules#
Enumerations#
Functions#
Initialize SHA-256 context.
Set up SHA-256 context.
SHA-256 process buffer.
SHA-256 final digest.
Process (a) block(s) of data to be hashed.
Process an arbitrary number of bytes to be hashed.
Process an arbitrary number of bytes to be hashed.
Enumeration Documentation#
SHA_Type_t#
SHA_Type_t
Type variable for SHA-256 Cryptography.
Enumerator | |
---|---|
SHA256 | SHA-256 type. |
44
of file platform/bootloader/security/sha/btl_sha256.h
Function Documentation#
btl_sha256_init#
void btl_sha256_init (btl_sha256_context * ctx)
Initialize SHA-256 context.
N/A | ctx | SHA-256 context to be initialized |
55
of file platform/bootloader/security/sha/btl_sha256.h
btl_sha256_starts_ret#
int btl_sha256_starts_ret (btl_sha256_context * ctx, int is224)
Set up SHA-256 context.
N/A | ctx | context to be initialized |
N/A | is224 | 0 = use SHA256, 1 = use SHA224 |
Returns
0
if successful
66
of file platform/bootloader/security/sha/btl_sha256.h
btl_sha256_update_ret#
int btl_sha256_update_ret (btl_sha256_context * ctx, const unsigned char * input, size_t ilen)
SHA-256 process buffer.
N/A | ctx | SHA-256 context |
N/A | input | buffer holding the data |
N/A | ilen | length of the input data |
Returns
0
if successful
78
of file platform/bootloader/security/sha/btl_sha256.h
btl_sha256_finish_ret#
int btl_sha256_finish_ret (btl_sha256_context * ctx, unsigned char output)
SHA-256 final digest.
N/A | ctx | SHA-256 context |
N/A | output | SHA-224/256 checksum result |
Returns
0
if successful
89
of file platform/bootloader/security/sha/btl_sha256.h
sha_x_process#
int sha_x_process (SHA_Type_t algo, uint8_t * state_in, const unsigned char * blockdata, uint8_t * state_out, uint32_t num_blocks)
Process (a) block(s) of data to be hashed.
N/A | algo | Which hashing algorithm to use |
[in] | state_in | Previous state of the hashing algorithm |
[in] | blockdata | Pointer to the block(s) of data |
[out] | state_out | Pointer to block of memory to store state |
N/A | num_blocks | Number of SHA blocks in data block |
Note
Watch the blocksize! Blocks are 64 bytes for SHA-1 through SHA-256, and 128 bytes for SHA-384 through SHA-512.
Watch the state size! State size is half the block size.
Returns
Zero on success. Negative error code on failure.
105
of file platform/bootloader/security/sha/btl_sha256.h
sha_x_update#
int sha_x_update (SHA_Type_t algo, const unsigned char * data, size_t data_len, uint8_t * state, unsigned char * buffer, uint32_t * counter)
Process an arbitrary number of bytes to be hashed.
N/A | algo | Which hashing algorithm to use |
[inout] | data | Pointer to the hashing algorithm's state buffer |
[in] | data_len | Pointer to the data to add to the hash |
[inout] | state | Pointer to a block buffer to retrieve/store a partial block in between calls to this function. Needs to have a size equal to the block size. |
[inout] | buffer | Counter variable keeping track of the amount of bytes hashed, to later be used for hash finalization. For first use, initialize with zeroes. |
[in] | counter | Length to data to add to hash |
Note
Watch the blocksize! Blocks are 64 bytes for SHA-1 through SHA-256, and 128 bytes for SHA-384 through SHA-512.
Watch the state size! State size is half the block size.
Watch the counter size! Counter is 64 bytes for SHA-1 through SHA-256, and 128 bytes for SHA-384 through SHA-512.
Returns
Zero on success. Negative error code on failure.
132
of file platform/bootloader/security/sha/btl_sha256.h
sha_x_finish#
int sha_x_finish (SHA_Type_t algo, uint8_t * state, uint8_t * buffer, uint32_t * counter, uint8_t * output)
Process an arbitrary number of bytes to be hashed.
N/A | algo | Which hashing algorithm to use |
[in] | state | Pointer to the hashing algorithm's state buffer |
[in] | buffer | Pointer to a block buffer to retrieve/store a partial block in between calls to this function. Needs to have a size equal to the block size. |
[inout] | counter | Counter variable keeping track of the amount of bytes hashed, to later be used for hash finalization. For first use, initialize with zeroes. |
[out] | output | Pointer to the destination of the hash. |
Note
Watch the blocksize! Blocks are 64 bytes for SHA-1 through SHA-256, and 128 bytes for SHA-384 through SHA-512.
Watch the state size! State size is half the block size.
Watch the counter size! Counter is 64 bytes for SHA-1 through SHA-256, and 128 bytes for SHA-384 through SHA-512.
Returns
Zero on success. Negative error code on failure.
159
of file platform/bootloader/security/sha/btl_sha256.h