mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2025-08-13 19:35:34 +00:00
Use node-rsa for private pkcs1 decryption.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const crypto = require('crypto');
|
||||
const NodeRSA = require('node-rsa');
|
||||
|
||||
const BigNumber = require('./BigNumber.js');
|
||||
const mgf1 = require('./MGF1');
|
||||
@@ -54,10 +55,14 @@ module.exports = class Crypto {
|
||||
}
|
||||
|
||||
static privateDecrypt(key, data) {
|
||||
return crypto.privateDecrypt({
|
||||
key: key.toPem(),
|
||||
padding: crypto.constants.RSA_PKCS1_PADDING,
|
||||
}, data);
|
||||
const keyRSA = new NodeRSA(
|
||||
key.toPem(),
|
||||
'pkcs1-private-pem', {
|
||||
encryptionScheme: 'pkcs1',
|
||||
environment: 'browser', // would use the crypto module by default, which blocks pkcs1
|
||||
},
|
||||
);
|
||||
return keyRSA.decrypt(data);
|
||||
}
|
||||
|
||||
static privateSign(key, data, outputEncoding = 'base64') {
|
||||
|
Reference in New Issue
Block a user