First I verify that my openssl is correct (compiled with FIPS support).
# openssl version
OpenSSL 1.0.2q-fips 20 Nov 2018
In normal mode:
# echo -n 123456 | openssl md5
(stdin)= e10adc3949ba59abbe56e057f20f883e
In FIPS mode:
# echo -n 123456 | OPENSSL_FIPS=1 openssl md5
Error setting digest md5
139993634896640:error:060A80A3:digital envelope routines:FIPS_DIGESTINIT:disabled for fips:fips_md.c:180:
As expected.
Now I want to verify that python behaves as expected too.
I have python 3.6 compiled with FIPS mode support:
# ./python
Python 3.6.8 (tags/v3.6.8-dirty:3c6b436a57, Apr 11 2019, 08:44:38)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2q-fips 20 Nov 2018'
I set it in FIPS mode:
>>> import ssl
>>> ssl.FIPS_mode_set(1)
>>> ssl.FIPS_mode()
1
And now I try to verify that it is running in FIPS mode:
>>> import hashlib
>>>
>>> m = hashlib.md5()
>>> m.update(b"Nobody inspects")
>>> m.digest()
b'>\xf7)\xcc\xf0\xccV\x07\x9c\xa5F\xd5\x80\x83\xdc\x12'
Why is md5
allowed in FIPS mode?
EDIT
I have verified that python is using openssl
implementation:
>>> hashlib.md5
<built-in function openssl_md5>