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:
parent
6764e24f20
commit
3d13f56314
@ -408,7 +408,18 @@ void HMacSha1(void *dst, void *key, UINT key_size, void *data, UINT data_size)
|
|||||||
// Calculate the HMAC
|
// Calculate the HMAC
|
||||||
void MdProcess(MD *md, void *dest, void *src, UINT size)
|
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
|
// Validate arguments
|
||||||
if (md == NULL || dest == NULL || (src != NULL && size == 0))
|
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_Init_ex(md->Ctx, NULL, 0, NULL, NULL);
|
||||||
HMAC_Update(md->Ctx, src, size);
|
HMAC_Update(md->Ctx, src, size);
|
||||||
|
|
||||||
r = 0;
|
|
||||||
HMAC_Final(md->Ctx, dest, &r);
|
HMAC_Final(md->Ctx, dest, &r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,6 +456,15 @@ MD *NewMd(char *name)
|
|||||||
m = ZeroMalloc(sizeof(MD));
|
m = ZeroMalloc(sizeof(MD));
|
||||||
|
|
||||||
StrCpy(m->Name, sizeof(m->Name), name);
|
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);
|
m->Md = (const struct evp_md_st *)EVP_get_digestbyname(name);
|
||||||
if (m->Md == NULL)
|
if (m->Md == NULL)
|
||||||
{
|
{
|
||||||
|
@ -359,6 +359,7 @@ struct CIPHER
|
|||||||
struct MD
|
struct MD
|
||||||
{
|
{
|
||||||
char Name[MAX_PATH];
|
char Name[MAX_PATH];
|
||||||
|
bool isNullMd;
|
||||||
const struct evp_md_st *Md;
|
const struct evp_md_st *Md;
|
||||||
struct hmac_ctx_st *Ctx;
|
struct hmac_ctx_st *Ctx;
|
||||||
UINT Size;
|
UINT Size;
|
||||||
|
Loading…
Reference in New Issue
Block a user