But! This might not be so easy, as compilers are smart. Last year, I saw an article showing some C code using this method. First a password was stored in a string, used to get some access, then the password was overwritten with spaces, and not used anymore. Or at least, the source code indicated that. However, the compiler noticed that the string had spaces put in it, and then it was no longer used. So, the compiler optimized the assignment to spaces away - it wasn't going to be used anyway.
In Perl, things are even more complex. A string isn't just a sequence of bytes terminated by a NUL with you holding a pointer to it. That sequence of bytes is there, but you aren't holding a pointer to it. I wouldn't know a pure Perl way of making sure that piece of memory gets overwritten. One could dive into the sources, and find a way that guarantees the string gets overwritten, but that may not work in another version anymore. But writing some XS code lets you get to the pointer, and then you can overwrite it.
Abigail
In reply to Re: Handling encryption safely
by Abigail-II
in thread Handling encryption safely
by bagu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |