HASH Chunk

See more on Chunks in general.

See the HASH-a chunk.

This is a “digest” of data in a stored file or a chunk, used to verify the integrety of the information. Each chunk contains a minimal 1-byte check. This chunk allows you to add stronger checking for each chunk desired, as well as checking on the expanded and restored file contents to verify that extraction worked properly.

A variety of algorithms are available, allowing you to choose between large and small values, on a per-chunk basis.

If the a (correlated) Flag is set, then the instance describes the extracted, restored file of that same DATA instance.

If the a (correlated) Flag is not set, then the instance describes one or more target chunks.

HASH Chunk for other target chunks

Flags

The a (correlated) Flag must be absent; if set see the description of HASH-a instead.

The i (instance index) flag must be set if and only if the r (range) flag is set.

The r (range), p, and c flags is allowed as usual.

The y (payload specification) flag is allowed, but rarely useful because the hash values won’t compress, and there is no need to encrypt the hash since the data being hashed is visible (the hash is of the final content of the target chunk’s payload, after any encryption has been applied). However, it is allowed because advanced transforms may be useful. But using it is discouraged if it isn’t specifically set up to add value.

The b (subtype) flag must be set.

Subtype

Subtype is set to 64 (hex 40).

HASH Chunk Payload

The Payload contains a target chunk ID, and a computed hash value for the target chunk.

Target Chunk ID

This is identical to the Chunk ID used by the TOCN chunk.

Hash Value

The hash algorithm is applied over the entire content of the target chunk, from the first byte of the size through the checksum inclusive.

Several hash algorithms are available, and which one is implied by the value’s size.

4-byte hash

This is the 32-bit hash published by Robert J. Jenkins Jr. at http://burtleburtle.net/bob/hash/evahash.html with reference implementation at http://burtleburtle.net/bob/c/lookup2.c.

... need a medium sized one...

20-byte SHA-1

... sizes for SHA-2...

Usage Notes

An implementation should verify the chunk matches the hash, for any HASH chunk it encounters. If the program notices HASH chunks via a HASH-n but doesn’t encounter the actual HASH chunk, inserting the disc just to check the hash should be optional.

A non-matching hash indicates an error in the associated chunk.

Examples

HASH-a Chunk for extracted file

HASH-a Flags

The a (correlated) Flag must be set; if absent see the description of HASH instead.

The i (instance index) flag must be cleared. All bundled instances have the same size and thus use the same hash algorithm.

Subtype

Subtype is set to 64 (hex 40).

Instance Number

The Instance Number matches the Instance Number of the DATA it applies to, as with any a-flagged chunk type.

HASH-a Chunk Payload

The Payload contains the Hash Value for the data, using the same algorithms keyed off the value’s size as described above.

Usage Notes

The hash is computed over the original contents of the DATA instance, before it is compressed and otherwise transformed and broken into one or more chunks. That is, compute the hash on the file after extracting it and compare against this value.

Examples


Valid HTML 4.01!

Page content copyright 2003 by John M. Dlugosz. Home:http://www.dlugosz.com, email:mailto:john@dlugosz.com