Movatterモバイル変換


[0]ホーム

URL:


drbg

packagestandard library
go1.25.5Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:13Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package drbg provides cryptographically secure random bytesusable by FIPS code. In FIPS mode it uses an SP 800-90A Rev. 1Deterministic Random Bit Generator (DRBG). Otherwise,it uses the operating system's random number generator.

Index

Constants

View Source
const (SeedSize = keySize +aes.BlockSize)

Variables

This section is empty.

Functions

funcRead

func Read(b []byte)

Read fills b with cryptographically secure random bytes. In FIPS mode, ituses an SP 800-90A Rev. 1 Deterministic Random Bit Generator (DRBG).Otherwise, it uses the operating system's random number generator.

funcReadWithReader

func ReadWithReader(rio.Reader, b []byte)error

ReadWithReader uses Reader to fill b with cryptographically secure randombytes. It is intended for use in APIs that expose a rand io.Reader.

If Reader is not the default Reader from crypto/rand,randutil.MaybeReadByte andfips140.RecordNonApproved are called.

funcReadWithReaderDeterministic

func ReadWithReaderDeterministic(rio.Reader, b []byte)error

ReadWithReaderDeterministic is like ReadWithReader, but it doesn't callrandutil.MaybeReadByte on non-default Readers.

Types

typeCounter

type Counter struct {// contains filtered or unexported fields}

Counter is an SP 800-90A Rev. 1 CTR_DRBG instantiated with AES-256.

Per Table 3, it has a security strength of 256 bits, a seed size of 384 bits,a counter length of 128 bits, a reseed interval of 2^48 requests, and amaximum request size of 2^19 bits (2^16 bytes, 64 KiB).

We support a narrow range of parameters that fit the needs of our RNG:AES-256, no derivation function, no personalization string, no predictionresistance, and 384-bit additional input.

WARNING: this type provides tightly scoped support for the DRBGfunctionality we need for FIPS 140-3 _only_. This type _should not_ be usedoutside of the FIPS 140-3 module for any other use.

In particular, as documented, Counter does not support the derivationfunction, or personalization strings which are necessary for safely usingthis DRBG for generic purposes without leaking sensitive values.

funcNewCounter

func NewCounter(entropy *[SeedSize]byte) *Counter

func (*Counter)Generate

func (c *Counter) Generate(out []byte, additionalInput *[SeedSize]byte) (reseedRequiredbool)

Generate produces at most maxRequestSize bytes of random data in out.

func (*Counter)Reseed

func (c *Counter) Reseed(entropy, additionalInput *[SeedSize]byte)

typeDefaultReader

type DefaultReader interface {// contains filtered or unexported methods}

DefaultReader is a sentinel type, embedded in the defaultcrypto/rand.Reader, used to recognize it when passed toAPIs that accept a rand io.Reader.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp