kyle 7755be49e9 Fix SHA-256 padding bug for messages of length 63 mod 64
pad_message wrote 0x00 into the last byte of the current block and
deferred the 0x80 pad byte to the next block when mbi == 63, producing
incorrect digests for every message whose length is 63 mod 64 (and
correspondingly wrong HMAC tags). Always write the pad byte in the
current block first, then flush an extra block only when the 8-byte
length field no longer fits.

Adds regression tests for SHA-256 boundary lengths 55/56/63/64/65 and
HMAC with a 63-byte message. Bumps to 1.0.4 for crates.io publication.

Ref: docs/LAGUNA-AUDIT.md
2026-09-17 12:25:23 -07:00
2025-12-29 01:43:50 -07:00

emsha: embedded secure hashing

This library is an HMAC-SHA-256 Rust library designed for embedded systems. It is built following the JPL Power of Ten rules. It was written in response to a need for a standalone HMAC-SHA-256 package that could run on several platforms, including several memory- constrained embedded platforms. It works without using the Rust standard environment.

I had previously written a C++ version; porting it to Rust seemed a natural way to keep trying to learn the language.

Note: it requires the 2024 edition of Rust due to its use of core::error::Error.

S
Description
embedded secure hashing
Readme
84 KiB
Languages
Rust 100%