public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Alex Elder <aelder@sgi.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH v3, 03/16] xfsprogs: metadump: drop unneeded use of a random character
Date: Thu, 24 Feb 2011 12:31:35 +1100	[thread overview]
Message-ID: <20110224013135.GQ3166@dastard> (raw)
In-Reply-To: <201102182121.p1ILL1x7029051@stout.americas.sgi.com>

On Fri, Feb 18, 2011 at 03:21:01PM -0600, Alex Elder wrote:
> With the exception of the last five bytes, an obfuscated name is
> simply a random string of (acceptable) characters.  The last five
> bytes are chosen, based on the random portion before them, such that
> the resulting obfuscated name has the same hash value as the
> original name.
> 
> This is done by essentially working backwards from the difference
> between the original hash and the hash value computed for the
> obfuscated name so far, picking final bytes based on how that
> difference gets manipulated by completing the hash computation.
> 
> Of those last 5 bytes, all but the upper half of the first one are
> completely determined by this process.  The upper part of the first
> one is currently computed as four random bits, just like all the
> earlier bytes in the obfuscated name.
> 
> It is not actually necessary to randomize these four upper bits,
> and we can simply make them 0.
> 
> Here's why:
> - The final bytes are pulled directly from the hash difference
>   mentioned above, with the lowest-order byte of the hash
>   determining the last character used in the name.
> - The upper nibble of the 5th-to-last byte in a name will affect the
>   lowest 4 bits of hash value and therefore the last byte of the
>   name.  Those four bits are combined with the hash computed from
>   the random characters generated earlier.
> - Because those earlier bytes were random, their hash value will
>   also be random, and in particular, the lowest-order four bits of
>   the hash will be random.
> - So it doesn't matter whether we choose all 0 bits or some other
>   random value for that upper nibble of the byte at offset
>   (namelen - 5).  When it's combined with the hash, the last byte of
>   the name will be random either way.
> 
> Therefore we will choose to use all 0's for that upper nibble.
> 
> Doing this simplifies the generation of two of the final five
> characters, and makes all five of them get computed in a consistent
> way.  We'll still get some small bit of obfuscation for even
> 5-character names, since the upper bits of the first character will
> generally be cleared and likely different from the original.
> 
> Add the use of a mask in the one case it wasn't used to be even more
> consistent.
> 
> Signed-off-by: Alex Elder <aelder@sgi.com>

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

      reply	other threads:[~2011-02-24  1:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-18 21:21 [PATCH v3, 03/16] xfsprogs: metadump: drop unneeded use of a random character Alex Elder
2011-02-24  1:31 ` Dave Chinner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110224013135.GQ3166@dastard \
    --to=david@fromorbit.com \
    --cc=aelder@sgi.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox