Menu

#36 dcpcrypt2 - Hashes are wrong for files > 2GB

v1.0 (example)
open
nobody
None
5
2018-03-16
2018-03-16
ahz
No

The MD5, SHA1 & SHA256 hashes are wrong for files > 2GB. (Other hashes not tested)

Steps to reproduce:
Use a file >2GB and compare the results of the appropriate hash function with the results of md5sum, sha1sum etc. (wingw or linux versions works here).

Expected root cause:
The procedure in TDCP_hash.UpdateStream(Stream: TStream; Size: longword) dcpcrypt2.pas uses a longword (parameter size) for calculating the next data block. This longword (32 bit) overflows at 2^32 bytes, resulting in wrong data blocks.

Temporary (read: not fully tested) solution:
Replace
procedure TDCP_hash.UpdateStream(Stream: TStream; Size: longword);
with
procedure TDCP_hash.UpdateStream(Stream: TStream; Size: Int64);

Discussion


Log in to post a comment.