Skip to content

Commit 80a20e3

Browse files
sykesmmastersingh24
authored andcommitted
Remove RSA crypto operations from BCCSP
The RSA operations are not used within Fabric. FAB-15753 #done Change-Id: I23d565b5f7990597dde79e6c7194e106371d45d3 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent d21e105 commit 80a20e3

25 files changed

+47
-1936
lines changed

bccsp/bccsp.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package bccsp

bccsp/bccsp_test.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,6 @@ func TestAESOpts(t *testing.T) {
4646
assert.False(t, opts.Ephemeral())
4747
}
4848

49-
func TestRSAOpts(t *testing.T) {
50-
test := func(ephemeral bool) {
51-
for _, opts := range []KeyGenOpts{
52-
&RSA1024KeyGenOpts{ephemeral},
53-
&RSA2048KeyGenOpts{ephemeral},
54-
&RSA3072KeyGenOpts{ephemeral},
55-
&RSA4096KeyGenOpts{ephemeral},
56-
} {
57-
expectedAlgorithm := reflect.TypeOf(opts).String()[7:14]
58-
assert.Equal(t, expectedAlgorithm, opts.Algorithm())
59-
assert.Equal(t, ephemeral, opts.Ephemeral())
60-
}
61-
}
62-
test(true)
63-
test(false)
64-
}
65-
6649
func TestECDSAOpts(t *testing.T) {
6750
test := func(ephemeral bool) {
6851
for _, opts := range []KeyGenOpts{
@@ -133,17 +116,13 @@ func TestHMAC(t *testing.T) {
133116

134117
func TestKeyGenOpts(t *testing.T) {
135118
expectedAlgorithms := map[reflect.Type]string{
136-
reflect.TypeOf(&HMACImportKeyOpts{}): "HMAC",
137-
reflect.TypeOf(&RSAKeyGenOpts{}): "RSA",
138-
reflect.TypeOf(&RSAGoPublicKeyImportOpts{}): "RSA",
139-
reflect.TypeOf(&X509PublicKeyImportOpts{}): "X509Certificate",
140-
reflect.TypeOf(&AES256ImportKeyOpts{}): "AES",
119+
reflect.TypeOf(&HMACImportKeyOpts{}): "HMAC",
120+
reflect.TypeOf(&X509PublicKeyImportOpts{}): "X509Certificate",
121+
reflect.TypeOf(&AES256ImportKeyOpts{}): "AES",
141122
}
142123
test := func(ephemeral bool) {
143124
for _, opts := range []KeyGenOpts{
144125
&HMACImportKeyOpts{ephemeral},
145-
&RSAKeyGenOpts{ephemeral},
146-
&RSAGoPublicKeyImportOpts{ephemeral},
147126
&X509PublicKeyImportOpts{ephemeral},
148127
&AES256ImportKeyOpts{ephemeral},
149128
} {

bccsp/idemixerrs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Copyright IBM Corp. All Rights Reserved.
33
44
SPDX-License-Identifier: Apache-2.0
55
*/
6+
67
package bccsp
78

89
import (

bccsp/opts.go

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package bccsp
@@ -32,19 +22,6 @@ const (
3222
// ECDSAReRand ECDSA key re-randomization
3323
ECDSAReRand = "ECDSA_RERAND"
3424

35-
// RSA at the default security level.
36-
// Each BCCSP may or may not support default security level. If not supported than
37-
// an error will be returned.
38-
RSA = "RSA"
39-
// RSA at 1024 bit security level.
40-
RSA1024 = "RSA1024"
41-
// RSA at 2048 bit security level.
42-
RSA2048 = "RSA2048"
43-
// RSA at 3072 bit security level.
44-
RSA3072 = "RSA3072"
45-
// RSA at 4096 bit security level.
46-
RSA4096 = "RSA4096"
47-
4825
// AES Advanced Encryption Standard at the default security level.
4926
// Each BCCSP may or may not support default security level. If not supported than
5027
// an error will be returned.
@@ -265,46 +242,13 @@ func (opts *HMACImportKeyOpts) Ephemeral() bool {
265242
}
266243

267244
// SHAOpts contains options for computing SHA.
268-
type SHAOpts struct {
269-
}
245+
type SHAOpts struct{}
270246

271247
// Algorithm returns the hash algorithm identifier (to be used).
272248
func (opts *SHAOpts) Algorithm() string {
273249
return SHA
274250
}
275251

276-
// RSAKeyGenOpts contains options for RSA key generation.
277-
type RSAKeyGenOpts struct {
278-
Temporary bool
279-
}
280-
281-
// Algorithm returns the key generation algorithm identifier (to be used).
282-
func (opts *RSAKeyGenOpts) Algorithm() string {
283-
return RSA
284-
}
285-
286-
// Ephemeral returns true if the key to generate has to be ephemeral,
287-
// false otherwise.
288-
func (opts *RSAKeyGenOpts) Ephemeral() bool {
289-
return opts.Temporary
290-
}
291-
292-
// RSAGoPublicKeyImportOpts contains options for RSA key importation from rsa.PublicKey
293-
type RSAGoPublicKeyImportOpts struct {
294-
Temporary bool
295-
}
296-
297-
// Algorithm returns the key importation algorithm identifier (to be used).
298-
func (opts *RSAGoPublicKeyImportOpts) Algorithm() string {
299-
return RSA
300-
}
301-
302-
// Ephemeral returns true if the key to generate has to be ephemeral,
303-
// false otherwise.
304-
func (opts *RSAGoPublicKeyImportOpts) Ephemeral() bool {
305-
return opts.Temporary
306-
}
307-
308252
// X509PublicKeyImportOpts contains options for importing public keys from an x509 certificate
309253
type X509PublicKeyImportOpts struct {
310254
Temporary bool

bccsp/pkcs11/conf.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type config struct {
2020
ellipticCurve asn1.ObjectIdentifier
2121
hashFunction func() hash.Hash
2222
aesBitLength int
23-
rsaBitLength int
2423
}
2524

2625
func (conf *config) setSecurityLevel(securityLevel int, hashFamily string) (err error) {
@@ -40,12 +39,10 @@ func (conf *config) setSecurityLevelSHA2(level int) (err error) {
4039
case 256:
4140
conf.ellipticCurve = oidNamedCurveP256
4241
conf.hashFunction = sha256.New
43-
conf.rsaBitLength = 2048
4442
conf.aesBitLength = 32
4543
case 384:
4644
conf.ellipticCurve = oidNamedCurveP384
4745
conf.hashFunction = sha512.New384
48-
conf.rsaBitLength = 3072
4946
conf.aesBitLength = 32
5047
default:
5148
err = fmt.Errorf("Security level not supported [%d]", level)
@@ -58,12 +55,10 @@ func (conf *config) setSecurityLevelSHA3(level int) (err error) {
5855
case 256:
5956
conf.ellipticCurve = oidNamedCurveP256
6057
conf.hashFunction = sha3.New256
61-
conf.rsaBitLength = 2048
6258
conf.aesBitLength = 32
6359
case 384:
6460
conf.ellipticCurve = oidNamedCurveP384
6561
conf.hashFunction = sha3.New384
66-
conf.rsaBitLength = 3072
6762
conf.aesBitLength = 32
6863
default:
6964
err = fmt.Errorf("Security level not supported [%d]", level)

bccsp/pkcs11/ecdsakey_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ func TestX509PublicKeyImportOptsKeyImporter(t *testing.T) {
3434
cert.PublicKey = "Hello world"
3535
_, err = ki.KeyImport(cert, &bccsp.X509PublicKeyImportOpts{})
3636
assert.Error(t, err)
37-
assert.Contains(t, err.Error(), "Certificate's public key type not recognized. Supported keys: [ECDSA, RSA]")
37+
assert.Contains(t, err.Error(), "Certificate's public key type not recognized. Supported keys: [ECDSA]")
3838
}

bccsp/pkcs11/impl.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package pkcs11
88

99
import (
1010
"crypto/ecdsa"
11-
"crypto/rsa"
1211
"crypto/x509"
1312
"os"
1413

@@ -138,10 +137,8 @@ func (csp *impl) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.K
138137
switch pk.(type) {
139138
case *ecdsa.PublicKey:
140139
return csp.KeyImport(pk, &bccsp.ECDSAGoPublicKeyImportOpts{Temporary: opts.Ephemeral()})
141-
case *rsa.PublicKey:
142-
return csp.KeyImport(pk, &bccsp.RSAGoPublicKeyImportOpts{Temporary: opts.Ephemeral()})
143140
default:
144-
return nil, errors.New("Certificate's public key type not recognized. Supported keys: [ECDSA, RSA]")
141+
return nil, errors.New("Certificate's public key type not recognized. Supported keys: [ECDSA]")
145142
}
146143

147144
default:

0 commit comments

Comments
 (0)