From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: Re: notmuch sha1 implementation broken on (some) big-endian architectures
Date: Sun, 24 Nov 2013 08:40:13 -0400 [thread overview]
Message-ID: <87bo1a6kia.fsf@zancas.localnet> (raw)
In-Reply-To: <87eh666mhp.fsf@zancas.localnet>
David Bremner <david@tethera.net> writes:
> The following code, when linked with libnotmuch.a and libutil.a does a
> passable imitation of sha1sum on amd64 (and I guess also i386) but
> computes a different digest on powerpc and probably sparc and s390x.
>
> In the long run we should maybe outsource hash computations to
> e.g. librhash, but I'd like a simpler fix for 0.17, if possible
Out of curiousity, I tried out a similar example with librhash, and it
works fine on powerpc.
#include <errno.h>
#include "rhash.h" /* LibRHash interface */
int main(int argc, char *argv[])
{
char digest[64];
char output[130];
rhash_library_init(); /* initialize static data */
int res = rhash_file(RHASH_SHA1, argv[1], digest);
if(res < 0) {
fprintf(stderr, "LibRHash error: %s: %s\n", argv[1], strerror(errno));
return 1;
}
/* convert binary digest to hexadecimal string */
rhash_print_bytes(output, digest, rhash_get_digest_size(RHASH_SHA1),RHPR_HEX);
printf("%s (%s) = %s\n", rhash_get_name(RHASH_SHA1), argv[1], output);
return 0;
}
next prev parent reply other threads:[~2013-11-24 12:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-24 11:57 notmuch sha1 implementation broken on (some) big-endian architectures David Bremner
2013-11-24 12:40 ` David Bremner [this message]
2013-11-24 16:42 ` Tomi Ollila
2013-11-24 21:29 ` [PATCH 1/2] lib: fix byte order test in libsha1.c david
2013-11-24 21:29 ` [PATCH 2/2] NEWS: News for big endian sha1 bug fix david
2013-11-25 3:10 ` Austin Clements
2013-11-26 13:07 ` [PATCH] util: detect byte order david
2013-11-26 17:42 ` Tomi Ollila
2013-11-27 0:38 ` [PATCH v2] " david
2013-11-27 8:04 ` Tomi Ollila
2013-11-27 12:26 ` David Bremner
2013-11-25 9:43 ` [PATCH 1/2] lib: fix byte order test in libsha1.c Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bo1a6kia.fsf@zancas.localnet \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).