Page MenuHome GnuPG

Libgcrypt error reading hashed value
Closed, ResolvedPublic

Description

I'm sure the sizes are wrong, but this caused a core dump:
Algo name is SHA256
Ohhhh jeeee: ... this is a bug (md.c:809:md_read)
Aborted (core dumped)

I created a hash algorithm with:
gcry_md_open(&hd, GCRY_MD_SHA256, GCRY_MD_FLAG_SECURE);

I then performed a read an SHA1 (not SHA256) in an invalid manner:
printf("Hashed value is %s\n", gcry_md_read(hd, GCRY_MD_SHA1));

Details

Version
1.6.1

Event Timeline

Well it is a bug in your code and not in Libgcrypt. The md_read function is
guaranteed to always return a valid digest. However if you explicitly for SHA1
and SHA1 is not enabeld in the context we can't continue. Better use 0 as
second arg to md_read.

I will improve the error message for 1.7.2

werner claimed this task.

commit 3f98b1e adds a better fatal error message. Will be released with 1.7.2.