gitee.com/zhaochuninhefei/fabric-ca-gm@v0.0.2/lib/keyrequestnopkcs11.go (about) 1 //go:build !pkcs11 2 // +build !pkcs11 3 4 /* 5 Copyright IBM Corp. All Rights Reserved. 6 7 SPDX-License-Identifier: Apache-2.0 8 */ 9 10 package lib 11 12 import ( 13 "gitee.com/zhaochuninhefei/fabric-ca-gm/internal/pkg/api" 14 "gitee.com/zhaochuninhefei/fabric-gm/bccsp" 15 ) 16 17 // GetKeyRequest constructs and returns api.KeyRequest object based on the bccsp 18 // configuration options 19 func GetKeyRequest(cfg *CAConfig) *api.KeyRequest { 20 if cfg.CSP.SwOpts != nil { 21 // 强制使用国密 22 return &api.KeyRequest{Algo: bccsp.SM2, Size: cfg.CSP.SwOpts.SecLevel} 23 } 24 return api.NewKeyRequest() 25 } 26 27 // TODO 添加GetKeyRequest的国密版本 28 func GetGMKeyRequest(cfg *CAConfig) *api.KeyRequest { 29 if cfg.CSP.SwOpts != nil { 30 return &api.KeyRequest{Algo: bccsp.SM2, Size: cfg.CSP.SwOpts.SecLevel} 31 } 32 return api.NewGMKeyRequest() 33 }