memzero

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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).

func Clone

func Clone(in []byte) []byte

Clone returns a new slice with the same contents as in. A nil input returns nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL