Documentation
¶
Overview ¶
Package memzero clears buffers that held key material or plaintext.
cryptfs copies keys it is given, then clears those copies when they are no longer needed. It does not modify caller-owned slices (for example a key stored on a struct).
What this does and does not guarantee: it overwrites the buffer it is given. It cannot reach copies made elsewhere, such as the expanded key schedule inside a crypto/cipher.Block, an HMAC's padded keys, or a string.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
func Bytes(b []byte)
Bytes overwrites every byte of b with zero.
It is not inlined, and keeps b reachable until the write is done, so the compiler cannot treat the clear as a dead store to a buffer that is about to go out of scope.
This is best-effort heap hygiene. It zeroes len(b) bytes only, so a caller that wants a slice's whole backing array cleared passes b[:cap(b)]. It does not reach copies of the data in CPU registers or on goroutine stacks. A host that needs those erased too can wrap its calls into this library in runtime/secret.Do; that package is experimental, needs GOEXPERIMENT=runtimesecret, and erases registers and stacks only on linux/amd64 and linux/arm64 (elsewhere Do just calls its function).
Types ¶
This section is empty.