| ▲ | kbolino 12 hours ago | |
There are two main reasons why this approach isn't sufficient at a technical level, which are brought up by comments on the original proposal: https://github.com/golang/go/issues/21865 1) You are almost certainly going to be passing that key material to some other functions, and those functions may allocate and copy your data around; while core crypto operations could probably be identified and given special protection in their own right, this still creates a hole for "helper" functions that sit in the middle 2) The compiler can always keep some data in registers, and most Go code can be interrupted at any time, with the registers of the running goroutine copied to somewhere in memory temporarily; this is beyond your control and cannot be patched up after the fact by you even once control returns to your goroutine So, even with your approach, (2) is a pretty serious and fundamental issue, and (1) is a pretty serious but mostly ergonomic issue. The two APIs also illustrate a basic difference in posture: secret.Do wipes everything except what you intentionally preserve beyond its scope, while scramble wipes only what you think it is important to wipe. | ||
| ▲ | voodooEntity 10 hours ago | parent [-] | |
Thanks, you brought up good points. While in my case i had a program in which i created an instance of such a secret , "used it" and than scrambled the variable it never left so it worked. Tho i didn't think of (2) which is especially problematic. Prolly still would scramble on places its viable to implement, trying to reduce the surface even if i cannot fully remove it. | ||