-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Pad GPG Key ID with preceding zeroes #20878
Pad GPG Key ID with preceding zeroes #20878
Conversation
The go crypto library does not pad keyIDs to 16 characters with preceding zeroes. This is a somewhat confusing thing for most users who expect these to have preceding zeroes. This PR prefixes any sub 16 length KeyID with preceding zeroes and removes preceding zeroes from KeyIDs inputted on the API. Fix go-gitea#20876 Signed-off-by: Andrew Thornton <art27@cantab.net>
7aab45a
to
bdf3c80
Compare
@@ -177,6 +178,12 @@ func VerifyUserGPGKey(ctx *context.APIContext) { | |||
token := asymkey_model.VerificationToken(ctx.Doer, 1) | |||
lastToken := asymkey_model.VerificationToken(ctx.Doer, 0) | |||
|
|||
form.KeyID = strings.TrimLeft(form.KeyID, "0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can keys start with zeros, or is a leading zero always seen as padding?
Because if it is the former, this will probably produce a lot of problems in the future…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at pubkey.KeyIDString()
The trimming is to fix potential issues relating to that
I have another question. Why is |
Backport go-gitea#20878 The go crypto library does not pad keyIDs to 16 characters with preceding zeroes. This is a somewhat confusing thing for most users who expect these to have preceding zeroes. This PR prefixes any sub 16 length KeyID with preceding zeroes and removes preceding zeroes from KeyIDs inputted on the API. Fix go-gitea#20876 Signed-off-by: Andrew Thornton <art27@cantab.net>
I'm afraid I don't understand what you're talking about. Open a new issue with an example. |
* giteaofficial/main: update current stable version [skip ci] Updated translations via Crowdin Fix mirror address setting not working (go-gitea#20850) Support Proxy protocol (go-gitea#12527) Fix SQL Query for `SearchTeam` (go-gitea#20844) Double check CloneURL is acceptable (go-gitea#20869) Fix graceful doc (go-gitea#20883) Pad GPG Key ID with preceding zeroes (go-gitea#20878) [skip ci] Updated translations via Crowdin call builtinUnused() if internal SSH is disabled (go-gitea#20877) Don't open new page for ext wiki on same repository (go-gitea#20725) [skip ci] Updated translations via Crowdin Fix the mode of custom dir to 0700 in docker-rootless (go-gitea#20861) Fix UI mis-align for PR commit history (go-gitea#20845)
Backport #20878 The go crypto library does not pad keyIDs to 16 characters with preceding zeroes. This is a somewhat confusing thing for most users who expect these to have preceding zeroes. This PR prefixes any sub 16 length KeyID with preceding zeroes and removes preceding zeroes from KeyIDs inputted on the API. Fix #20876 Signed-off-by: Andrew Thornton <art27@cantab.net>
The go crypto library does not pad keyIDs to 16 characters with preceding zeroes. This
is a somewhat confusing thing for most users who expect these to have preceding zeroes.
This PR prefixes any sub 16 length KeyID with preceding zeroes and removes preceding
zeroes from KeyIDs inputted on the API.
Fix #20876
Signed-off-by: Andrew Thornton art27@cantab.net