Repository navigation
codecs: the genesis of webcpp::codecs - #1
Merged
Merged
Conversation
added 30 commits
November 26, 2026 06:42
… test rules codecs-run and codecs-compile
… builds as a list
…the buffer forms, over a format of the tests' own
…ange, two-word names, the saturation refusal tested, a stable refusal type
…de into fixed byte types and value codecs
…e input refusal names the input, the typed decode's noexcept follows the value codec, saturating bounds of static inputs, the text buffer form's rows
…na and the throwing allocator
…and the throwing allocator, a failed conversion puts an appending token back, tokens hold what was written, a constant capacity, plain refusal messages
…or, every buffer wiped before it is returned
…ove assignments that may copy
…e standard containers take it, a doc reference without a colon
…uctor not explicit (LWG 2193), swap as std::allocator_traits says, the test allocators' moves keep their source, the wipes of the pmr string and of the secret bytes' move checked
…tor that has one, noexcept by the trait as the standard containers'
…token or the requested type, under secure's guard, every temporary wiped
…ation fails, a scratch in place or of its allocator assigned on success alone and wiped of what the target does not get
…tion the check reads, one-sentence briefs of swap
…e, the allocators' moves suppressed by the check's name, a guard made by parentheses
…un on every target
…other type stops the build instead of passing to the public arithmetic, a message case; secret_operation_v's Token is void for none
added 26 commits
November 30, 2026 02:04
… checked before they are read, one main tag per page listing
…ads a result with exceptions off
…fault), and one rule for the sizes of a refused input A codec may have encode_fault(format, bytes), detected and checked as configuration_fault is; the core asks it in every encode form after the configuration's fault and before its size check and any prepare, so that a token is never prepared for an encode that then fails and the error does not depend on the input's size. bech32 implements it (no human-readable part, a text past MaximumLength, a word above 31 by masks declassified once), the armor too (no label), and over forwards its inner link's and its outer link's on an intermediate in place. Every size without an error channel keeps one rule: SIZE_MAX for an input refused for its size, 0 for one refused for a fault of the configuration or of the encode (codecs::encoded_size, a codec's encoded_size, bech32's past MaximumLength, format_encoder::output_size).
…o and abandon, noexcept when they cannot throw over's constructor and copy and move assignments allocate nothing: noexcept exactly when the links' and the allocator's copies, moves and assignments are (the allocator made again where it has no assignment). append_to's and assign_to's shrink_to, and append_to's abandon, only shrink a string or a vector, which cannot throw: noexcept. noexcept_test pins both.
… fault from their first call buffered and each ask the one-shot transformer they hold for the fault of its configuration when they are made (detail::transformer_configuration_probe, a format's encoder and decoder giving their format's), and report it from their first call, whatever it is, and from every call after, also after reset, as the transformer itself does. buffered_test and each_test pin it.
…end a secret payload to a secret type armor_t holds its label privately, as basic_bech32 holds its part, and label() gives it back (empty for none or an overflowed one); the format stays trivially copyable and constexpr. armor_parts and bech32_parts are public types, never wiped: their Doc Comments send a PRIVATE KEY or an nsec to a secret typed decode with the label or the part in the format, or to the secret stream decoder's label() or human_readable_part(). The tests pin the accessor and both secret paths.
The Doc Comments of format_encoder and format_decoder, and the streams chapter, state the precondition a chain's stream adds: it is a pipe of its links' streams, not moved between a receive that reports output_pending and the next needs_input or finished, unless it has reported an error.
base32's, base64's and the armor's one-shot decode wipe their reader's few bytes always, not because a one-shot form is not told whether it is secret (R7's overloads tell it), but because their arithmetic does not change and a wipe of a few bytes is cheaper than a tagged overload; base58, with a large scratch, wipes through its secret overloads.
refuse_hold_above_maximum's message was bech32's; it now names the format's maximum_hold, as the core states every rule, and bech32's own class-level static_assert keeps its wording. The message test reads the new text.
percent's decode is boost::urls::decode, which promises nothing of overlapping buffers: its page and the overview's table say input and output must not overlap, as base58's, bech32's and the armor's do, and percent_test no longer pins an in-place decode as a promise.
…itive of its own codecs defines secret_text, secret_bytes and the heap secret types, built on secure's: what it keeps none of is a guard, a secret value type (secure::secret<N>), a wipe primitive (secure::erase_secret) or a constant-time primitive.
…twin tests
Every header writes (std::min)(...), (std::max)(...), (std::max)({...}) and
(std::numeric_limits<T>::max)(), as CODING-GUIDELINES.md's rule says, so
that <windows.h>'s min and max macros, defined before it without NOMINMAX,
break none of them. windows_h_before and windows_h_after include every
public header beside a bare <windows.h> and use the formats, as crypto's
twins do: native, with their teeth on the MSVC lanes.
with_carriage_returns in armor_files.hpp; decodes_to, without_padding, expect_tail_unchanged, expect_in_place (given the reference encoder's text) and expect_empty_text_decodes in the new decode_checks.hpp; reset_guards in timing_seam.hpp; dit_applies in timing_dit.hpp; wipes_of_size, wiped_of_size and wiped_elsewhere in wipe_recorder.hpp; five_frames in toy_media.hpp; letters_of and letters_of_letters in letters.hpp; key32 in the new key32.hpp; all_zero is allocators.hpp's reads_zero; write_be16 and read_be16 in be16.hpp for every sixteen-bit value codec. The one-shot verdict of every chunking, public and secret, is chunkings.hpp's expect_the_one_shot_verdict, with a hook for the part a decoder gives, and it now runs the secret decoder over valid texts too; check_hex_streams calls stream_in_random_chunks.
1000 random inputs of 0 to 24 bytes, in lower and upper case: the first 40 over every chunking, the rest over 8 random chunkings each, through the public and the secret encoder and decoder; the header comment says what the test does.
…_fuzz runs the path in place target.hpp's check_text streams each text through the format's secret decoder too, split as the public one is, and requires the same bytes or the same error; base58's targets through buffered(decoder(format, secret_operation)) in place. over_fuzz also gives the text's first 32 characters as a std::span of a static size, whose intermediate is in place: they decode, and as bytes encode, as the same characters of a dynamic size do, and take no block of the arena.
…mat lines even base64_stream_test's secret decoder now also decodes a tail with every other character at fault, as its comment says; msan_report.mjs's header no longer points at its own last sentence; own_format.cpp says why constant_time is [[maybe_unused]] (the program runs no secret operation and no transformer, its readers); the changelog's format lines each say whether the format is constant time, streams natively and decodes in place.
SIZE_MAX is written once, detail::size_maximum in detail/core/size_maximum.hpp, as (std::numeric_limits<std::size_t>::max)() with the one NOLINT that says why the parentheses are there (readability-redundant-parentheses), instead of 35 times; over's probe names its intermediate's type so that its initializer fits one line; the wipe comments of base32, base64 and the armor formatted.
size_maximum's NOLINT on one line; over's probe reads constants, not calls whose noexcept operands name an allocating function (clang-tidy's exception-escape followed them); the new tests inside their anonymous namespaces, the moved-from streams' checks marked as Review Focus 5's, encode_fault_test's picky formats named, its token's result const; over_fuzz's static span taken from a span of the text.
over_fuzz's static span of bytes made from a named pointer, its initializer on one line; the windows_h twins read the decoded size with no chain of calls.
Its local small is rpcndr.h's macro under a bare <windows.h>: the MSVC lane's windows_h_before stopped there. It is lower now.
…a prepare of SIZE_MAX
…SVC C4458: output hid the member)
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
webcpp::codecs' genesis: one contract for converting bytes and typed values to text and back, and any data through one-shot and stream transformers, built on webcpp::secure.
Design: libraries/codecs/openspec/changes/genesis in webcpporg/proposals. Verified locally on clang, gcc 15, wasip2, wasip3, Emscripten, MSVC 14.3 and 14.5 (x64, arm64 for the timing tests), both own lanes and both lints.