Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions bccsp/sw/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ package sw
import (
"crypto/elliptic"
"crypto/sha256"
"crypto/sha3"
"crypto/sha512"
"fmt"
"hash"

"golang.org/x/crypto/sha3"
)

type config struct {
Expand Down Expand Up @@ -57,12 +56,16 @@ func (conf *config) setSecurityLevelSHA3(level int) (err error) {
switch level {
case 256:
conf.ellipticCurve = elliptic.P256()
conf.hashFunction = sha3.New256
conf.hashFunction = func() hash.Hash {
return sha3.New256()
}
conf.rsaBitLength = 2048
conf.aesBitLength = 32
case 384:
conf.ellipticCurve = elliptic.P384()
conf.hashFunction = sha3.New384
conf.hashFunction = func() hash.Hash {
return sha3.New384()
}
conf.rsaBitLength = 3072
conf.aesBitLength = 32
default:
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"crypto/elliptic"
"crypto/rand"
"crypto/sha256"
"crypto/sha3"
"crypto/sha512"
"crypto/x509"
"crypto/x509/pkix"
Expand All @@ -30,7 +31,6 @@ import (
"github.com/hyperledger/fabric-lib-go/bccsp/sw/mocks"
"github.com/hyperledger/fabric-lib-go/bccsp/utils"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3"
)

var (
Expand Down
11 changes: 8 additions & 3 deletions bccsp/sw/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ package sw
import (
"crypto/elliptic"
"crypto/sha256"
"crypto/sha3"
"crypto/sha512"
"hash"
"reflect"

"github.com/hyperledger/fabric-lib-go/bccsp"
"github.com/pkg/errors"
"golang.org/x/crypto/sha3"
)

// NewDefaultSecurityLevel returns a new instance of the software-based BCCSP
Expand Down Expand Up @@ -75,8 +76,12 @@ func NewWithParams(securityLevel int, hashFamily string, keyStore bccsp.KeyStore
swbccsp.AddWrapper(reflect.TypeOf(&bccsp.SHAOpts{}), &hasher{hash: conf.hashFunction})
swbccsp.AddWrapper(reflect.TypeOf(&bccsp.SHA256Opts{}), &hasher{hash: sha256.New})
swbccsp.AddWrapper(reflect.TypeOf(&bccsp.SHA384Opts{}), &hasher{hash: sha512.New384})
swbccsp.AddWrapper(reflect.TypeOf(&bccsp.SHA3_256Opts{}), &hasher{hash: sha3.New256})
swbccsp.AddWrapper(reflect.TypeOf(&bccsp.SHA3_384Opts{}), &hasher{hash: sha3.New384})
swbccsp.AddWrapper(reflect.TypeOf(&bccsp.SHA3_256Opts{}), &hasher{hash: func() hash.Hash {
return sha3.New256()
}})
swbccsp.AddWrapper(reflect.TypeOf(&bccsp.SHA3_384Opts{}), &hasher{hash: func() hash.Hash {
return sha3.New384()
}})

// Set the key generators
swbccsp.AddWrapper(reflect.TypeOf(&bccsp.ECDSAKeyGenOpts{}), &ecdsaKeyGenerator{curve: conf.ellipticCurve})
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/stretchr/testify v1.9.0
github.com/sykesm/zap-logfmt v0.0.4
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.37.0
golang.org/x/tools v0.28.0
google.golang.org/grpc v1.67.1
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down
27 changes: 0 additions & 27 deletions vendor/golang.org/x/crypto/LICENSE

This file was deleted.

22 changes: 0 additions & 22 deletions vendor/golang.org/x/crypto/PATENTS

This file was deleted.

66 changes: 0 additions & 66 deletions vendor/golang.org/x/crypto/sha3/doc.go

This file was deleted.

128 changes: 0 additions & 128 deletions vendor/golang.org/x/crypto/sha3/hashes.go

This file was deleted.

23 changes: 0 additions & 23 deletions vendor/golang.org/x/crypto/sha3/hashes_noasm.go

This file was deleted.

Loading