summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS.md8
-rw-r--r--checksum.c33
-rw-r--r--lib/md-defines.h19
-rw-r--r--lib/mdigest.h1
-rw-r--r--rsync.1.md3
5 files changed, 63 insertions, 1 deletions
diff --git a/NEWS.md b/NEWS.md
index cbeb31b7..3535e21b 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -9,7 +9,13 @@
### ENHANCEMENTS:
- Added negotiated daemon-auth support that allows a stronger checksum digest
- to be used.
+ to be used. Added SHA512, SHA256, and SHA1 digests to MD5 & MD4. These new
+ digests are at the highest priority in the new negotiation list.
+
+- Added support for SHA1, SHA256, and SHA512 digests in file checksums. While
+ This tends to be overkill, if someone needs it, it is available. These
+ overly-long checksums are at the lowest priority in the normal checksum
+ negotation list.
### PACKAGING RELATED:
diff --git a/checksum.c b/checksum.c
index 4fa8faa0..68ea0fa0 100644
--- a/checksum.c
+++ b/checksum.c
@@ -57,6 +57,15 @@ struct name_num_item valid_checksums_items[] = {
#endif
{ CSUM_MD5, NNI_BUILTIN|NNI_EVP, "md5", NULL },
{ CSUM_MD4, NNI_BUILTIN|NNI_EVP, "md4", NULL },
+#ifdef SHA_DIGEST_LENGTH
+ { CSUM_SHA1, NNI_EVP, "sha1", NULL },
+#endif
+#ifdef SHA256_DIGEST_LENGTH
+ { CSUM_SHA256, NNI_EVP, "sha256", NULL },
+#endif
+#ifdef SHA512_DIGEST_LENGTH
+ { CSUM_SHA512, NNI_EVP, "sha512", NULL },
+#endif
{ CSUM_NONE, 0, "none", NULL },
{ 0, 0, NULL, NULL }
};
@@ -66,6 +75,15 @@ struct name_num_obj valid_checksums = {
};
struct name_num_item valid_auth_checksums_items[] = {
+#ifdef SHA512_DIGEST_LENGTH
+ { CSUM_SHA512, NNI_EVP, "sha512", NULL },
+#endif
+#ifdef SHA256_DIGEST_LENGTH
+ { CSUM_SHA256, NNI_EVP, "sha256", NULL },
+#endif
+#ifdef SHA_DIGEST_LENGTH
+ { CSUM_SHA1, NNI_EVP, "sha1", NULL },
+#endif
{ CSUM_MD5, NNI_BUILTIN|NNI_EVP, "md5", NULL },
{ CSUM_MD4, NNI_BUILTIN|NNI_EVP, "md4", NULL },
{ 0, 0, NULL, NULL }
@@ -211,6 +229,18 @@ int csum_len_for_type(int cst, BOOL flist_csum)
return MD4_DIGEST_LEN;
case CSUM_MD5:
return MD5_DIGEST_LEN;
+#ifdef SHA_DIGEST_LENGTH
+ case CSUM_SHA1:
+ return SHA_DIGEST_LENGTH;
+#endif
+#ifdef SHA256_DIGEST_LENGTH
+ case CSUM_SHA256:
+ return SHA256_DIGEST_LENGTH;
+#endif
+#ifdef SHA512_DIGEST_LENGTH
+ case CSUM_SHA512:
+ return SHA512_DIGEST_LENGTH;
+#endif
case CSUM_XXH64:
case CSUM_XXH3_64:
return 64/8;
@@ -236,6 +266,9 @@ int canonical_checksum(int csum_type)
break;
case CSUM_MD4:
case CSUM_MD5:
+ case CSUM_SHA1:
+ case CSUM_SHA256:
+ case CSUM_SHA512:
return -1;
case CSUM_XXH64:
case CSUM_XXH3_64:
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"
diff --git a/rsync.1.md b/rsync.1.md
index c62e82ea..bd9182a7 100644
--- a/rsync.1.md
+++ b/rsync.1.md
@@ -1727,6 +1727,9 @@ expand it.
- `xxh64` (aka `xxhash`)
- `md5`
- `md4`
+ - `sha1`
+ - `sha256`
+ - `sha512`
- `none`
Run `rsync --version` to see the default checksum list compiled into your