From eaaf2d53a385d6b13fcff33734675c3d886b5b51 Mon Sep 17 00:00:00 2001 From: Calvin Metcalf Date: Thu, 18 Dec 2014 16:31:43 -0500 Subject: [PATCH] varient encoding of password protected keys --- package.json | 2 +- test/index.js | 44 ++++++++++++++++++++++++++++++++++++++++ test/pass.dsa.1024.priv | 11 ++++++++++ test/pass.dsa.1024.pub | 12 +++++++++++ test/pass.rsa.1024.priv | 18 ++++++++++++++++ test/pass.rsa.1024.pub | 6 ++++++ test/pass.rsa.2028.priv | 30 +++++++++++++++++++++++++++ test/pass.rsa.2028.pub | 9 ++++++++ test/pass2.dsa.1024.priv | 15 ++++++++++++++ test/pass2.dsa.1024.pub | 12 +++++++++++ 10 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 test/pass.dsa.1024.priv create mode 100644 test/pass.dsa.1024.pub create mode 100644 test/pass.rsa.1024.priv create mode 100644 test/pass.rsa.1024.pub create mode 100644 test/pass.rsa.2028.priv create mode 100644 test/pass.rsa.2028.pub create mode 100644 test/pass2.dsa.1024.priv create mode 100644 test/pass2.dsa.1024.pub diff --git a/package.json b/package.json index 38f1bf5..42cc94d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "bn.js": "^0.15.2", "elliptic": "^0.15.14", "inherits": "^2.0.1", - "parse-asn1": "^1.1.0", + "parse-asn1": "^1.2.0", "readable-stream": "^1.0.33" }, "devDependencies": { diff --git a/test/index.js b/test/index.js index 1b58c28..2122618 100644 --- a/test/index.js +++ b/test/index.js @@ -39,6 +39,34 @@ var dsa2 = { private: fs.readFileSync(__dirname + '/dsa.2048.priv'), public: fs.readFileSync(__dirname + '/dsa.2048.pub') }; +var dsapass = { + private: { + key:fs.readFileSync(__dirname + '/pass.dsa.1024.priv'), + passphrase:'password' + }, + public: fs.readFileSync(__dirname + '/pass.dsa.1024.pub') +}; +var dsapass2 = { + private: { + key:fs.readFileSync(__dirname + '/pass2.dsa.1024.priv'), + passphrase:'password' + }, + public: fs.readFileSync(__dirname + '/pass2.dsa.1024.pub') +}; +var rsapass = { + private: { + key:fs.readFileSync(__dirname + '/pass.rsa.1024.priv'), + passphrase:'password' + }, + public: fs.readFileSync(__dirname + '/pass.rsa.1024.pub') +}; +var rsapass2 = { + private: { + key:fs.readFileSync(__dirname + '/pass.rsa.2028.priv'), + passphrase:'password' + }, + public: fs.readFileSync(__dirname + '/pass.rsa.2028.pub') +}; function isNode10() { return process.version && process.version.split('.').length === 3 && parseInt(process.version.split('.')[1], 10) <= 10; } @@ -105,6 +133,22 @@ testIt(nonrsa1024, new Buffer('sha512 with 1024 keys non-rsa key'), 'RSA-SHA512' testIt(rsa2028, new Buffer('SHA512 with 2028 keys'), 'RSA-SHA512'); if (!isNode10()) { ectestIt(ecpass, new Buffer('ecdsa with password'), 'ecdsa-with-SHA1'); + ectestIt(dsapass, new Buffer('dsa with 1024 keys and a password'), 'DSA-SHA'); + ectestIt(dsapass2, new Buffer('dsa with 1024 keys and a password varient'), 'DSA-SHA'); + testIt(rsapass, new Buffer('sha1 with 1024 keys and password, varient'), 'RSA-SHA1'); + testIt(rsapass2, new Buffer('sha1 with 2024 keys and password, varient'), 'RSA-SHA1'); + testIt(rsapass, new Buffer('sha224 with 1024 keys and password, varient'), 'RSA-SHA224'); + testIt(rsapass2, new Buffer('sha224 with 2024 keys and password, varient'), 'RSA-SHA224'); + testIt(rsapass, new Buffer('sha256 with 1024 keys and password, varient'), 'RSA-SHA256'); + testIt(rsapass2, new Buffer('sha256 with 2024 keys and password, varient'), 'RSA-SHA256'); + testIt(rsapass, new Buffer('sha384 with 1024 keys and password, varient'), 'RSA-SHA384'); + testIt(rsapass2, new Buffer('sha384 with 2024 keys and password, varient'), 'RSA-SHA384'); + testIt(rsapass, new Buffer('sha512 with 1024 keys and password, varient'), 'RSA-SHA512'); + testIt(rsapass2, new Buffer('sha512 with 2024 keys and password, varient'), 'RSA-SHA512'); + testIt(rsapass, new Buffer('rmd160 with 1024 keys and password, varient'), 'RSA-RIPEMD160'); + testIt(rsapass2, new Buffer('rmd160 with 2024 keys and password, varient'), 'RSA-RIPEMD160'); + testIt(rsapass, new Buffer('md5 with 1024 keys and password, varient'), 'RSA-MD5'); + testIt(rsapass2, new Buffer('md5 with 2024 keys and password, varient'), 'RSA-MD5'); testIt(pass1024, new Buffer('sha1 with 1024 keys and password'), 'RSA-SHA1'); testIt(pass1024, new Buffer('sha224 with 1024 keys and password'), 'RSA-SHA224'); testIt(pass1024, new Buffer('sha256 with 1024 keys and password'), 'RSA-SHA256'); diff --git a/test/pass.dsa.1024.priv b/test/pass.dsa.1024.priv new file mode 100644 index 0000000..aab5fc2 --- /dev/null +++ b/test/pass.dsa.1024.priv @@ -0,0 +1,11 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIBnzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQI1z4IJORFws4CAggA +MB0GCWCGSAFlAwQBAgQQq7f0CuKCTITfPS5Xax1H4wSCAVDFyIjYVXfBNe+BARqz +Tfo09y4vKkErOb7Sz4bQkAjRLjOXiUjM4eTNtivml8NqVrQTKAghN+ggxj416OD4 +oq6Ns7Ncbd4Xm5Ni8wrrWbJxVog6rAa/ioU0sfgRExYy/xE2Q9KkW+VE7SUwanwY +e81Od9qNM5KhZGM1yUSKa0JA6Xqb8dAqBo9rVt8DceumB9OP83xV3fLEimSZfR6p +slA1P/dTvKxwhpguQe4Z3OkzTzGCxyboqeRW1woNHKbxjzzSHcaki9SHQm3xpUW8 +hRAJd6OtDnLbkE9MnC+UcI3mjru1xfnR5MU7qG7e9nvOhEDVaDkiK3DbrSf0B0Bi +p1hyX1XsSXDewSEd/mlfMLdD8WecgUtl9ea7JzxY3/6R78yB951I5TmY45mp/v+N +tbxEv29B65UKf0ac7gVw4LNy8JF2ef/L/meEmBoIAE71f+8= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/test/pass.dsa.1024.pub b/test/pass.dsa.1024.pub new file mode 100644 index 0000000..80a731e --- /dev/null +++ b/test/pass.dsa.1024.pub @@ -0,0 +1,12 @@ +-----BEGIN PUBLIC KEY----- +MIIBtzCCASwGByqGSM44BAEwggEfAoGBAOY0KsTt5EpJ4LtlD3xRS5mDiGE1CMNp +0S9X0sK8kP8Aps8iYwMLbZYglk18GCNnCk4SjbAnZHSB3kaIv6AKQc2J8W2YV5se +3VhpKOFst7bqRtkGsl8uJtGlKTiXNclkv2jsKOrsBokSD1USGCECTNeMt3OgziRc +Z1dS+djSOZ2nAhUAzB96SpxlAak+K/QLVJ+lDe5DcY0CgYEAtxX1/HckvhlhHQyK +ZWLQsDfZBILbhc+OLDpOyT6cJS/sJzfFIYZgK5M3rOS4OmzdYfJccQAuGq+TVJQ3 +VcYOdbrIANJV8CDrn4jkkejTzJI6fCwAkPWOyxw8kbV1Hsoy6WLfSCHKpBUcrogA +qRGESqBVTawjyF/ECX667y/P49MDgYQAAoGAXYmxO4+52C1gBzh7GgTwNLJl7bLn +gOhKTFlKhT36VjMjeFfdXmBVBVbfUottKZby/gVX1IXT38PStB/dswbF45bGDdoS +zMFjYmHTtLtrU/4hReVtvb5MYmrPDFX58SwcSRRO/cH6WJPvfu4Aq0cJZA9Kb0B9 +5Wo18JxAqvPtTB8= +-----END PUBLIC KEY----- diff --git a/test/pass.rsa.1024.priv b/test/pass.rsa.1024.priv new file mode 100644 index 0000000..b67bd80 --- /dev/null +++ b/test/pass.rsa.1024.priv @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-192-CBC,04D2D7882E0C474E07E542FE997D2A49 + +vfB5Gtm34n3SeI6JELjWiGw6O+j+tGR6Wbi3SNeAZkfSA8PTjei6PVHr+dGK5zMd +nTckd0EpxItqxEdtLK6GtBIa9KRd3cEbayHmyyybH2FC4STXJCUFBe2eb7ZKmnCl +RB5FcmAqExif+QOJwHnZw6DTzq+oGSwi9cSoy2qE62FgXkj8uKAYcBLONmsP1YQA +4zIub4bnEbIghL/swEB/HVS86FyMCsMXrHEOnSuUUBf/UfZFNypI6kVUNXlItnN1 +14eeRsBD37VkL7dAQPMx+Dwm7DbU07QWrVvzgmWlu3KqR0tRNA9e4a5f14XOYxgS +HZ+XVZK8iAd+76OnprlFtGDowDXGM0wUXPYq5j8WpKxNsVs2RV+S6U0gQLoSqNxt +We7UPWZufzEdjTUO8q9KhdGqFmJ53XIYClZf0bp148b+Bk3P+dN5TbmKQEfulScn +rTLTRo34fdTIAJr5BJh0OXGNs9rFlMJ9Nz4FwVTEB1DMerXtt9ICdhud9BktRhvq +axgoz+XA3LrBrlPPcrSCZyIYjZFydGSkzg439OyDEZ6+uRmc0qhWA4j6AgXx6gGR +NvvypoFVKvXqEq/2F+SVyyMGrm4xPmsr/HUBeE9SmuTzNzDfVAM/xerqIoR2szR0 +O0hwtOj4fk7//cd1CjFzd0JiF/SqMkHxkdbmIC9qlhshkWlQbvvhbefodYPuGxmj +L1TaPgX36OcrQSodzyWBN5tSmmX1Nmftcz7iwc4AKrqkdnM3sPS3SczsAjMWrjRr +7iYhdPQSZtxVCTjACU3h7scNAg9AU6l4YZrowR//J6U= +-----END RSA PRIVATE KEY----- diff --git a/test/pass.rsa.1024.pub b/test/pass.rsa.1024.pub new file mode 100644 index 0000000..3506c33 --- /dev/null +++ b/test/pass.rsa.1024.pub @@ -0,0 +1,6 @@ +-----BEGIN PUBLIC KEY----- +MIGcMA0GCSqGSIb3DQEBAQUAA4GKADCBhgJ/OwswbFo/uyC8ltGf/yA1A+gV5IGd +nAgPbUSI3GzbHCA+x+TLG/tLvbRw3r1smppY/jkkpiVW1ErSMuN0uixp5gb78Z9r +H1XpWb5WWgp3WaY/9EHMjMdOkQ/9LVZvRvl/M/Fi6owP+q+amJI1BEjECYfbhGL3 +rmlVdq4qXc40QwIDAQAB +-----END PUBLIC KEY----- diff --git a/test/pass.rsa.2028.priv b/test/pass.rsa.2028.priv new file mode 100644 index 0000000..99e8213 --- /dev/null +++ b/test/pass.rsa.2028.priv @@ -0,0 +1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2l/6mZBmgV1Nfy/cQU6U5s3S1Xc75UDQVLms3CIOpFTRIpecNTdfa31fYy/svy0 +M2lWTbCva0dOyuvMUhTgBL4I7Qa2dUMPXHMZatV5ooHYq/BZJA1r84C5cM5r+umE +2LLv/BlUr7RaQHhaKGn4Qhpzo5yRDE9mEqDpLVkbg8SxMsdf/pEF5/VyUwA9t8RT +fKVsInRd386tDqJSDbSFqKTvLztr/5YCyzZzvC2YB1voko/caOGd2d/G51Ij+bXU +xEN8U4fHDBsHwPUGb31uZUhTXpL37KiOqZmXFoH2usmuvx882XvyGcV0F4tstMaR +KLKzl2PwqzAYGFexLkYKMz0TYIeN6h3b86ETazPPU49nkaEU23Dx21J2Rb3UlH+I +lDQF3wuH1QlYiTnlcVa/Zu4QQg0/iP8ALkZ06mvn9e9mOtnA8gsh4B2oLqc19VLU +bcpv40dV1H3W9Lcx9B8JYUp0c/Oyno1D7Yj3tjGcwMKECmUpHi4kksehVo0/P933 +xmFmC6eyWYVdO9upvY/vKSB7b1dMt85iWr3gnMsSfRYc6jsbSxdjOPST46UsIzjx +wa1DS6+Bv5tiaC4uC6X+0tCAZo+UOQMYUbTGRR/7g/c= +-----END RSA PRIVATE KEY----- diff --git a/test/pass.rsa.2028.pub b/test/pass.rsa.2028.pub new file mode 100644 index 0000000..655cc3a --- /dev/null +++ b/test/pass.rsa.2028.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBHjANBgkqhkiG9w0BAQEFAAOCAQsAMIIBBgKB/gy7mjaWgPeFdVYDZWRCA9BN +iv3pPb0es27+FKY0hszLaOw47ExCtAWpDsH48TXAfyHBYwBLguayfk4LGIupxb+C +GMbRo3xEp0CbfY1Jby26T9vGjRC1foHDDUJG84uaRbyHqaf4i6zt4gVR+xlAEIjk +aFAAK8cOoXAT1CVqGLLljUCchL8PjaHj/yriZ/S7rdwlI3LnABxwwmLrmR/v71Wt +pmO/aNG8N+1po+QwaghTkyQ59E/ZvAuOkFWHok2q/R6PYAa2jdZ9zim0FqOP+nkQ +aEDRbBFBmBqTv5fFGfk2WsAfKf/RG0/VFd+ZeM5251TeTvXH695nlSGauVl9AgMB +AAE= +-----END PUBLIC KEY----- diff --git a/test/pass2.dsa.1024.priv b/test/pass2.dsa.1024.priv new file mode 100644 index 0000000..29e3673 --- /dev/null +++ b/test/pass2.dsa.1024.priv @@ -0,0 +1,15 @@ +-----BEGIN DSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,DC173C6DFD455EBE462A35D6AB9A603A + +FoC3sxbdUFJTaNtRpooMxaX2lcQRLUz8qcRhzDBn5a1kaMHp2JM3KlHK5aauybT4 +ilmlKJ9sSm8pFLAWPKbkczSgZ+X6p/51v4zaEJSebZ98p32kQk87XJQE7aYroxYV +UfM5PSOoKWilj+LZQQEXV10qDoYGrnbSdoNSxYW5V1a1aP+ua0EO7m9MUYkoLxi3 +SJ/s2h/5KM3TOz7d7DOZuSoNm+0n6YC4aqQnR3lmEtAXEYLQqLhH2Q3FTKTHwBQw +HgMBAzcXOS1YSw6Ekwh1eZamizrOEC4I6oZEHoUBqRfbsQ8tu77kDq2ovQSyn8Fp +SeE64m3GgZOYdfcDuNZ0ccmm3shBBfTfD9AwR+1thklKO3oaaLEHb6TmnkD79rEz +9WsiVxoN7vqqWdgoeyl7REOB6WLQp8kYS4FoRG0QB/ZS8Hs/Tf17QPnrQNiMkvP7 +sJSHmlaMKXjWXK0VoN94kfZKUXwkzLD1VXuXFCnUkznWU0tahYi06b8/SVXc6EG+ +0mzylckH7UnjOQfxSFAlZ+e/PiX80tcPakxYbk+f1Nv7L0NOyhrDv18KUbv9mEpV +Ysild1m7/QSF0u1qmjmGNQ== +-----END DSA PRIVATE KEY----- diff --git a/test/pass2.dsa.1024.pub b/test/pass2.dsa.1024.pub new file mode 100644 index 0000000..80a731e --- /dev/null +++ b/test/pass2.dsa.1024.pub @@ -0,0 +1,12 @@ +-----BEGIN PUBLIC KEY----- +MIIBtzCCASwGByqGSM44BAEwggEfAoGBAOY0KsTt5EpJ4LtlD3xRS5mDiGE1CMNp +0S9X0sK8kP8Aps8iYwMLbZYglk18GCNnCk4SjbAnZHSB3kaIv6AKQc2J8W2YV5se +3VhpKOFst7bqRtkGsl8uJtGlKTiXNclkv2jsKOrsBokSD1USGCECTNeMt3OgziRc +Z1dS+djSOZ2nAhUAzB96SpxlAak+K/QLVJ+lDe5DcY0CgYEAtxX1/HckvhlhHQyK +ZWLQsDfZBILbhc+OLDpOyT6cJS/sJzfFIYZgK5M3rOS4OmzdYfJccQAuGq+TVJQ3 +VcYOdbrIANJV8CDrn4jkkejTzJI6fCwAkPWOyxw8kbV1Hsoy6WLfSCHKpBUcrogA +qRGESqBVTawjyF/ECX667y/P49MDgYQAAoGAXYmxO4+52C1gBzh7GgTwNLJl7bLn +gOhKTFlKhT36VjMjeFfdXmBVBVbfUottKZby/gVX1IXT38PStB/dswbF45bGDdoS +zMFjYmHTtLtrU/4hReVtvb5MYmrPDFX58SwcSRRO/cH6WJPvfu4Aq0cJZA9Kb0B9 +5Wo18JxAqvPtTB8= +-----END PUBLIC KEY-----