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

SSH key cannot be verified due to 2047 length #20249

Closed
BeeFox-sys opened this issue Jul 5, 2022 · 3 comments · Fixed by #20272
Closed

SSH key cannot be verified due to 2047 length #20249

BeeFox-sys opened this issue Jul 5, 2022 · 3 comments · Fixed by #20272
Labels

Comments

@BeeFox-sys
Copy link

Description

When generating an rsa ssh key, there is a chance the final bit is a zero, resulting in a 2047 bit length key, by default git tea does not allow for these keys. this should be changed to allow people to use them.

Gitea Version

1.17.0+dev-759-g761db4d53

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

https://try.gitea.io/user/settings/keys

Database

No response

@zeripath
Copy link
Contributor

zeripath commented Jul 5, 2022

Does this happen for other key types too?

If not, we should change this:

MinimumKeySizes: map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 2048},

to:

		MinimumKeySizes:               map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 2047},

and add a comment as to why this is 2047 rather than 2048.

If so, we should change this:

if minLen, found := setting.SSH.MinimumKeySizes[keyType]; found && length >= minLen {

to:

	if minLen, found := setting.SSH.MinimumKeySizes[keyType]; found && length + 1 >= minLen {

and add a comment explaining that we allow one byte shorter due to accepting an initial/terminal 0.


If you're able to find out which of the above is the case then we can make the patch.

In the meantime as a workaround you can change the defaults to allow minimums one byte less in size.

@BeeFox-sys
Copy link
Author

I am unsure as i do not run gitea myself, and was advised by the person who runs the server. we did implement the workaround and that worked fine but i still opened an issue after some research into why it was happening

@zeripath
Copy link
Contributor

zeripath commented Jul 6, 2022

OK I think it's only rsa that can be affected here. So I'll just do a very simple pr.

zeripath added a commit to zeripath/gitea that referenced this issue Jul 6, 2022
Unfortunately it appears that 2048 bit RSA keys can occasionally be created in such
a way that they appear to have 2047 bit length. This PR simply changes our defaults to
allow these.

Fix go-gitea#20249

Signed-off-by: Andrew Thornton <[email protected]>
techknowlogick pushed a commit that referenced this issue Jul 6, 2022
Unfortunately it appears that 2048 bit RSA keys can occasionally be created in such
a way that they appear to have 2047 bit length. This PR simply changes our defaults to
allow these.

Fix #20249

Signed-off-by: Andrew Thornton <[email protected]>
dineshsalunke pushed a commit to dineshsalunke/gitea that referenced this issue Jul 9, 2022
Unfortunately it appears that 2048 bit RSA keys can occasionally be created in such
a way that they appear to have 2047 bit length. This PR simply changes our defaults to
allow these.

Fix go-gitea#20249

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit to zeripath/gitea that referenced this issue Jul 17, 2022
Backport go-gitea#20272

Unfortunately it appears that 2048 bit RSA keys can occasionally be created in such
a way that they appear to have 2047 bit length. This PR simply changes our defaults to
allow these.

Fix go-gitea#20249

Signed-off-by: Andrew Thornton <[email protected]>
techknowlogick added a commit that referenced this issue Jul 18, 2022
Backport #20272

Unfortunately it appears that 2048 bit RSA keys can occasionally be created in such
a way that they appear to have 2047 bit length. This PR simply changes our defaults to
allow these.

Fix #20249

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
vsysoev pushed a commit to IntegraSDL/gitea that referenced this issue Aug 10, 2022
Unfortunately it appears that 2048 bit RSA keys can occasionally be created in such
a way that they appear to have 2047 bit length. This PR simply changes our defaults to
allow these.

Fix go-gitea#20249

Signed-off-by: Andrew Thornton <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants