howto do a hash
Sergi Blanch i Torné
sergi at calcurco.cat
Thu Jan 1 18:48:24 CET 2009
Hi!
In side a method I need to do a hash, but this hash can be from different
lengths. I mean. I'm thinking in use the 'gcry_md_spec_t' to point to the
correct one depending on the runtime length, and call the references when is
need. Something like:
gcry_md_spec_t *hash;
if (kek_len == 128) hash = &_gcry_digest_spec_sha256;//algo SHA256
else if (kek_len == 192) hash = &_gcry_digest_spec_sha384;//algo SHA384
else if (kek_len == 256) hash = &_gcry_digest_spec_sha512;//algo SHA512
else return GPG_ERR_NOT_SUPPORTED;
So far, so good? Then I the procedure I think I have to do is:
hash->init(context);
hash->write(context,buffer,sizeof(buffer));
hash->final(context);
result = hash->read(context);
What I don't know now is how to correctly create this 'context'? Everywhere
this is a 'pointer to void', and I cannot read the how.
Thanks!
/Sergi.
More information about the Gcrypt-devel
mailing list