Text: add RFC 4648 base32 encode/decode #49

Closed
opened 2026-12-03 13:27:07 +00:00 by faumaray · 1 comment
Owner

Context: Forge M04 identity needs base32 for TOTP secrets and recovery-code display. Forge currently ships a temporary table-driven RFC 4648 implementation and tracks this as VL-TEXT-01.

Need:

  • base32_encode / base32_decode over std::span<const std::byte> in Void::Text, uppercase alphabet, optional padding on encode, case-insensitive decode, strict rejection of invalid characters and lengths.
  • No exceptions for malformed input; return std::optional or Void::Result.

Tests/gate: RFC 4648 §10 vectors, unpadded and padded forms, invalid alphabet/padding/length cases. Forge M04 swaps its temporary implementation for this.

Context: Forge M04 identity needs base32 for TOTP secrets and recovery-code display. Forge currently ships a temporary table-driven RFC 4648 implementation and tracks this as VL-TEXT-01. Need: - `base32_encode` / `base32_decode` over `std::span<const std::byte>` in `Void::Text`, uppercase alphabet, optional padding on encode, case-insensitive decode, strict rejection of invalid characters and lengths. - No exceptions for malformed input; return `std::optional` or `Void::Result`. Tests/gate: RFC 4648 §10 vectors, unpadded and padded forms, invalid alphabet/padding/length cases. Forge M04 swaps its temporary implementation for this.
Author
Owner

Implemented in main as f158d7b: Void::Text::base32_encode(span<const std::byte>, bool pad = true) and Void::Text::base32_decode(string_view | span<const std::byte>, TextLimits) wrappers over the RFC 4648 codec merged for #43. Uppercase output, optional padding, case-insensitive strict decode (rejects invalid alphabet, impossible lengths, malformed padding and non-zero trailing bits) returning std::optional with no exceptions. RFC 4648 vectors and invalid cases are covered; Testing;Text with -Werror passes (539 tests, 536 passed, 3 skipped). Pushed to origin/main. Closing as done.

Implemented in `main` as `f158d7b`: `Void::Text::base32_encode(span<const std::byte>, bool pad = true)` and `Void::Text::base32_decode(string_view | span<const std::byte>, TextLimits)` wrappers over the RFC 4648 codec merged for #43. Uppercase output, optional padding, case-insensitive strict decode (rejects invalid alphabet, impossible lengths, malformed padding and non-zero trailing bits) returning `std::optional` with no exceptions. RFC 4648 vectors and invalid cases are covered; `Testing;Text` with `-Werror` passes (539 tests, 536 passed, 3 skipped). Pushed to origin/main. Closing as done.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Void/Library#49