summaryrefslogtreecommitdiff
path: root/lib/md5.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/md5.c')
-rw-r--r--lib/md5.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/md5.c b/lib/md5.c
index 4baa9638..a2eebdb0 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -2,6 +2,7 @@
* RFC 1321 compliant MD5 implementation
*
* Copyright (C) 2001-2003 Christophe Devine
+ * Copyright (C) 2007-2020 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +20,7 @@
#include "rsync.h"
+#ifndef USE_OPENSSL
void md5_begin(md_context *ctx)
{
ctx->A = 0x67452301;
@@ -146,6 +148,10 @@ static void md5_process(md_context *ctx, const uchar data[CSUM_CHUNK])
ctx->D += D;
}
+#if defined(HAVE_SIMD) && (CSUM_CHUNK == 64)
+extern void md5_process_asm(md_context *ctx, const void *data, size_t num);
+#endif
+
void md5_update(md_context *ctx, const uchar *input, uint32 length)
{
uint32 left, fill;
@@ -170,11 +176,20 @@ void md5_update(md_context *ctx, const uchar *input, uint32 length)
left = 0;
}
+#if defined(HAVE_SIMD) && (CSUM_CHUNK == 64)
+ if (length >= CSUM_CHUNK) {
+ uint32 chunks = length / CSUM_CHUNK;
+ md5_process_asm(ctx, input, chunks);
+ length -= chunks * CSUM_CHUNK;
+ input += chunks * CSUM_CHUNK;
+ }
+#else
while (length >= CSUM_CHUNK) {
md5_process(ctx, input);
length -= CSUM_CHUNK;
input += CSUM_CHUNK;
}
+#endif
if (length)
memcpy(ctx->buffer + left, input, length);
@@ -206,6 +221,9 @@ void md5_result(md_context *ctx, uchar digest[MD5_DIGEST_LEN])
SIVALu(digest, 8, ctx->C);
SIVALu(digest, 12, ctx->D);
}
+#endif
+
+#ifdef TEST_MD5
void get_md5(uchar *out, const uchar *input, int n)
{
@@ -215,8 +233,6 @@ void get_md5(uchar *out, const uchar *input, int n)
md5_result(&ctx, out);
}
-#ifdef TEST_MD5
-
#include <stdlib.h>
#include <stdio.h>