github.com/cactusblossom/fabric-ca@v0.0.0-20200611062428-0082fc643826/lib/keyrequest.go (about)

     1  // +build pkcs11
     2  
     3  /*
     4  Copyright IBM Corp. All Rights Reserved.
     5  
     6  SPDX-License-Identifier: Apache-2.0
     7  */
     8  
     9  package lib
    10  
    11  import "github.com/hyperledger/fabric-ca/api"
    12  
    13  // GetKeyRequest constructs and returns api.BasicKeyRequest object based on the bccsp
    14  // configuration options
    15  func GetKeyRequest(cfg *CAConfig) *api.BasicKeyRequest {
    16  	if cfg.CSP.SwOpts != nil {
    17  		return &api.BasicKeyRequest{Algo: "ecdsa", Size: cfg.CSP.SwOpts.SecLevel}
    18  	} else if cfg.CSP.Pkcs11Opts != nil {
    19  		return &api.BasicKeyRequest{Algo: "ecdsa", Size: cfg.CSP.Pkcs11Opts.SecLevel}
    20  	} else {
    21  		return api.NewBasicKeyRequest()
    22  	}
    23  }