1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 09:29:52 +03:00

Merge PR #639: Encrypt: support NULL message digest

This commit is contained in:
Davide Beatrici 2018-08-12 12:19:30 +02:00 committed by GitHub
commit c9b56bf590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;