github.com/bestbeforetoday/fabric-ca@v2.0.0-alpha+incompatible/util/mocks/bccsp.go (about)

     1  /*
     2  Copyright IBM Corp. 2017 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  		 http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package mocks
    18  
    19  import (
    20  	"hash"
    21  
    22  	"github.com/hyperledger/fabric/bccsp"
    23  	"github.com/stretchr/testify/mock"
    24  )
    25  
    26  // BCCSP mocks a BCCSP to be used in the util package
    27  type BCCSP struct {
    28  	mock.Mock
    29  }
    30  
    31  // KeyGen generates a key using opts.
    32  func (*BCCSP) KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error) {
    33  	panic("implement me")
    34  }
    35  
    36  // KeyDeriv derives a key from k using opts.
    37  // The opts argument should be appropriate for the primitive used.
    38  func (*BCCSP) KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error) {
    39  	panic("implement me")
    40  }
    41  
    42  // KeyImport imports a key from its raw representation using opts.
    43  // The opts argument should be appropriate for the primitive used.
    44  func (m *BCCSP) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error) {
    45  	args := m.Called(raw, opts)
    46  	if args.Get(0) == nil {
    47  		return nil, args.Error(1)
    48  	}
    49  	return args.Get(0).(bccsp.Key), args.Error(1)
    50  }
    51  
    52  // GetKey returns the key this CSP associates to
    53  // the Subject Key Identifier ski.
    54  func (*BCCSP) GetKey(ski []byte) (k bccsp.Key, err error) {
    55  	panic("implement me")
    56  }
    57  
    58  // Hash hashes messages msg using options opts.
    59  // If opts is nil, the default hash function will be used.
    60  func (*BCCSP) Hash(msg []byte, opts bccsp.HashOpts) (hash []byte, err error) {
    61  	panic("implement me")
    62  }
    63  
    64  // GetHash returns and instance of hash.Hash using options opts.
    65  // If opts is nil, the default hash function will be returned.
    66  func (*BCCSP) GetHash(opts bccsp.HashOpts) (h hash.Hash, err error) {
    67  	panic("implement me")
    68  }
    69  
    70  // Sign signs digest using key k.
    71  // The opts argument should be appropriate for the algorithm used.
    72  //
    73  // Note that when a signature of a hash of a larger message is needed,
    74  // the caller is responsible for hashing the larger message and passing
    75  // the hash (as digest).
    76  func (*BCCSP) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error) {
    77  	panic("implement me")
    78  }
    79  
    80  // Verify verifies signature against key k and digest
    81  // The opts argument should be appropriate for the algorithm used.
    82  func (*BCCSP) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error) {
    83  	panic("implement me")
    84  }
    85  
    86  // Encrypt encrypts plaintext using key k.
    87  // The opts argument should be appropriate for the algorithm used.
    88  func (*BCCSP) Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) (ciphertext []byte, err error) {
    89  	panic("implement me")
    90  }
    91  
    92  // Decrypt decrypts ciphertext using key k.
    93  // The opts argument should be appropriate for the algorithm used.
    94  func (*BCCSP) Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error) {
    95  	panic("implement me")
    96  }