Skip to content

Commit

Permalink
[FAB-6258] Bump fabric third_party revision
Browse files Browse the repository at this point in the history
Change-Id: Ifbb36fe86bef648faecf03a42cee936fc725a790
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Dec 21, 2017
1 parent 8d39602 commit d0a811d
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ FABRIC_DEV_REGISTRY_PRE_CMD ?= docker login -u docker -p docker nexus3.hyperledg
THIRDPARTY_FABRIC_CA_BRANCH ?= master
THIRDPARTY_FABRIC_CA_COMMIT ?= v1.1.0-preview
THIRDPARTY_FABRIC_BRANCH ?= master
THIRDPARTY_FABRIC_COMMIT ?= 750c1393168aae3f910c8d7831860dbd6f259078
THIRDPARTY_FABRIC_COMMIT ?= 8cad01d9f6ca890a8e09218c20ceabb9eea34103

# Force removal of images in cleanup (overridable)
FIXTURE_DOCKER_REMOVE_FORCE ?= false
Expand Down
1 change: 0 additions & 1 deletion internal/github.com/hyperledger/fabric-ca/util/csp.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func ImportBCCSPKeyFromPEM(keyFile string, myCSP apicryptosuite.CryptoSuite, tem
// ImportBCCSPKeyFromPEMBytes attempts to create a private BCCSP key from a pem byte slice
func ImportBCCSPKeyFromPEMBytes(keyBuff []byte, myCSP apicryptosuite.CryptoSuite, temporary bool) (apicryptosuite.Key, error) {
keyFile := "pem bytes"

key, err := factory.PEMtoPrivateKey(keyBuff, nil)
if err != nil {
return nil, errors.WithMessage(err, fmt.Sprintf("Failed parsing private key from %s", keyFile))
Expand Down
7 changes: 3 additions & 4 deletions internal/github.com/hyperledger/fabric-ca/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@ import (
"io/ioutil"
"math/big"
mrand "math/rand"

"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
factory "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/cryptosuitebridge"

"net/http"
"path/filepath"
"reflect"
"regexp"
"strings"
"time"

"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
factory "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/cryptosuitebridge"

"github.com/hyperledger/fabric-sdk-go/pkg/errors"

"golang.org/x/crypto/ocsp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ package signer

import (
"crypto"
"io"

"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"

"io"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/bccsp/utils"
"github.com/hyperledger/fabric-sdk-go/pkg/errors"
)
Expand Down
5 changes: 3 additions & 2 deletions internal/github.com/hyperledger/fabric/bccsp/sw/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,10 @@ func (csp *impl) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signat
return nil, errors.New("Invalid digest. Cannot be empty.")
}

signer, found := csp.signers[reflect.TypeOf(k)]
keyType := reflect.TypeOf(k)
signer, found := csp.signers[keyType]
if !found {
return nil, errors.Errorf("Unsupported 'SignKey' provided [%v]", k)
return nil, errors.Errorf("Unsupported 'SignKey' provided [%s]", keyType)
}

signature, err = signer.Sign(k, digest, opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ type ChaincodeProvider interface {
GetContext(ledger ledger.PeerLedger, txid string) (context.Context, ledger.TxSimulator, error)
// GetCCContext returns an opaque chaincode context
GetCCContext(cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal) interface{}
// GetCCValidationInfoFromLSCC returns the VSCC and the policy listed by LSCC for the supplied chaincode
GetCCValidationInfoFromLSCC(ctxt context.Context, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, chainID string, chaincodeID string) (string, []byte, error)
// ExecuteChaincode executes the chaincode given context and args
ExecuteChaincode(ctxt context.Context, cccid interface{}, args [][]byte) (*pb.Response, *pb.ChaincodeEvent, error)
// Execute executes the chaincode given context and spec (invocation or deploy)
Expand Down
5 changes: 2 additions & 3 deletions internal/github.com/hyperledger/fabric/msp/identities.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import (
"crypto/rand"
"crypto/x509"
"encoding/hex"

"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"

"encoding/pem"
"time"

"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"

"github.com/golang/protobuf/proto"
bccsp "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge"
flogging "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/sdkpatch/logbridge"
Expand Down
11 changes: 0 additions & 11 deletions internal/github.com/hyperledger/fabric/msp/mspimplsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,6 @@ func (msp *bccspmsp) setupCAs(conf *m.FabricMSPConfig) error {
msp.opts.Intermediates.AddCert(id.(*identity).cert)
}

// make and fill the set of admin certs (if present)
msp.admins = make([]Identity, len(conf.Admins))
for i, admCert := range conf.Admins {
id, _, err := msp.getIdentityFromConf(admCert)
if err != nil {
return err
}

msp.admins[i] = id
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import (
"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
)

type signer interface {
// Sign the message
Sign(msg []byte) ([]byte, error)
}

// GetEnvelopeFromBlock gets an envelope from a block's Data field.
func GetEnvelopeFromBlock(data []byte) (*common.Envelope, error) {
//Block always begins with an envelope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,34 @@ func SignedBy(index int32) *cb.SignaturePolicy {
// SignedByMspMember creates a SignaturePolicyEnvelope
// requiring 1 signature from any member of the specified MSP
func SignedByMspMember(mspId string) *cb.SignaturePolicyEnvelope {
return signedByFabricEntity(mspId, msp.MSPRole_MEMBER)
}

// SignedByMspClient creates a SignaturePolicyEnvelope
// requiring 1 signature from any client of the specified MSP
func SignedByMspClient(mspId string) *cb.SignaturePolicyEnvelope {
return signedByFabricEntity(mspId, msp.MSPRole_CLIENT)
}

// SignedByMspPeer creates a SignaturePolicyEnvelope
// requiring 1 signature from any peer of the specified MSP
func SignedByMspPeer(mspId string) *cb.SignaturePolicyEnvelope {
return signedByFabricEntity(mspId, msp.MSPRole_PEER)
}

// SignedByMspOrderer creates a SignaturePolicyEnvelope
// requiring 1 signature from any orderer of the specified MSP
func SignedByMspOrderer(mspId string) *cb.SignaturePolicyEnvelope {
return signedByFabricEntity(mspId, msp.MSPRole_ORDERER)
}

// SignedByFabricEntity creates a SignaturePolicyEnvelope
// requiring 1 signature from any fabric entity, having the passed role, of the specified MSP
func signedByFabricEntity(mspId string, role msp.MSPRole_MSPRoleType) *cb.SignaturePolicyEnvelope {
// specify the principal: it's a member of the msp we just found
principal := &msp.MSPPrincipal{
PrincipalClassification: msp.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&msp.MSPRole{Role: msp.MSPRole_MEMBER, MspIdentifier: mspId})}
Principal: utils.MarshalOrPanic(&msp.MSPRole{Role: role, MspIdentifier: mspId})}

// create the policy: it requires exactly 1 signature from the first (and only) principal
p := &cb.SignaturePolicyEnvelope{
Expand Down Expand Up @@ -148,6 +172,27 @@ func SignedByAnyMember(ids []string) *cb.SignaturePolicyEnvelope {
return signedByAnyOfGivenRole(msp.MSPRole_MEMBER, ids)
}

// SignedByAnyClient returns a policy that requires one valid
// signature from a client of any of the orgs whose ids are
// listed in the supplied string array
func SignedByAnyClient(ids []string) *cb.SignaturePolicyEnvelope {
return signedByAnyOfGivenRole(msp.MSPRole_CLIENT, ids)
}

// SignedByAnyOrderer returns a policy that requires one valid
// signature from an orderer of any of the orgs whose ids are
// listed in the supplied string array
func SignedByAnyOrderer(ids []string) *cb.SignaturePolicyEnvelope {
return signedByAnyOfGivenRole(msp.MSPRole_ORDERER, ids)
}

// SignedByAnyPeer returns a policy that requires one valid
// signature from an orderer of any of the orgs whose ids are
// listed in the supplied string array
func SignedByAnyPeer(ids []string) *cb.SignaturePolicyEnvelope {
return signedByAnyOfGivenRole(msp.MSPRole_PEER, ids)
}

// SignedByAnyAdmin returns a policy that requires one valid
// signature from a admin of any of the orgs whose ids are
// listed in the supplied string array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/msp"
)

var regex *regexp.Regexp = regexp.MustCompile("^([[:alnum:]]+)([.])(member|admin)$")
var regex *regexp.Regexp = regexp.MustCompile("^([[:alnum:]]+)([.])(member|admin|client|peer|orderer)$")
var regexErr *regexp.Regexp = regexp.MustCompile("^No parameter '([^']+)' found[.]$")

// a stub function - it returns the same string as it's passed.
Expand Down Expand Up @@ -143,7 +143,7 @@ func secondPass(args ...interface{}) (interface{}, error) {
switch t := principal.(type) {
/* if it's a string, we expect it to be formed as
<MSP_ID> . <ROLE>, where MSP_ID is the MSP identifier
and ROLE is either a member of an admin*/
and ROLE is either a member, an admin, a client, a peer or an orderer*/
case string:
/* split the string */
subm := regex.FindAllStringSubmatch(t, -1)
Expand All @@ -153,10 +153,19 @@ func secondPass(args ...interface{}) (interface{}, error) {

/* get the right role */
var r msp.MSPRole_MSPRoleType
if subm[0][3] == "member" {
switch subm[0][3] {
case "member":
r = msp.MSPRole_MEMBER
} else {
case "admin":
r = msp.MSPRole_ADMIN
case "client":
r = msp.MSPRole_CLIENT
case "peer":
r = msp.MSPRole_PEER
case "orderer":
r = msp.MSPRole_ORDERER
default:
return nil, fmt.Errorf("Error parsing role %s", t)
}

/* build the principal we've been told */
Expand Down Expand Up @@ -214,7 +223,7 @@ func newContext() *context {
//
// where
// - ORG is a string (representing the MSP identifier)
// - ROLE is either the string "member" or the string "admin" representing the required role
// - ROLE is either the string "member", "admin", "client", "peer", or the string "orderer" representing the required role
func FromString(policy string) (*common.SignaturePolicyEnvelope, error) {
// first we translate the and/or business into outof gates
intermediate, err := govaluate.NewEvaluableExpressionWithFunctions(policy, map[string]govaluate.ExpressionFunction{"AND": and, "and": and, "OR": or, "or": or, "OUTOF": outof, "outof": outof, "OutOf": outof})
Expand Down
Loading

0 comments on commit d0a811d

Please sign in to comment.