summaryrefslogtreecommitdiff
path: root/checksum.c
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2020-05-28 12:05:54 -0700
committerWayne Davison <wayne@opencoder.net>2020-05-28 12:33:36 -0700
commitd7521f54282fe7dc7c259a52624a0ac75ccb8f11 (patch)
treeb1ad9977ac646e160b0e9b20aeec79d4ae1f67ce /checksum.c
parentc7f10de4426375fc721ecd815ceddae7766c6598 (diff)
downloadrsync-d7521f54282fe7dc7c259a52624a0ac75ccb8f11.tar.gz
The xxh* checksums don't need to be reversed on output.
Diffstat (limited to 'checksum.c')
-rw-r--r--checksum.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/checksum.c b/checksum.c
index 5576ede9..cf3000d9 100644
--- a/checksum.c
+++ b/checksum.c
@@ -162,9 +162,29 @@ int csum_len_for_type(int cst, BOOL flist_csum)
return 0;
}
+/* Returns 0 if the checksum is not canonical (i.e. it includes a seed value).
+ * Returns 1 if the public sum order matches our internal sum order.
+ * Returns -1 if the public sum order is the reverse of our internal sum order.
+ */
int canonical_checksum(int csum_type)
{
- return csum_type >= CSUM_MD4 ? 1 : 0;
+ switch (csum_type) {
+ case CSUM_NONE:
+ case CSUM_MD4_ARCHAIC:
+ case CSUM_MD4_OLD:
+ case CSUM_MD4_BUSTED:
+ break;
+ case CSUM_MD4:
+ case CSUM_MD5:
+ return -1;
+#ifdef SUPPORT_XXHASH
+ case CSUM_XXH64:
+ return 1;
+#endif
+ default: /* paranoia to prevent missing case values */
+ exit_cleanup(RERR_UNSUPPORTED);
+ }
+ return 0;
}
#ifndef HAVE_SIMD /* See simd-checksum-*.cpp. */