Skip to content

Commit

Permalink
FABN-1331
Browse files Browse the repository at this point in the history
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
  • Loading branch information
huxd committed Jul 31, 2019
1 parent 24bc2e8 commit 950b81f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fabric-common/lib/impl/bccsp_pkcs11.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,9 @@ class CryptoSuite_PKCS11 extends CryptoSuite {
* containing the private key and the public key.
*/
generateEphemeralKey(opts) {
if (!opts) {
opts = {};
}
if (opts !== null && (typeof opts.algorithm === 'undefined' || opts.algorithm === null)) {
opts.algorithm = 'ECDSA';
}
Expand Down Expand Up @@ -1024,6 +1027,9 @@ class CryptoSuite_PKCS11 extends CryptoSuite {
createKeyFromRaw(pem, opts) {
const optsLocal = opts ? opts : {};
const token = !optsLocal.ephemeral;
if (optsLocal !== null && (typeof optsLocal.algorithm === 'undefined' || optsLocal.algorithm === null)) {
optsLocal.algorithm = 'X509Certificate';
}
switch (optsLocal.algorithm.toUpperCase()) {
case 'X509CERTIFICATE':
return new ECDSAKey(KEYUTIL.getKey(pem));
Expand Down

0 comments on commit 950b81f

Please sign in to comment.