1

I am having a problem writing a program which verifies the checksum in the superblock of an HDF5, Version 2 file. I am not using the HDF5 software, but I have a copy of H5_checksum_fletcher32 (from the HDF5 H5checksum.c) in my code.

I can assume that the file signature block is at position 0.

My logic is:

Let offset = the value of byte 9 of the file.

The superblock spans bytes 0 to (15+4*offset). 

The last 4 bytes are the checksum as an unsigned int.

The checksum should equal H5_checksum_fletcher32 applied to bytes 0 to (11+4*offset).

I have applied this logic to several test files from NOAA that I believe to be reliable, but the checksum never matches the result of H5_checksum_fletcher32. The other values in the superblock appear to be correct. Can anyone see the flaw in my logic?

jkane
  • 51
  • 1
  • I assume you're counting from 0, as the offset is tenth byte of the superblock. Also, if you're just trying to check if a file is valid, there is [h5check](http://www.hdfgroup.org/products/hdf5_tools/h5check.html). – Yossarian Aug 14 '14 at 09:51

1 Answers1

1

From the HDF5 file format specification:

All checksums used in the format are computed with the Jenkins' lookup3 algorithm.

This is provided in H5checksum.c as H5_checksum_lookup3().

Actually, it seems the correct routine to call is H5_checksum_metadata(), but this just calls H5_checksum_lookup3() using a macro.

Yossarian
  • 5,226
  • 1
  • 37
  • 59