- gcry_md_hash_buffer(digest->algo, outdata, indata, inlen);
+ unsigned int len = gcry_md_get_algo_dlen(digest->algo);
+
+ if(digest->hmac) {
+ char *tmpdata;
+ gcry_md_reset(digest->hmac);
+ gcry_md_write(digest->hmac, indata, inlen);
+ tmpdata = gcry_md_read(digest->hmac, digest->algo);
+ if(!tmpdata)
+ return false;
+ memcpy(outdata, tmpdata, digest->maclength);
+ } else {
+ char tmpdata[len];
+ gcry_md_hash_buffer(digest->algo, tmpdata, indata, inlen);
+ memcpy(outdata, tmpdata, digest->maclength);
+ }
+