1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-10 01:34: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:
Davide Beatrici
2018-09-22 06:35:30 +02:00
parent 69b35f875a
commit 3f5f716357
41 changed files with 329 additions and 371 deletions

View File

@ -635,7 +635,7 @@ UINT DCRegister(DDNS_CLIENT *c, bool ipv6, DDNS_REGISTER_PARAM *p, char *replace
PackAddStr(req, "current_azure_ip", current_azure_ip);
}
HashSha1(key_hash, key_str, StrLen(key_str));
Sha1(key_hash, key_str, StrLen(key_str));
BinToStr(key_hash_str, sizeof(key_hash_str), key_hash, sizeof(key_hash));
StrLower(key_hash_str);
@ -963,7 +963,7 @@ DDNS_CLIENT *NewDDNSClient(CEDAR *cedar, UCHAR *key, INTERNET_SETTING *t)
Copy(c->Key, key, SHA1_SIZE);
}
HashSha1(key_hash, c->Key, sizeof(c->Key));
Sha1(key_hash, c->Key, sizeof(c->Key));
if (t != NULL)
@ -1035,7 +1035,7 @@ void DCGenNewKey(UCHAR *key)
GetCurrentMachineIpProcessHash(hash);
WriteBuf(b, hash, sizeof(hash));
HashSha1(key, b->Buf, b->Size);
Sha1(key, b->Buf, b->Size);
Rand(rand, sizeof(rand));
for (i = 0;i < SHA1_SIZE;i++)