rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
link_sha256.h File Reference

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

 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.

Detailed Description

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

Function Documentation

◆ link_sha256()

void link_sha256 ( const void * data,
size_t len,
uint8_t out[LINK_SHA256_BYTES] )

The digest of len bytes in one call.

Parameters
dataThe bytes to digest; may be NULL when len is 0.
lenNumber of bytes in data.
outReceives the 32-byte digest.

◆ link_sha256_final()

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.

Parameters
sThe state, from link_sha256_init() and link_sha256_update().
outReceives the 32-byte digest.

◆ link_sha256_init()

void link_sha256_init ( link_sha256_t * s)

Start a computation: set the initial hash value and clear the state.

Parameters
sThe state to set up. NULL does nothing.

◆ link_sha256_update()

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.

Parameters
sThe state, from link_sha256_init().
dataThe bytes to fold in; may be NULL when len is 0.
lenNumber of bytes in data.