diff options
Diffstat (limited to 'node_modules/parse-asn1/fixProc.js')
-rw-r--r-- | node_modules/parse-asn1/fixProc.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/node_modules/parse-asn1/fixProc.js b/node_modules/parse-asn1/fixProc.js index 655c3cf2e..b50042ab0 100644 --- a/node_modules/parse-asn1/fixProc.js +++ b/node_modules/parse-asn1/fixProc.js @@ -1,7 +1,7 @@ // adapted from https://github.com/apatil/pemstrip -var findProc = /Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m -var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m -var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m +var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m +var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----/m +var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m var evp = require('evp_bytestokey') var ciphers = require('browserify-aes') module.exports = function (okey, password) { @@ -10,11 +10,11 @@ module.exports = function (okey, password) { var decrypted if (!match) { var match2 = key.match(fullRegex) - decrypted = new Buffer(match2[2].replace(/\r?\n/g, ''), 'base64') + decrypted = new Buffer(match2[2].replace(/[\r\n]/g, ''), 'base64') } else { var suite = 'aes' + match[1] var iv = new Buffer(match[2], 'hex') - var cipherText = new Buffer(match[3].replace(/\r?\n/g, ''), 'base64') + var cipherText = new Buffer(match[3].replace(/[\r\n]/g, ''), 'base64') var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key var out = [] var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) |