Article View: news.software.nntp
Article #63297Re: Content-SHA1-Tree
From: Curt Welch
Date: Sun, 19 Jan 2003 07:35
Date: Sun, 19 Jan 2003 07:35
388 lines
19379 bytes
19379 bytes
Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
> [Curt Welch]:
> >
> > Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote:
> > > I thought I'd try my hand at writing a specification of
> > > Content-SHA1-Tree, but before foisting it on the MIME people, I
> > > guess it's best that people here (at least Curt) has a look at it
> > > and sees that it is right.
> >
> > The first issue is the name. I'm not sure what it should
> > be. SHA1-Tree implies to me that it's either just the hash value
> > of the content, or it's the entire tree of hash values. But the
> > xBin-Siganture header is not a hash value of the content of the
> > article, it's hash values of all the data from the full file which
> > is not included in this article.
> >
> > MIME supports some digital signature standards doesn't it? What
> > type of MIME headers are used to hold signature data? Is it a
> > Content-? header?
>
> they use a multipart with two content-types, application/pkcs7-mime
> and application/pkcs7-signature.
>
> > I'm thinking you need something like Content-Xbin-Signature:
> > instead of trying to think of it as a "generic" hash system which
> > is what happens when you use "SHA1-Tree".
>
> perhaps, but SHA1-Tree is more descriptive (and not strictly wrong)
> than Xbin-Signature. SHA1-Tree sounds more sexy, Xbin-Signature
> sounds like something cooked up in a bedroom. perhaps
> "SHA1-Signature"? or "Tree-Signature"? not a big issue for me,
> though.
The important fact is that it's data which includes not only the idea of a
tree hash build on SHA1, but it also includes a defined block size (unless
you want to include the block size in the header data somewhere), and, it's
not just a hash value for the full file, but it's the hash of the missing
data, which makes it even more unlike anything else. Nothing comes to mind
as a "correct" name for this data. "signature" is the closesest I've been
able to come up with but even that doesn't really fit with the more tyical
use of the word for these things. Well, maybe something like "checksum" or
"CRC" really fits the concept beter because it's information used to verify
the integrety of the data.
Is there a generic name/word for checksum or CRC?
It seems the header should be something like
Content-<standard>-<generic-word-for-checksum>:
Where <standard> is some name which refers to the standard used (xBin has
been the working title here). SHA1-22500-TreeHash would be stupid
alternative but that's the idea I'm after.
> > In the MIME way of things, if you needed the full hash in the
> > headers I would expect it to show up either in a different header,
> > (Content-Full-File-XBin-Hash:) or show up at a named paramater in
> > some other header?
>
> why? I think it fits naturally as the first hash in the signature
> data. another header makes the parser more complex.
Ok, I take that back. To veryify the data you need the full hash. The
rest of the header is useless if you don't have the full-hash somewhere to
compare the result to so it does actaully fit nicely there.
> > Full-File-Details: size=NNN; hash=XXX
> >
> > ???
>
> the header name must begin with "Content-". MIME is both very strict
> and very lenient about this, since it will accept any unknown
> Content-Header, but disallow any NonContent-Header.
Ok.
> > > The first hash in the list is always the identifying hash, but
> > > notice that there is nothing to identify hash4 as hash4. This
> > > must be deduced from the total size of the file and which blocks
> > > are included in the fragment.
> >
> > Which points out that to understand this header, you must have
> > that other data. I think that pretty much means you need to
> > define how that would be done in Mime Headers as well and you
> > won't be able to get this header defined as a standard without
> > also defining those headers.
>
> that's why I'm pushing for extending Content-Disposition with this
> data in comp.mail.mime.
I don't do mime. But, I was just looking at the "content-disposition" RFC
and it looks like the entire point of the header is to specify display
symantics. (i.e. data should be displaied in-line vs as an attachement).
Puting important content information that just seems completley wrong.
> so far, I've had little success, people want
> to do Content-Type: application/fragment,
It seems to me that putting it there assume that the mime tool isn't going
to deal with the fragment. It's just going to pass the data to some
external application which knows how to deal with "fragments". If that in
fact is how it would be done, then the important meta data like the
Signature and the full file size and the segment offset and size would be
embeded in the data and not in the mime headers.
> which I think is a horrible
> layering violation (this was Jeremy's suggestion as well, a year ago).
> it's interesting to note that there is no requirement to have an
> approved RFC to register a new parameter for Content-Disposition, it
> suffices to present a description for its semantics to IANA. it's
> more important to convince Chris Morse than the MIME crowd, if you
> know what I'm saying.
I don't know who Chris Morse is so no I don't know what you mean. But
that's not really important anyhow.
This touches on the issues of "doing it right", vs "squezing it into a
cornor somewhwhere just to make it work". Content-Disposition might just
happen to be a free corner you can stick crap in easily instead of doing it
right.
It gets to the point of trying to decide if "doing it right" is really
important enough to justify. We can make usenet work fine without MIME.
So the issue is, is this important enough for e-mail and MIME to get it
done "right"?
> > What is the correct content-type for a segment of a jpg file?
>
> there is no mechanism for it.
Yeah, I know.
I was really trying to ask "what should be the correct content-type of a
segment of a jpg file"?
> > > Each hash is a 160-bit number presented in BASE64. It will
> > > generally require 27 characters to encode, but with many leading
> > > zero bits, it can be less.
> >
> > I encoded it not as a 160 bit number but as 20 bytes in straight
> > MIME BASE64, which means you chop it into 6 bit chunks left to
> > right instead of right to left and you do not remove leading
> > zeros.
>
Encoding it as number is natural if the data fits in an "int" which the 160
bit hash doesn't. If it doesn't fit in an int, then encoding it as an
array of bytes using the standard MIME base64 algorithm for encoding byte
data seems more natural to me.
> > The numbers (but not the hash) in the Message-ID I encoded as base64
> > numbers. (i.e. right to left with leading zeros removed).
>
> that's why I chose to represent the hash the same way, the code must
> have a function to transform a number into BASE64, anyway. the
> question is: is it better to require the implementation to have _one_
> generalised function than to require it to have _two_ functions which
> are slightly easier to implement?
>
> oh! we need to specify whether the numbers are encoded as little- or
> big-endian. little-endian is a tiny bit easier to code, just do:
>
> while number > 0
> output number AND 111111b
> number SHIFT RIGHT 6
>
> big-endian needs buffering to reverse the order of the octets.
> intuitively, as a Westerner, I'd expect the numbers to be big-endian.
For the numeric values, I used big-endian and did buffer it.
I don't know how SHA1 is defined in the standards, but in the code I used,
it was defined as an array of bytes (unsigned char digest[20]), not as a
160 bit number. So you first have to define big vs little endian
conversion to define how the 160 bit number is constructed from those 20
bytes, then, when converting to BASE64, you have to define how base64
numbers are output. If you think about it as a number, then you want to
follow the normal convention and and output the high-order base64 "digits"
first (on the left).
But, since it's already an array of bytes and not a number, I think it's
more obvious (particually in MIME) to output it just like you would output
a 20 byte file which was BASE64 encoded.
For the xBin message-id stuff, I think treating the hash the same way there
makes sense, and treating the numeric values differently (as base64 numbers
where leading "zeros" (which is actually A in the MIME base64 alphabet) are
truncated is justifyed.
> > > When used with large files, the number of hashes can become
> > > quite large. It is suggested that the header is folded on
> > > whitespace to keep line length down.
> >
> > What does MIME say about header lengths? Anything?
>
> RFC 2047 says:
>
> While there is no limit to the length of a multiple-line header
> field, each line of a header field that contains one or more
> 'encoded-word's is limited to 76 characters.
>
> we don't use encoded-words, so we're actually free to do what we like
> within the bounds of the transmitting protocol (SMTP or NNTP).
Cool, then that's not an issue.
> > > The size of a block must be constant across implementations. The
> > > chosen value is 22500 octets.
> >
> > I'e had second thoughts about that which I hope to post here at
> > some points.
>
> well, it is easy to change this number during discussion.
>
> > For now, my argument of being uuencode compatible and the lack of
> > any real need to be power of two based is valid. But down the
> > road, I see servers optimized to store these blocks, and at that
> > point, power-of-two sized junks would be justified. So maybe it
> > does make sense to try and make it a power-of-two based hash block
> > size now. The question then becomes, how much problem will this
> > cause for uuencode posts????
>
> you've still convinced me that the overhead for the non-power-of-two
> is down in the noise. 500 line blocks is also friendly to uuencode
> users. MIME users don't do multipart posts, so they probably don't
> have any feel for how many lines a post should be chopped into. (76
> BASE64 digits gives a block size of 394.7 lines :-)
Yeah, it's not the computation overhead, it's that a news/file server which
is designed from the ground up to store xBin data would use the xBin hash
block size it's basic unit of storage. It would have an interface which
would allow you to store and fetch individual blocks from any xbin-id file.
(STORE <file-id> <blocknumber>, and GET <file-id> <blocknumber>). It would
be a serious efficency issue if you have to store 22500 byte blocks in this
file system instead of power-of-two blocks. To make that work nicely in
the future, I'm thinking something like 32K blocks would be better. But is
making things worse for uuencode now going to prevent us from every getting
to the point where we would want to build this xBin file system in the
future? Maybe.
> > > did I miss anything an implementer needs to know? can the
> > > presentation be improved (of course it can! please help! :-)
> >
> > Your post is good. But the complex problem is that you are
> > starting to define how it will all fit into MIME. I don't think
> > you can get away with defining only this one header now.
>
> right, there are three pieces to the puzzle:
>
> the signature
> the fragment information
> the Message-ID convention
>
> MIME will not care about that last one. it's just an optimisation
> hack for news.
Right.
> > If you could, then we could use that as the standard X-Bin header
> > even for non-MIME posts. And that seems like it would be wise. So
> > looking into this future seems worth the time.
>
> uuencoded posts can use the MIME headers, but shouldn't include
> "MIME-Version: 1.0" unless the document is well-formed. (it can be,
> but it is not common to do that -- why bother when BASE64 is more
> efficient anyway?)
>
> > But MIME just doesn't currently support the concept of a
> > file-segment. You can transport them in MIME of course as generic
> > application/octect-stream data chunks, but then that approach
> > would encourage you to put the file informaion and the signature
> > information into the data instead of in the MIME headers. i.e.,
> > either "what you are trasporting" is hidden to the MIME
> > application (the application/octet-stream" approach, or the "what
> > you are transporting" is "known" to the mime application, in which
> > case the signature and other full-file information needs to be in
> > the MIME headers.
>
> yeah. I detest that approach.
>
> > So, for it do be done correctly in MIME, it needs to be defined at
> > the MIME header level, like you are tying to do here. But to be
> > compatible with all other MIME aware clients which have allready
> > been writen without any support for the idea of a "file segment",
> > it's going to be a bit complex to figure out the best way to
> > shoe-horn this very basic concept into a standard (and all the
> > existing applications) which were never meant to support it.
>
> any new feature needs new code to support it. by adding the fragment
> information to Content-Disposition, old clients will simply store or
> present the fragment as if it was the complete file. the user can
> piece them together himself if he elects to save to disk. the icky
> point is preview, since the fragment will lack the headers of the
> complete file. a quality implementation will of course handle bogus
> data without incident and tell the user that the decode failed. a bad
> implementation may crash, it's even conceivable you can smash its
> stack. but a malcious user could have sent that fragment as if it was
> a complete file anyway, so it doesn't impact the security
> considerations.
>
> > I'm sure this can be done, and it's probably not even that hard,
> > but I do suspect it's a lot of work and I suspect that trying to
> > define one header like Content-SHA1-Tree without addressing the
> > entire problem would be the wrong approach.
>
> I try to address the entire problem, but I also try to keep separate
> issues separate. fragmentation is useful even without a signature to
> verify its integrity.
Right, the signature/integrity header should be separate like you are
doing. I think that fits nicely into mime. It's just a question of the
name and format and other minor stuff that's not a big issue.
> similarily, Content-SHA1-Tree can be used on a
> file posted in a single article (it will contain only the root hash),
> although in that case most people would choose to use the existing
> Content-MD5 instead. but the mechanisms are orthogonal.
Interesting how that works when you include the full-hash in the header
like that.
> > My thought is that it would be better to leave MIME out of the
> > problem intentionally for now, and create something that's custom
> > designed to solve the problems of Usenet.
>
> let me here what you think needs be different.
I think we are getting closer. The signature header is starting to feel
like it fits in MIME to me now.
> > Then, later, if the standard catches on for Usenet, the MIME guys
> > might be motivated to attack the general problem of the correct
> > way to support "file-segments" in MIME messages. Once that was
> > done, and if it was done correctly so it could support xBin
> > messages, then Usenet could evolve to correctly labeling all the
> > xBin articles with the correct MIME headers as well.
>
> yEnc and uuencode makes such a mess of even basic things like
> filenames -- it would be benificial to allow Content-Type and
> Content-Disposition to override their cruft. but a
> Content-Disposition containing only "offset=NNNN; total-size=NNNN"
> would be sufficient of course.
Ok, but Content-Disposition just seems the wrong place to put this data (it
has nothing to do with display issues) which seems to me belongs more in
something like Content-Type. Has MIME used Content-Disposition for any
thing else like this which really belongs in Conetent-Type?
> > It would be good if we could take a stab like you have done to see
> > what the header "should" look like to fit in MIME. If a later
> > version of MIME could use the same header, it would of course make
> > the conversion to MIME easier later. But it just always seems
> > that the standards that come later are always forced to change
> > something anyhow and that the odds of picking something know that
> > will work later with MIME are very small....
>
> we can do this in MIME today[1]. neither Content-X nor parameters for
> Content-Disposition require concensus in the working groups.
The Content-X is sounding good now. But you haven't sold me on the idea
that using Content-Disposition would be good. It really feels to me like
it needs to be done in the Content-Type: though I don't know if it's
possible at this late point in the development of MIME because what I'm
talking about is something which I think would break most MIME systems if
it's done how I'm thinking. You need a Content-Type: header which says
"this is a segment of a file and the full-file is: xxx" where xxx is the
normal Content-Type: header.
Something like:
Content-Type: fragment/image/jpg; segment-offset=XXXX segment-size=YYY
Maybe the answer is that it's just too late to "do it right" which means we
are forced to go to the application/fragment and do something like:
Content-Type: application/fragment; file-type=image/jpg frag-offset=XX
...
Then there's the complexity of the PAR data and how that will fit into
mime:
Content-Type: application/par-fragment; ...
--
Curt Welch http://CurtWelch.Com/
curt@kcwc.com Webmaster for http://NewsReader.Com/
Technical Details
Message-ID:
<20030119023525.732$LI@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!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mailReferences:
<1r3co0fjr2.fsf@vingodur.ifi.uio.no> <20030118143342.130$IV@newsreader.com> <1ru1g6j7o4.fsf@fjorir.ifi.uio.no>Show Full Headers
Complete Article Headers
Message-ID: <20030119023525.732$LI@newsreader.com>
Subject: Re: Content-SHA1-Tree
Date: Sun, 19 Jan 2003 07:35:25 +0000
From: curt@kcwc.com (Curt Welch)
References: <1r3co0fjr2.fsf@vingodur.ifi.uio.no> <20030118143342.130$IV@newsreader.com> <1ru1g6j7o4.fsf@fjorir.ifi.uio.no>
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!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
Organization: NewsReader.Com
Newsgroups: news.software.nntp
X-Trace: NewsReader.Com vFQ3MYK6B/0Q2KxYFGeqYQ.iC_q5OTSgWYgD.TXFM2mxPXj
X-Face: "p}G*1KH{+F7EYGKLb>ogDguabZ+%,?^epeFB!nzu`)`$=QcvL1KF6<0GH!Tbc!Sqo[|tV5
%IW48mQf3K=Ci&gZ7]]aazx@]Y-nq!r5{yH/#,?@lDdUDvOfByB2hVW0.@OM%{l/{cT'{w
X-Url: http://CurtWelch.Com/
User-Agent: NewsReader.Com
Lines: 387