Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit fdeaed1

Browse files
committed
[FAB-7577] Separate cryptosuite pkgs
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>
1 parent 65c26f4 commit fdeaed1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+956
-1066
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ FABRIC_DEVSTABLE_VERSION_MAJOR := 1
4141
GO_LDFLAGS ?= -s
4242
GO_TESTFLAGS ?=
4343
FABRIC_SDK_EXPERIMENTAL ?= true
44-
FABRIC_SDK_PKCS11 ?= false
4544
FABRIC_SDK_EXTRA_GO_TAGS ?=
4645
FABRIC_SDK_POPULATE_VENDOR ?= true
4746

@@ -138,17 +137,13 @@ FABRIC_STABLE_PKCS11_INTTEST := true
138137
FABRIC_PREV_INTTEST := true
139138
FABRIC_PRERELEASE_INTTEST := true
140139
FABRIC_DEVSTABLE_INTTEST := true
141-
FABRIC_SDK_PKCS11 := true
142140
endif
143141

144142
# Setup Go Tags
145143
GO_TAGS := $(FABRIC_SDK_EXTRA_GO_TAGS)
146144
ifeq ($(FABRIC_SDK_EXPERIMENTAL),true)
147145
GO_TAGS += experimental
148146
endif
149-
ifeq ($(FABRIC_SDK_PKCS11),true)
150-
GO_TAGS += pkcs11
151-
endif
152147

153148
# Detect subtarget execution
154149
ifdef FABRIC_SDKGO_SUBTARGET
@@ -214,6 +209,11 @@ unit-test: checks depend populate
214209
.PHONY: unit-tests
215210
unit-tests: unit-test
216211

212+
.PHONY: unit-tests-pkcs11
213+
unit-tests-pkcs11: checks depend populate
214+
@FABRIC_SDKGO_CODELEVEL=$(FABRIC_CODELEVEL_UNITTEST_TAG) FABRIC_SDKGO_CODELEVEL_VER=$(FABRIC_CODELEVEL_UNITTEST_VER) $(TEST_SCRIPTS_PATH)/unit-pkcs11.sh
215+
216+
217217
.PHONY: integration-tests-stable
218218
integration-tests-stable: clean depend populate
219219
@cd $(FIXTURE_DOCKERENV_PATH) && \

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ You're good to go, happy coding! Check out the examples for usage demonstrations
2222

2323
### Examples
2424

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

@@ -68,7 +69,6 @@ make clean
6869

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

7474
## Contributing to the Go SDK

def/fabapi/context/defprovider/sdk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/hyperledger/fabric-sdk-go/def/fabapi/opt"
1515
configImpl "github.com/hyperledger/fabric-sdk-go/pkg/config"
1616
"github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite"
17-
cryptosuiteimpl "github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite/bccsp"
17+
cryptosuiteimpl "github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite/bccsp/sw"
1818
"github.com/hyperledger/fabric-sdk-go/pkg/errors"
1919
kvs "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/keyvaluestore"
2020
signingMgr "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/signingmgr"

def/fabapi/fabapi_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,11 @@ func TestNewDefaultSDKFromByte(t *testing.T) {
222222
},
223223
}
224224

225-
defer func() {
226-
if r := recover(); r == nil {
227-
t.Errorf("The code did not panic")
228-
}
229-
}()
230-
231225
// new SDK expected to panic due to wrong config type which didn't load the configs
232-
NewSDK(setup)
226+
_, err = NewSDK(setup)
227+
if err == nil {
228+
t.Fatalf("NewSDK should have returned error due to bad config")
229+
}
233230

234231
}
235232

def/fabapi/pkgfactory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
fabca "github.com/hyperledger/fabric-sdk-go/api/apifabca"
1313
fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
1414
configImpl "github.com/hyperledger/fabric-sdk-go/pkg/config"
15-
cryptosuite "github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite/bccsp"
15+
cryptosuite "github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite/bccsp/sw"
1616
"github.com/hyperledger/fabric-sdk-go/pkg/errors"
1717
fabricCAClient "github.com/hyperledger/fabric-sdk-go/pkg/fabric-ca-client"
1818
clientImpl "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client"

internal/github.com/hyperledger/fabric-ca/sdkpatch/cryptosuitebridge/cryptosuitebridge.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
1818
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp"
19-
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp/factory"
2019
cspsigner "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp/signer"
2120
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp/utils"
2221
"github.com/hyperledger/fabric-sdk-go/pkg/cryptosuite"
@@ -48,11 +47,6 @@ const (
4847
X509Certificate = bccsp.X509Certificate
4948
)
5049

51-
// FactoryOpts holds configuration information used to initialize bccsp factory implementations
52-
type FactoryOpts struct {
53-
*factory.FactoryOpts
54-
}
55-
5650
// NewCspSigner is a bridge for bccsp signer.New call
5751
func NewCspSigner(csp apicryptosuite.CryptoSuite, key apicryptosuite.Key) (crypto.Signer, error) {
5852
return cspsigner.New(csp, key)

internal/github.com/hyperledger/fabric/bccsp/factory/factory.go

Lines changed: 0 additions & 97 deletions
This file was deleted.

internal/github.com/hyperledger/fabric/bccsp/factory/nopkcs11.go

Lines changed: 0 additions & 103 deletions
This file was deleted.

internal/github.com/hyperledger/fabric/bccsp/factory/opts.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)