after compiling and testing some functions available in the gnuTLS library I am having problems using the crypto library. When I try to generate a hash using
gnutls_hash_hd_t *dig;
gnutls_hash_init (dig, GNUTLS_DIG_SHA1);
for then calculate a hash using
gnutls_hash (dig, const void * ptext, size_t ptext_len);
my problen appears when
gnutls_hash_init (dig, GNUTLS_DIG_SHA1);
calls gnutls_malloc() inside crypto-api.c givng me a segfault. I dont know what and doing wrong and gnuTLS API is not very begginer friendly, any kind of suggestions and advices are welcome
The function
gnutls_hash_init
does not allocate the memory for thegnutls_hash_hd_t
. Rather, it expects a pointer to an existing allocation.So the correct usage would be e.g.