-
Notifications
You must be signed in to change notification settings - Fork 29
Use SHA-256 for subject key id on FIPS 140-3 mode #703
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
Conversation
76c3932 to
65bc58a
Compare
This commit adds the fipsutil package that reports whether the cryptography libraries are operating in FIPS 140-3 mode. It also uses the 160 leftmost bits of SHA-256 to generate the Subject Key Ids
65bc58a to
ab27c79
Compare
|
Linter issues fixed in #704. |
| func Test_generateSubjectKeyID_fips(t *testing.T) { | ||
| if !fipsutil.Enabled() { | ||
| t.Skip("FIPS 140-3 mode is not enabled") | ||
| } |
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.
Could t.Setenv help executing the tests at all times, but with the GODEBUG env var set for this test?
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.
No, I've tried but GODEBUG cannot be changed after initializing, it will panic if you do it. See https://github.com/golang/go/blob/279da965329a74cd75320f15cb9672a282690ab7/src/crypto/fips140/fips140.go#L26-L28
if currentlyEnabled != fips140.Enabled {
panic("crypto/fips140: GODEBUG setting changed after program start")
}
jose/encrypt.go
Outdated
| return data, nil | ||
| } | ||
| return nil, errors.New("failed to decrypt JWE: invalid password") | ||
| return nil, errors.New("failed to decrypt JWE: invalid password" + err.Error()) |
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.
Added a space, but other options might work too. No fmt.Errorf?
| return nil, errors.New("failed to decrypt JWE: invalid password" + err.Error()) | |
| return nil, errors.New("failed to decrypt JWE: invalid password " + err.Error()) |
| "github.com/stretchr/testify/assert" | ||
| "go.step.sm/crypto/fipsutil" |
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.
| "github.com/stretchr/testify/assert" | |
| "go.step.sm/crypto/fipsutil" | |
| "github.com/stretchr/testify/assert" | |
| "go.step.sm/crypto/fipsutil" |
d618af5 to
21ffe8f
Compare
21ffe8f to
9fd47c3
Compare
Description
This commit adds the fips util package, which reports whether the cryptography libraries are operating in FIPS 140-3 mode.
It also uses the 160 leftmost bits of SHA-256 to generate the Subject Key IDs.
Related: