-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add CNG crypto backend #645
Conversation
b236f6f
to
3293b62
Compare
I think it works--it parallels nicely with |
I like
This makes me like it more 😄 |
c649559
to
41e174a
Compare
|
||
- if boring.Enabled { | ||
+ if boring.Enabled && | ||
+ (!goexperiment.CNGCrypto || (len(priv.Primes) == 2 && hash != crypto.MD5SHA1)) { |
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.
Here's what I was mentioning in the Go sync--the inversion:
(!goexperiment.CNGCrypto || (len(priv.Primes) == 2 && hash != crypto.MD5SHA1))
!( goexperiment.CNGCrypto && (len(priv.Primes) != 2 || hash == crypto.MD5SHA1))
I think of the right side as a list of unsupported/fallback cases and it's quite a bit easier to read as positives rather than negatives:
len(priv.Primes) == 2 && hash != crypto.MD5SHA1)
"does every unsupported case not match"len(priv.Primes) != 2 || hash == crypto.MD5SHA1)
"does any unsupported case match"
Maybe it's just me. I can certainly figure it out either way, so I'm happy to go with whatever makes the most sense for anyone else. 😄
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.
Done! 0236a2e
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.
LGTM, just a comment/doc suggestion and a question.
+ // CNGCrypto has too many stdlib fallbacks, | ||
+ // so Unreachable is not always true. | ||
+ if !goexperiment.CNGCrypto { |
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.
I think it's worth elaborating a bit here... my understanding from poking around is that this is because CNGCrypto has more fallbacks than boring/openssl, and I think this is saying that there are enough extra fallbacks that if we were to remove boring.Unreachable()
from each of those code paths, Unreachable
becomes useless. Is that right?
I assume it's also not worthwhile to make backend-specific Unreachable calls, so they can be tailored to the fallbacks necessary for each backend?
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.
I give it another thought, and it was easier than expected to make backend-specific Unreachable calls:
358a6e6.
Co-authored-by: Davis Goodin <[email protected]>
This PR integrates https://github.com/microsoft/go-crypto-winnative as a Go backend.
Tips for the reviewers:
goexperiment=cngcrypto
.As agreed, we will fallback to Go crypto when CNG does not implement an algorithm or a parameter required by Go. The complete list can be found at microsoft/go-crypto-winnative#4.
I'll add an exhaustive documentation of what to expect and how to use CNG backend once this PR lands.
@dagood @jaredpar @chsienki how does
goexperiment=cngcrypto
resonates to you? People will understand thatcngcrypto
is the CNG Windows backend? Alternatives?Closes #476