Problem when hashing

Werner Koch wk at gnupg.org
Thu Feb 24 15:20:48 CET 2005


On Thu, 24 Feb 2005 13:41:00 +0100, Madelman  said:

> So, I suppose it is caused by the leading zero byte in the hash, but where does
> this byte come from? How can I solve this problem?

That is to mark the number as positive.  What you should do is to
use

    unsigned char md[20];

    ...
    rc = gcry_sexp_build (&hash, NULL,
                          "(data (flags pkcs1) (hash sha1 %b))",
			  (size_t)20, md);

That's far easier, isn't it?  Make sure that the first argument of %b
has the type size_t, the second one is a pointer of course.


Shalom-Salam,

   Werner







More information about the Gcrypt-devel mailing list