1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-12 02:34:59 +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

@ -253,7 +253,7 @@ void CiGetCurrentMachineHashOld(void *data)
Trim(name);
StrUpper(name);
Hash(data, name, StrLen(name), true);
Sha0(data, name, StrLen(name));
}
// Get current machine hash
@ -272,7 +272,7 @@ void CiGetCurrentMachineHash(void *data)
Trim(name);
StrUpper(name);
Hash(data, name, StrLen(name), true);
Sha0(data, name, StrLen(name));
}
// Get current machine hash (without using domain name)
@ -297,7 +297,7 @@ void CiGetCurrentMachineHashNew(void *data)
Trim(name);
StrUpper(name);
Hash(data, name, StrLen(name), true);
Sha0(data, name, StrLen(name));
}
@ -5722,7 +5722,7 @@ L_TRY:
SetTimeout(s, 10000);
Hash(hash_password, password, StrLen(password), true);
Sha0(hash_password, password, StrLen(password));
if (key != NULL)
{
@ -8772,7 +8772,7 @@ bool CtGetPasswordSetting(CLIENT *c, RPC_CLIENT_PASSWORD_SETTING *a)
return false;
}
Hash(hash, "", 0, true);
Sha0(hash, "", 0);
if (Cmp(hash, c->EncryptedPassword, SHA1_SIZE) == 0)
{
a->IsPasswordPresented = false;
@ -8801,7 +8801,7 @@ bool CtSetPassword(CLIENT *c, RPC_CLIENT_PASSWORD *pass)
if (StrCmp(str, "********") != 0)
{
// Hash the password
Hash(c->EncryptedPassword, str, StrLen(str), true);
Sha0(c->EncryptedPassword, str, StrLen(str));
}
c->PasswordRemoteOnly = pass->PasswordRemoteOnly;
@ -9154,7 +9154,7 @@ void CiInitConfiguration(CLIENT *c)
CLog(c, "LC_LOAD_CONFIG_3");
// Do the initial setup because the configuration file does not exist
// Clear the password
Hash(c->EncryptedPassword, "", 0, true);
Sha0(c->EncryptedPassword, "", 0);
// Initialize the client configuration
// Disable remote management
c->Config.AllowRemoteConfig = false;
@ -9773,7 +9773,7 @@ bool CiReadSettingFromCfg(CLIENT *c, FOLDER *root)
if (CfgGetByte(root, "EncryptedPassword", c->EncryptedPassword, SHA1_SIZE) == false)
{
Hash(c->EncryptedPassword, "", 0, true);
Sha0(c->EncryptedPassword, "", 0);
}
c->PasswordRemoteOnly = CfgGetBool(root, "PasswordRemoteOnly");
@ -10439,7 +10439,7 @@ CLIENT *CiNewClient()
c->NotifyCancelList = NewList(NULL);
Hash(c->EncryptedPassword, "", 0, true);
Sha0(c->EncryptedPassword, "", 0);
#ifdef OS_WIN32
c->GlobalPulse = MsOpenOrCreateGlobalPulse(CLIENT_GLOBAL_PULSE_NAME);