🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #62422

Re: xBin (Power-Post 2003 - requesting input from authorities..)

#62422
From: Rene
Date: Mon, 23 Dec 2002 23:56
149 lines
9056 bytes
curt@kcwc.com (Curt Welch) wrote:
> > let me see if I understand you correctly.  let's say it's a 13 part
> > posting.
[nifty ASCII art deleted]
> > part 1 should include its own hash, as well as a, g, j, and l.
> Right idea, wrong answer.
>
> To verify the data in the part, you must re-calculate the hash from the
> data. to see if it matches.  So the hashes you listed are the ones which
> you must calculate, not the ones which will be included in the header.
> So what you include with part 1 is hash 2, b, h, and k.  What the code
> calcuates are the hash values a, g, j, l when it wants to verify the data
> is part of a file with a tree-hash value of l.

I *thought* there must be more to that tree than just that... yes this
makes *much* more sense now. You didn't tell until now though :) Still, if
you first get all the leave-hashes, you can construct the tree or the file
hash just as well. Your method however distributes the hashes over all the
parts. This adds another layer of security (at the costs of more
complexity) on top of the system. An attacker cannot start to manipulate
message-parts until he has all the hashes in the nodes and only then can
start to create parts that look as if they are valid by having most hashes
correct. (but only most, he fails anyway)

By using this system, a newsreader can intelligently identify bogus parts
by just looking at the xbin-header. (because he most likely got some of the
upper hashes after having downloaded some valid parts) and can dismiss
posts that have the wrong hashes there.

> A posted part can included multiple blocks.  So lets say a single article
> included blocks 4 and 5.  To recalcute the tree-hash for the file, you
> would need to include the hash values a, 3, on one side, and 6, d, and k
> from the other.  The order of the hash values in the Signature: header

This makes the algorithm quite a bit more complicated. Only needing to
fetch and calculate one leave (and the way upwards to the root) is quite
easy, having to cope with an arbitrary number of spanned leave-branches
makes it more complicated. But still doable.

> the blocks in the file.  Which hash values need to be included is known
> by the program because The signature header starts with the full file
> hash (which is only requried there since I'm suggesting not including the
> full 160 bits in the Message-ID), and then is followed by the hash values
> required from the file in the correct order.

Well why not include the hash in full? 160 bits are 20 chars, but what's
more, each char is only a 0..9 or a a..f. You can further mangle them into
something smaller using a larger alphabet...

I'd rather spend the full 20 chars than to risk there is a "natural
collision" because of the truncated hash length.

> You don't even need to do that if you trust the strength of the hash
> (which is the whole point here).  All you need to do is re-calcaute the
> file-hash and make sure it matches the full-file hash of the file you are
> trying to download.

It's even quite fast, because all those partial hashes can be stored in
memory. And hashing of in-memory data is fast. The slowest part of it will
be the hashing of the just downloaded block - and that needs to be done
anyways to ensure integrity.

> This works much like a normal hash of the entire file in terms of
> verifying that the data is what you were looking for.  The advantage of
> the tree hash is that you can calcaute the entire file hash given only a
> small segment of data from the file, and a small handfull of hash values
> for the rest of the file.  The hash values in the signature are data as
> well because they all get hashed.  So it's just as hard to fake those as
> it is to fake the file data.

Yes, and especially, if someone wants to make a "good fake", which looks
mostly ok, he needs to know all the hashes of the tree. But he will get
them only once all parts of the file are already posted, at which time his
attack will probably not even confuse newsreader.

> You just include the hashes which outline the internal tree.  The
> internal tree hash values are re-calcuated from the data to prove the
> data is correct.

...and since parts of the internal nodes are stored in the header-line, a
newsreader can compare his limited knowledge of the tree he already has and
quickly decide if that part is a candidate, or if it is an impossible
addition - and not even bother downloading it.

> The number of hash values in the signature is worse case something like 2
> * log2(N) where N is the number of hash blocks in the file.  Most times,
> the number is closer to just log2(N).

I'd have to look into what happens if one article spans many branches. But
I think 2*log2(N) is the upper bound.

> > you mentioned the problems finding a block size which fits the
> > uuencode line length.  I think you should ignore that problem.  if the
> > software is written correctly, it will handle the "short" line without
> > problems.  also, neither MIME nor yEnc has this problem, so I think
> > it's unnecessary to make the block size something obscure just for bug
> > compatibility with uudecode.
> I thought that too. I assumed block sizes which were a power of 2 would
> be more logical.  But in fact, the job of calculating the hash in the
> first place is a problem of reading "blocks" which match the hash you
> use.  for SHA-1, it works in 20 byte blocks.  So it's working with an
> obscure block size already which fails to fall correctly across any
> power-of-two sized blocks.  Yet that really has no measurable effect on

No that's wrong Curt. SHA-1, like the MD4 and MD5 algorithms with which I
worked, don't care at all what the input size is. Actually, they measure it
in bit, not byte. You can feed them 0 bit input data, you can feed them 1
bit input data or you can feed them 324463452344523bit input data. They
simply don't care. They *do* an internal alignment but in the case of
SHA-1, I just skimmed through the documentation
(http://www.itl.nist.gov/fipspubs/fip180-1.htm) and SHA-1 works internally
with a block size of 512bits or 64 bytes. Still you don't need to align
yourself to that size. If you don't feed it an aligned bit-stream, the
algorithm adds padding on its own. Its output value is always 20 bytes,
however, it eats what you feed it. You absolutely don't need to constrain
yourself to anything just for the hash-algorithm.

For the sake of speed using file i/o, I'd recommend a multiple of 1024 or
4096, whatever the OS' are best suited to process atomically.

> the speed of calculating the hash because the problem is always a simple
> sequential scan of the file which is well optimized on all systems
> already.

...provided you use a buffer size they are optimized for. I think a
multiple of 1024 is a safe bet here.

> The issues which did seem important as that the larger the block size,
> the less hash values you need in the signature.  So bigger is better for
> that. But since parts must be split on block boundries, the bigger the
> block, the less granularity you get when trying to pick an article size,
> which means if you try to make all the articles the same size (a good
> thing), the ability to do that is limited by your block size.

Let's just say, I'd try to keep it below 1024 blocks(that's 2^10 so 10
levels in the tree) for todays normal sized file (whatever that is...)
maybe a bit bigger considering future developements. The algorithm, of
course, doesn't care about the levels, however the more there are, the more
memory and cpu cycles will need to be used to traverse it.

> 4500 seemed to be a good number for uuencode as well as a reasonable
> balance between granularity and hash signature size.

Well as I said, I'd make it a multiple of the OS' file io system.

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Technical Details
Message-ID: <20021223185652.700$BS@newsreader.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed3.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
References: <cdda0v4h6t52ov7abf1j0qkpo843itf4se@4ax.com> <cfka0vsbjdlbdmtv2gg8qnehok033qh5f1@4ax.com> <20021223041127.986$6M_-_@newsreader.com> <1rfzsoaacf.fsf@vingodur.ifi.uio.no> <20021223180543.105$Wn@newsreader.com>

Show Full Headers
Complete Article Headers
Message-ID: <20021223185652.700$BS@newsreader.com>
Subject: Re: xBin (Power-Post 2003 - requesting input from authorities..)
Date: Mon, 23 Dec 2002 23:56:52 +0000
From: Rene <invalid@email.addr>
References: <cdda0v4h6t52ov7abf1j0qkpo843itf4se@4ax.com> <cfka0vsbjdlbdmtv2gg8qnehok033qh5f1@4ax.com> <20021223041127.986$6M_-_@newsreader.com> <1rfzsoaacf.fsf@vingodur.ifi.uio.no> <20021223180543.105$Wn@newsreader.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed3.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
Organization: NewsReader.Com Subscriber
Newsgroups: news.software.nntp
X-Trace: NewsReader.Com 9mnzI.SjeNaYInfj/kul2.JS1CkXwrBu6OOIxEK.iOZnV@+
Lines: 148