From 58e0d58489472e78fc824b7654c59aa45b1c08ca Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 11 Nov 2013 18:31:34 -0800 Subject: add rabbit and tripledes ciphers - probably need a pconfig to set the default --- js/crypto.js | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/crypto.js b/js/crypto.js index 50282d18f..a7b278537 100644 --- a/js/crypto.js +++ b/js/crypto.js @@ -48,18 +48,43 @@ function red_encrypt(alg, elem,text) { if((alg == 'rot13') || (alg == 'triple-rot13')) newdiv = "[crypt alg='rot13']" + str_rot13(text) + '[/crypt]'; - else if(alg == 'aes256') { - // This is the prompt we're going to use when the receiver tries to open it. - // Maybe "Grandma's maiden name" or "our secret place" or something. + if(alg == 'aes256') { + + // This is the prompt we're going to use when the receiver tries to open it. + // Maybe "Grandma's maiden name" or "our secret place" or something. + + var enc_hint = prompt(aStr['passhint']); + + enc_text = CryptoJS.AES.encrypt(text,enc_key); + + encrypted = enc_text.toString(); + + newdiv = "[crypt alg='aes256' hint='" + enc_hint + "']" + encrypted + '[/crypt]'; + } + if(alg == 'rabbit') { + + // This is the prompt we're going to use when the receiver tries to open it. + // Maybe "Grandma's maiden name" or "our secret place" or something. - var enc_hint = prompt(aStr['passhint']); + var enc_hint = prompt(aStr['passhint']); - enc_text = CryptoJS.AES.encrypt(text,enc_key); + enc_text = CryptoJS.Rabbit.encrypt(text,enc_key); + encrypted = enc_text.toString(); - encrypted = enc_text.toString(); + newdiv = "[crypt alg='rabbit' hint='" + enc_hint + "']" + encrypted + '[/crypt]'; + } + if(alg == '3des') { + + // This is the prompt we're going to use when the receiver tries to open it. + // Maybe "Grandma's maiden name" or "our secret place" or something. + + var enc_hint = prompt(aStr['passhint']); + + enc_text = CryptoJS.TripleDES.encrypt(text,enc_key); + encrypted = enc_text.toString(); - newdiv = "[crypt alg='aes256' hint='" + enc_hint + "']" + encrypted + '[/crypt]'; + newdiv = "[crypt alg='3des' hint='" + enc_hint + "']" + encrypted + '[/crypt]'; } enc_key = ''; @@ -102,6 +127,14 @@ function red_decrypt(alg,hint,text,elem) { var enc_key = prompt((hint.length) ? hint : aStr['passphrase']); enc_text = CryptoJS.AES.decrypt(text,enc_key); } + if(alg == 'rabbit') { + var enc_key = prompt((hint.length) ? hint : aStr['passphrase']); + enc_text = CryptoJS.Rabbit.decrypt(text,enc_key); + } + if(alg == '3des') { + var enc_key = prompt((hint.length) ? hint : aStr['passphrase']); + enc_text = CryptoJS.TripleDES.decrypt(text,enc_key); + } enc_key = ''; -- cgit v1.2.3