feat(digest): constant-time comparison #149
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/96-constant-time-compare"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #96
Digest.equalsConstantTime(other)is the primary API (owner decision recorded on the issue);constantTimeEqual(a: Bytes, b: Bytes)is a thin wrapper over it. Ordinary TorbScript instd/digest, no native, no seed change.false(lengths are not secret); otherwise every byte pair is read and differences are combined by XOR/OR with no early exit.std/digest/tests/constant-time.test.trb: equal, first/last/middle byte, lowest bit, unequal length (both orders), empty/empty, empty/non-empty, each checked against==; plus anHmacSha256result compared without conversion.docs/standard-library/digest.mddocuments the method and wrapper withtrb checkexamples, states what is promised (no data-dependent early exit in the source) and not (no guarantee against compiler or CPU timing effects);skills/and the std index regenerated.docs/design/WEB.mdF7 row marked done for the comparison part.Gates:
sh tools/gates.sh aran in a gcc container (no toolchain on the worker host). The first run was red on five gates, all caused by this change and fixed in the commit:format --checkof the new test, the stale std index (docs index,docs check), staleskills/(docs skill), and an example usingSha256.of(...)with parentheses (doc --check). After the fixesformat --check .,docs index --check,docs skill --check,doc --check --no-run stdandtorb test std/digest(43 passed) are green; the remaining gates were green in the first run. Forge CI is the full confirmation.Approved (head
cd9c550, CI combined status success).constant-time.test.trbcovers equal, first/middle/last byte, lowest bit, unequal length (both orders), empty cases, each checked against==, plus an HMAC case. CI green on this head.skills/and the WEB.md F7 row are updated; the docs/skill/index gates are green.std/digest.Non-blocking: none.