|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
SHA-256 (Secure Hash Algorithm, 256-bit digest), as FIPS (Federal Information Processing Standard) 180-4 section 6.2 states it. More...
#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | link_sha256_t |
| The state of a SHA-256 computation in progress. More... | |
Macros | |
| #define | LINK_SHA256_BYTES 32u |
| Bytes in a digest. | |
Functions | |
| void | link_sha256_init (link_sha256_t *s) |
| Start a computation: set the initial hash value and clear the state. | |
| void | link_sha256_update (link_sha256_t *s, const void *data, size_t len) |
Fold len bytes in. data may be NULL when len is 0. | |
| void | link_sha256_final (link_sha256_t *s, uint8_t out[LINK_SHA256_BYTES]) |
Pad, finish and write the 32-byte digest. s is spent afterwards. | |
| void | link_sha256 (const void *data, size_t len, uint8_t out[LINK_SHA256_BYTES]) |
The digest of len bytes in one call. | |
SHA-256 (Secure Hash Algorithm, 256-bit digest), as FIPS (Federal Information Processing Standard) 180-4 section 6.2 states it.
The IOmcu update checks an image with it at both ends: the panel over the image it sends, the IOmcu over what it wrote to flash. One routine in shared/link, so the two ends and the host suite compute the same function and the suite holds it to the standard's test vectors.
Fed in pieces of any length; the state is 108 bytes and no allocation. Portable C, no hardware unit used on either chip.
SPDX-License-Identifier: MIT
| void link_sha256 | ( | const void * | data, |
| size_t | len, | ||
| uint8_t | out[LINK_SHA256_BYTES] ) |
The digest of len bytes in one call.
| data | The bytes to digest; may be NULL when len is 0. |
| len | Number of bytes in data. |
| out | Receives the 32-byte digest. |
| void link_sha256_final | ( | link_sha256_t * | s, |
| uint8_t | out[LINK_SHA256_BYTES] ) |
Pad, finish and write the 32-byte digest. s is spent afterwards.
| s | The state, from link_sha256_init() and link_sha256_update(). |
| out | Receives the 32-byte digest. |
| void link_sha256_init | ( | link_sha256_t * | s | ) |
Start a computation: set the initial hash value and clear the state.
| s | The state to set up. NULL does nothing. |
| void link_sha256_update | ( | link_sha256_t * | s, |
| const void * | data, | ||
| size_t | len ) |
Fold len bytes in. data may be NULL when len is 0.
| s | The state, from link_sha256_init(). |
| data | The bytes to fold in; may be NULL when len is 0. |
| len | Number of bytes in data. |