aboutsummaryrefslogtreecommitdiff
path: root/internal/mocks
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-05-21 20:31:09 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-06-21 19:46:54 +0200
commit97540f9ded30f68f9fda62f66f3006414cbfd5b7 (patch)
tree329db21d4e63aba70711d8e897fd95713f1cc1f9 /internal/mocks
parent1f9ec26e11052e1ab24b854e997404a42ef5bfd0 (diff)
move mock signer to internal/
Diffstat (limited to 'internal/mocks')
-rw-r--r--internal/mocks/signer/signer.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/mocks/signer/signer.go b/internal/mocks/signer/signer.go
new file mode 100644
index 0000000..a4ec30d
--- /dev/null
+++ b/internal/mocks/signer/signer.go
@@ -0,0 +1,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
+}