diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-06-07 00:19:40 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-06-07 00:19:40 +0200 |
commit | 932d29fd08c8ff401e471b4f764537493ccbd483 (patch) | |
tree | e840a4c62db92e84201fe9ceaa0594d99176792c /pkg/mocks/crypto.go | |
parent | bdf7a53d61cf044e526cc9123ca296615f838288 (diff) | |
parent | 345fe658fa8a4306caa74f72a618e499343675c2 (diff) |
Merge branch 'design' into main
Diffstat (limited to 'pkg/mocks/crypto.go')
-rw-r--r-- | pkg/mocks/crypto.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pkg/mocks/crypto.go b/pkg/mocks/crypto.go new file mode 100644 index 0000000..87c883a --- /dev/null +++ b/pkg/mocks/crypto.go @@ -0,0 +1,23 @@ +package mocks + +import ( + "crypto" + "crypto/ed25519" + "io" +) + +// TestSign implements the signer interface. It can be used to mock an Ed25519 +// signer that always return the same public key, signature, and error. +type TestSigner struct { + PublicKey *[ed25519.PublicKeySize]byte + Signature *[ed25519.SignatureSize]byte + Error error +} + +func (ts *TestSigner) Public() crypto.PublicKey { + return ed25519.PublicKey(ts.PublicKey[:]) +} + +func (ts *TestSigner) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) { + return ts.Signature[:], ts.Error +} |