From c6da2325e39600995ac5b586be986dc553543060 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Sat, 4 May 2013 15:59:29 +0530 Subject: [PATCH] Allow SKEIN to be used as a Global Dedupe chunk lookup hash. --- rabin/global/dedupe_config.c | 18 ++++++++++++++++-- rabin/rabin_dedup.c | 2 +- utils/utils.h | 3 +++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/rabin/global/dedupe_config.c b/rabin/global/dedupe_config.c index b0368c5..29bc70b 100644 --- a/rabin/global/dedupe_config.c +++ b/rabin/global/dedupe_config.c @@ -128,6 +128,12 @@ get_cksum_type(char *cksum_name) } else if (strcmp(cksum_name, "KECCAK512") == 0) { return (CKSUM_KECCAK512); + + } else if (strcmp(cksum_name, "SKEIN256") == 0) { + return (CKSUM_SKEIN256); + + } else if (strcmp(cksum_name, "SKEIN512") == 0) { + return (CKSUM_SKEIN512); } return (CKSUM_INVALID); } @@ -155,6 +161,12 @@ get_cksum_str(cksum_t ck) } else if (ck == CKSUM_KECCAK512) { return ("KECCAK512"); + + } else if (ck == CKSUM_SKEIN256) { + return ("SKEIN256"); + + } else if (ck == CKSUM_SKEIN512) { + return ("SKEIN512"); } return ("INVALID"); } @@ -165,10 +177,12 @@ get_cksum_sz(cksum_t ck) if (ck == CKSUM_CRC64) { return (8); - } else if (ck == CKSUM_SHA256 || ck == CKSUM_BLAKE256 || ck == CKSUM_KECCAK256) { + } else if (ck == CKSUM_SHA256 || ck == CKSUM_BLAKE256 || ck == CKSUM_KECCAK256 || + ck == CKSUM_SKEIN256) { return (32); - } else if (ck == CKSUM_SHA512 || ck == CKSUM_BLAKE512 || ck == CKSUM_KECCAK512) { + } else if (ck == CKSUM_SHA512 || ck == CKSUM_BLAKE512 || ck == CKSUM_KECCAK512 || + ck == CKSUM_SKEIN512) { return (64); } return (0); diff --git a/rabin/rabin_dedup.c b/rabin/rabin_dedup.c index bcc6322..d0fa12d 100755 --- a/rabin/rabin_dedup.c +++ b/rabin/rabin_dedup.c @@ -221,7 +221,7 @@ create_dedupe_context(uint64_t chunksize, uint64_t real_chunksize, int rab_blk_s chunk_cksum = 0; if ((ck = getenv("PCOMPRESS_CHUNK_HASH_GLOBAL")) != NULL) { - if (get_checksum_props(ck, &chunk_cksum, &cksum_bytes, &mac_bytes, 0) != 0 || + if (get_checksum_props(ck, &chunk_cksum, &cksum_bytes, &mac_bytes, 1) != 0 || strcmp(ck, "CRC64") == 0) { fprintf(stderr, "Invalid PCOMPRESS_CHUNK_HASH_GLOBAL. Reverting to default.\n"); chunk_cksum = -1; diff --git a/utils/utils.h b/utils/utils.h index f6c9720..ce62866 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -160,6 +160,9 @@ typedef enum { * Backwards compatibility options. SKEIN in release 1.2 was replaced with * Blake2 from 1.3 onwards (for sheer speed of Blake2). We want to be able * to decode archives created with 1.2. New archives do not use SKEIN. + * + * However SKEIN can be used as a chunk/block hash for Global Deduplication. + * So it will not be removed. */ CKSUM_SKEIN256 = 0x800, CKSUM_SKEIN512 = 0x900,