-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
boringcrypto: Not using FIPS compliant calls for SHA functions (also should we add md5? for easy proof of FIPS mode on) #66513
Comments
Duplicate of #45565 |
@seankhliao Thanks for the pointer to #45565 but I don't think this is a direct duplicate of that bug. I can see the crossover where I am asking why md5() is not implemented in boringcrypto and I see #45565 (comment) indicates that is working as designed and it is up to the application to not cal md5(), but my bigger concern here is that all the functions in sha.go are using the low level openssl calls, instead of the high level ones that go via the fips provider. |
I figured closed bugs won't get any attention and to remove the confusion over md5 and concentrate on the sha issue I raised a new bug: #66520 |
Go version
go1.20.12
Output of
go env
in your module/workspace:What did you do?
After building a golang binary I wanted to prove that boringcrypto was using the openssl library in FIPS mode (my kernel was already in FIPS mode) and the way I had done that for other languages was to attempt an md5 hash and see that openssl threw an error. AFter ralising the the md5() function of golang is not implemented in boringcrypto I set about patching my copy by copying the way the sha1 functions work but for md5. After getting this to work I was surprised when the md5() function returned the hash, instead of returning an erorr. Using
LD_DEBUG=symbols
I could see that my binary was correctly calling into openssl for both an md5() call and a sha1() call:when executrd with
LD_DEBUG=symbols
produced:A bit of digging around and I found this section in the openssl fips page (https://www.openssl.org/docs/manmaster/man7/fips_module.html):
It appears that the
MD5_*
andSHA1_*
functions are considered low level APIs by openssl and so avoid the FIPS module. I tested this theory by creating a small C program that first uses the low level MD5 api and then the haigh levelEVP_
MD5 api:Which when ran with FIPS enabled (either via the cmd line parameter, or on a kernel with fips=1) gives the output:
Which seems to prove that the MD5_ methods, and so presumably all the SHA*_ methods do not go via the fips module. I wasn't able to find a way to configure the system to disallow a one of the SHA* hashes to test my theory with the SHA*_ functions though.
Note I was actually using go-toolset on Redhat, but I think the changes required are in the boringcrypto code in https://github.com/golang/go/blob/master/src/crypto/internal/boring/sha.go and other places.
I also think it would be handy to add an implementation of md5 (would be very simlar to the fixed sha implementation) in boringcrypto so that you can try an md5 hash and see it refused. It would also need to use the EVP_ methods.
What did you see happen?
Covered above, sorry.
What did you expect to see?
I expected to be able to prove that the binary was running openssl in fips mode, by seeing it deny a bad algorithmn, such as md5.
The text was updated successfully, but these errors were encountered: