Promoted to rsync.
[rsync.git/patches.git] / sha1.diff
diff --git a/sha1.diff b/sha1.diff
deleted file mode 100644 (file)
index 45596d3..0000000
--- a/sha1.diff
+++ /dev/null
@@ -1,116 +0,0 @@
-This patch adds sha1 to the checksum code when the openssl library is available.
-It also enables SHA1 checksum hashing in the daemon auth code.
-
-To use this patch, run these commands for a successful build:
-
-    patch -p1 <patches/fix-checksums.diff
-    patch -p1 <patches/sha1.diff
-    ./configure                               (optional if already run)
-    make
-
-based-on: patch/master/fix-checksums
-diff --git a/checksum.c b/checksum.c
---- 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
---- a/lib/md-defines.h
-+++ b/lib/md-defines.h
-@@ -1,8 +1,19 @@
- /* Keep this simple so both C and ASM can use it */
-+/*#undef SHA512_DIGEST_LENGTH*/
-+/*#undef SHA256_DIGEST_LENGTH*/
-+
- #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 +27,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
---- 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"