MCPcopy Create free account
hub / github.com/diasurgical/devilution / VerifyDataBlockHash

Function VerifyDataBlockHash

3rdParty/StormLib/src/SBaseCommon.cpp:1692–1713  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1690
1691
1692bool VerifyDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE expected_md5)
1693{
1694#ifdef FULL
1695 hash_state md5_state;
1696 BYTE md5_digest[MD5_DIGEST_SIZE];
1697
1698 // Don't verify the block if the MD5 is not valid.
1699 if(!IsValidMD5(expected_md5))
1700 return true;
1701
1702 // Calculate the MD5 of the data block
1703 md5_init(&md5_state);
1704 md5_process(&md5_state, (unsigned char *)pvDataBlock, cbDataBlock);
1705 md5_done(&md5_state, md5_digest);
1706
1707 // Does the MD5's match?
1708 return (memcmp(md5_digest, expected_md5, MD5_DIGEST_SIZE) == 0);
1709#else
1710 assert(0);
1711 return false;
1712#endif
1713}
1714
1715void CalculateDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE md5_hash)
1716{

Callers 1

Calls 1

IsValidMD5Function · 0.85

Tested by

no test coverage detected