[redland-dev] Digests, Endianness and Bit Order

Simon Cross simon at sanbi.ac.za
Wed Mar 30 12:21:28 BST 2005


I'm currently using Redland on both PPC (Gentoo, Mac G4, for
development) and Intel (FreeBSD, production).  It seems that the MD5
digests created by the internal md5 digest code differs on the two

Looking at rdf_digest_md5.c I can see a byteReverse function which gets
called when WORDS_BIGENDIAN is defined so I modified the Gentoo ebuild
to add -DWORDS_BIGENDIAN and recompiled just to be sure.  This didn't
seem to change anything so I assume ./configure was already correctly
detecting the endianness.

This just leaves the bit ordering.  PPC seems to be MSB while the Intel
machine is LSB.  I assume the constant bit fields used in
rdf_digest_md5.c would thus be incorrect on PPC?

I'm not really a bit-level C expert so I'm hoping someone can (a)
confirm that I am not making some stupid mistake and (b) suggest a good
way of fixing the problem.

I've attached a small C file which demonstrates the problem (you'll need
to run it on two machines with different bit orders).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hash-test.c
Type: text/x-csrc
Size: 621 bytes
Desc: not available
Url : http://lists.gnomehack.com/pipermail/redland-dev/attachments/20050330/ca692d7a/hash-test.c

More information about the redland-dev mailing list