@@ -17,7 +17,6 @@ limitations under the License.
17
17
package msp
18
18
19
19
import (
20
- "crypto/ecdsa"
21
20
"crypto/x509"
22
21
"fmt"
23
22
"time"
@@ -30,7 +29,6 @@ import (
30
29
"github.com/hyperledger/fabric/core/crypto/bccsp"
31
30
"github.com/hyperledger/fabric/core/crypto/bccsp/factory"
32
31
"github.com/hyperledger/fabric/core/crypto/bccsp/signer"
33
- "github.com/hyperledger/fabric/core/crypto/bccsp/sw"
34
32
)
35
33
36
34
// This is an instantiation of an MSP that
@@ -127,19 +125,22 @@ func (msp *bccspmsp) Setup(configFile string) error {
127
125
return fmt .Errorf ("Failed to parse x509 cert, err %s" , err )
128
126
}
129
127
130
- // Extract the keypair
131
- pemKey , _ := pem .Decode (id .PublicSigner .Key )
132
- key , err := x509 .ParseECPrivateKey (pemKey .Bytes )
128
+ // Get public key
129
+ pub , err := msp .bccsp .KeyImport (cert , & bccsp.X509PublicKeyImportOpts {Temporary : true })
133
130
if err != nil {
134
- return fmt .Errorf ("Failed to parse keypair , err %s" , err )
131
+ return fmt .Errorf ("Failed to import certificate's public key , err %s" , err )
135
132
}
136
133
137
- // get the keypair in the right format
138
- pub := sw .NewEcdsaPublicKey (cert .PublicKey .(* ecdsa.PublicKey ))
134
+ // Get secret key
135
+ pemKey , _ := pem .Decode (id .PublicSigner .Key )
136
+ key , err := msp .bccsp .KeyImport (pemKey .Bytes , & bccsp.ECDSAPrivateKeyImportOpts {Temporary : true })
137
+ if err != nil {
138
+ return fmt .Errorf ("Failed to import EC private key, err %s" , err )
139
+ }
139
140
140
141
// get the peer signer
141
142
peerSigner := & signer.CryptoSigner {}
142
- err = peerSigner .Init (msp .bccsp , sw . NewEcdsaPrivateKey ( key ) )
143
+ err = peerSigner .Init (msp .bccsp , key )
143
144
if err != nil {
144
145
return fmt .Errorf ("Failed initializing CryptoSigner, err %s" , err )
145
146
}
@@ -158,7 +159,10 @@ func (msp *bccspmsp) Setup(configFile string) error {
158
159
}
159
160
160
161
// get the CA keypair in the right format
161
- CAPub := sw .NewEcdsaPublicKey (CACert .PublicKey .(* ecdsa.PublicKey ))
162
+ CAPub , err := msp .bccsp .KeyImport (CACert , & bccsp.X509PublicKeyImportOpts {Temporary : true })
163
+ if err != nil {
164
+ return fmt .Errorf ("Failed to import certitifacate's public key [%s]" , err )
165
+ }
162
166
163
167
// Set the trusted identity related to the ROOT CA
164
168
rootCaIdentity := newIdentity (& IdentityIdentifier {Mspid : MSPID , Value : "ROOTCA" }, CACert , CAPub )
@@ -256,7 +260,12 @@ func (msp *bccspmsp) DeserializeIdentity(serializedID []byte) (Identity, error)
256
260
id := & IdentityIdentifier {Mspid : ProviderIdentifier {Value : msp .id .Value },
257
261
Value : "PEER" } // TODO: where should this identifier be obtained from?
258
262
259
- return newIdentity (id , cert , sw .NewEcdsaPublicKey (cert .PublicKey .(* ecdsa.PublicKey ))), nil
263
+ pub , err := msp .bccsp .KeyImport (cert , & bccsp.X509PublicKeyImportOpts {Temporary : true })
264
+ if err != nil {
265
+ return nil , fmt .Errorf ("Failed to import certitifacateś public key [%s]" , err )
266
+ }
267
+
268
+ return newIdentity (id , cert , pub ), nil
260
269
}
261
270
262
271
func (msp * bccspmsp ) DeleteSigningIdentity (identifier string ) (bool , error ) {
0 commit comments