Use fixed-size spans for XEd25519 inputs - #114
Conversation
|
Good thing to catch, but this isn't the right way to solve this: rather the xed25519 code should be updated to take fixed size span arguments (e.g. This likely needs some fixing at some call sites to make it work properly, for instance using |
|
Looking at this 👍 |
7e823e0 to
89c6acb
Compare
|
updated this to use fixed-size spans for the binary API, with the string overloads validating before converting to them i also updated the blinding and group-key call sites, and reran the full release test suite thanks for pointing me in the right direction |
jagerman
left a comment
There was a problem hiding this comment.
Looks good to me, thanks for the PR!
Forward-port of #114 (dev commit 89c6acb) onto pfs. Most of #114 is already here: the byte refactor (7662405) had independently given the binary API fixed-extent spans, so sign/verify/pubkey already reject wrong sizes at compile time, the string overloads already validate, and the blinding / group-keys call sites already pass sized views. Two things were missing. First, pfs's verify(string_view) returned false for a wrong-sized signature or pubkey where #114 throws std::invalid_argument, so it conflated "you passed a malformed argument" with "this signature does not verify". Align with dev: letting pfs keep return-false would silently revert #114's behaviour when pfs eventually lands on dev. Nothing in the tree calls the string overloads -- every call site uses the span overloads -- and the return-false came in incidentally with 7662405 rather than as a considered choice. Second, port #114's regression test for the rejected sizes. The three string overloads all validated a length and then narrowed to a fixed span; that is now one require_bytes<N> helper, which also gives the arguments #114's exception wording.
Records dev up to 2b27d27 as merged, keeping pfs's tree unchanged (-s ours). All four PRs in the range are now applied to pfs: - #116 (this-is-not-c) via #115 this-is-not-c-pfs - #118 (renewal-target-no-proof-fetch) via #119 renewal-target-no-proof-fetch-pfs - #120 (macOS C response holders) forward-ported in e682e6b - #114 (fixed-size XEd25519 spans) forward-ported in b03709d Verified for the two that were already applied: #119's user_profile.cpp change is line-identical to #118's, and for #116/#115 the `errs` error-vector is gone from both branches with identical parse_error usage.
summary
the binary C++ XEd25519 API now uses fixed-size spans for keys and signatures, making invalid input sizes a compile-time error
the dynamic string overloads validate sizes before converting to those fixed spans, and the affected blinding and group-key call sites now pass explicitly sized views or fixed arrays
tests
./utils/format.sh verifycmake --build build-clean --target testAll --parallel 2./build-clean/tests/testAll "[xed25519]"./build-clean/tests/testAll "*blinded*"./build-clean/tests/testAll "Group Keys*"./build-clean/tests/testAll