ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
sntrup761.cpp File Reference

Streamlined NTRU Prime sntrup761 - full KEM: KeyGen, Encaps, Decaps (see sntrup761.h). More...

Go to the source code of this file.

Detailed Description

Streamlined NTRU Prime sntrup761 - full KEM: KeyGen, Encaps, Decaps (see sntrup761.h).

Ported from OpenSSH's embedded sntrup761 reference (public domain; D. J. Bernstein, C. Chuengsatiansup, T. Lange, C. van Vredendaal). We target a known set of platforms (the ESP32 variants + native), so the constant-time integer helpers are written directly with our int widths instead of the reference's portable crypto_int layer. The generic Encode/Decode take a scratch arena rather than the reference's variable-length recursion arrays, so the stack stays bounded. SHA-512 and the RNG come from the SSH crypto seams; byte encodings and the hashing (prefix bytes 1/2/3/4) match OpenSSH exactly, so a ciphertext produced here decapsulates on a real peer and a public key generated here encapsulates on one - verified byte-exact against the reference both ways.

Everything NOT called out above tracks upstream line for line on purpose - crypto_sort_int32 is upstream's own vendored djbsort (supercop crypto_sort/int32/portable4), and R3_recip / Rq_recip3 are unchanged. The way this file gets re-audited when a new sntrup revision lands is to diff it against upstream, so inherited lines keep upstream's shape even where our style rules differ (multi-declarator locals, the sort's goto, its nesting depth). sonar-project.properties carries the matching rule carve-outs, scoped to this file; the project-written wrappers below follow house style normally.

Definition in file sntrup761.cpp.