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

Commit 950b81f

Browse files
author
huxd
committed
FABN-1331
fix functions in bccsp_pkcs11.js to check input parameter opts and set default for algorithm before using them: createKeyFromRaw generateEphemeralKey Signed-off-by: huxd <huxd@cn.ibm.com> Change-Id: I9632ff33ba005c50c171e8001440e643e636684e
1 parent 24bc2e8 commit 950b81f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fabric-common/lib/impl/bccsp_pkcs11.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,9 @@ class CryptoSuite_PKCS11 extends CryptoSuite {
800800
* containing the private key and the public key.
801801
*/
802802
generateEphemeralKey(opts) {
803+
if (!opts) {
804+
opts = {};
805+
}
803806
if (opts !== null && (typeof opts.algorithm === 'undefined' || opts.algorithm === null)) {
804807
opts.algorithm = 'ECDSA';
805808
}
@@ -1024,6 +1027,9 @@ class CryptoSuite_PKCS11 extends CryptoSuite {
10241027
createKeyFromRaw(pem, opts) {
10251028
const optsLocal = opts ? opts : {};
10261029
const token = !optsLocal.ephemeral;
1030+
if (optsLocal !== null && (typeof optsLocal.algorithm === 'undefined' || optsLocal.algorithm === null)) {
1031+
optsLocal.algorithm = 'X509Certificate';
1032+
}
10271033
switch (optsLocal.algorithm.toUpperCase()) {
10281034
case 'X509CERTIFICATE':
10291035
return new ECDSAKey(KEYUTIL.getKey(pem));

0 commit comments

Comments
 (0)