Skip to content

Commit

Permalink
[FAB-18323] CherryPick: remove ephemeral from BCCSP SW options (#1553)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Sykes <[email protected]>
Signed-off-by: Wenjian Qiao <[email protected]>
  • Loading branch information
sykesm authored and wenjianqiao committed Dec 2, 2020
1 parent cb36614 commit e4c2594
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bccsp/factory/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BCCSP:
cfgVariations := []*FactoryOpts{
{},
{ProviderName: "SW"},
{ProviderName: "SW", SwOpts: &SwOpts{HashFamily: "SHA2", SecLevel: 256, Ephemeral: true}},
{ProviderName: "SW", SwOpts: &SwOpts{HashFamily: "SHA2", SecLevel: 256}},
yamlBCCSP,
}

Expand Down
1 change: 0 additions & 1 deletion bccsp/factory/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func GetDefaultOpts() *FactoryOpts {
SwOpts: &SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
},
}
}
Expand Down
1 change: 0 additions & 1 deletion bccsp/factory/pkcs11_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func TestInitFactoriesInvalidArgs(t *testing.T) {
func TestGetBCCSPFromOpts(t *testing.T) {
opts := GetDefaultOpts()
opts.SwOpts.FileKeystore = &FileKeystoreOpts{KeyStorePath: os.TempDir()}
opts.SwOpts.Ephemeral = false
csp, err := GetBCCSPFromOpts(opts)
assert.NoError(t, err)
assert.NotNil(t, csp)
Expand Down
9 changes: 2 additions & 7 deletions bccsp/factory/swfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ func (f *SWFactory) Get(config *FactoryOpts) (bccsp.BCCSP, error) {

var ks bccsp.KeyStore
switch {
case swOpts.Ephemeral:
ks = sw.NewDummyKeyStore()
case swOpts.FileKeystore != nil:
fks, err := sw.NewFileBasedKeyStore(nil, swOpts.FileKeystore.KeyStorePath, false)
if err != nil {
Expand All @@ -66,11 +64,8 @@ func (f *SWFactory) Get(config *FactoryOpts) (bccsp.BCCSP, error) {
// SwOpts contains options for the SWFactory
type SwOpts struct {
// Default algorithms when not specified (Deprecated?)
SecLevel int `mapstructure:"security" json:"security" yaml:"Security"`
HashFamily string `mapstructure:"hash" json:"hash" yaml:"Hash"`

// Keystore Options
Ephemeral bool `mapstructure:"tempkeys,omitempty" json:"tempkeys,omitempty"`
SecLevel int `mapstructure:"security" json:"security" yaml:"Security"`
HashFamily string `mapstructure:"hash" json:"hash" yaml:"Hash"`
FileKeystore *FileKeystoreOpts `mapstructure:"filekeystore,omitempty" json:"filekeystore,omitempty" yaml:"FileKeyStore"`
DummyKeystore *DummyKeystoreOpts `mapstructure:"dummykeystore,omitempty" json:"dummykeystore,omitempty"`
InmemKeystore *InmemKeystoreOpts `mapstructure:"inmemkeystore,omitempty" json:"inmemkeystore,omitempty"`
Expand Down
12 changes: 11 additions & 1 deletion bccsp/pkcs11/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ func New(opts PKCS11Opts, keyStore bccsp.KeyStore) (bccsp.BCCSP, error) {
}

sessions := make(chan pkcs11.SessionHandle, sessionCacheSize)
csp := &impl{swCSP, conf, ctx, sessions, slot, pin, lib, opts.SoftVerify, opts.Immutable}
csp := &impl{
BCCSP: swCSP,
conf: conf,
ctx: ctx,
sessions: sessions,
slot: slot,
pin: pin,
lib: lib,
softVerify: opts.SoftVerify,
immutable: opts.Immutable,
}
csp.returnSession(*session)
return csp, nil
}
Expand Down
1 change: 0 additions & 1 deletion msp/configbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func SetupBCCSPKeystoreConfig(bccspConfig *factory.FactoryOpts, keystoreDir stri
// Only override the KeyStorePath if it was left empty
if bccspConfig.SwOpts.FileKeystore == nil ||
bccspConfig.SwOpts.FileKeystore.KeyStorePath == "" {
bccspConfig.SwOpts.Ephemeral = false
bccspConfig.SwOpts.FileKeystore = &factory.FileKeystoreOpts{KeyStorePath: keystoreDir}
}
}
Expand Down
2 changes: 0 additions & 2 deletions msp/configbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestSetupBCCSPKeystoreConfig(t *testing.T) {
bccspConfig.SwOpts = &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
}
rtnConfig = SetupBCCSPKeystoreConfig(bccspConfig, keystoreDir)
assert.NotNil(t, rtnConfig.SwOpts.FileKeystore)
Expand Down Expand Up @@ -77,7 +76,6 @@ func TestSetupBCCSPKeystoreConfig(t *testing.T) {
bccspConfig.SwOpts = &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
}
rtnConfig = SetupBCCSPKeystoreConfig(bccspConfig, keystoreDir)
assert.NotNil(t, rtnConfig.SwOpts.FileKeystore)
Expand Down
2 changes: 0 additions & 2 deletions orderer/common/server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ func TestLoadLocalMSP(t *testing.T) {
SwOpts: &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
},
},
},
Expand Down Expand Up @@ -876,7 +875,6 @@ func genesisConfig(t *testing.T, genesisFile string) *localconfig.TopLevel {
SwOpts: &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
},
},
},
Expand Down

0 comments on commit e4c2594

Please sign in to comment.