[gnutls-devel] GnuTLS | Use custom free/realloc for GMP to safely delete temporary secrets (!1554)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Wed Mar 16 18:22:40 CET 2022




Tobias Heider commented on a discussion on lib/safe-memfuncs.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1554#note_877415137

> + * @old_size: the size of memory before reallocation
> + * @new_size: the size of memory after reallocation
> + *
> + * This function will operate similarly to realloc(), but will safely
> + * zeroize discarded memory.
> + *
> + **/
> +void *gnutls_realloc_zero(void *data, size_t old_size, size_t new_size)
> +{
> +	void *newptr = NULL;
> +
> +	/* mini-gmp always passes old_size of 0 */
> +	if (old_size == 0) {
> +		newptr = realloc(data, new_size);
> +		if (newptr == NULL)
> +			abort();

In a previous comment @dueno noted that this is what GMP does by default. I copied what they are doing.

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1554#note_877415137
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20220316/7e6216a5/attachment.html>


More information about the Gnutls-devel mailing list