Skip to content

Commit

Permalink
[FAB-7577] Separate cryptosuite pkgs
Browse files Browse the repository at this point in the history
This patch splits the cryptosuite packages for sw & pkcs11
along with the underlying BCCSP factory packages for sw, pkcs11
& plugin.
Usage of the default BCCSP methods are also removed.
PKCS11 testing is split into its own package and now repeats
the e2e test with a PKCS11 configuration.

Change-Id: I484df92094588d07c0655f97c7e27abe5967d99e
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Jan 3, 2018
1 parent 65c26f4 commit fdeaed1
Show file tree
Hide file tree
Showing 50 changed files with 956 additions and 1,066 deletions.
10 changes: 5 additions & 5 deletions Makefile
Expand Up @@ -41,7 +41,6 @@ FABRIC_DEVSTABLE_VERSION_MAJOR := 1
GO_LDFLAGS ?= -s
GO_TESTFLAGS ?=
FABRIC_SDK_EXPERIMENTAL ?= true
FABRIC_SDK_PKCS11 ?= false
FABRIC_SDK_EXTRA_GO_TAGS ?=
FABRIC_SDK_POPULATE_VENDOR ?= true

Expand Down Expand Up @@ -138,17 +137,13 @@ FABRIC_STABLE_PKCS11_INTTEST := true
FABRIC_PREV_INTTEST := true
FABRIC_PRERELEASE_INTTEST := true
FABRIC_DEVSTABLE_INTTEST := true
FABRIC_SDK_PKCS11 := true
endif

# Setup Go Tags
GO_TAGS := $(FABRIC_SDK_EXTRA_GO_TAGS)
ifeq ($(FABRIC_SDK_EXPERIMENTAL),true)
GO_TAGS += experimental
endif
ifeq ($(FABRIC_SDK_PKCS11),true)
GO_TAGS += pkcs11
endif

# Detect subtarget execution
ifdef FABRIC_SDKGO_SUBTARGET
Expand Down Expand Up @@ -214,6 +209,11 @@ unit-test: checks depend populate
.PHONY: unit-tests
unit-tests: unit-test

.PHONY: unit-tests-pkcs11
unit-tests-pkcs11: checks depend populate
@FABRIC_SDKGO_CODELEVEL=$(FABRIC_CODELEVEL_UNITTEST_TAG) FABRIC_SDKGO_CODELEVEL_VER=$(FABRIC_CODELEVEL_UNITTEST_VER) $(TEST_SCRIPTS_PATH)/unit-pkcs11.sh


.PHONY: integration-tests-stable
integration-tests-stable: clean depend populate
@cd $(FIXTURE_DOCKERENV_PATH) && \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -22,9 +22,10 @@ You're good to go, happy coding! Check out the examples for usage demonstrations

### Examples

- [E2E Test](test/integration/e2e/end_to_end_test.go): Basic example that uses SDK to query and execute transaction
- [E2E Test](test/integration/e2e/end_to_end.go): Basic example that uses SDK to query and execute transaction
- [Multi Org Test](test/integration/orgs/multiple_orgs_test.go): An example that has multiple organisations involved in transaction
- [Dynamic Endorser Selection](test/integration/sdk/sdk_provider_test.go): An example that uses dynamic endorser selection (based on chaincode policy)
- [E2E PKCS11 Test](test/integration/pkcs11/e2e_test.go): E2E Test using a PKCS11 crypto suite and configuration
- [CLI](https://github.com/securekey/fabric-examples/tree/master/fabric-cli/): An example CLI for Fabric built with the Go SDK.
- More examples needed!

Expand Down Expand Up @@ -68,7 +69,6 @@ make clean

### Go Tags
The following Go tags can be supplied to enable additional functionality:
- pkcs11: includes support for configuring BCCSP with PKCS11 provider. Note: libltdl must be installed.
- experimental: includes support for experimental features.

## Contributing to the Go SDK
Expand Down
2 changes: 1 addition & 1 deletion def/fabapi/context/defprovider/sdk.go
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/hyperledger/fabric-sdk-go/def/fabapi/opt"
configImpl "github.com/hyperledger/fabric-sdk-go/pkg/config"
"github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite"
cryptosuiteimpl "github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite/bccsp"
cryptosuiteimpl "github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite/bccsp/sw"
"github.com/hyperledger/fabric-sdk-go/pkg/errors"
kvs "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/keyvaluestore"
signingMgr "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/signingmgr"
Expand Down
11 changes: 4 additions & 7 deletions def/fabapi/fabapi_test.go
Expand Up @@ -222,14 +222,11 @@ func TestNewDefaultSDKFromByte(t *testing.T) {
},
}

defer func() {
if r := recover(); r == nil {
t.Errorf("The code did not panic")
}
}()

// new SDK expected to panic due to wrong config type which didn't load the configs
NewSDK(setup)
_, err = NewSDK(setup)
if err == nil {
t.Fatalf("NewSDK should have returned error due to bad config")
}

}

Expand Down
2 changes: 1 addition & 1 deletion def/fabapi/pkgfactory.go
Expand Up @@ -12,7 +12,7 @@ import (
fabca "github.com/hyperledger/fabric-sdk-go/api/apifabca"
fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
configImpl "github.com/hyperledger/fabric-sdk-go/pkg/config"
cryptosuite "github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite/bccsp"
cryptosuite "github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite/bccsp/sw"
"github.com/hyperledger/fabric-sdk-go/pkg/errors"
fabricCAClient "github.com/hyperledger/fabric-sdk-go/pkg/fabric-ca-client"
clientImpl "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client"
Expand Down
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp/factory"
cspsigner "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp/signer"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp/utils"
"github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite"
Expand Down Expand Up @@ -48,11 +47,6 @@ const (
X509Certificate = bccsp.X509Certificate
)

// FactoryOpts holds configuration information used to initialize bccsp factory implementations
type FactoryOpts struct {
*factory.FactoryOpts
}

// NewCspSigner is a bridge for bccsp signer.New call
func NewCspSigner(csp apicryptosuite.CryptoSuite, key apicryptosuite.Key) (crypto.Signer, error) {
return cspsigner.New(csp, key)
Expand Down
97 changes: 0 additions & 97 deletions internal/github.com/hyperledger/fabric/bccsp/factory/factory.go

This file was deleted.

103 changes: 0 additions & 103 deletions internal/github.com/hyperledger/fabric/bccsp/factory/nopkcs11.go

This file was deleted.

39 changes: 0 additions & 39 deletions internal/github.com/hyperledger/fabric/bccsp/factory/opts.go

This file was deleted.

0 comments on commit fdeaed1

Please sign in to comment.