You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Applications written to use the OpenSSL 3.0 FIPS module should not use any legacy APIs or features that avoid the FIPS module. Specifically this includes:
Low level cryptographic APIs (use the high level APIs, such as EVP, instead)
It appears that the MD5_* and SHA1_* 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 level EVP_ MD5 api:
Which when ran with FIPS enabled (either via the cmd line parameter, or on a kernel with fips=1) gives the output:
gcc md5_fips_test.c -o md5_fips_test -lssl -lcrypto
./md5_fips_test 1
Setting FIPS mode to 1
FIPS Mode: 1
Attempting md5 hash via MD5_ methods.
17b31dce96b9d6c6d0a6ba95f47796fb
Attempting md5 hash via EVP_ methods.
Message digest initialization failed.
140030451414848:error:060800C8:digital envelope routines:EVP_DigestInit_ex:disabled for FIPS:crypto/evp/digest.c:135:
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.
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:
@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.
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: