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

crypto/rsa: pss may have wrong salt length #42741

Open
zhangzhanli opened this issue Nov 20, 2020 · 2 comments
Open

crypto/rsa: pss may have wrong salt length #42741

zhangzhanli opened this issue Nov 20, 2020 · 2 comments
Milestone

Comments

@zhangzhanli
Copy link

@zhangzhanli zhangzhanli commented Nov 20, 2020

crypto/rsa/pss.go : 272 in latest version of go

When PSSOptions's saltLength is PSSSaltLengthAuto, we just try to maximize the length of salt. But there are some problems with it where the bit length of N of private key is congruent to 1 module 8. (i.e. bitlen(N) == 8k + 1) . Under these situations, when checking emLen in crypto/rsa/pss.go : 50 which is equal to hLen+sLen+1, we will alway get an error "key size too small for PSS signature". And I didn't see there are such problems with openssl. So, maybe we need a change?

@zhangzhanli zhangzhanli changed the title rsa pss may has wrong salt length rsa pss may have wrong salt length Nov 20, 2020
@martisch martisch changed the title rsa pss may have wrong salt length crypto/rsa: pss may have wrong salt length Nov 20, 2020
@martisch
Copy link
Contributor

@martisch martisch commented Nov 20, 2020

@FiloSottile
Copy link
Member

@FiloSottile FiloSottile commented Dec 2, 2020

Yep, this is broken and has been broken at least since Go 1.13, so not a Go 1.16 fix. Scheduling for 1.17, thank you!

https://play.golang.org/p/hgTw2zJW2OI

@FiloSottile FiloSottile added this to the Go1.17 milestone Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.