mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-12 10:44:58 +03:00
Revamp digest functions
- Hash() has been removed because it was ambiguous, Md5() and Sha0() are proper replacements. - HMacMd5() and HMacSha1() now share a common implementation handled by the new Internal_HMac() function. - NewMd() and MdProcess() now support plain hashing (without the key). - NewMd(), SetMdKey() and MdProcess() now check the OpenSSL functions' return value and in case of failure a debug message is printed along with the error string, if available. - SetMdKey()'s return value has been changed from void to bool, so that it's possible to know whether the function succeeded or not. - MdProcess()' return value has been changed from void to UINT (unsigned int) and the function now returns the number of bytes written by HMAC_Final() or EVP_DigestFinal_ex().
This commit is contained in:
@ -466,7 +466,7 @@ bool CfgSaveExW3(CFG_RW *rw, FOLDER *f, wchar_t *name, UINT *written_size, bool
|
||||
return false;
|
||||
}
|
||||
// Hash the contents
|
||||
Hash(hash, b->Buf, b->Size, true);
|
||||
Sha0(hash, b->Buf, b->Size);
|
||||
|
||||
// Compare the contents to be written with the content which was written last
|
||||
if (rw != NULL)
|
||||
@ -661,7 +661,7 @@ FOLDER *CfgReadW(wchar_t *name)
|
||||
// Check the hash
|
||||
ReadBuf(b, hash1, sizeof(hash1));
|
||||
|
||||
Hash(hash2, ((UCHAR *)b->Buf) + 8 + SHA1_SIZE, b->Size - 8 - SHA1_SIZE, true);
|
||||
Sha0(hash2, ((UCHAR *)b->Buf) + 8 + SHA1_SIZE, b->Size - 8 - SHA1_SIZE);
|
||||
|
||||
if (Cmp(hash1, hash2, SHA1_SIZE) != 0)
|
||||
{
|
||||
@ -1105,7 +1105,7 @@ BUF *CfgFolderToBufBin(FOLDER *f)
|
||||
CfgOutputFolderBin(b, f);
|
||||
|
||||
// Hash
|
||||
Hash(((UCHAR *)b->Buf) + 8, ((UCHAR *)b->Buf) + 8 + SHA1_SIZE, b->Size - 8 - SHA1_SIZE, true);
|
||||
Sha0(((UCHAR *)b->Buf) + 8, ((UCHAR *)b->Buf) + 8 + SHA1_SIZE, b->Size - 8 - SHA1_SIZE);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
Reference in New Issue
Block a user