Documentation
¶
Overview ¶
Package testsign implements both a mock and fake type for testing the endorsement signing code paths.
Index ¶
- func ExtendManifest(initial, key, path, primarySigningKey string) []byte
- func Init(t testing.TB, s **nonprod.Signer, opts *Options) func()
- func MakeSigner(_ context.Context, opts *Options) (*nonprod.Signer, error)
- func RootRand() io.Reader
- func SignerRand() io.Reader
- type FakeMutation
- type KeyInfo
- type MockSigner
- func (m *MockSigner) CABundle(_ context.Context, keyName string) ([]byte, error)
- func (m *MockSigner) Certificate(_ context.Context, keyVersionName string) ([]byte, error)
- func (m *MockSigner) Finalize(_ context.Context, mutation styp.CertificateAuthorityMutation) error
- func (m *MockSigner) NewMutation() styp.CertificateAuthorityMutation
- func (m *MockSigner) PrepareResources(context.Context) error
- func (m *MockSigner) PrimaryRootKeyVersion(_ context.Context) (string, error)
- func (m *MockSigner) PrimarySigningKeyVersion(_ context.Context) (string, error)
- func (m *MockSigner) PublicKey(_ context.Context, keyVersionName string) ([]byte, error)
- func (m *MockSigner) Sign(_ context.Context, keyVersionName string, toSign []byte) ([]byte, error)
- func (m *MockSigner) Wipeout(context.Context) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtendManifest ¶
ExtendManifest creates a textproto based on an initial textproto with extensions to the entries and a possible modification to the primary signing key version name.
func MakeSigner ¶
MakeSigner creates a new Signer with signer keys of the given names.
func RootRand ¶
RootRand is a test-only deterministic source of randomness for use with the root key.
func SignerRand ¶
SignerRand is a test-only deterministic source of randomness for use with the signer key.
Types ¶
type FakeMutation ¶
type FakeMutation struct { Root string Signer string RootCert *x509.Certificate Certs map[string]*x509.Certificate }
FakeMutation manages changes to the MockSigner through the CertificateAuthorityMutation interface.
func (*FakeMutation) AddSigningKeyCert ¶
func (m *FakeMutation) AddSigningKeyCert(keyVersionName string, cert *x509.Certificate)
AddSigningKeyCert adds a certificate for the given keyVersionName to the CA.
func (*FakeMutation) SetPrimaryRootKeyVersion ¶
func (m *FakeMutation) SetPrimaryRootKeyVersion(keyVersionName string)
SetPrimaryRootKeyVersion updates the mutation object to change the primary root key version to the given one.
func (*FakeMutation) SetPrimarySigningKeyVersion ¶
func (m *FakeMutation) SetPrimarySigningKeyVersion(keyVersionName string)
SetPrimarySigningKeyVersion updates the mutation object to change the primary signing key version to the given one.
func (*FakeMutation) SetRootKeyCert ¶
func (m *FakeMutation) SetRootKeyCert(cert *x509.Certificate)
SetRootKeyCert changes the CA's stored root certificate to cert.
type KeyInfo ¶
type KeyInfo struct { // CommonName is the key's certificate subject common name. CommonName string // KeyVersionName is the key's unique name (path) for use in signing requests. KeyVersionName string }
KeyInfo represents configurable parts of a fake signer's representation of a key.
type MockSigner ¶
type MockSigner struct { Certificates map[string][]byte CABundles map[string][]byte // Signatures maps a key name to a map of hex-encoded toSign bytes to its signature bytes Signatures map[string]map[string][]byte PublicKeys map[string][]byte RootKeyVersion string SigningKeyVersion string PrepareErr error }
MockSigner implements the CertificateAuthority and Signer interfaces to parrot back results.
func (*MockSigner) CABundle ¶
CABundle returns the CA chain of certificates for certifying the given key's certificate.
func (*MockSigner) Certificate ¶
Certificate returns the certificate of the given keyVersionName.
func (*MockSigner) Finalize ¶
func (m *MockSigner) Finalize(_ context.Context, mutation styp.CertificateAuthorityMutation) error
Finalize completes any unflushed changes that the given mutation represents. The mutation object should be the same type as NewMutation returns.
func (*MockSigner) NewMutation ¶
func (m *MockSigner) NewMutation() styp.CertificateAuthorityMutation
NewMutation returns an object that manages changes to the CA's persistent state.
func (*MockSigner) PrepareResources ¶
func (m *MockSigner) PrepareResources(context.Context) error
PrepareResources ensures all necessary resources are present for the CA to function. This is needed for bootstrapping.
func (*MockSigner) PrimaryRootKeyVersion ¶
func (m *MockSigner) PrimaryRootKeyVersion(_ context.Context) (string, error)
PrimaryRootKeyVersion returns the keyVersionName of the active root key.
func (*MockSigner) PrimarySigningKeyVersion ¶
func (m *MockSigner) PrimarySigningKeyVersion(_ context.Context) (string, error)
PrimarySigningKeyVersion returns the keyVersionName of the active signing key.