Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: encoding/base32: add Encoding.Strict #53844

Open
dsnet opened this issue Jul 13, 2022 · 2 comments
Open

proposal: encoding/base32: add Encoding.Strict #53844

dsnet opened this issue Jul 13, 2022 · 2 comments

Comments

@dsnet
Copy link
Member

dsnet commented Jul 13, 2022

base64.Encoding.Strict was added in #15656, but there was no equivalent method added to base32.Encoding.
To be consistent, I propose we add the equivalent functionality but rename it. The name Strict is unhelpful since there are multiple dimensions that the encoding could be stricter on.

I propose adding the following methods to both base32 and base64:

// RejectNonZeroPadding creates a new encoding identical to enc except
// that decoding requires trailing padding bits to be zero,
// as described in RFC 4648 section 3.5.
func (enc Encoding) RejectNonZeroPadding(enable bool) *Encoding 

and we deprecate the existing base64.Encoding.Strict method.

@dsnet dsnet added the Proposal label Jul 13, 2022
@gopherbot gopherbot added this to the Proposal milestone Jul 13, 2022
@ianlancetaylor ianlancetaylor added this to Incoming in Proposals (old) Jul 13, 2022
@gopherbot
Copy link

Change https://go.dev/cl/532296 mentions this issue: encoding: support RejectNonZeroPadding in base32 and base64

@dsnet
Copy link
Member Author

dsnet commented Oct 2, 2023

This feature combined with #53845 makes it possible to implement a truly bijective mapping between baseXX and binary data. This would allow the use of base32 and base64 to produce a truly canonical encoding per RFC 4648, section 3.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

2 participants