testutil

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package testutil is a collection of test utilities for the AEAD crypter.

Index

Constants

View Source
const (
	ValidResult   = "valid"
	InvalidResult = "invalid"
)

Constants indicating whether the test vector is valid or not.

Variables

This section is empty.

Functions

func Dehex

func Dehex(s string) []byte

Dehex converts a byte string into a byte array.

func IsFailure

func IsFailure(result string, err error, got, expected []byte) bool

IsFailure takes in test result validity, error message, test output, expected test output, and returns true if the test failed.

Types

type CryptoTestVector

type CryptoTestVector struct {
	Desc                                        string
	ID                                          int
	Key, Plaintext, Ciphertext, Tag, Nonce, Aad []byte
	Result                                      string
	AllocateDst                                 bool
}

CryptoTestVector is a struct representing a test vector for an S2AAEADCrypter instance.

func ParseWycheProofTestVectors

func ParseWycheProofTestVectors(jsonFilePath string, shouldFilter func(TestGroup) bool, t *testing.T) []CryptoTestVector

ParseWycheProofTestVectors takes a path to a WycheProof test vector, a test group filter, and returns the resulting CryptoTestVector. The test group filter will be used to filter out unsupported test inputs.

type TestFile

type TestFile struct {
	TestGroups []TestGroup `json:"testGroups"`
}

TestFile is a struct for a WycheProof test file.

type TestGroup

type TestGroup struct {
	IVSize  int          `json:"ivSize"`
	KeySize int          `json:"keySize"`
	TagSize int          `json:"tagSize"`
	Tests   []TestVector `json:"tests"`
}

TestGroup is a struct for a WycheProof test group.

type TestVector

type TestVector struct {
	TcID    int    `json:"tcId"`
	Comment string `json:"comment"`
	Key     string `json:"key"`
	IV      string `json:"iv"`
	Aad     string `json:"aad"`
	Msg     string `json:"msg"`
	Ct      string `json:"ct"`
	Tag     string `json:"tag"`
	Result  string `json:"result"`
}

TestVector is a struct for a WycheProof test vector.

Jump to

Keyboard shortcuts

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