cryptotest

package standard library
go1.26.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func FetchModule ΒΆ added in go1.24.0

func FetchModule(t *testing.T, module, version string) string

FetchModule fetches the module at the given version and returns the directory containing its source tree. It skips the test if fetching modules is not possible in this environment.

func MustSupportFIPS140 ΒΆ added in go1.26.0

func MustSupportFIPS140(t *testing.T)

func NoExtraMethods ΒΆ added in go1.25.0

func NoExtraMethods(t *testing.T, ms any, allowed ...string)

NoExtraMethods checks that the concrete type of *ms has no exported methods beyond the methods of the interface type of *ms, and any others specified in the allowed list.

These methods are accessible through interface upgrades, so they end up part of the API even if undocumented per Hyrum's Law.

ms must be a pointer to a non-nil interface.

func SkipTestAllocations ΒΆ added in go1.24.0

func SkipTestAllocations(t *testing.T)

SkipTestAllocations skips the test if there are any factors that interfere with allocation optimizations.

func TestAEAD ΒΆ added in go1.24.0

func TestAEAD(t *testing.T, mAEAD MakeAEAD)

TestAEAD performs a set of tests on cipher.AEAD implementations, checking the documented requirements of NonceSize, Overhead, Seal and Open.

func TestAllImplementations ΒΆ added in go1.24.0

func TestAllImplementations(t *testing.T, pkg string, f func(t *testing.T))

TestAllImplementations runs the provided test function with each available implementation of the package registered with crypto/internal/impl. If there are no alternative implementations for pkg, f is invoked directly once.

func TestBlock ΒΆ added in go1.24.0

func TestBlock(t *testing.T, keySize int, mb MakeBlock)

TestBlock performs a set of tests on cipher.Block implementations, checking the documented requirements of BlockSize, Encrypt, and Decrypt.

func TestBlockMode ΒΆ added in go1.24.0

func TestBlockMode(t *testing.T, block cipher.Block, makeEncrypter, makeDecrypter MakeBlockMode)

TestBlockMode performs a set of tests on cipher.BlockMode implementations, checking the documented requirements of CryptBlocks.

func TestHash ΒΆ

func TestHash(t *testing.T, mh MakeHash)

TestHash performs a set of tests on hash.Hash implementations, checking the documented requirements of Write, Sum, Reset, Size, and BlockSize.

func TestStream ΒΆ added in go1.24.0

func TestStream(t *testing.T, ms MakeStream)

TestStream performs a set of tests on cipher.Stream implementations, checking the documented requirements of XORKeyStream.

func TestStreamFromBlock ΒΆ added in go1.24.0

func TestStreamFromBlock(t *testing.T, block cipher.Block, blockMode func(b cipher.Block, iv []byte) cipher.Stream)

TestStreamFromBlock creates a Stream from a cipher.Block used in a cipher.BlockMode. It addresses Issue 68377 by checking for a panic when the BlockMode uses an IV with incorrect length. For a valid IV, it also runs all TestStream tests on the resulting stream.

Types ΒΆ

type MakeAEAD ΒΆ added in go1.24.0

type MakeAEAD func() (cipher.AEAD, error)

MakeAEAD returns a cipher.AEAD instance.

Multiple calls to MakeAEAD must return equivalent instances, so for example the key must be fixed.

type MakeBlock ΒΆ added in go1.24.0

type MakeBlock func(key []byte) (cipher.Block, error)

type MakeBlockMode ΒΆ added in go1.24.0

type MakeBlockMode func(b cipher.Block, iv []byte) cipher.BlockMode

MakeBlockMode returns a cipher.BlockMode instance. It expects len(iv) == b.BlockSize().

type MakeHash ΒΆ

type MakeHash func() hash.Hash

type MakeStream ΒΆ added in go1.24.0

type MakeStream func() cipher.Stream

MakeStream returns a cipher.Stream instance.

Multiple calls to MakeStream must return equivalent instances, so for example the key and/or IV must be fixed.

Jump to

Keyboard shortcuts

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