aboutsummaryrefslogtreecommitdiff
path: root/internal/mocks/signer/signer.go
blob: a4ec30d79fc4aca5fedced7607cfbbf1b222fc05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package signer

import (
	"crypto"
	"crypto/ed25519"
	"io"
)

// Signer implements crypto.Signer with fixed outputs.  Use for tests only.
type Signer struct {
	PublicKey []byte
	Signature []byte
	Error     error
}

func (s *Signer) Public() crypto.PublicKey {
	return ed25519.PublicKey(s.PublicKey[:])
}

func (s *Signer) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
	return s.Signature[:], s.Error
}