From 58e0d58489472e78fc824b7654c59aa45b1c08ca Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 11 Nov 2013 18:31:34 -0800 Subject: [PATCH] add rabbit and tripledes ciphers - probably need a pconfig to set the default --- js/crypto.js | 47 +++++++++++++++++++++++++++++++++++------ view/php/theme_init.php | 2 ++ 2 files changed, 42 insertions(+), 7 deletions(-) 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') { - var enc_hint = prompt(aStr['passhint']); + // 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. - enc_text = CryptoJS.AES.encrypt(text,enc_key); + var enc_hint = prompt(aStr['passhint']); - encrypted = enc_text.toString(); + enc_text = CryptoJS.AES.encrypt(text,enc_key); - newdiv = "[crypt alg='aes256' hint='" + enc_hint + "']" + encrypted + '[/crypt]'; + 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']); + + enc_text = CryptoJS.Rabbit.encrypt(text,enc_key); + 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='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 = ''; diff --git a/view/php/theme_init.php b/view/php/theme_init.php index ab28180f2..0867c989d 100644 --- a/view/php/theme_init.php +++ b/view/php/theme_init.php @@ -27,6 +27,8 @@ head_add_js('library/jgrowl/jquery.jgrowl_minimized.js'); head_add_js('library/tinymce/jscripts/tiny_mce/tiny_mce_src.js'); head_add_js('library/cryptojs/components/core-min.js'); head_add_js('library/cryptojs/rollups/aes.js'); +head_add_js('library/cryptojs/rollups/rabbit.js'); +head_add_js('library/cryptojs/rollups/tripledes.js'); head_add_js('js/acl.js'); head_add_js('js/webtoolkit.base64.js'); head_add_js('js/main.js');