From 7772c87c837aaf66e39b487b0bc011f3e70bfd60 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sat, 5 Jun 2021 13:13:50 +0200 Subject: added a simple mock signer --- mocks/crypto.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 mocks/crypto.go (limited to 'mocks') diff --git a/mocks/crypto.go b/mocks/crypto.go new file mode 100644 index 0000000..87c883a --- /dev/null +++ b/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 +} -- cgit v1.2.3