1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

Encrypt: support NULL message digest

This commit is contained in:
Davide Beatrici 2018-08-12 01:53:30 +02:00
parent 6764e24f20
commit 3d13f56314
2 changed files with 22 additions and 3 deletions

View File

@ -408,7 +408,18 @@ void HMacSha1(void *dst, void *key, UINT key_size, void *data, UINT data_size)
// Calculate the HMAC
void MdProcess(MD *md, void *dest, void *src, UINT size)
{
int r;
int r = 0;
if (md != NULL && md->isNullMd)
{
if (dest != src)
{
Copy(dest, src, size);
}
return;
}
// Validate arguments
if (md == NULL || dest == NULL || (src != NULL && size == 0))
{
@ -417,8 +428,6 @@ void MdProcess(MD *md, void *dest, void *src, UINT size)
HMAC_Init_ex(md->Ctx, NULL, 0, NULL, NULL);
HMAC_Update(md->Ctx, src, size);
r = 0;
HMAC_Final(md->Ctx, dest, &r);
}
@ -447,6 +456,15 @@ MD *NewMd(char *name)
m = ZeroMalloc(sizeof(MD));
StrCpy(m->Name, sizeof(m->Name), name);
if (StrCmpi(name, "[null-digest]") == 0 ||
StrCmpi(name, "NULL") == 0 ||
IsEmptyStr(name))
{
m->isNullMd = true;
return m;
}
m->Md = (const struct evp_md_st *)EVP_get_digestbyname(name);
if (m->Md == NULL)
{

View File

@ -359,6 +359,7 @@ struct CIPHER
struct MD
{
char Name[MAX_PATH];
bool isNullMd;
const struct evp_md_st *Md;
struct hmac_ctx_st *Ctx;
UINT Size;