ENHANCEMENTS:
- - Various checksum enhancements, including x86_64 optimizations for the
- rolling checksum, optimizations for the MD5 checksums, the addition of
- xxhash checksums, and a simple checksum negotation heuristic that will
- ensure that it is easier to add improved checksum algorithms in the
+ - Various checksum enhancements, including the optional use of openssl's
+ MD5 checksum algorithms, x86_64 optimizations for the rolling checksum,
+ x86_64 optimizations for the (non-openssl) MD5 checksum, the addition of
+ xxhash checksum support, and a simple checksum negotation heuristic that
+ will ensure that it is easier to add new checksum algorithms in the
future. Currently the x86_64 optimizations require the use of the
--enable-simd flag to configure, but they will probably be enabled by
default in the near future.
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
+ * In addition, as a special exception, the copyright holders give
+ * permission to dynamically link rsync with the OpenSSL and xxhash
+ * libraries when those libraries are being distributed in compliance
+ * with their license terms, and to distribute a dynamically linked
+ * combination of rsync and these libraries. This is also considered
+ * to be covered under the GPL's System Libraries exception.
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#ifdef SUPPORT_XXHASH
#include "xxhash.h"
#endif
+#ifdef USE_OPENSSL
+#include "openssl/md5.h"
+#endif
extern int am_server;
extern int local_server;
#define MAX_CHECKSUM_LIST 1024
+#ifndef USE_OPENSSL
+#define MD5_CTX md_context
+#define MD5_Init md5_begin
+#define MD5_Update md5_update
+#define MD5_Final(digest, cptr) md5_result(cptr, digest)
+#endif
+
int xfersum_type = 0; /* used for the file transfer checksums */
int checksum_type = 0; /* used for the pre-transfer (--checksum) checksums */
const char *negotiated_csum_name = NULL;
void get_checksum2(char *buf, int32 len, char *sum)
{
md_context m;
+ MD5_CTX m5;
switch (xfersum_type) {
case CSUM_MD5: {
uchar seedbuf[4];
- md5_begin(&m);
+ MD5_Init(&m5);
if (proper_seed_order) {
if (checksum_seed) {
SIVALu(seedbuf, 0, checksum_seed);
- md5_update(&m, seedbuf, 4);
+ MD5_Update(&m5, seedbuf, 4);
}
- md5_update(&m, (uchar *)buf, len);
+ MD5_Update(&m5, (uchar *)buf, len);
} else {
- md5_update(&m, (uchar *)buf, len);
+ MD5_Update(&m5, (uchar *)buf, len);
if (checksum_seed) {
SIVALu(seedbuf, 0, checksum_seed);
- md5_update(&m, seedbuf, 4);
+ MD5_Update(&m5, seedbuf, 4);
}
}
- md5_result(&m, (uchar *)sum);
+ MD5_Final((uchar *)sum, &m5);
break;
}
case CSUM_MD4:
struct map_struct *buf;
OFF_T i, len = st_p->st_size;
md_context m;
+ MD5_CTX m5;
int32 remainder;
int fd;
switch (checksum_type) {
case CSUM_MD5:
- md5_begin(&m);
+ MD5_Init(&m5);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
- md5_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
+ MD5_Update(&m5, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
remainder = (int32)(len - i);
if (remainder > 0)
- md5_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
+ MD5_Update(&m5, (uchar *)map_ptr(buf, i, remainder), remainder);
- md5_result(&m, (uchar *)sum);
+ MD5_Final((uchar *)sum, &m5);
break;
case CSUM_MD4:
case CSUM_MD4_OLD:
static int32 sumresidue;
static md_context md;
+static MD5_CTX m5;
static int cursum_type;
#ifdef SUPPORT_XXHASH
XXH64_state_t* xxh64_state = NULL;
switch (csum_type) {
case CSUM_MD5:
- md5_begin(&md);
+ MD5_Init(&m5);
break;
case CSUM_MD4:
mdfour_begin(&md);
{
switch (cursum_type) {
case CSUM_MD5:
- md5_update(&md, (uchar *)p, len);
+ MD5_Update(&m5, (uchar *)p, len);
break;
case CSUM_MD4:
case CSUM_MD4_OLD:
{
switch (cursum_type) {
case CSUM_MD5:
- md5_result(&md, (uchar *)sum);
+ MD5_Final((uchar *)sum, &m5);
break;
case CSUM_MD4:
case CSUM_MD4_OLD:
netdb.h malloc.h float.h limits.h iconv.h libcharset.h langinfo.h \
sys/acl.h acl/libacl.h attr/xattr.h sys/xattr.h sys/extattr.h \
popt.h popt/popt.h linux/falloc.h netinet/in_systm.h netinet/ip.h \
- zlib.h xxhash.h)
+ zlib.h xxhash.h openssl/md5.h)
AC_HEADER_MAJOR_FIXED
-dnl Do you want to disable use of xxhash checksums
+AC_MSG_CHECKING([whether to enable use of openssl crypto library])
+AC_ARG_ENABLE([openssl],
+ AS_HELP_STRING([--disable-openssl],[disable openssl crypto library]))
+AH_TEMPLATE([USE_OPENSSL],
+[Undefine if you do not want to use openssl crypto library. By default this is defined.])
+if test x"$enable_openssl" != x"no" && test x"$ac_cv_header_openssl_md5_h" = x"yes"; then
+ AC_MSG_RESULT(yes)
+ AC_SEARCH_LIBS(MD5_Init, crypto)
+ AC_DEFINE(USE_OPENSSL)
+else
+ AC_MSG_RESULT(no)
+fi
+
+AC_MSG_CHECKING([whether to enable the xxhash support])
AC_ARG_ENABLE([xxhash],
AS_HELP_STRING([--disable-xxhash],[disable xxhash checksums]))
AH_TEMPLATE([SUPPORT_XXHASH],
[Undefine if you do not want xxhash checksums. By default this is defined.])
-if test x"$enable_xxhash" != x"no"; then
- if test x"$ac_cv_header_xxhash_h" = x"yes"; then
- AC_SEARCH_LIBS(XXH64_createState, xxhash)
- AC_DEFINE(SUPPORT_XXHASH)
- fi
+if test x"$enable_xxhash" != x"no" && test x"$ac_cv_header_xxhash_h" = x"yes"; then
+ AC_MSG_RESULT(yes)
+ AC_SEARCH_LIBS(XXH64_createState, xxhash)
+ AC_DEFINE(SUPPORT_XXHASH)
+else
+ AC_MSG_RESULT(no)
fi
AC_CACHE_CHECK([if makedev takes 3 args],rsync_cv_MAKEDEV_TAKES_3_ARGS,[