summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2022-09-10 10:23:36 -0700
committerWayne Davison <wayne@opencoder.net>2022-09-10 11:48:44 -0700
commitae16850dc58e884eb9f5cb7f772342b2db28f471 (patch)
treead0fb1728258dcc927eeef5219ac32add0b0f0ef /lib
parent7e2711bb2b4b30bc842dd8670c34a87e2ca0c2df (diff)
downloadrsync-ae16850dc58e884eb9f5cb7f772342b2db28f471.tar.gz
Add support for various SHA checksum digests
The main purpose of the SHA checksums are to allow the daemon auth code to pick a stonger digest method when negotiating the auth digest to use. However, the SHA digests are also available for use in file checksums, should someon really want to use one of them. The new digests are listed from strongest to weakest at the start of the daemon auth list, giving them the highest priority. The new digests are listed from weakest to strongest near the end of the checksum list, giving them the lowest priority of use for file checksums.
Diffstat (limited to 'lib')
-rw-r--r--lib/md-defines.h19
-rw-r--r--lib/mdigest.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/md-defines.h b/lib/md-defines.h
index 5adf19f8..6ef6a689 100644
--- a/lib/md-defines.h
+++ b/lib/md-defines.h
@@ -1,8 +1,24 @@
/* Keep this simple so both C and ASM can use it */
+/* These allow something like CFLAGS=-DDISABLE_SHA512_DIGEST */
+#ifdef DISABLE_SHA256_DIGEST
+#undef SHA256_DIGEST_LENGTH
+#endif
+#ifdef DISABLE_SHA512_DIGEST
+#undef SHA512_DIGEST_LENGTH
+#endif
+
#define MD4_DIGEST_LEN 16
#define MD5_DIGEST_LEN 16
+#if defined SHA512_DIGEST_LENGTH
+#define MAX_DIGEST_LEN SHA512_DIGEST_LENGTH
+#elif defined SHA256_DIGEST_LENGTH
+#define MAX_DIGEST_LEN SHA256_DIGEST_LENGTH
+#elif defined SHA_DIGEST_LENGTH
+#define MAX_DIGEST_LEN SHA_DIGEST_LENGTH
+#else
#define MAX_DIGEST_LEN MD5_DIGEST_LEN
+#endif
#define CSUM_CHUNK 64
@@ -16,3 +32,6 @@
#define CSUM_XXH64 6
#define CSUM_XXH3_64 7
#define CSUM_XXH3_128 8
+#define CSUM_SHA1 9
+#define CSUM_SHA256 10
+#define CSUM_SHA512 11
diff --git a/lib/mdigest.h b/lib/mdigest.h
index 1e816901..9d52ef5f 100644
--- a/lib/mdigest.h
+++ b/lib/mdigest.h
@@ -1,6 +1,7 @@
/* The include file for both the MD4 and MD5 routines. */
#ifdef USE_OPENSSL
+#include <openssl/sha.h>
#include <openssl/evp.h>
#endif
#include "md-defines.h"