parse-asn1
Advanced tools
Comparing version 5.1.0 to 5.1.1
// 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') | ||
@@ -13,7 +13,7 @@ var ciphers = require('browserify-aes') | ||
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 | ||
@@ -20,0 +20,0 @@ var out = [] |
{ | ||
"name": "parse-asn1", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "utility library for parsing asn1 files for use with browserify-sign.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
#parse-asn1 | ||
# parse-asn1 | ||
@@ -3,0 +3,0 @@ [![TRAVIS](https://secure.travis-ci.org/crypto-browserify/parse-asn1.png)](http://travis-ci.org/crypto-browserify/parse-asn1) |
@@ -83,2 +83,29 @@ var test = require('tape') | ||
function testEOL (keys) { | ||
var publicKey = keys.public.toString() | ||
var newLineRegex = /\r?\n/g | ||
var genPrivate = function (replace) { | ||
if (keys.private.key) { | ||
return { key: keys.private.key.toString().replace(newLineRegex, replace), passphrase: keys.private.passphrase } | ||
} else { | ||
return keys.private.toString().replace(newLineRegex, replace) | ||
} | ||
} | ||
var testN = { | ||
private: genPrivate('\n'), | ||
public: publicKey.replace(newLineRegex, '\n') | ||
} | ||
testIt(testN) | ||
var testR = { | ||
private: genPrivate('\r'), | ||
public: publicKey.replace(newLineRegex, '\r') | ||
} | ||
testIt(testR) | ||
var testRN = { | ||
private: genPrivate('\r\n'), | ||
public: publicKey.replace(newLineRegex, '\r\n') | ||
} | ||
testIt(testRN) | ||
} | ||
testIt(dsa) | ||
@@ -98,1 +125,16 @@ testIt(dsa2) | ||
testIt(cert) | ||
testEOL(dsa) | ||
testEOL(dsa2) | ||
testEOL(rsa1024) | ||
testEOL(ec) | ||
testEOL(rsa2028) | ||
testEOL(nonrsa1024) | ||
testEOL(ecpass) | ||
testEOL(dsapass) | ||
testEOL(dsapass2) | ||
testEOL(rsapass) | ||
testEOL(rsapass2) | ||
testEOL(pass1024) | ||
testEOL(pass1024) | ||
testEOL(cert) |
37094
38
473