SHA-256 Hardware Accelerated implementation. More...
Data Structures | |
| struct | pico_sha256_state |
| SHA-256 state used by the API. More... | |
Typedefs | |
| typedef struct pico_sha256_state | pico_sha256_state_t |
| SHA-256 state used by the API. | |
Functions | |
| void | pico_sha256_cleanup (pico_sha256_state_t *state) |
| Release the internal lock on the SHA-256 hardware. | |
| int | pico_sha256_try_start (pico_sha256_state_t *state, enum sha256_endianness endianness, bool use_dma) |
| Start a SHA-256 calculation returning immediately with an error if the SHA-256 hardware is not available. | |
| int | pico_sha256_start_blocking_until (pico_sha256_state_t *state, enum sha256_endianness endianness, bool use_dma, absolute_time_t until) |
| Start a SHA-256 calculation waiting for a defined period for the SHA-256 hardware to be available. | |
| static int | pico_sha256_start_blocking (pico_sha256_state_t *state, enum sha256_endianness endianness, bool use_dma) |
| Start a SHA-256 calculation, blocking forever waiting until the SHA-256 hardware is available. | |
| void | pico_sha256_update (pico_sha256_state_t *state, const uint8_t *data, size_t data_size_bytes) |
| Add byte data to be SHA-256 calculation. | |
| void | pico_sha256_update_blocking (pico_sha256_state_t *state, const uint8_t *data, size_t data_size_bytes) |
| Add byte data to be SHA-256 calculation. | |
| void | pico_sha256_finish (pico_sha256_state_t *state, sha256_result_t *out) |
| Finish the SHA-256 calculation and return the result. | |
SHA-256 Hardware Accelerated implementation.
RP2350 is equipped with a hardware accelerated implementation of the SHA-256 hash algorithm. This should be much quicker than performing a SHA-256 checksum in software.
| void pico_sha256_cleanup | ( | pico_sha256_state_t * | state | ) |
Release the internal lock on the SHA-256 hardware.
Release the internal lock on the SHA-256 hardware. Does nothing if the internal lock was not claimed.
| state | A pointer to a pico_sha256_state_t instance |
| void pico_sha256_finish | ( | pico_sha256_state_t * | state, |
| sha256_result_t * | out ) |
Finish the SHA-256 calculation and return the result.
Ends the SHA-256 calculation freeing the hardware for use by another caller. You must have called pico_sha256_try_start already.
| state | A pointer to a pico_sha256_state_t instance |
| out | The SHA-256 checksum |
|
inlinestatic |
Start a SHA-256 calculation, blocking forever waiting until the SHA-256 hardware is available.
Initialises the hardware and state ready to start a new SHA-256 calculation. Only one instance can be started at any time.
| state | A pointer to a pico_sha256_state_t instance |
| endianness | SHA256_BIG_ENDIAN or SHA256_LITTLE_ENDIAN for data in and data out |
| use_dma | Set to true to use DMA internally to copy data to hardware. This is quicker at the expense of hardware DMA resources. |
| int pico_sha256_start_blocking_until | ( | pico_sha256_state_t * | state, |
| enum sha256_endianness | endianness, | ||
| bool | use_dma, | ||
| absolute_time_t | until ) |
Start a SHA-256 calculation waiting for a defined period for the SHA-256 hardware to be available.
Initialises the hardware and state ready to start a new SHA-256 calculation. Only one instance can be started at any time.
| state | A pointer to a pico_sha256_state_t instance |
| endianness | SHA256_BIG_ENDIAN or SHA256_LITTLE_ENDIAN for data in and data out |
| use_dma | Set to true to use DMA internally to copy data to hardware. This is quicker at the expense of hardware DMA resources. |
| until | How long to wait for the SHA hardware to be available |
| int pico_sha256_try_start | ( | pico_sha256_state_t * | state, |
| enum sha256_endianness | endianness, | ||
| bool | use_dma ) |
Start a SHA-256 calculation returning immediately with an error if the SHA-256 hardware is not available.
Initialises the hardware and state ready to start a new SHA-256 calculation. Only one instance can be started at any time.
| state | A pointer to a pico_sha256_state_t instance |
| endianness | SHA256_BIG_ENDIAN or SHA256_LITTLE_ENDIAN for data in and data out |
| use_dma | Set to true to use DMA internally to copy data to hardware. This is quicker at the expense of hardware DMA resources. |
| void pico_sha256_update | ( | pico_sha256_state_t * | state, |
| const uint8_t * | data, | ||
| size_t | data_size_bytes ) |
Add byte data to be SHA-256 calculation.
Add byte data to be SHA-256 calculation You may call this as many times as required to add all the data needed. You must have called pico_sha256_try_start (or equivalent) already.
| state | A pointer to a pico_sha256_state_t instance |
| data | Pointer to the data to be added to the calculation |
| data_size_bytes | Amount of data to add |
| void pico_sha256_update_blocking | ( | pico_sha256_state_t * | state, |
| const uint8_t * | data, | ||
| size_t | data_size_bytes ) |
Add byte data to be SHA-256 calculation.
Add byte data to be SHA-256 calculation You may call this as many times as required to add all the data needed. You must have called pico_sha256_try_start already.
| state | A pointer to a pico_sha256_state_t instance |
| data | Pointer to the data to be added to the calculation |
| data_size_bytes | Amount of data to add |