Skip to content

Commit

Permalink
md4: use init/update/final functions in Secure Transport
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzman committed Feb 25, 2020
1 parent 3f74e5e commit ca38e76
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions lib/md4.c
Expand Up @@ -100,36 +100,21 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
/* The last #include file should be: */
#include "memdebug.h"

typedef struct {
void *data;
unsigned long size;
} MD4_CTX;
typedef CC_MD4_CTX MD4_CTX;

static void MD4_Init(MD4_CTX *ctx)
{
ctx->data = NULL;
ctx->size = 0;
(void)CC_MD4_Init(ctx);
}

static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
{
if(ctx->data == NULL) {
ctx->data = malloc(size);
if(ctx->data != NULL) {
memcpy(ctx->data, data, size);
ctx->size = size;
}
}
(void)CC_MD4_Update(ctx, data, (CC_LONG)size);
}

static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
{
if(ctx->data != NULL) {
(void)CC_MD4(ctx->data, (CC_LONG) ctx->size, result);

Curl_safefree(ctx->data);
ctx->size = 0;
}
(void)CC_MD4_Final(result, ctx);
}

#elif defined(USE_WIN32_CRYPTO)
Expand Down

0 comments on commit ca38e76

Please sign in to comment.