Skip to content

crypto/rsa: vary amount of randomness used by operations #21915

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

Closed
rsc opened this issue Sep 18, 2017 · 2 comments
Closed

crypto/rsa: vary amount of randomness used by operations #21915

rsc opened this issue Sep 18, 2017 · 2 comments

Comments

@rsc
Copy link
Contributor

rsc commented Sep 18, 2017

We discovered that various routines pass a deterministic randomness source to RSA routines in tests to guarantee deterministic output (which is fine) but then they also end up implicitly relying on the fact that each RSA routine reads a certain amount of randomness given certain inputs (which is maybe not fine), which sets up the next read from that randomness source a certain way. If RSA were to read extra bytes, it would break the future reads from the random source.

https://golang.org/cl/63912 adds tests for this in dev.boringcrypto, to match Go 1.9, but @agl suggests that maybe we should break this code, to reserve future flexibility for crypto/rsa. It would suffice to read just a few extra bytes, and the randomness here does not have to be crypto-strength. Something like:

c := make(chan int)
close(c)
var n int
select {
case <-c:
	n = 0
case <-c:
	n = 1
case <-c:
	n = 2
case <-c:
	n = 3
}

would be good enough, or we could expose the runtime's fastrand to crypto/rsa.

/cc @agl @FiloSottile

@rsc rsc added this to the Proposal milestone Sep 18, 2017
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/64451 mentions this issue: crypto: randomly read an extra byte of randomness in some places.

@rsc
Copy link
Contributor Author

rsc commented Oct 16, 2017

Adam agrees that we should do this, so I think as far as a proposal we can accept this. The implementation is pending.

@rsc rsc modified the milestones: Proposal, Go1.10 Oct 16, 2017
@rsc rsc changed the title proposal: crypto/rsa: vary amount of randomness used by operations crypto/rsa: vary amount of randomness used by operations Oct 16, 2017
@rsc rsc modified the milestones: Go1.10, Go1.11 Nov 22, 2017
@golang golang locked and limited conversation to collaborators Jun 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants