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

SHA-256 (Secure Hash Algorithm, 256 bit), FIPS 180-4, in portable C. More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  fw_sha256_t

Macros

#define FW_SHA256_BYTES   32u

Functions

void fw_sha256_init (fw_sha256_t *s)
void fw_sha256_add (fw_sha256_t *s, const void *data, size_t n)
void fw_sha256_done (fw_sha256_t *s, uint8_t out[FW_SHA256_BYTES])
void fw_sha256 (const void *data, size_t n, uint8_t out[FW_SHA256_BYTES])

Detailed Description

SHA-256 (Secure Hash Algorithm, 256 bit), FIPS 180-4, in portable C.

The panel's application image carries the SHA-256 of everything before it in its last 32 bytes; the update checks it before the first erase. Written here rather than taken from mbedTLS so the check is the same code on the host and on the panel, and the host suite can feed it the cases a card produces. Speed is not the point: a 1.2MB image is hashed once per update.

Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).

SPDX-License-Identifier: MIT

Function Documentation

◆ fw_sha256()

void fw_sha256 ( const void * data,
size_t n,
uint8_t out[FW_SHA256_BYTES] )

The digest of n bytes at data in one call.