bitbake: utils/ply: Change md5 usages to work on FIPS enabled hosts

hashlib.md5() is not permitted on a FIPS enabled host system.  This is due
to md5 not being an approved hash algorithm.

Instead use:
 hashlib.new('MD5', usedforsecurity=False)

This is allowed, as it's clear the hash is used for a non-security purpose.

Note: utils.py version should never be used to verify file integrity, but
instead be used to identify if the file may have changed.  sha256 should be
used for integrity purposes.

(Bitbake rev: af866dd077867cba0129757bfcc689551445e9d7)

Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mark Hatle 2022-02-28 19:30:53 -06:00 committed by Richard Purdie
parent 1d98b3aaae
commit d895863af1
2 changed files with 3 additions and 6 deletions

View File

@ -538,7 +538,7 @@ def md5_file(filename):
Return the hex string representation of the MD5 checksum of filename.
"""
import hashlib
return _hasher(hashlib.md5(), filename)
return _hasher(hashlib.new('MD5', usedforsecurity=False), filename)
def sha256_file(filename):
"""

View File

@ -2797,11 +2797,8 @@ class ParserReflect(object):
# Compute a signature over the grammar
def signature(self):
try:
from hashlib import md5
except ImportError:
from md5 import md5
try:
sig = md5()
import hashlib
sig = hashlib.new('MD5', usedforsecurity=False)
if self.start:
sig.update(self.start.encode('latin-1'))
if self.prec: