From 166990670a5c996bb9cadb51bda4ed9ffbd88cc4 Mon Sep 17 00:00:00 2001 From: R Date: Fri, 4 Dec 2026 04:33:20 -0300 Subject: [PATCH] third_party: RFC 9180's test vectors (cfrg/draft-irtf-cfrg-hpke at 5f503c5) as /third_party//hpke, test data of crypto's HPKE The CFRG's test-vectors.json, Appendix A's source, pinned shallow as third_party/libs/hpke: /third_party//hpke gives a test its directory by WEBCPP_TEST_HPKE, wasmtime is given it on WASI, and a test runs again when the file changes. A build that names it without the checkout stops with the command that checks it out. The repository is an IETF Contribution under the IETF Trust's Legal Provisions (code components under the Simplified BSD License); the submodule redistributes nothing. The pin and the refusal are tested in tools/test/third_party_test.py; the guidelines' third-party table, AGENTS.md's lists and the release notes name it. --- .gitmodules | 4 ++++ AGENTS.md | 4 ++-- CODING-GUIDELINES.md | 1 + doc/releases/0.1.0.adoc | 2 ++ third_party/Jamfile | 26 ++++++++++++++++++++++++++ third_party/libs/hpke | 1 + tools/test/third_party_test.py | 27 +++++++++++++++++++++++++++ 7 files changed, 63 insertions(+), 2 deletions(-) create mode 160000 third_party/libs/hpke diff --git a/.gitmodules b/.gitmodules index e88abe7..b8dcfa6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -102,3 +102,7 @@ [submodule "libs/codecs"] path = libs/codecs url = ../codecs.git +[submodule "third_party/libs/hpke"] + path = third_party/libs/hpke + url = https://github.com/cfrg/draft-irtf-cfrg-hpke.git + shallow = true diff --git a/AGENTS.md b/AGENTS.md index 9f27c23..f2f0b13 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -114,7 +114,7 @@ webcpp/ a submodule under third_party/libs/, pinned at a commit and keeping its own licence (openssl, libdatachannel, bearssl, secp256k1, bitcoin for ctaes, xkcp, libsodium, blake3, and the test data wycheproof, bips, - JSON-Schema-Test-Suite and nativejson-benchmark), and the Jamfile that + hpke, JSON-Schema-Test-Suite and nativejson-benchmark), and the Jamfile that declares it as /webcpp/third_party// and /third_party// (guidelines chapter 10) doc/ the index page (index.adoc, Jamfile) @@ -271,7 +271,7 @@ Jamroot is its build configuration, and `libs/` is its repository. - for crypto: nothing installed, with the pinned submodules initialised: `git submodule update --init third_party/libs/bearssl third_party/libs/secp256k1 third_party/libs/bitcoin third_party/libs/wycheproof - third_party/libs/bips third_party/libs/ed25519-speccheck`, and + third_party/libs/bips third_party/libs/ed25519-speccheck third_party/libs/hpke`, and `third_party/libs/openssl` for its OpenSSL backend (below); b2 builds every backend from its sources; - for Botan (`/third_party//botan`, webcpp::hash's `backends::botan` and diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 9d81dbb..a9f6699 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -995,6 +995,7 @@ update --init third_party/libs/`; a build that needs none never looks. | `ca_certificates` | Dated Mozilla/curl CA data snapshot under `third_party/ca_certificates`, verified against its manifest and embedded by a build-generated header; updated explicitly by `tools/ca_certificates/update.py` | MPL-2.0 | | `ctaes` | `src/crypto/ctaes` of `bitcoin/bitcoin` v31.1 at `9be056a` (commit `9be056a8a72b624dae9623b2f7bded92c2a21c91`), the submodule `third_party/libs/bitcoin`, shallow; `third_party/Jamfile` compiles its `ctaes.c` alone, with webcpp::crypto's canary, on every target (`WEBCPP_CRYPTO_HAS_CTAES=1`); the tree's `src/secp256k1/` subtree is never on an include path and no glob over `third_party/libs` reaches it | MIT | | `ed25519-speccheck` | `novifinancial/ed25519-speccheck` at `65519336` (2021-02-26), shallow, test data: crypto's tests read the twelve Ed25519 edge cases of "Taming the many EdDSAs", its `cases.json`, at run time under the directory its define `WEBCPP_TEST_ED25519_SPECCHECK` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when it changes | Apache-2.0 | +| `hpke` | `cfrg/draft-irtf-cfrg-hpke` at `5f503c5` (2021-05-24), shallow, test data: crypto's tests read RFC 9180's test vectors, its `test-vectors.json` (Appendix A's source, 128 entries), at run time under the directory its define `WEBCPP_TEST_HPKE` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when it changes | IETF Trust Legal Provisions (BCP 78; code components under the Simplified BSD License) | | `json-schema-test-suite` | the JSON Schema Test Suite at `5b0ee16` (2026-09-21), test data: a test that names it reads the suite at run time from the directory its define `WEBCPP_TEST_JSON_SCHEMA_TEST_SUITE` gives, on every target (wasmtime is given it, `webcpp.data`), and runs again when a file of the suite changes | MIT | | `libdatachannel` | libdatachannel 0.24.6 at `6b1e2e620f1e37f0eafeee702eaea0043cb305fd`, with pinned libjuice, libsrtp, plog and usrsctp sources; static native archives built by upstream CMake through B2 against the same source-built OpenSSL, from a staged copy the patches of `tools/libdatachannel/patches` correct | MPL-2.0 and the nested dependencies' own licences | | `nativejson-benchmark` | Milo Yip's nativejson-benchmark at `478d572` (2022-10-28), test data: document's benchmarks (`libs/document/bench`) read its `data/canada.json`, `data/citm_catalog.json` and `data/twitter.json` at run time under the directory its define `WEBCPP_TEST_NATIVEJSON_BENCHMARK` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when one of them changes; its own submodules are never checked out | MIT | diff --git a/doc/releases/0.1.0.adoc b/doc/releases/0.1.0.adoc index 762670a..f1befb8 100644 --- a/doc/releases/0.1.0.adoc +++ b/doc/releases/0.1.0.adoc @@ -182,6 +182,8 @@ target through `/webcpp/third_party//wycheproof`. `/third_party//secp256k1`, its tables chosen by `webcpp-secp256k1-tables`. * Added bitcoin/bips to `third_party/`, whose BIP340 vectors a test reads on every target through `/third_party//bips`. +* Added RFC 9180's test vectors (cfrg/draft-irtf-cfrg-hpke) to `third_party/`, +which crypto's HPKE tests read on every target through `/third_party//hpke`. * Changed `/third_party//bips` to also serve BIP341's `bip-0341/wallet-test-vectors.json`, whose cases run again when it changes. * Changed the lint to never read third-party code under `third_party/libs/`. diff --git a/third_party/Jamfile b/third_party/Jamfile index 887f329..9c2453f 100644 --- a/third_party/Jamfile +++ b/third_party/Jamfile @@ -153,6 +153,32 @@ alias bips : : @bips-checked-out : : $(.bips-files) ; explicit bips ; +# cfrg/draft-irtf-cfrg-hpke, shallow: test data, never compiled, an IETF +# Contribution under the IETF Trust's Legal Provisions (BCP 78; code +# components under the Simplified BSD License). A test that names hpke reads +# RFC 9180's test vectors, test-vectors.json (Appendix A's source), from the +# directory WEBCPP_TEST_HPKE names, with forward slashes, the directory given +# to wasmtime on WASI (webcpp.data), and runs again when it changes. +path-constant HPKE : libs/hpke ; +.hpke = [ regex.replace $(HPKE) "\\\\" "/" ] ; +.hpke-files = [ glob libs/hpke/test-vectors.json ] ; + +rule hpke-checked-out ( properties * ) +{ + if ! [ path.exists [ path.native $(HPKE)/test-vectors.json ] ] + { + errors.user-error "third_party/libs/hpke is not checked out: it holds no" + "test-vectors.json. Check it out with `git submodule update --init" + "third_party/libs/hpke`." ; + } +} + +alias hpke : : @hpke-checked-out : : + "\"WEBCPP_TEST_HPKE=\\\"$(.hpke)\\\"\"" + [ webcpp.data $(HPKE) ] + $(.hpke-files) ; +explicit hpke ; + # novifinancial/ed25519-speccheck (Apache-2.0), shallow: test data, never # compiled. A test that names ed25519-speccheck reads the twelve Ed25519 edge # cases of "Taming the many EdDSAs", cases.json, from the directory diff --git a/third_party/libs/hpke b/third_party/libs/hpke new file mode 160000 index 0000000..5f503c5 --- /dev/null +++ b/third_party/libs/hpke @@ -0,0 +1 @@ +Subproject commit 5f503c564da00b0687b3de75f1dfbdfc4079ad31 diff --git a/tools/test/third_party_test.py b/tools/test/third_party_test.py index 5d189ee..5f15c48 100755 --- a/tools/test/third_party_test.py +++ b/tools/test/third_party_test.py @@ -109,6 +109,12 @@ ED25519_SPECCHECK = 'third_party/libs/ed25519-speccheck' +HPKE = 'third_party/libs/hpke' + +# The commit cfrg/draft-irtf-cfrg-hpke is pinned at: RFC 9180's test vectors, its +# test-vectors.json (libs/crypto/test/support/hpke_vectors.hpp). +HPKE_COMMIT = '5f503c564da00b0687b3de75f1dfbdfc4079ad31' + # The commit novifinancial/ed25519-speccheck is pinned at: the twelve Ed25519 edge cases of # "Taming the many EdDSAs", its cases.json (libs/crypto/test/ed25519_speccheck_test.cpp). ED25519_SPECCHECK_COMMIT = '65519336fda78a3d016e947df6d82848aca0c9da' @@ -363,6 +369,12 @@ def test_ed25519_speccheck_is_pinned(_: Path) -> None: assert listed.stdout.split()[:2] == ['160000', ED25519_SPECCHECK_COMMIT], listed.stdout +def test_hpke_is_pinned(_: Path) -> None: + listed = subprocess.run(['git', '-C', str(harness.ROOT), 'ls-files', '-s', HPKE], + capture_output=True, text=True, check=True) + assert listed.stdout.split()[:2] == ['160000', HPKE_COMMIT], listed.stdout + + def test_bips_target_files(_: Path) -> None: jamfile = (harness.ROOT / 'third_party' / 'Jamfile').read_text() found = re.search(r'^\.bips-files = \[ glob ([^\]]*)\] ;', jamfile, re.MULTILINE) @@ -510,6 +522,19 @@ def test_ed25519_speccheck_not_checked_out_is_refused(root: Path) -> None: harness.expect(harness.run_b2(root, 'libs/demo/test//pass'), True) +def test_hpke_not_checked_out_is_refused(root: Path) -> None: + harness.third_party_of_its_own(root, 'hpke', checked_out=False) + harness.add_library(root, 'hpke_reader', ( + 'import webcpp ;\n\nwebcpp.run reads_vectors : reads_vectors.cpp\n' + ' : /webcpp/third_party//hpke ;\n'), + {'reads_vectors.cpp': 'int main() { return 0; }\n'}) + result = harness.run_b2(root, 'libs/hpke_reader/test') + harness.expect(result, False, 'third_party/libs/hpke is not checked out', + 'git submodule update --init third_party/libs/hpke') + # A build that needs no vectors never looks for them. + harness.expect(harness.run_b2(root, 'libs/demo/test//pass'), True) + + def test_ctaes_not_checked_out_is_refused(root: Path) -> None: harness.copy_integration_libraries(root, 'config', 'crypto') harness.third_party_of_its_own(root, 'bitcoin', checked_out=False) @@ -1186,8 +1211,10 @@ def test_botan_test_program_runs(root: Path) -> None: test_a_changed_suite_file_runs_the_test_again, test_a_suite_not_checked_out_is_refused, test_ed25519_speccheck_not_checked_out_is_refused, + test_hpke_not_checked_out_is_refused, test_bips_is_pinned, test_ed25519_speccheck_is_pinned, + test_hpke_is_pinned, test_bips_target_files, test_bip352_vectors_match_libsecp256k1, test_bearssl_is_pinned,