aboutsummaryrefslogtreecommitdiff
path: root/mocks
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-06-05 13:13:50 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-06-05 13:13:50 +0200
commit7772c87c837aaf66e39b487b0bc011f3e70bfd60 (patch)
tree296e12564474f83a02e936dee985366b3fe466db /mocks
parent38e228dd5aec0bf641dd096acf90aa8c6ad3234c (diff)
added a simple mock signer
Diffstat (limited to 'mocks')
-rw-r--r--mocks/crypto.go23
1 files changed, 23 insertions, 0 deletions
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
+}