Skip to content

Commit bc318d7

Browse files
authored
ENH: Add support for python in FIPS mode for document identifier (#3438)
In FIPS mode, md5 might be available and approved. It might also be available, but only on opt-in basis for unapproved usage. And very strict systems might not have md5 even on opt-in basis. Python has API to expose this as "usedforsecurity=False" argument, see python documentation. The rolling document checksum is not used for cryptograpic protection, but rather used out of convenience. Hence allow using MD5 on more FIPS systems. This is no effective change for regular non-fips python builds.
1 parent ac22d3c commit bc318d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pypdf/_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class ObjectDeletionFlag(enum.IntFlag):
136136

137137

138138
def _rolling_checksum(stream: BytesIO, blocksize: int = 65536) -> str:
139-
hash = hashlib.md5()
139+
hash = hashlib.md5(usedforsecurity=False)
140140
for block in iter(lambda: stream.read(blocksize), b""):
141141
hash.update(block)
142142
return hash.hexdigest()

0 commit comments

Comments
 (0)