|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Layer: L5 Session · Build flags: none (uses the always-compiled SSH crypto primitives)
This is not a server - it is a power-on self-test. It runs the SSH stack's streaming SHA-256, HMAC-SHA-256, and AES-256-CTR primitives against published known-answer vectors and prints PASS/FAIL over Serial. On the ESP32 those primitives route through mbedTLS and the hardware accelerator, so this confirms the device's hardware crypto path actually matches the specifications. It runs on the host too (native tests use the same vectors), which is why verifying expected vectors against real tools matters.
Known-answer testing (KAT). Each block sets up an input with a known output from an authoritative source, runs the primitive, and compares bytes:
SHA-256("abc") - FIPS 180-4"Hi There", key = 0x0b * 20)Streaming is exercised on purpose. The SHA test feeds the message in two chunks ("a" then "bc") so the incremental init/update/final path is covered, not just a one-shot hash:
Keys are wiped. The stateless AES-256-CTR primitive rebuilds its key schedule in the shared crypto scratch (crypto_work) and wipes it after each call - the same hygiene the SSH server uses for session keys, with no key material left on the stack or in BSS.
This is the test to run after enabling or changing the hardware crypto paths: if it prints ALL TESTS PASSED, the primitives are byte-correct on your silicon.
No feature flags needed:
Flash, open Serial at 115200, and expect ALL TESTS PASSED.
The complete sketch (SSHCryptoSelfTest.ino), reproduced verbatim with added explanatory comments: