pkcs11test

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package pkcs11test implements utilities for testing the chaps pkcs#11 keystore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeP11TestTokenAuthData

func ChangeP11TestTokenAuthData(ctx context.Context, r hwsec.CmdRunner, scratchpadPath, authData, newAuthData string) error

ChangeP11TestTokenAuthData changes authorization data auth_data by new_auth_data stored in scratchpadPath.

func CleanupP11TestToken

func CleanupP11TestToken(ctx context.Context, r hwsec.CmdRunner, scratchpadPath string) error

CleanupP11TestToken deletes the test token stored in scratchpadPath.

func CleanupScratchpad

func CleanupScratchpad(ctx context.Context, r hwsec.CmdRunner, scratchpadPath string) error

CleanupScratchpad removes the scratchpad at ScratchpadPath. This is usually called at the end of the test.

func LoadP11TestToken

func LoadP11TestToken(ctx context.Context, r hwsec.CmdRunner, scratchpadPath, authData string) (string, error)

LoadP11TestToken loads the test token onto a slot stored in scratchpadPath and return the slot number. LoadP11TestToken returns an invalid slot number that is larger than the max slot chapsd supports with non-nil error when it fails.

func PrepareScratchpadAndTestFiles

func PrepareScratchpadAndTestFiles(ctx context.Context, r hwsec.CmdRunner, scratchpadPath string) (testfile1, testfile2 string, retErr error)

PrepareScratchpadAndTestFiles prepares the scratchpad space at ScratchpadPath by ensuring that it is empty before the test, and exists after the call. Also, this creates 2 test files in it for testing. The path to the 2 test files are returned, and err is nil iff the operation is successful. This is usually called at the start of pkcs#11 related tests.

func SetupP11TestToken

func SetupP11TestToken(ctx context.Context, r hwsec.CmdRunner, scratchpadPath string) error

SetupP11TestToken configures a PKCS #11 database in scratchpadPath.

func SignAndVerify

func SignAndVerify(ctx context.Context, p *pkcs11.Chaps, key *pkcs11.KeyInfo, input, altInput string, mechanism *pkcs11.MechanismInfo) error

SignAndVerify is just a convenient runner to test both signing and verification. altInput is path to another test file that differs in content to input. It is used to check that verify() indeed reject corrupted input.

func UnloadP11TestToken

func UnloadP11TestToken(ctx context.Context, r hwsec.CmdRunner, scratchpadPath string) error

UnloadP11TestToken unloads loaded test token stored in scratchpadPath.

Types

This section is empty.

Jump to

Keyboard shortcuts

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