-
Notifications
You must be signed in to change notification settings - Fork 0
/
signer.go
47 lines (35 loc) · 1.31 KB
/
signer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2018 ProximaX Limited. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package crypto
// Signer wraps DSA signing and verification logic.
type Signer struct {
signer DsaSigner
}
// NewSigner creates a signer around a DsaSigner.
func NewSigner(signer DsaSigner) *Signer {
return &Signer{signer}
}
// NewSignerFromKeyPair creates a signer around a KeyPair.
func NewSignerFromKeyPair(keyPair *KeyPair, engine CryptoEngine) *Signer {
if engine == nil {
engine = CryptoEngines.DefaultEngine
}
return NewSigner(engine.CreateDsaSigner(keyPair))
}
// Sign implemented interface DsaSigner method
func (ref *Signer) Sign(data []byte) (*Signature, error) {
return ref.signer.Sign(data)
}
// Verify implemented interface DsaSigner method
func (ref *Signer) Verify(data []byte, signature *Signature) bool {
return ref.signer.Verify(data, signature)
}
// IsCanonicalSignature implemented interface DsaSigner method
func (ref *Signer) IsCanonicalSignature(signature *Signature) bool {
return ref.signer.IsCanonicalSignature(signature)
}
// MakeSignatureCanonical implemented interface DsaSigner method
func (ref *Signer) MakeSignatureCanonical(signature *Signature) (*Signature, error) {
return ref.signer.MakeSignatureCanonical(signature)
}