Skip to content

Commit

Permalink
Sync MD5 changes from OpenBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemj committed Apr 8, 2023
1 parent ee56a52 commit b2e54bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/md5.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: md5.h,v 1.15 2004/05/03 17:30:14 millert Exp $ */
/* $OpenBSD: md5.h,v 1.17 2012/12/05 23:19:57 deraadt Exp $ */

/*
* This code implements the MD5 message-digest algorithm.
Expand Down
12 changes: 5 additions & 7 deletions src/md5.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: md5.c,v 1.7 2004/05/28 15:10:27 millert Exp $ */
/* $OpenBSD: md5.c,v 1.12 2020/10/13 04:42:28 guenther Exp $ */

/*
* This code implements the MD5 message-digest algorithm.
Expand Down Expand Up @@ -39,7 +39,7 @@
(cp)[1] = (value) >> 8; \
(cp)[0] = (value); } while (0)

static uint8_t PADDING[MD5_BLOCK_LENGTH] = {
static const uint8_t PADDING[MD5_BLOCK_LENGTH] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Expand Down Expand Up @@ -128,11 +128,9 @@ MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *ctx)
int i;

MD5Pad(ctx);
if (digest != NULL) {
for (i = 0; i < 4; i++)
PUT_32BIT_LE(digest + i * 4, ctx->state[i]);
memset(ctx, 0, sizeof(*ctx));
}
for (i = 0; i < 4; i++)
PUT_32BIT_LE(digest + i * 4, ctx->state[i]);
memset(ctx, 0, sizeof(*ctx));
}


Expand Down

0 comments on commit b2e54bc

Please sign in to comment.