mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-06 07:44:57 +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:
@ -147,7 +147,7 @@ PRAND *NewPRand(void *key, UINT key_size)
|
||||
|
||||
r = ZeroMalloc(sizeof(PRAND));
|
||||
|
||||
HashSha1(r->Key, key, key_size);
|
||||
Sha1(r->Key, key, key_size);
|
||||
|
||||
r->Rc4 = NewCrypt(key, key_size);
|
||||
|
||||
@ -2459,7 +2459,7 @@ BUF *FileToBuf(IO *o)
|
||||
}
|
||||
|
||||
// Take a hash
|
||||
Hash(hash2, buf, size, false);
|
||||
Md5(hash2, buf, size);
|
||||
|
||||
// Compare the hashes
|
||||
if (Cmp(hash1, hash2, sizeof(hash1)) != 0)
|
||||
@ -2664,7 +2664,7 @@ bool BufToFile(IO *o, BUF *b)
|
||||
}
|
||||
|
||||
// Hash the data
|
||||
Hash(hash, b->Buf, b->Size, false);
|
||||
Md5(hash, b->Buf, b->Size);
|
||||
|
||||
size = Endian32(b->Size);
|
||||
|
||||
|
Reference in New Issue
Block a user