[New-bugs-announce] [issue9216] FIPS support for hashlib
report at bugs.python.org
Sat Jul 10 02:22:15 CEST 2010
New submission from Dave Malcolm <dmalcolm at redhat.com>:
(taking the liberty of adding gregory.p.smith to the "nosy" list; hope that's OK)
This is a higher-level take on issue 9146.
Some versions of OpenSSL have a FIPS mode that can refuse the use of non-certified hashes.
The idea is that FIPS mode should prevent the use of non-certified hashes for security uses. For example, MD5 shouldn't be used for signatures these days (see e.g. http://www.kb.cert.org/vuls/id/836068).
However, there are legitimate non-security uses of these hashes. For example, one might use MD5 hashes of objects to places them in bins for later retrieval, purely as a speed optimization (e.g. files in directories on a filesystem).
I'm working on a patch to hashlib which would better support this, but it involves an API expansion, and I wanted to sound things out first.
The API idea is to introduce a new keyword argument, say "usedforsecurity" to hashlib.new() and to the named hashlib constructors, such as hashlib.md5(). This would default to True. If code is using these hashes in FIPS mode, the developer needs to override this: usedforsecurity=False to mark the callsite as a non-security-sensitive location. Internally, this would lead to the EVP_MD_CTX being initialized with EVP_MD_CTX_FLAG_NON_FIPS_ALLOW.
This way, if you run unaudited code in an environment that cares about FIPS, the code will raise exceptions if it uses a non-valid hash, but during code audit the callsites can be marked clearly as "usedforsecurity=False", and be used as before.
In non-FIPS environments, the flag would be ignored.
Am I right in thinking that the _hashlib module should be treated as an implementation detail here? The entry points within _hashlib are likely to double, with a pair of pre-initialized contexts, one with the flag, one without.
Does this sound reasonable? Thanks.
components: Library (Lib)
nosy: dmalcolm, gregory.p.smith
stage: needs patch
title: FIPS support for hashlib
versions: Python 3.2
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce