-
Notifications
You must be signed in to change notification settings - Fork 0
/
mockcryptosuite.go
56 lines (44 loc) · 1.41 KB
/
mockcryptosuite.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
48
49
50
51
52
53
54
55
56
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package mocks
import (
"crypto/sha256"
"hash"
"github.com/aiguo186/fabric-sdk-go-gm/internal/github.com/aiguo186/fabric/bccsp"
"github.com/aiguo186/fabric-sdk-go-gm/pkg/common/providers/core"
)
// MockCryptoSuite implementation
type MockCryptoSuite struct {
}
// KeyGen mock key gen
func (m *MockCryptoSuite) KeyGen(opts core.KeyGenOpts) (k core.Key, k1 bccsp.Key, err error) {
return nil, nil, nil
}
// KeyImport mock key import
func (m *MockCryptoSuite) KeyImport(raw interface{},
opts core.KeyImportOpts) (k core.Key, err error) {
return nil, nil
}
// GetKey mock get key
func (m *MockCryptoSuite) GetKey(ski []byte) (k core.Key, err error) {
return nil, nil
}
// Hash mock hash
func (m *MockCryptoSuite) Hash(msg []byte, opts core.HashOpts) (hash []byte, err error) {
return nil, nil
}
// GetHash mock get hash
func (m *MockCryptoSuite) GetHash(opts core.HashOpts) (hash.Hash, error) {
return sha256.New(), nil
}
// Sign mock signing
func (m *MockCryptoSuite) Sign(k core.Key, digest []byte,
opts core.SignerOpts) (signature []byte, err error) {
return []byte("testSignature"), nil
}
// Verify mock verify implementation
func (m *MockCryptoSuite) Verify(k core.Key, signature, digest []byte, opts core.SignerOpts) (valid bool, err error) {
return true, nil
}