Hi,
I've received a bug report saying that Nettle functions leave secret values lying around on the stack or in deallocated heap memory when they return.
Nettle generally does not take any steps to wipe or cleanup memory that might hold secrets when no longer used. Which I think differs from many other crypto libraries.
In the past, I have argued that an application can't really know which parts of its user data is secret and which isn't. Not only cryptographic keys are sensitive, the plaintext protected by those keys might be as sensitive. And sensitive data is typically handled also by non-cryptographic applications, say your text editor or email program or ai assistant. For this reason, it ought to be the responsibility of the operating system to protect each application's memory, with techniques like MMU-based memory protection, and encryption of any memory pages swapped out to disk.
So my question: Would it improve security if Nettle is changed to make more of an effort of explicitly clear deallocated (or otherwise no longer used) memory on the heap and the stack? Or maybe make an mainly regarding the stack; an applications can configure custom heap allocation functions, and that way ensure that memory is cleared on free, but there's no corresponding application control over Nettle's stack usage.
Regards, /Niels