|
| | PROTOCORE_NS_LAYOUT (Sha256Ns, init, update, final, hash) |
| embed_bool | protocore_sha256_init (uint8_t *work) |
| | Start a digest.
|
| embed_bool | protocore_sha256_update (uint8_t *work, const uint8_t *data, size_t len) |
| | Feed the running digest a chunk.
|
| embed_bool | protocore_sha256_final (uint8_t *work, uint8_t *out) |
| | Pad, compress the last block, write the 32 bytes out.
|
| embed_bool | protocore_sha256_hash (uint8_t *work, const uint8_t *data, size_t len, uint8_t *out) |
| | Init, update and final in one call, for a message already whole.
|
SHA-256 (FIPS 180-4) - streaming and one-shot digest.
The shared SHA-256 primitive for the whole library (SSH per-packet HMAC and KEX exchange-hash, TLS 1.3 / QUIC / DTLS key schedules, SNMPv3, JWT, CSRF, SMB 2.x message signing). The entries below are one surface over both arms: a part with a hashing peripheral compresses on it, a part without runs the FIPS 180-4 rounds. Mirrors the sha512 structure.
Sha256Ns::final leaves the running digest where it was: the padded blocks compress into a copy of the state, so the hash keeps taking data afterwards. That is what lets TLS 1.3 read Transcript-Hash at every stage the key schedule asks for without snapshotting anything.
work is PROTOCORE_SHA256_BORROW secure bytes the CALLER took, at an address it knows. It is not held past the call, so nothing here aliases it. The caller releases it, and the pool wipes on release; this module neither takes it, holds it, releases it, nor wipes it. The borrow IS the digest, so two running hashes are two borrows and never collide.
- Author
- Douglas Quigg (dstroy0)
- Date
- 2026
Definition in file sha256.h.