subprocess

package
v0.0.0-...-68aa458 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: ISC Imports: 14 Imported by: 0

Documentation

Overview

Package subprocess contains functionality to talk to a modulewrapper for testing of various algorithm implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Subprocess

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

Subprocess is a "middle" layer that interacts with a FIPS module via running a command and speaking a simple protocol over stdin/stdout.

func New

func New(path string) (*Subprocess, error)

New returns a new Subprocess middle layer that runs the given binary.

func NewWithIO

func NewWithIO(cmd *exec.Cmd, in io.WriteCloser, out io.ReadCloser) *Subprocess

NewWithIO returns a new Subprocess middle layer with the given ReadCloser and WriteCloser. The returned Subprocess will call Wait on the Cmd when closed.

func (*Subprocess) Barrier

func (m *Subprocess) Barrier(callback func()) error

Barrier runs callback after all outstanding TransactAsync callbacks have been run.

func (*Subprocess) Close

func (m *Subprocess) Close()

Close signals the child process to exit and waits for it to complete.

func (*Subprocess) Config

func (m *Subprocess) Config() ([]byte, error)

Config returns a JSON blob that describes the supported primitives. The format of the blob is defined by ACVP. See http://usnistgov.github.io/ACVP/artifacts/draft-fussell-acvp-spec-00.html#rfc.section.11.15.2.1

func (*Subprocess) Flush

func (m *Subprocess) Flush() error

Flush tells the subprocess to complete all outstanding requests and waits for all outstanding TransactAsync callbacks to complete.

func (*Subprocess) Process

func (m *Subprocess) Process(algorithm string, vectorSet []byte) (any, error)

Process runs a set of test vectors and returns the result.

func (*Subprocess) Transact

func (m *Subprocess) Transact(cmd string, expectedNumResults int, args ...[]byte) ([][]byte, error)

func (*Subprocess) TransactAsync

func (m *Subprocess) TransactAsync(cmd string, expectedNumResults int, args [][]byte, callback func(result [][]byte) error)

TransactAsync performs a single request--response pair with the subprocess. The callback will run at some future point, in a separate goroutine. All callbacks will, however, be run in the order that TransactAsync was called. Use Flush to wait for all outstanding callbacks.

type Transactable

type Transactable interface {
	Transact(cmd string, expectedResults int, args ...[]byte) ([][]byte, error)
	TransactAsync(cmd string, expectedResults int, args [][]byte, callback func([][]byte) error)
	Barrier(callback func()) error
	Flush() error
}

Transactable provides an interface to allow test injection of transactions that don't call a server.

Jump to

Keyboard shortcuts

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