Do not return uninitialized char *.
replace deprecated gnutls_datum with gnutls_datum_t.
Correctly overwrite the diffie-helman shared secret memory buffer with 0 before free. sizeof(unsigned char *) is the size of the pointer not the size of the buffer it is pointint to.