cryptotest

Imports

Imports #

"bytes"
"hash"
"io"
"math/rand"
"testing"
"time"
"crypto/internal/boring"
"crypto/internal/impl"
"internal/goos"
"internal/testenv"
"testing"
"bytes"
"crypto/cipher"
"crypto/subtle"
"fmt"
"strings"
"testing"
"bytes"
"crypto/cipher"
"fmt"
"testing"
"crypto/internal/boring"
"internal/asan"
"internal/msan"
"internal/race"
"internal/testenv"
"runtime"
"testing"
"bytes"
"crypto/cipher"
"testing"
"bytes"
"crypto/cipher"
"testing"
"bytes"
"encoding/json"
"internal/testenv"
"os"
"testing"

Constants & Variables

bufCap var #

Each test is executed with each of the buffer lengths in bufLens.

var bufCap = 10000

bufLens var #

Each test is executed with each of the buffer lengths in bufLens.

var bufLens = []int{...}

lengths var #

var lengths = []int{...}

Type Aliases

MakeAEAD type #

MakeAEAD returns a cipher.AEAD instance. Multiple calls to MakeAEAD must return equivalent instances, so for example the key must be fixed.

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

MakeBlock type #

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

MakeBlockMode type #

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

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

MakeHash type #

type MakeHash func() hash.Hash

MakeStream type #

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.

type MakeStream func() cipher.Stream

Functions

FetchModule function #

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 FetchModule(t *testing.T, module string, version string) string

SkipTestAllocations function #

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

func SkipTestAllocations(t *testing.T)

getSum function #

Helper function for getting Sum. Checks that Sum doesn't change hash state.

func getSum(t *testing.T, h hash.Hash, buff []byte) []byte

isDeterministic function #

func isDeterministic(aead cipher.AEAD) bool

mustPanic function #

func mustPanic(t *testing.T, msg string, f func())

newRandReader function #

func newRandReader(t *testing.T) io.Reader

openWithoutError function #

Helper function to Open and authenticate ciphertext. Checks that Open doesn't error (assuming ciphertext was well-formed with corresponding nonce and additional data).

func openWithoutError(t *testing.T, aead cipher.AEAD, plaintext []byte, nonce []byte, ciphertext []byte, addData []byte) []byte

sealMsg function #

Helper function to Seal a plaintext with additional data. Checks that ciphertext isn't bigger than the plaintext length plus Overhead()

func sealMsg(t *testing.T, aead cipher.AEAD, ciphertext []byte, nonce []byte, plaintext []byte, addData []byte) []byte

testBlockMode function #

func testBlockMode(t *testing.T, bm MakeBlockMode, b cipher.Block, iv []byte)

testBlockModePair function #

func testBlockModePair(t *testing.T, b cipher.Block, enc MakeBlockMode, dec MakeBlockMode, iv []byte)

testCipher function #

func testCipher(t *testing.T, cipher func(dst []byte, src []byte), blockSize int)

truncateHex function #

func truncateHex(b []byte) string

writeToHash function #

Helper function for writing. Verifies that Write does not error.

func writeToHash(t *testing.T, h hash.Hash, p []byte)

Generated with Arrow