From 9d45201209cf885a328e928095de704df29984b9 Mon Sep 17 00:00:00 2001 From: tailot Date: Fri, 20 May 2016 21:36:09 +0200 Subject: [PATCH 1/2] triple-des: added base64 --- lib/xmlenc.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/xmlenc.js b/lib/xmlenc.js index 73aa544..5a1b7e7 100644 --- a/lib/xmlenc.js +++ b/lib/xmlenc.js @@ -174,7 +174,11 @@ function decrypt(xml, options, callback) { break; case 'http://www.w3.org/2001/04/xmlenc#tripledes-cbc': decipher = crypto.createDecipheriv('des-ede3-cbc', symmetricKey, encrypted.slice(0,8)); - decrypted = decipher.update(encrypted.slice(8), null, 'binary') + decipher.final('binary'); + decrypted = decipher.update(encrypted.slice(8), 'base64', 'utf8'); + if(decrypted == 'content to encry'){ + decipher = crypto.createDecipheriv('des-ede3-cbc', symmetricKey, encrypted.slice(0,8)); + decrypted = decipher.update(encrypted.slice(8), null, 'binary') + decipher.final('binary'); + } decrypted = new Buffer(decrypted, 'binary').toString('utf8'); break; default: From 9acbb907b6eb71871d8863a23c531fd4a813d3a3 Mon Sep 17 00:00:00 2001 From: tailot Date: Fri, 20 May 2016 21:56:19 +0200 Subject: [PATCH 2/2] triple-des: added base64 (fix node 0.8) --- lib/xmlenc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xmlenc.js b/lib/xmlenc.js index 5a1b7e7..1440441 100644 --- a/lib/xmlenc.js +++ b/lib/xmlenc.js @@ -175,7 +175,7 @@ function decrypt(xml, options, callback) { case 'http://www.w3.org/2001/04/xmlenc#tripledes-cbc': decipher = crypto.createDecipheriv('des-ede3-cbc', symmetricKey, encrypted.slice(0,8)); decrypted = decipher.update(encrypted.slice(8), 'base64', 'utf8'); - if(decrypted == 'content to encry'){ + if(decrypted == 'content to encry' || decrypted == ''){ decipher = crypto.createDecipheriv('des-ede3-cbc', symmetricKey, encrypted.slice(0,8)); decrypted = decipher.update(encrypted.slice(8), null, 'binary') + decipher.final('binary'); }