howto do a hash
Werner Koch
wk at gnupg.org
Mon Jan 5 13:56:15 CET 2009
On Fri, 2 Jan 2009 11:36, sergi at calcurco.cat said:
> err = gcry_md_open(&hd,algo,GCRY_MD_FLAG_SECURE);
> err = gcry_md_enable(hd,algo);
The gcry_md_enable call is superfluous because you enabled algorithm
ALGO already with gcry_md_open.
> Then the buffer can be a 'byte array', and after the values concatenation, the
I don't understand why you insist on a byte array; you may pass any
memory block to gcry_md_write. Given that you know the hash algorithm
in advance and that there is just one contiguous memory range to hash, I
suggest to use gcry_md_hash_buffer instead. This has the advantage that
it can be highly optimized on some CPUs (modern VIA CPUs ferature a
SHA-1 and a SHA-256 implementation which work on an entire buffer and
return the finalized hash).
Shalom-Salam,
Werner
--
Die Gedanken sind frei. Auschnahme regelt ein Bundeschgesetz.
More information about the Gcrypt-devel
mailing list