1 Star 0 Fork 0

妥協/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
testutils.go 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package entities
import (
"fmt"
"sync"
b "github.com/hyperledger/fabric/bccsp"
"github.com/hyperledger/fabric/bccsp/factory"
)
var bccspInst b.BCCSP
var o sync.Once
func initOnce() {
factory.InitFactories(nil)
bccspInst = factory.GetDefault()
}
func GetEncrypterEntityForTest(id string) (EncrypterEntity, error) {
o.Do(initOnce)
sk, err := bccspInst.KeyGen(&b.AES256KeyGenOpts{Temporary: true})
if err != nil {
return nil, fmt.Errorf("GetEncrypterEntityForTest error: KeyGen returned %s", err)
}
ent, err := NewEncrypterEntity(id, bccspInst, sk, &b.AESCBCPKCS7ModeOpts{}, &b.AESCBCPKCS7ModeOpts{})
if err != nil {
return nil, fmt.Errorf("GetEncrypterEntityForTest error: NewEncrypterEntity returned %s", err)
}
return ent, nil
}
func GetEncrypterSignerEntityForTest(id string) (EncrypterSignerEntity, error) {
o.Do(initOnce)
sk_enc, err := bccspInst.KeyGen(&b.AES256KeyGenOpts{Temporary: true})
if err != nil {
return nil, fmt.Errorf("GetEncrypterSignerEntityForTest error: KeyGen returned %s", err)
}
sk_sig, err := bccspInst.KeyGen(&b.ECDSAP256KeyGenOpts{Temporary: true})
if err != nil {
return nil, fmt.Errorf("GetEncrypterSignerEntityForTest error: KeyGen returned %s", err)
}
ent, err := NewEncrypterSignerEntity(id, bccspInst, sk_enc, sk_sig, &b.AESCBCPKCS7ModeOpts{}, &b.AESCBCPKCS7ModeOpts{}, nil, &b.SHA256Opts{})
if err != nil {
return nil, fmt.Errorf("GetEncrypterSignerEntityForTest error: NewEncrypterSignerEntity returned %s", err)
}
return ent, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liurenhao/fabric.git
git@gitee.com:liurenhao/fabric.git
liurenhao
fabric
fabric
v1.4.11

搜索帮助