URI: 
       Xor the given seed into the buzhash table - dedup - deduplicating backup program
  HTML git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 042e687f46e7c334def143a387c332e6884cd078
   DIR parent c86adacd4c9ec47d68823fbb768ec3fc7e5c23c0
  HTML Author: sin <sin@2f30.org>
       Date:   Sun, 19 May 2019 18:52:14 +0300
       
       Xor the given seed into the buzhash table
       
       This is the first step to try and mitigate against fingerprinting
       attacks.  The current code does not have any effect on the initial
       state of the buzhash algorithm.
       
       Diffstat:
         M chunker.c                           |      10 ++++++++--
         M chunker.h                           |       2 +-
         M dup-pack.c                          |       3 ++-
       
       3 files changed, 11 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/chunker.c b/chunker.c
       @@ -17,6 +17,7 @@ struct chunker {
                size_t maxsize;
                size_t mask;
                size_t winsize;
       +        uint32_t seed;
        };
        
        /*
       @@ -28,7 +29,7 @@ struct chunker {
         * exactly 50% chance that a XOR operation would flip all the bits in
         * the hash.
         */
       -static const uint32_t buztbl[] = {
       +static uint32_t buztbl[] = {
                0xbc9fa594,0x30a8f827,0xced627a7,0xdb46a745,0xcfa4a9e8,0x77cccb59,0xddb66276,0x3adc532f,
                0xfe8b67d3,0x8155b59e,0x0c893666,0x1d757009,0x17394ee4,0x85d94c07,0xcacd52da,0x076c6f79,
                0xead0a798,0x6c7ccb4a,0x2639a1b8,0x3aa5ae32,0x3e6218d2,0xb290d980,0xa5149521,0x4b426119,
       @@ -124,9 +125,10 @@ cgetsize(struct chunker *c)
        
        struct chunker *
        copen(int fd, size_t minsize, size_t maxsize,
       -      size_t mask, size_t winsize)
       +      size_t mask, size_t winsize, uint32_t seed)
        {
                struct chunker *c;
       +        size_t i;
        
                c = calloc(1, sizeof(*c));
                if (c == NULL) {
       @@ -146,6 +148,10 @@ copen(int fd, size_t minsize, size_t maxsize,
                c->maxsize = maxsize;
                c->mask = mask;
                c->winsize = winsize;
       +        c->seed = seed;
       +
       +        for (i = 0; i < sizeof(buztbl) / sizeof(buztbl[0]); i++)
       +                buztbl[i] ^= c->seed;
                return c;
        }
        
   DIR diff --git a/chunker.h b/chunker.h
       @@ -1,6 +1,6 @@
        struct chunker;
        
       -extern struct chunker *copen(int, size_t, size_t, size_t, size_t);
       +extern struct chunker *copen(int, size_t, size_t, size_t, size_t, uint32_t);
        extern void cclose(struct chunker *);
        extern ssize_t cfill(struct chunker *);
        extern void *cget(struct chunker *, size_t *);
   DIR diff --git a/dup-pack.c b/dup-pack.c
       @@ -4,6 +4,7 @@
        #include <err.h>
        #include <fcntl.h>
        #include <limits.h>
       +#include <stdint.h>
        #include <stdio.h>
        #include <stdlib.h>
        #include <unistd.h>
       @@ -62,7 +63,7 @@ pack(struct sctx *sctx, struct bctx *bctx)
        {
                struct chunker *c;
        
       -        if ((c = copen(0, BSIZEMIN, BSIZEMAX, HMASKBITS, WINSIZE)) == NULL)
       +        if ((c = copen(0, BSIZEMIN, BSIZEMAX, HMASKBITS, WINSIZE, 0)) == NULL)
                        printerr("copen");
        
                while (cfill(c) > 0) {