Version Description
It is highly recommended that you upgrade to WP Live Chat Support version 8.0.30 for security reasons.
Download this release
Release Info
Developer | WP-LiveChat |
Plugin | WP Live Chat Support |
Version | 8.0.32 |
Comparing to | |
See all releases |
Code changes from version 8.0.31 to 8.0.32
- config.php +1 -1
- functions.php +196 -0
- includes/aes_fast.php +706 -0
- includes/cryptoHelpers.php +100 -0
- includes/settings_page.php +26 -0
- js/wplc_gutenberg.js +15 -15
- languages/wplivechat-fa_IR.mo +0 -0
- languages/wplivechat-fa_IR.po +3 -4
- languages/wplivechat-pt_BR.mo +0 -0
- languages/wplivechat-pt_BR.po +3 -4
- modules/advanced_features.php +14 -1
- modules/advanced_tools.php +0 -3
- readme.txt +14 -0
- wp-live-chat-support.php +64 -107
config.php
CHANGED
@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
-
define('WPLC_PLUGIN_VERSION', "8.0.
|
11 |
define('WPLC_PLUGIN_DIR', dirname(__FILE__));
|
12 |
define('WPLC_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
|
13 |
define('WPLC_PLUGIN', plugin_basename( __FILE__ ) );
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
+
define('WPLC_PLUGIN_VERSION', "8.0.32");
|
11 |
define('WPLC_PLUGIN_DIR', dirname(__FILE__));
|
12 |
define('WPLC_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
|
13 |
define('WPLC_PLUGIN', plugin_basename( __FILE__ ) );
|
functions.php
CHANGED
@@ -596,6 +596,9 @@ function wplc_return_user_chat_messages($cid,$wplc_settings = false,$cdata = fal
|
|
596 |
|
597 |
if (!$system_notification) {
|
598 |
/* this is a normal message */
|
|
|
|
|
|
|
599 |
|
600 |
$msg_array = maybe_unserialize( $msg );
|
601 |
|
@@ -801,6 +804,10 @@ function wplc_return_chat_messages($cid, $transcript = false, $html = true, $wpl
|
|
801 |
|
802 |
if (!$system_notification) {
|
803 |
|
|
|
|
|
|
|
|
|
804 |
$msg = apply_filters("wplc_filter_message_control_out",$msg);
|
805 |
|
806 |
if( is_serialized( $msg ) ){
|
@@ -1007,6 +1014,9 @@ function wplc_return_admin_chat_messages($cid) {
|
|
1007 |
|
1008 |
if (!$system_notification) {
|
1009 |
/* this is a normal message */
|
|
|
|
|
|
|
1010 |
|
1011 |
$msg_array = maybe_unserialize( $msg );
|
1012 |
|
@@ -2848,6 +2858,36 @@ if (!function_exists("wplc_choose_hook_control_head")) {
|
|
2848 |
}
|
2849 |
}
|
2850 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2851 |
|
2852 |
/**
|
2853 |
* Add to the tabs filter
|
@@ -2859,6 +2899,12 @@ if (!function_exists("wplc_choose_hook_control_head")) {
|
|
2859 |
if (!function_exists("wplc_business_hours_filter_control_setting_tabs")) {
|
2860 |
add_filter("wplc_filter_setting_tabs","wplc_business_hours_filter_control_setting_tabs");
|
2861 |
function wplc_business_hours_filter_control_setting_tabs($tab_array) {
|
|
|
|
|
|
|
|
|
|
|
|
|
2862 |
$tab_array['business-hours'] = array(
|
2863 |
'href' => '#wplc-business-hours',
|
2864 |
'icon' => 'fa fa-clock-o',
|
@@ -2869,6 +2915,156 @@ if (!function_exists("wplc_business_hours_filter_control_setting_tabs")) {
|
|
2869 |
}
|
2870 |
}
|
2871 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2872 |
|
2873 |
|
2874 |
if (!function_exists("wplc_inex_filter_control_display_contents")) {
|
596 |
|
597 |
if (!$system_notification) {
|
598 |
/* this is a normal message */
|
599 |
+
if(function_exists('wplc_encrypt_decrypt_msg')){
|
600 |
+
$msg = wplc_encrypt_decrypt_msg($msg);
|
601 |
+
}
|
602 |
|
603 |
$msg_array = maybe_unserialize( $msg );
|
604 |
|
804 |
|
805 |
if (!$system_notification) {
|
806 |
|
807 |
+
if(function_exists('wplc_encrypt_decrypt_msg')){
|
808 |
+
$msg = wplc_encrypt_decrypt_msg($msg);
|
809 |
+
}
|
810 |
+
|
811 |
$msg = apply_filters("wplc_filter_message_control_out",$msg);
|
812 |
|
813 |
if( is_serialized( $msg ) ){
|
1014 |
|
1015 |
if (!$system_notification) {
|
1016 |
/* this is a normal message */
|
1017 |
+
if(function_exists('wplc_encrypt_decrypt_msg')){
|
1018 |
+
$msg = wplc_encrypt_decrypt_msg($msg);
|
1019 |
+
}
|
1020 |
|
1021 |
$msg_array = maybe_unserialize( $msg );
|
1022 |
|
2858 |
}
|
2859 |
}
|
2860 |
|
2861 |
+
/**
|
2862 |
+
* Encrypt the message via the filter
|
2863 |
+
* @param string $msg The message
|
2864 |
+
* @return string
|
2865 |
+
* @since 1.0.00
|
2866 |
+
* @author Nick Duncan <nick@wp-livechat.com>
|
2867 |
+
*/
|
2868 |
+
if (!function_exists("wplc_encrypt_filter_control_message_control")) {
|
2869 |
+
add_filter("wplc_filter_message_control","wplc_encrypt_filter_control_message_control",10,1);
|
2870 |
+
function wplc_encrypt_filter_control_message_control($msg) {
|
2871 |
+
$msg = wplc_encrypt_encrypt_msg($msg);
|
2872 |
+
return $msg;
|
2873 |
+
}
|
2874 |
+
}
|
2875 |
+
|
2876 |
+
/**
|
2877 |
+
* Decrypt the message via the filter
|
2878 |
+
* @param string $msg The message
|
2879 |
+
* @return string
|
2880 |
+
* @since 1.0.00
|
2881 |
+
* @author Nick Duncan <nick@wp-livechat.com>
|
2882 |
+
*/
|
2883 |
+
if (!function_exists("wplc_encrypt_filter_control_out_message_control")) {
|
2884 |
+
add_filter("wplc_filter_message_control_out","wplc_encrypt_filter_control_out_message_control",10,1);
|
2885 |
+
function wplc_encrypt_filter_control_out_message_control($msg) {
|
2886 |
+
$msg = wplc_encrypt_decrypt_msg($msg);
|
2887 |
+
return $msg;
|
2888 |
+
}
|
2889 |
+
}
|
2890 |
+
|
2891 |
|
2892 |
/**
|
2893 |
* Add to the tabs filter
|
2899 |
if (!function_exists("wplc_business_hours_filter_control_setting_tabs")) {
|
2900 |
add_filter("wplc_filter_setting_tabs","wplc_business_hours_filter_control_setting_tabs");
|
2901 |
function wplc_business_hours_filter_control_setting_tabs($tab_array) {
|
2902 |
+
$tab_array[9] = array(
|
2903 |
+
"href" => "#tabs-9",
|
2904 |
+
"icon" => 'fa fa-lock',
|
2905 |
+
"label" => __("Encryption","wplivechat")
|
2906 |
+
);
|
2907 |
+
|
2908 |
$tab_array['business-hours'] = array(
|
2909 |
'href' => '#wplc-business-hours',
|
2910 |
'icon' => 'fa fa-clock-o',
|
2915 |
}
|
2916 |
}
|
2917 |
|
2918 |
+
/**
|
2919 |
+
* Encrypt the message
|
2920 |
+
* @since 1.0.0
|
2921 |
+
* @return void
|
2922 |
+
* @author Jarryd Long <jarryd@wp-livechat.com>
|
2923 |
+
*/
|
2924 |
+
if (!function_exists("wplc_encrypt_encrypt_msg")) {
|
2925 |
+
function wplc_encrypt_encrypt_msg($plaintext){
|
2926 |
+
|
2927 |
+
$wplc_encrypt_data = get_option("WPLC_ENCRYPT_SETTINGS");
|
2928 |
+
if(isset($wplc_encrypt_data['wplc_enable_encryption']) && intval($wplc_encrypt_data['wplc_enable_encryption']) == 1){
|
2929 |
+
|
2930 |
+
$encrypted_salt = get_option( "wp-live-chat-support-pro_key" );
|
2931 |
+
$api_key = get_option('wplc_api_key');
|
2932 |
+
|
2933 |
+
if( $api_key != '' ){
|
2934 |
+
/**
|
2935 |
+
* Use the current API key and don't change anything
|
2936 |
+
*/
|
2937 |
+
$api_key = $api_key;
|
2938 |
+
} else {
|
2939 |
+
/**
|
2940 |
+
* It's empty so lets fix this
|
2941 |
+
*/
|
2942 |
+
if( $encrypted_salt != '' ){
|
2943 |
+
|
2944 |
+
$api_key = $encrypted_salt;
|
2945 |
+
|
2946 |
+
} else {
|
2947 |
+
|
2948 |
+
$api_key = '';
|
2949 |
+
|
2950 |
+
}
|
2951 |
+
}
|
2952 |
+
if($api_key != ''){
|
2953 |
+
$api_key = substr($api_key, 0, 10);
|
2954 |
+
|
2955 |
+
$plaintext_utf8 = utf8_encode($plaintext);
|
2956 |
+
$inputData = cryptoHelpers::convertStringToByteArray($plaintext);
|
2957 |
+
$keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($api_key));
|
2958 |
+
$keyLength = count($keyAsNumbers);
|
2959 |
+
$iv = cryptoHelpers::generateSharedKey(16);
|
2960 |
+
|
2961 |
+
$encrypted = AES::encrypt(
|
2962 |
+
$inputData,
|
2963 |
+
AES::modeOfOperation_CBC,
|
2964 |
+
$keyAsNumbers,
|
2965 |
+
$keyLength,
|
2966 |
+
$iv
|
2967 |
+
);
|
2968 |
+
|
2969 |
+
$retVal = $encrypted['originalsize'] . " "
|
2970 |
+
. cryptoHelpers::toHex($iv) . " "
|
2971 |
+
. cryptoHelpers::toHex($encrypted['cipher']);
|
2972 |
+
|
2973 |
+
$message = array(
|
2974 |
+
'e' => 1,
|
2975 |
+
'm' => $retVal
|
2976 |
+
);
|
2977 |
+
return maybe_serialize($message);
|
2978 |
+
} else {
|
2979 |
+
$message = array(
|
2980 |
+
'e' => 0,
|
2981 |
+
'm' => $plaintext
|
2982 |
+
);
|
2983 |
+
return maybe_serialize($message);
|
2984 |
+
}
|
2985 |
+
} else {
|
2986 |
+
$message = array(
|
2987 |
+
'e' => 0,
|
2988 |
+
'm' => $plaintext
|
2989 |
+
);
|
2990 |
+
return maybe_serialize($message);
|
2991 |
+
}
|
2992 |
+
}
|
2993 |
+
}
|
2994 |
+
|
2995 |
+
/**
|
2996 |
+
* Decrypt the message
|
2997 |
+
* Updated in 8.0.32 for backwards compatibility
|
2998 |
+
* @since 1.0.0
|
2999 |
+
* @return void
|
3000 |
+
* @author Jarryd Long <jarryd@wp-livechat.com>
|
3001 |
+
*/
|
3002 |
+
if (!function_exists("wplc_encrypt_decrypt_msg")) {
|
3003 |
+
function wplc_encrypt_decrypt_msg($input){
|
3004 |
+
|
3005 |
+
$messages = maybe_unserialize($input);
|
3006 |
+
|
3007 |
+
|
3008 |
+
if(is_array($messages)){
|
3009 |
+
/** Check already in place to determine if a message was previously encrypted */
|
3010 |
+
if($messages['e'] == 1){
|
3011 |
+
/* This message was encrypted */
|
3012 |
+
$encrypted_salt = get_option( "wp-live-chat-support-pro_key" );
|
3013 |
+
$api_key = get_option('wplc_api_key');
|
3014 |
+
|
3015 |
+
if( $api_key != '' ){
|
3016 |
+
/**
|
3017 |
+
* Use the current API key and don't change anything
|
3018 |
+
*/
|
3019 |
+
$api_key = $api_key;
|
3020 |
+
} else {
|
3021 |
+
/**
|
3022 |
+
* It's empty so lets fix this
|
3023 |
+
*/
|
3024 |
+
if( $encrypted_salt != '' ){
|
3025 |
+
|
3026 |
+
$api_key = $encrypted_salt;
|
3027 |
+
|
3028 |
+
} else {
|
3029 |
+
|
3030 |
+
$api_key = '';
|
3031 |
+
|
3032 |
+
}
|
3033 |
+
}
|
3034 |
+
|
3035 |
+
$api_key = substr($api_key, 0, 10);
|
3036 |
+
$cipherSplit = explode( " ", $messages['m']);
|
3037 |
+
$originalSize = intval($cipherSplit[0]);
|
3038 |
+
$iv = cryptoHelpers::toNumbers($cipherSplit[1]);
|
3039 |
+
$cipherText = $cipherSplit[2];
|
3040 |
+
|
3041 |
+
$cipherIn = cryptoHelpers::toNumbers($cipherText);
|
3042 |
+
$keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($api_key));
|
3043 |
+
$keyLength = count($keyAsNumbers);
|
3044 |
+
|
3045 |
+
$decrypted = AES::decrypt(
|
3046 |
+
$cipherIn,
|
3047 |
+
$originalSize,
|
3048 |
+
AES::modeOfOperation_CBC,
|
3049 |
+
$keyAsNumbers,
|
3050 |
+
$keyLength,
|
3051 |
+
$iv
|
3052 |
+
);
|
3053 |
+
|
3054 |
+
$hexDecrypted = cryptoHelpers::toHex($decrypted);
|
3055 |
+
$retVal = pack("H*" , $hexDecrypted);
|
3056 |
+
|
3057 |
+
return stripslashes($retVal);
|
3058 |
+
} else {
|
3059 |
+
return stripslashes($messages['m']);
|
3060 |
+
}
|
3061 |
+
} else{
|
3062 |
+
return stripslashes($input);
|
3063 |
+
}
|
3064 |
+
}
|
3065 |
+
|
3066 |
+
}
|
3067 |
+
|
3068 |
|
3069 |
|
3070 |
if (!function_exists("wplc_inex_filter_control_display_contents")) {
|
includes/aes_fast.php
ADDED
@@ -0,0 +1,706 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* aes.php: implements AES - Advanced Encryption Standard
|
5 |
+
* from the SlowAES project, http://code.google.com/p/slowaes/
|
6 |
+
*
|
7 |
+
* Copyright (c) 2008 Josh Davis ( http://www.josh-davis.org ),
|
8 |
+
* Mark Percival ( http://mpercival.com ),
|
9 |
+
*
|
10 |
+
* Ported from C code written by Laurent Haan ( http://www.progressive-coding.com )
|
11 |
+
*
|
12 |
+
* Ported from JavaScript to PHP by ALeX Kazik
|
13 |
+
*
|
14 |
+
* Licensed under the Apache License, Version 2.0
|
15 |
+
* http://www.apache.org/licenses/
|
16 |
+
*/
|
17 |
+
|
18 |
+
class AES {
|
19 |
+
/*
|
20 |
+
* START AES SECTION
|
21 |
+
*/
|
22 |
+
|
23 |
+
const keySize_128 = 16;
|
24 |
+
const keySize_192 = 24;
|
25 |
+
const keySize_256 = 32;
|
26 |
+
|
27 |
+
// Rijndael S-box
|
28 |
+
private static $sbox = array(
|
29 |
+
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
|
30 |
+
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
|
31 |
+
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
|
32 |
+
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
|
33 |
+
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
|
34 |
+
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
|
35 |
+
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
|
36 |
+
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
|
37 |
+
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
|
38 |
+
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
|
39 |
+
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
|
40 |
+
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
|
41 |
+
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
42 |
+
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
|
43 |
+
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
|
44 |
+
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
|
45 |
+
);
|
46 |
+
|
47 |
+
// Rijndael Inverted S-box
|
48 |
+
private static $rsbox = array(
|
49 |
+
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb
|
50 |
+
, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb
|
51 |
+
, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e
|
52 |
+
, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25
|
53 |
+
, 0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 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61
|
64 |
+
, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
|
65 |
+
);
|
66 |
+
|
67 |
+
/* rotate the word eight bits to the left */
|
68 |
+
private static function rotate($word){
|
69 |
+
$c = $word[0];
|
70 |
+
for ($i = 0; $i < 3; $i++)
|
71 |
+
$word[$i] = $word[$i+1];
|
72 |
+
$word[3] = $c;
|
73 |
+
|
74 |
+
return $word;
|
75 |
+
}
|
76 |
+
|
77 |
+
// Rijndael Rcon
|
78 |
+
private static $Rcon = array(
|
79 |
+
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
|
80 |
+
0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3,
|
81 |
+
0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f,
|
82 |
+
0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d,
|
83 |
+
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab,
|
84 |
+
0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d,
|
85 |
+
0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25,
|
86 |
+
0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01,
|
87 |
+
0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d,
|
88 |
+
0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa,
|
89 |
+
0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a,
|
90 |
+
0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02,
|
91 |
+
0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,
|
92 |
+
0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef,
|
93 |
+
0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94,
|
94 |
+
0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04,
|
95 |
+
0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f,
|
96 |
+
0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5,
|
97 |
+
0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33,
|
98 |
+
0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb
|
99 |
+
);
|
100 |
+
|
101 |
+
private static $G2X = array(
|
102 |
+
0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16,
|
103 |
+
0x18, 0x1a, 0x1c, 0x1e, 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e,
|
104 |
+
0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, 0x40, 0x42, 0x44, 0x46,
|
105 |
+
0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
|
106 |
+
0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76,
|
107 |
+
0x78, 0x7a, 0x7c, 0x7e, 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e,
|
108 |
+
0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0xa0, 0xa2, 0xa4, 0xa6,
|
109 |
+
0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
|
110 |
+
0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6,
|
111 |
+
0xd8, 0xda, 0xdc, 0xde, 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee,
|
112 |
+
0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe, 0x1b, 0x19, 0x1f, 0x1d,
|
113 |
+
0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05,
|
114 |
+
0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d,
|
115 |
+
0x23, 0x21, 0x27, 0x25, 0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55,
|
116 |
+
0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45, 0x7b, 0x79, 0x7f, 0x7d,
|
117 |
+
0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65,
|
118 |
+
0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d,
|
119 |
+
0x83, 0x81, 0x87, 0x85, 0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5,
|
120 |
+
0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5, 0xdb, 0xd9, 0xdf, 0xdd,
|
121 |
+
0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5,
|
122 |
+
0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed,
|
123 |
+
0xe3, 0xe1, 0xe7, 0xe5
|
124 |
+
);
|
125 |
+
|
126 |
+
private static $G3X = array(
|
127 |
+
0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d,
|
128 |
+
0x14, 0x17, 0x12, 0x11, 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39,
|
129 |
+
0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21, 0x60, 0x63, 0x66, 0x65,
|
130 |
+
0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71,
|
131 |
+
0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d,
|
132 |
+
0x44, 0x47, 0x42, 0x41, 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9,
|
133 |
+
0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1, 0xf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x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16,
|
148 |
+
0x1f, 0x1c, 0x19, 0x1a
|
149 |
+
);
|
150 |
+
|
151 |
+
private static $G9X = array(
|
152 |
+
0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f, 0x48, 0x41, 0x5a, 0x53,
|
153 |
+
0x6c, 0x65, 0x7e, 0x77, 0x90, 0x99, 0x82, 0x8b, 0xb4, 0xbd, 0xa6, 0xaf,
|
154 |
+
0xd8, 0xd1, 0xca, 0xc3, 0xfc, 0xf5, 0xee, 0xe7, 0x3b, 0x32, 0x29, 0x20,
|
155 |
+
0x1f, 0x16, 0x0d, 0x04, 0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c,
|
156 |
+
0xab, 0xa2, 0xb9, 0xb0, 0x8f, 0x86, 0x9d, 0x94, 0xe3, 0xea, 0xf1, 0xf8,
|
157 |
+
0xc7, 0xce, 0xd5, 0xdc, 0x76, 0x7f, 0x64, 0x6d, 0x52, 0x5b, 0x40, 0x49,
|
158 |
+
0x3e, 0x37, 0x2c, 0x25, 0x1a, 0x13, 0x08, 0x01, 0xe6, 0xef, 0xf4, 0xfd,
|
159 |
+
0xc2, 0xcb, 0xd0, 0xd9, 0xae, 0xa7, 0xbc, 0xb5, 0x8a, 0x83, 0x98, 0x91,
|
160 |
+
0x4d, 0x44, 0x5f, 0x56, 0x69, 0x60, 0x7b, 0x72, 0x05, 0x0c, 0x17, 0x1e,
|
161 |
+
0x21, 0x28, 0x33, 0x3a, 0xdd, 0xd4, 0xcf, 0xc6, 0xf9, 0xf0, 0xeb, 0xe2,
|
162 |
+
0x95, 0x9c, 0x87, 0x8e, 0xb1, 0xb8, 0xa3, 0xaa, 0xec, 0xe5, 0xfe, 0xf7,
|
163 |
+
0xc8, 0xc1, 0xda, 0xd3, 0xa4, 0xad, 0xb6, 0xbf, 0x80, 0x89, 0x92, 0x9b,
|
164 |
+
0x7c, 0x75, 0x6e, 0x67, 0x58, 0x51, 0x4a, 0x43, 0x34, 0x3d, 0x26, 0x2f,
|
165 |
+
0x10, 0x19, 0x02, 0x0b, 0xd7, 0xde, 0xc5, 0xcc, 0xf3, 0xfa, 0xe1, 0xe8,
|
166 |
+
0x9f, 0x96, 0x8d, 0x84, 0xbb, 0xb2, 0xa9, 0xa0, 0x47, 0x4e, 0x55, 0x5c,
|
167 |
+
0x63, 0x6a, 0x71, 0x78, 0x0f, 0x06, 0x1d, 0x14, 0x2b, 0x22, 0x39, 0x30,
|
168 |
+
0x9a, 0x93, 0x88, 0x81, 0xbe, 0xb7, 0xac, 0xa5, 0xd2, 0xdb, 0xc0, 0xc9,
|
169 |
+
0xf6, 0xff, 0xe4, 0xed, 0x0a, 0x03, 0x18, 0x11, 0x2e, 0x27, 0x3c, 0x35,
|
170 |
+
0x42, 0x4b, 0x50, 0x59, 0x66, 0x6f, 0x74, 0x7d, 0xa1, 0xa8, 0xb3, 0xba,
|
171 |
+
0x85, 0x8c, 0x97, 0x9e, 0xe9, 0xe0, 0xfb, 0xf2, 0xcd, 0xc4, 0xdf, 0xd6,
|
172 |
+
0x31, 0x38, 0x23, 0x2a, 0x15, 0x1c, 0x07, 0x0e, 0x79, 0x70, 0x6b, 0x62,
|
173 |
+
0x5d, 0x54, 0x4f, 0x46
|
174 |
+
);
|
175 |
+
|
176 |
+
private static $GBX = array(
|
177 |
+
0x00, 0x0b, 0x16, 0x1d, 0x2c, 0x27, 0x3a, 0x31, 0x58, 0x53, 0x4e, 0x45,
|
178 |
+
0x74, 0x7f, 0x62, 0x69, 0xb0, 0xbb, 0xa6, 0xad, 0x9c, 0x97, 0x8a, 0x81,
|
179 |
+
0xe8, 0xe3, 0xfe, 0xf5, 0xc4, 0xcf, 0xd2, 0xd9, 0x7b, 0x70, 0x6d, 0x66,
|
180 |
+
0x57, 0x5c, 0x41, 0x4a, 0x23, 0x28, 0x35, 0x3e, 0x0f, 0x04, 0x19, 0x12,
|
181 |
+
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, 0x8b, 0x80,
|
195 |
+
0xe9, 0xe2, 0xff, 0xf4, 0xc5, 0xce, 0xd3, 0xd8, 0x7a, 0x71, 0x6c, 0x67,
|
196 |
+
0x56, 0x5d, 0x40, 0x4b, 0x22, 0x29, 0x34, 0x3f, 0x0e, 0x05, 0x18, 0x13,
|
197 |
+
0xca, 0xc1, 0xdc, 0xd7, 0xe6, 0xed, 0xf0, 0xfb, 0x92, 0x99, 0x84, 0x8f,
|
198 |
+
0xbe, 0xb5, 0xa8, 0xa3
|
199 |
+
);
|
200 |
+
|
201 |
+
private static $GDX = array(
|
202 |
+
0x00, 0x0d, 0x1a, 0x17, 0x34, 0x39, 0x2e, 0x23, 0x68, 0x65, 0x72, 0x7f,
|
203 |
+
0x5c, 0x51, 0x46, 0x4b, 0xd0, 0xdd, 0xca, 0xc7, 0xe4, 0xe9, 0xfe, 0xf3,
|
204 |
+
0xb8, 0xb5, 0xa2, 0xaf, 0x8c, 0x81, 0x96, 0x9b, 0xbb, 0xb6, 0xa1, 0xac,
|
205 |
+
0x8f, 0x82, 0x95, 0x98, 0xd3, 0xde, 0xc9, 0xc4, 0xe7, 0xea, 0xfd, 0xf0,
|
206 |
+
0x6b, 0x66, 0x71, 0x7c, 0x5f, 0x52, 0x45, 0x48, 0x03, 0x0e, 0x19, 0x14,
|
207 |
+
0x37, 0x3a, 0x2d, 0x20, 0x6d, 0x60, 0x77, 0x7a, 0x59, 0x54, 0x43, 0x4e,
|
208 |
+
0x05, 0x08, 0x1f, 0x12, 0x31, 0x3c, 0x2b, 0x26, 0xbd, 0xb0, 0xa7, 0xaa,
|
209 |
+
0x89, 0x84, 0x93, 0x9e, 0xd5, 0xd8, 0xcf, 0xc2, 0xe1, 0xec, 0xfb, 0xf6,
|
210 |
+
0xd6, 0xdb, 0xcc, 0xc1, 0xe2, 0xef, 0xf8, 0xf5, 0xbe, 0xb3, 0xa4, 0xa9,
|
211 |
+
0x8a, 0x87, 0x90, 0x9d, 0x06, 0x0b, 0x1c, 0x11, 0x32, 0x3f, 0x28, 0x25,
|
212 |
+
0x6e, 0x63, 0x74, 0x79, 0x5a, 0x57, 0x40, 0x4d, 0xda, 0xd7, 0xc0, 0xcd,
|
213 |
+
0xee, 0xe3, 0xf4, 0xf9, 0xb2, 0xbf, 0xa8, 0xa5, 0x86, 0x8b, 0x9c, 0x91,
|
214 |
+
0x0a, 0x07, 0x10, 0x1d, 0x3e, 0x33, 0x24, 0x29, 0x62, 0x6f, 0x78, 0x75,
|
215 |
+
0x56, 0x5b, 0x4c, 0x41, 0x61, 0x6c, 0x7b, 0x76, 0x55, 0x58, 0x4f, 0x42,
|
216 |
+
0x09, 0x04, 0x13, 0x1e, 0x3d, 0x30, 0x27, 0x2a, 0xb1, 0xbc, 0xab, 0xa6,
|
217 |
+
0x85, 0x88, 0x9f, 0x92, 0xd9, 0xd4, 0xc3, 0xce, 0xed, 0xe0, 0xf7, 0xfa,
|
218 |
+
0xb7, 0xba, 0xad, 0xa0, 0x83, 0x8e, 0x99, 0x94, 0xdf, 0xd2, 0xc5, 0xc8,
|
219 |
+
0xeb, 0xe6, 0xf1, 0xfc, 0x67, 0x6a, 0x7d, 0x70, 0x53, 0x5e, 0x49, 0x44,
|
220 |
+
0x0f, 0x02, 0x15, 0x18, 0x3b, 0x36, 0x21, 0x2c, 0x0c, 0x01, 0x16, 0x1b,
|
221 |
+
0x38, 0x35, 0x22, 0x2f, 0x64, 0x69, 0x7e, 0x73, 0x50, 0x5d, 0x4a, 0x47,
|
222 |
+
0xdc, 0xd1, 0xc6, 0xcb, 0xe8, 0xe5, 0xf2, 0xff, 0xb4, 0xb9, 0xae, 0xa3,
|
223 |
+
0x80, 0x8d, 0x9a, 0x97
|
224 |
+
);
|
225 |
+
|
226 |
+
private static $GEX = array(
|
227 |
+
0x00, 0x0e, 0x1c, 0x12, 0x38, 0x36, 0x24, 0x2a, 0x70, 0x7e, 0x6c, 0x62,
|
228 |
+
0x48, 0x46, 0x54, 0x5a, 0xe0, 0xee, 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 0x5e, 0x50, 0x0a, 0x04, 0x16, 0x18, 0x32, 0x3c, 0x2e, 0x20,
|
243 |
+
0xec, 0xe2, 0xf0, 0xfe, 0xd4, 0xda, 0xc8, 0xc6, 0x9c, 0x92, 0x80, 0x8e,
|
244 |
+
0xa4, 0xaa, 0xb8, 0xb6, 0x0c, 0x02, 0x10, 0x1e, 0x34, 0x3a, 0x28, 0x26,
|
245 |
+
0x7c, 0x72, 0x60, 0x6e, 0x44, 0x4a, 0x58, 0x56, 0x37, 0x39, 0x2b, 0x25,
|
246 |
+
0x0f, 0x01, 0x13, 0x1d, 0x47, 0x49, 0x5b, 0x55, 0x7f, 0x71, 0x63, 0x6d,
|
247 |
+
0xd7, 0xd9, 0xcb, 0xc5, 0xef, 0xe1, 0xf3, 0xfd, 0xa7, 0xa9, 0xbb, 0xb5,
|
248 |
+
0x9f, 0x91, 0x83, 0x8d
|
249 |
+
);
|
250 |
+
|
251 |
+
// Key Schedule Core
|
252 |
+
private static function core($word,$iteration){
|
253 |
+
/* rotate the 32-bit word 8 bits to the left */
|
254 |
+
$word = self::rotate($word);
|
255 |
+
/* apply S-Box substitution on all 4 parts of the 32-bit word */
|
256 |
+
for ($i = 0; $i < 4; ++$i)
|
257 |
+
$word[$i] = self::$sbox[$word[$i]];
|
258 |
+
/* XOR the output of the rcon operation with i to the first part (leftmost) only */
|
259 |
+
$word[0] = $word[0]^self::$Rcon[$iteration];
|
260 |
+
return $word;
|
261 |
+
}
|
262 |
+
|
263 |
+
/* Rijndael's key expansion
|
264 |
+
* expands an 128,192,256 key into an 176,208,240 bytes key
|
265 |
+
*
|
266 |
+
* expandedKey is a pointer to an char array of large enough size
|
267 |
+
* key is a pointer to a non-expanded key
|
268 |
+
*/
|
269 |
+
private static function expandKey($key,$size)
|
270 |
+
{
|
271 |
+
$expandedKeySize = (16*(self::numberOfRounds($size)+1));
|
272 |
+
|
273 |
+
/* current expanded keySize, in bytes */
|
274 |
+
$currentSize = 0;
|
275 |
+
$rconIteration = 1;
|
276 |
+
$t = array(); // temporary 4-byte variable
|
277 |
+
|
278 |
+
$expandedKey = array();
|
279 |
+
for($i = 0;$i < $expandedKeySize;$i++)
|
280 |
+
$expandedKey[$i] = 0;
|
281 |
+
|
282 |
+
/* set the 16,24,32 bytes of the expanded key to the input key */
|
283 |
+
for ($j = 0; $j < $size; $j++)
|
284 |
+
$expandedKey[$j] = $key[$j];
|
285 |
+
$currentSize += $size;
|
286 |
+
|
287 |
+
while ($currentSize < $expandedKeySize)
|
288 |
+
{
|
289 |
+
/* assign the previous 4 bytes to the temporary value t */
|
290 |
+
for ($k = 0; $k < 4; $k++)
|
291 |
+
$t[$k] = $expandedKey[($currentSize - 4) + $k];
|
292 |
+
|
293 |
+
/* every 16,24,32 bytes we apply the core schedule to t
|
294 |
+
* and increment rconIteration afterwards
|
295 |
+
*/
|
296 |
+
if($currentSize % $size == 0)
|
297 |
+
$t = self::core($t, $rconIteration++);
|
298 |
+
|
299 |
+
/* For 256-bit keys, we add an extra sbox to the calculation */
|
300 |
+
if($size == self::keySize_256 && (($currentSize % $size) == 16))
|
301 |
+
for($l = 0; $l < 4; $l++)
|
302 |
+
$t[$l] = self::$sbox[$t[$l]];
|
303 |
+
|
304 |
+
/* We XOR t with the four-byte block 16,24,32 bytes before the new expanded key.
|
305 |
+
* This becomes the next four bytes in the expanded key.
|
306 |
+
*/
|
307 |
+
for($m = 0; $m < 4; $m++) {
|
308 |
+
$expandedKey[$currentSize] = $expandedKey[$currentSize - $size] ^ $t[$m];
|
309 |
+
$currentSize++;
|
310 |
+
}
|
311 |
+
}
|
312 |
+
return $expandedKey;
|
313 |
+
}
|
314 |
+
|
315 |
+
// Adds (XORs) the round key to the state
|
316 |
+
private static function addRoundKey($state,$roundKey){
|
317 |
+
for ($i = 0; $i < 16; $i++)
|
318 |
+
$state[$i] = $state[$i] ^ $roundKey[$i];
|
319 |
+
return $state;
|
320 |
+
}
|
321 |
+
|
322 |
+
// Creates a round key from the given expanded key and the
|
323 |
+
// position within the expanded key.
|
324 |
+
private static function createRoundKey($expandedKey,$roundKeyPointer){
|
325 |
+
$roundKey = array();
|
326 |
+
for ($i = 0; $i < 4; $i++)
|
327 |
+
for ($j = 0; $j < 4; $j++)
|
328 |
+
$roundKey[$j*4+$i] = $expandedKey[$roundKeyPointer + $i*4 + $j];
|
329 |
+
return $roundKey;
|
330 |
+
}
|
331 |
+
|
332 |
+
/* substitute all the values from the state with the value in the SBox
|
333 |
+
* using the state value as index for the SBox
|
334 |
+
*/
|
335 |
+
private static function subBytes($state,$isInv){
|
336 |
+
for ($i = 0; $i < 16; $i++)
|
337 |
+
$state[$i] = $isInv?self::$rsbox[$state[$i]]:self::$sbox[$state[$i]];
|
338 |
+
return $state;
|
339 |
+
}
|
340 |
+
|
341 |
+
/* iterate over the 4 rows and call shiftRow() with that row */
|
342 |
+
private static function shiftRows($state,$isInv){
|
343 |
+
for ($i = 0; $i < 4; $i++)
|
344 |
+
$state = self::shiftRow($state,$i*4, $i,$isInv);
|
345 |
+
return $state;
|
346 |
+
}
|
347 |
+
|
348 |
+
/* each iteration shifts the row to the left by 1 */
|
349 |
+
private static function shiftRow($state,$statePointer,$nbr,$isInv){
|
350 |
+
for ($i = 0; $i < $nbr; $i++)
|
351 |
+
{
|
352 |
+
if($isInv)
|
353 |
+
{
|
354 |
+
$tmp = $state[$statePointer + 3];
|
355 |
+
for ($j = 3; $j > 0; $j--)
|
356 |
+
$state[$statePointer + $j] = $state[$statePointer + $j-1];
|
357 |
+
$state[$statePointer] = $tmp;
|
358 |
+
}
|
359 |
+
else
|
360 |
+
{
|
361 |
+
$tmp = $state[$statePointer];
|
362 |
+
for ($j = 0; $j < 3; $j++)
|
363 |
+
$state[$statePointer + $j] = $state[$statePointer + $j+1];
|
364 |
+
$state[$statePointer + 3] = $tmp;
|
365 |
+
}
|
366 |
+
}
|
367 |
+
return $state;
|
368 |
+
}
|
369 |
+
|
370 |
+
// galois multipication of the 4x4 matrix
|
371 |
+
private static function mixColumns($state,$isInv){
|
372 |
+
$t = array();
|
373 |
+
|
374 |
+
if (!$isInv) {
|
375 |
+
for ($c = 0; $c < 4; $c++) {
|
376 |
+
$t[ $c] = self::$G2X[$state[$c]] ^ self::$G3X[$state[4+$c]] ^ $state[8+$c] ^ $state[12+$c];
|
377 |
+
$t[ 4+$c] = $state[$c] ^ self::$G2X[$state[4+$c]] ^ self::$G3X[$state[8+$c]] ^ $state[12+$c];
|
378 |
+
$t[ 8+$c] = $state[$c] ^ $state[4+$c] ^ self::$G2X[$state[8+$c]] ^ self::$G3X[$state[12+$c]];
|
379 |
+
$t[12+$c] = self::$G3X[$state[$c]] ^ $state[4+$c] ^ $state[8+$c] ^ self::$G2X[$state[12+$c]];
|
380 |
+
}
|
381 |
+
}else {
|
382 |
+
for ($c = 0; $c < 16; $c+=4) {
|
383 |
+
$t[ $c] = self::$GEX[$state[$c]] ^ self::$GBX[$state[4+$c]] ^ self::$GDX[$state[8+$c]] ^ self::$G9X[$state[12+$c]];
|
384 |
+
$t[1+$c] = self::$G9X[$state[$c]] ^ self::$GEX[$state[4+$c]] ^ self::$GBX[$state[8+$c]] ^ self::$GDX[$state[12+$c]];
|
385 |
+
$t[2+$c] = self::$GDX[$state[$c]] ^ self::$G9X[$state[4+$c]] ^ self::$GEX[$state[8+$c]] ^ self::$GBX[$state[12+$c]];
|
386 |
+
$t[3+$c] = self::$GBX[$state[$c]] ^ self::$GDX[$state[4+$c]] ^ self::$G9X[$state[8+$c]] ^ self::$GEX[$state[12+$c]];
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
return $t;
|
391 |
+
}
|
392 |
+
|
393 |
+
// applies the 4 operations of the forward round in sequence
|
394 |
+
private static function round($state, $roundKey){
|
395 |
+
$state = self::subBytes($state,false);
|
396 |
+
$state = self::shiftRows($state,false);
|
397 |
+
$state = self::mixColumns($state,false);
|
398 |
+
$state = self::addRoundKey($state, $roundKey);
|
399 |
+
return $state;
|
400 |
+
}
|
401 |
+
|
402 |
+
// applies the 4 operations of the inverse round in sequence
|
403 |
+
private static function invRound($state,$roundKey){
|
404 |
+
$state = self::shiftRows($state,true);
|
405 |
+
$state = self::subBytes($state,true);
|
406 |
+
$state = self::addRoundKey($state, $roundKey);
|
407 |
+
$state = self::mixColumns($state,true);
|
408 |
+
return $state;
|
409 |
+
}
|
410 |
+
|
411 |
+
/*
|
412 |
+
* Perform the initial operations, the standard round, and the final operations
|
413 |
+
* of the forward aes, creating a round key for each round
|
414 |
+
*/
|
415 |
+
private static function main($state,$expandedKey,$nbrRounds){
|
416 |
+
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,0));
|
417 |
+
for ($i = 1; $i < $nbrRounds; $i++)
|
418 |
+
$state = self::round($state, self::createRoundKey($expandedKey,16*$i));
|
419 |
+
$state = self::subBytes($state,false);
|
420 |
+
$state = self::shiftRows($state,false);
|
421 |
+
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,16*$nbrRounds));
|
422 |
+
return $state;
|
423 |
+
}
|
424 |
+
|
425 |
+
/*
|
426 |
+
* Perform the initial operations, the standard round, and the final operations
|
427 |
+
* of the inverse aes, creating a round key for each round
|
428 |
+
*/
|
429 |
+
private static function invMain($state, $expandedKey, $nbrRounds){
|
430 |
+
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,16*$nbrRounds));
|
431 |
+
for ($i = $nbrRounds-1; $i > 0; $i--)
|
432 |
+
$state = self::invRound($state, self::createRoundKey($expandedKey,16*$i));
|
433 |
+
$state = self::shiftRows($state,true);
|
434 |
+
$state = self::subBytes($state,true);
|
435 |
+
$state = self::addRoundKey($state, self::createRoundKey($expandedKey,0));
|
436 |
+
return $state;
|
437 |
+
}
|
438 |
+
|
439 |
+
private static function numberOfRounds($size){
|
440 |
+
$nbrRounds;
|
441 |
+
switch ($size) /* set the number of rounds */
|
442 |
+
{
|
443 |
+
case self::keySize_128:
|
444 |
+
$nbrRounds = 10;
|
445 |
+
break;
|
446 |
+
case self::keySize_192:
|
447 |
+
$nbrRounds = 12;
|
448 |
+
break;
|
449 |
+
case self::keySize_256:
|
450 |
+
$nbrRounds = 14;
|
451 |
+
break;
|
452 |
+
default:
|
453 |
+
return null;
|
454 |
+
break;
|
455 |
+
}
|
456 |
+
return $nbrRounds;
|
457 |
+
}
|
458 |
+
|
459 |
+
// encrypts a 128 bit input block against the given key of size specified
|
460 |
+
private static function encryptBlock($input,$key,$size){
|
461 |
+
$output = array();
|
462 |
+
$block = array(); /* the 128 bit block to encode */
|
463 |
+
$nbrRounds = self::numberOfRounds($size);
|
464 |
+
/* Set the block values, for the block:
|
465 |
+
* a0,0 a0,1 a0,2 a0,3
|
466 |
+
* a1,0 a1,1 a1,2 a1,3
|
467 |
+
* a2,0 a2,1 a2,2 a2,3
|
468 |
+
* a3,0 a3,1 a3,2 a3,3
|
469 |
+
* the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3
|
470 |
+
*/
|
471 |
+
for ($i = 0; $i < 4; $i++) /* iterate over the columns */
|
472 |
+
for ($j = 0; $j < 4; $j++) /* iterate over the rows */
|
473 |
+
$block[($i+($j*4))] = $input[($i*4)+$j];
|
474 |
+
|
475 |
+
/* expand the key into an 176, 208, 240 bytes key */
|
476 |
+
$expandedKey = self::expandKey($key, $size); /* the expanded key */
|
477 |
+
/* encrypt the block using the expandedKey */
|
478 |
+
$block = self::main($block, $expandedKey, $nbrRounds);
|
479 |
+
for ($k = 0; $k < 4; $k++) /* unmap the block again into the output */
|
480 |
+
for ($l = 0; $l < 4; $l++) /* iterate over the rows */
|
481 |
+
$output[($k*4)+$l] = $block[($k+($l*4))];
|
482 |
+
return $output;
|
483 |
+
}
|
484 |
+
|
485 |
+
// decrypts a 128 bit input block against the given key of size specified
|
486 |
+
private static function decryptBlock($input, $key, $size){
|
487 |
+
$output = array();
|
488 |
+
$block = array(); /* the 128 bit block to decode */
|
489 |
+
$nbrRounds = self::numberOfRounds($size);
|
490 |
+
/* Set the block values, for the block:
|
491 |
+
* a0,0 a0,1 a0,2 a0,3
|
492 |
+
* a1,0 a1,1 a1,2 a1,3
|
493 |
+
* a2,0 a2,1 a2,2 a2,3
|
494 |
+
* a3,0 a3,1 a3,2 a3,3
|
495 |
+
* the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3
|
496 |
+
*/
|
497 |
+
for ($i = 0; $i < 4; $i++) /* iterate over the columns */
|
498 |
+
for ($j = 0; $j < 4; $j++) /* iterate over the rows */
|
499 |
+
$block[($i+($j*4))] = $input[($i*4)+$j];
|
500 |
+
/* expand the key into an 176, 208, 240 bytes key */
|
501 |
+
$expandedKey = self::expandKey($key, $size);
|
502 |
+
/* decrypt the block using the expandedKey */
|
503 |
+
$block = self::invMain($block, $expandedKey, $nbrRounds);
|
504 |
+
for ($k = 0; $k < 4; $k++)/* unmap the block again into the output */
|
505 |
+
for ($l = 0; $l < 4; $l++)/* iterate over the rows */
|
506 |
+
$output[($k*4)+$l] = $block[($k+($l*4))];
|
507 |
+
return $output;
|
508 |
+
}
|
509 |
+
/*
|
510 |
+
* END AES SECTION
|
511 |
+
*/
|
512 |
+
|
513 |
+
/*
|
514 |
+
* START MODE OF OPERATION SECTION
|
515 |
+
*/
|
516 |
+
//structure of supported modes of operation
|
517 |
+
const modeOfOperation_OFB = 0;
|
518 |
+
const modeOfOperation_CFB = 1;
|
519 |
+
const modeOfOperation_CBC = 2;
|
520 |
+
|
521 |
+
// gets a properly padded block
|
522 |
+
private static function getPaddedBlock($bytesIn,$start,$end,$mode){
|
523 |
+
if($end - $start > 16)
|
524 |
+
$end = $start + 16;
|
525 |
+
|
526 |
+
$xarray = array_slice($bytesIn, $start, $end-$start);
|
527 |
+
|
528 |
+
$cpad = 16 - count($xarray);
|
529 |
+
|
530 |
+
while(count($xarray) < 16){
|
531 |
+
array_push($xarray, $cpad);
|
532 |
+
}
|
533 |
+
|
534 |
+
return $xarray;
|
535 |
+
}
|
536 |
+
|
537 |
+
/*
|
538 |
+
* Mode of Operation Encryption
|
539 |
+
* bytesIn - Input String as array of bytes
|
540 |
+
* mode - mode of type modeOfOperation
|
541 |
+
* key - a number array of length 'size'
|
542 |
+
* size - the bit length of the key
|
543 |
+
* iv - the 128 bit number array Initialization Vector
|
544 |
+
*/
|
545 |
+
public static function encrypt($bytesIn, $mode, $key, $size, $iv){
|
546 |
+
if(count($key)%$size)
|
547 |
+
{
|
548 |
+
throw new Exception('Key length does not match specified size.');
|
549 |
+
}
|
550 |
+
if(count($iv)%16)
|
551 |
+
{
|
552 |
+
throw new Exception('iv length must be 128 bits.');
|
553 |
+
}
|
554 |
+
// the AES input/output
|
555 |
+
$byteArray = array();
|
556 |
+
$input = array();
|
557 |
+
$output = array();
|
558 |
+
$ciphertext = array();
|
559 |
+
$cipherOut = array();
|
560 |
+
// char firstRound
|
561 |
+
$firstRound = true;
|
562 |
+
if ($bytesIn !== null)
|
563 |
+
{
|
564 |
+
for ($j = 0;$j < ceil(count($bytesIn)/16); $j++)
|
565 |
+
{
|
566 |
+
$start = $j*16;
|
567 |
+
$end = $j*16+16;
|
568 |
+
if($j*16+16 > count($bytesIn))
|
569 |
+
$end = count($bytesIn);
|
570 |
+
$byteArray = self::getPaddedBlock($bytesIn,$start,$end,$mode);
|
571 |
+
if ($mode == self::modeOfOperation_CFB)
|
572 |
+
{
|
573 |
+
if ($firstRound)
|
574 |
+
{
|
575 |
+
$output = self::encryptBlock($iv, $key, $size);
|
576 |
+
$firstRound = false;
|
577 |
+
}
|
578 |
+
else
|
579 |
+
$output = self::encryptBlock($input, $key, $size);
|
580 |
+
for ($i = 0; $i < 16; $i++)
|
581 |
+
$ciphertext[$i] = $byteArray[$i] ^ $output[$i];
|
582 |
+
for($k = 0;$k < $end-$start;$k++)
|
583 |
+
array_push($cipherOut, $ciphertext[$k]);
|
584 |
+
$input = $ciphertext;
|
585 |
+
}
|
586 |
+
else if ($mode == self::modeOfOperation_OFB)
|
587 |
+
{
|
588 |
+
if ($firstRound)
|
589 |
+
{
|
590 |
+
$output = self::encryptBlock($iv, $key, $size);
|
591 |
+
$firstRound = false;
|
592 |
+
}
|
593 |
+
else
|
594 |
+
$output = self::encryptBlock($input, $key, $size);
|
595 |
+
for ($i = 0; $i < 16; $i++)
|
596 |
+
$ciphertext[$i] = $byteArray[$i] ^ $output[$i];
|
597 |
+
for($k = 0;$k < $end-$start;$k++)
|
598 |
+
array_push($cipherOut, $ciphertext[$k]);
|
599 |
+
$input = $output;
|
600 |
+
}
|
601 |
+
else if ($mode == self::modeOfOperation_CBC)
|
602 |
+
{
|
603 |
+
for ($i = 0; $i < 16; $i++)
|
604 |
+
$input[$i] = $byteArray[$i] ^ (($firstRound) ? $iv[$i] : $ciphertext[$i]);
|
605 |
+
$firstRound = false;
|
606 |
+
$ciphertext = self::encryptBlock($input, $key, $size);
|
607 |
+
// always 16 bytes because of the padding for CBC
|
608 |
+
for($k = 0;$k < 16;$k++)
|
609 |
+
array_push($cipherOut, $ciphertext[$k]);
|
610 |
+
}
|
611 |
+
}
|
612 |
+
}
|
613 |
+
return array('mode' => $mode, 'originalsize' => count($bytesIn), 'cipher' => $cipherOut);
|
614 |
+
}
|
615 |
+
|
616 |
+
/*
|
617 |
+
* Mode of Operation Decryption
|
618 |
+
* cipherIn - Encrypted String as array of bytes
|
619 |
+
* originalsize - The unencrypted string length - required for CBC
|
620 |
+
* mode - mode of type modeOfOperation
|
621 |
+
* key - a number array of length 'size'
|
622 |
+
* size - the bit length of the key
|
623 |
+
* iv - the 128 bit number array Initialization Vector
|
624 |
+
*/
|
625 |
+
public static function decrypt($cipherIn,$originalsize,$mode,$key,$size,$iv)
|
626 |
+
{
|
627 |
+
if(count($key)%$size)
|
628 |
+
{
|
629 |
+
throw new Exception('Key length does not match specified size.');
|
630 |
+
return null;
|
631 |
+
}
|
632 |
+
if(count($iv)%16)
|
633 |
+
{
|
634 |
+
throw new Exception('iv length must be 128 bits.');
|
635 |
+
}
|
636 |
+
// the AES input/output
|
637 |
+
$ciphertext = array();
|
638 |
+
$input = array();
|
639 |
+
$output = array();
|
640 |
+
$byteArray = array();
|
641 |
+
$bytesOut = array();
|
642 |
+
// char firstRound
|
643 |
+
$firstRound = true;
|
644 |
+
if ($cipherIn !== null)
|
645 |
+
{
|
646 |
+
for ($j = 0;$j < ceil(count($cipherIn)/16); $j++)
|
647 |
+
{
|
648 |
+
$start = $j*16;
|
649 |
+
$end = $j*16+16;
|
650 |
+
if($j*16+16 > count($cipherIn))
|
651 |
+
$end = count($cipherIn);
|
652 |
+
$ciphertext = self::getPaddedBlock($cipherIn,$start,$end,$mode);
|
653 |
+
if ($mode == self::modeOfOperation_CFB)
|
654 |
+
{
|
655 |
+
if ($firstRound)
|
656 |
+
{
|
657 |
+
$output = self::encryptBlock($iv, $key, $size);
|
658 |
+
$firstRound = false;
|
659 |
+
}
|
660 |
+
else
|
661 |
+
$output = self::encryptBlock($input, $key, $size);
|
662 |
+
for ($i = 0; $i < 16; $i++)
|
663 |
+
$byteArray[$i] = $output[$i] ^ $ciphertext[$i];
|
664 |
+
for($k = 0;$k < $end-$start;$k++)
|
665 |
+
array_push($bytesOut, $byteArray[$k]);
|
666 |
+
$input = $ciphertext;
|
667 |
+
}
|
668 |
+
else if ($mode == self::modeOfOperation_OFB)
|
669 |
+
{
|
670 |
+
if ($firstRound)
|
671 |
+
{
|
672 |
+
$output = self::encryptBlock($iv, $key, $size);
|
673 |
+
$firstRound = false;
|
674 |
+
}
|
675 |
+
else
|
676 |
+
$output = self::encryptBlock($input, $key, $size);
|
677 |
+
for ($i = 0; $i < 16; $i++)
|
678 |
+
$byteArray[$i] = $output[$i] ^ $ciphertext[$i];
|
679 |
+
for($k = 0;$k < $end-$start;$k++)
|
680 |
+
array_push($bytesOut, $byteArray[$k]);
|
681 |
+
$input = $output;
|
682 |
+
}
|
683 |
+
else if($mode == self::modeOfOperation_CBC)
|
684 |
+
{
|
685 |
+
$output = self::decryptBlock($ciphertext, $key, $size);
|
686 |
+
for ($i = 0; $i < 16; $i++)
|
687 |
+
$byteArray[$i] = (($firstRound) ? $iv[$i] : $input[$i]) ^ $output[$i];
|
688 |
+
$firstRound = false;
|
689 |
+
if ($originalsize < $end)
|
690 |
+
for($k = 0;$k < $originalsize-$start;$k++)
|
691 |
+
array_push($bytesOut, $byteArray[$k]);
|
692 |
+
else
|
693 |
+
for($k = 0;$k < $end-$start;$k++)
|
694 |
+
array_push($bytesOut, $byteArray[$k]);
|
695 |
+
$input = $ciphertext;
|
696 |
+
}
|
697 |
+
}
|
698 |
+
}
|
699 |
+
return $bytesOut;
|
700 |
+
}
|
701 |
+
/*
|
702 |
+
* END MODE OF OPERATION SECTION
|
703 |
+
*/
|
704 |
+
}
|
705 |
+
|
706 |
+
?>
|
includes/cryptoHelpers.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* cryptoHelpers.php: implements AES - Advanced Encryption Standard
|
5 |
+
* from the SlowAES project, http://code.google.com/p/slowaes/
|
6 |
+
*
|
7 |
+
* Copyright (c) 2008 Josh Davis ( http://www.josh-davis.org ),
|
8 |
+
* Mark Percival ( http://mpercival.com ),
|
9 |
+
* Johan Sundstrom ( http://ecmanaut.blogspot.com ),
|
10 |
+
* John Resig ( http://ejohn.org )
|
11 |
+
*
|
12 |
+
* Ported from JavaScript to PHP by ALeX Kazik
|
13 |
+
*
|
14 |
+
* Licensed under the Apache License, Version 2.0
|
15 |
+
* http://www.apache.org/licenses/
|
16 |
+
*/
|
17 |
+
|
18 |
+
class cryptoHelpers {
|
19 |
+
/*
|
20 |
+
for utf8 en-/decoding see:
|
21 |
+
http://www.php.net/manual/en/function.utf8-encode.php
|
22 |
+
http://www.php.net/manual/en/function.iconv.php
|
23 |
+
http://www.php.net/manual/en/function.mb-convert-encoding.php
|
24 |
+
*/
|
25 |
+
|
26 |
+
//convert a number array to a hex string
|
27 |
+
public static function toHex($args){
|
28 |
+
if(func_num_args() != 1 || !is_array($args)){
|
29 |
+
$args = func_get_args();
|
30 |
+
}
|
31 |
+
$ret = '';
|
32 |
+
for($i = 0; $i < count($args) ;$i++)
|
33 |
+
$ret .= sprintf('%02x', $args[$i]);
|
34 |
+
return $ret;
|
35 |
+
}
|
36 |
+
|
37 |
+
//convert a hex string to a number array
|
38 |
+
public static function toNumbers($s){
|
39 |
+
$ret = array();
|
40 |
+
for($i=0; $i<strlen($s); $i+=2){
|
41 |
+
$ret[] = hexdec(substr($s, $i, 2));
|
42 |
+
}
|
43 |
+
return $ret;
|
44 |
+
}
|
45 |
+
|
46 |
+
// get a random number in the range [min,max]
|
47 |
+
public static function getRandom($min,$max){
|
48 |
+
if($min === null)
|
49 |
+
$min = 0;
|
50 |
+
if($max === null)
|
51 |
+
$max = 1;
|
52 |
+
return mt_rand($min, $max);
|
53 |
+
}
|
54 |
+
|
55 |
+
public static function generateSharedKey($len){
|
56 |
+
if($len === null)
|
57 |
+
$len = 16;
|
58 |
+
$key = array();
|
59 |
+
for($i = 0; $i < $len; $i++)
|
60 |
+
$key[] = self::getRandom(0,255);
|
61 |
+
return $key;
|
62 |
+
}
|
63 |
+
|
64 |
+
public static function generatePrivateKey($s,$size){
|
65 |
+
if(function_exists('mhash') && defined('MHASH_SHA256')){
|
66 |
+
return convertStringToByteArray(substr(mhash(MHASH_SHA256, $s), 0, $size));
|
67 |
+
}else{
|
68 |
+
throw new Exception('cryptoHelpers::generatePrivateKey currently requires mhash');
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
public static function convertStringToByteArray($s){
|
73 |
+
$byteArray = array();
|
74 |
+
for($i = 0; $i < strlen($s); $i++){
|
75 |
+
$byteArray[] = ord($s[$i]);
|
76 |
+
}
|
77 |
+
return $byteArray;
|
78 |
+
}
|
79 |
+
|
80 |
+
public static function convertByteArrayToString($byteArray){
|
81 |
+
$s = '';
|
82 |
+
for($i = 0; $i < count($byteArray); $i++){
|
83 |
+
$s .= chr($byteArray[$i]);
|
84 |
+
}
|
85 |
+
return $s;
|
86 |
+
}
|
87 |
+
|
88 |
+
public static function base64_encode_line($b){
|
89 |
+
return base64_encode(self::convertByteArrayToString($b));
|
90 |
+
}
|
91 |
+
|
92 |
+
public static function base64_encode($b){
|
93 |
+
$b64 = self::base64_encode_line($b);
|
94 |
+
return chunk_split($b, 64, "\n");
|
95 |
+
}
|
96 |
+
|
97 |
+
public static function base64_decode($b){
|
98 |
+
return self::convertStringToByteArray(base64_decode($b));
|
99 |
+
}
|
100 |
+
};
|
includes/settings_page.php
CHANGED
@@ -86,6 +86,7 @@ if (get_option("WPLC_HIDE_CHAT") == true) {
|
|
86 |
$wplc_auto_responder_settings = get_option( "WPLC_AUTO_RESPONDER_SETTINGS" );
|
87 |
$wplc_acbc_data = get_option("WPLC_ACBC_SETTINGS");
|
88 |
$wplc_bh_settings = get_option( "wplc_bh_settings" );
|
|
|
89 |
|
90 |
$wplc_quick_response_order_by = isset( $wplc_settings['wplc_quick_response_orderby'] ) ? sanitize_text_field( $wplc_settings['wplc_quick_response_orderby'] ) : 'title';
|
91 |
$wplc_quick_response_order = isset( $wplc_settings['wplc_quick_response_order'] ) ? sanitize_text_field( $wplc_settings['wplc_quick_response_order'] ) : 'DESC';
|
@@ -1403,6 +1404,31 @@ if (isset($wplc_settings['wplc_hide_when_offline']) && intval($wplc_settings['wp
|
|
1403 |
echo $content;
|
1404 |
?>
|
1405 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1406 |
<?php do_action("wplc_hook_settings_page_more_tabs"); ?>
|
1407 |
|
1408 |
</div>
|
86 |
$wplc_auto_responder_settings = get_option( "WPLC_AUTO_RESPONDER_SETTINGS" );
|
87 |
$wplc_acbc_data = get_option("WPLC_ACBC_SETTINGS");
|
88 |
$wplc_bh_settings = get_option( "wplc_bh_settings" );
|
89 |
+
$wplc_encrypt_data = get_option("WPLC_ENCRYPT_SETTINGS");
|
90 |
|
91 |
$wplc_quick_response_order_by = isset( $wplc_settings['wplc_quick_response_orderby'] ) ? sanitize_text_field( $wplc_settings['wplc_quick_response_orderby'] ) : 'title';
|
92 |
$wplc_quick_response_order = isset( $wplc_settings['wplc_quick_response_order'] ) ? sanitize_text_field( $wplc_settings['wplc_quick_response_order'] ) : 'DESC';
|
1404 |
echo $content;
|
1405 |
?>
|
1406 |
|
1407 |
+
<div id="tabs-9">
|
1408 |
+
<h3><?php _e("Chat Encryption", "wplivechat") ?></h3>
|
1409 |
+
<table class='form-table wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
|
1410 |
+
<tr>
|
1411 |
+
<td width='300' valign='top'><?php _e("Enable Encryption", "wplivechat") ?>: <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('All messages will be encrypted when being sent to and from the user and agent.', 'wplivechat'); ?>"></i></td>
|
1412 |
+
<td>
|
1413 |
+
<input type="checkbox" name="wplc_enable_encryption" id="wplc_enable_encryption" value="1" <?php if(isset($wplc_encrypt_data['wplc_enable_encryption']) && $wplc_encrypt_data['wplc_enable_encryption'] == 1){ echo 'checked'; } ?>/>
|
1414 |
+
</td>
|
1415 |
+
</tr>
|
1416 |
+
<tr>
|
1417 |
+
<td width='300'></td>
|
1418 |
+
<td>
|
1419 |
+
<p class='notice notice-error'>
|
1420 |
+
<?php _e('Please note: Chat messages will only be encrypted and decrypted if you have inserted your WP Live Chat Support API Key with a previous version of our Pro add-on as this key was required.', 'wplivechat'); ?>
|
1421 |
+
<?php _e('Once enabled, all messages sent will be encrypted. This cannot be undone.', 'wplivechat'); ?>
|
1422 |
+
</p>
|
1423 |
+
|
1424 |
+
<p class='update-nag'>
|
1425 |
+
<?php _e('Please note: Message encryption will be deprecated in our next major release.', 'wplivechat'); ?>
|
1426 |
+
</p>
|
1427 |
+
</td>
|
1428 |
+
</tr>
|
1429 |
+
</table>
|
1430 |
+
</div>
|
1431 |
+
|
1432 |
<?php do_action("wplc_hook_settings_page_more_tabs"); ?>
|
1433 |
|
1434 |
</div>
|
js/wplc_gutenberg.js
CHANGED
@@ -93,21 +93,21 @@ jQuery(function($){
|
|
93 |
|
94 |
function initiate_gutenberg_settings() {
|
95 |
// Editor
|
96 |
-
var editor_js = ace.edit( 'wplc_custom_js_editor' );
|
97 |
-
editor_js.setTheme( 'ace/theme/monokai' );
|
98 |
-
editor_js.getSession().setMode( 'ace/mode/javascript' );
|
99 |
-
editor_js.setValue( $('#wplc_custom_js').val(), 1 );
|
100 |
-
editor_js.getSession().on("change", function () {
|
101 |
-
|
102 |
-
});
|
103 |
-
|
104 |
-
var editor_css = ace.edit( 'wplc_custom_css_editor' );
|
105 |
-
editor_css.setTheme( 'ace/theme/monokai' );
|
106 |
-
editor_css.getSession().setMode( 'ace/mode/css' );
|
107 |
-
editor_css.setValue( $('#wplc_custom_css').val(), 1 );
|
108 |
-
editor_css.getSession().on("change", function () {
|
109 |
-
|
110 |
-
});
|
111 |
|
112 |
var editor_html = ace.edit( 'wplc_custom_html_editor' );
|
113 |
editor_html.$blockScrolling = Infinity;
|
93 |
|
94 |
function initiate_gutenberg_settings() {
|
95 |
// Editor
|
96 |
+
// var editor_js = ace.edit( 'wplc_custom_js_editor' );
|
97 |
+
// editor_js.setTheme( 'ace/theme/monokai' );
|
98 |
+
// editor_js.getSession().setMode( 'ace/mode/javascript' );
|
99 |
+
// editor_js.setValue( $('#wplc_custom_js').val(), 1 );
|
100 |
+
// editor_js.getSession().on("change", function () {
|
101 |
+
// $('#wplc_custom_js').val( editor_js.getSession().getValue() );
|
102 |
+
// });
|
103 |
+
|
104 |
+
// var editor_css = ace.edit( 'wplc_custom_css_editor' );
|
105 |
+
// editor_css.setTheme( 'ace/theme/monokai' );
|
106 |
+
// editor_css.getSession().setMode( 'ace/mode/css' );
|
107 |
+
// editor_css.setValue( $('#wplc_custom_css').val(), 1 );
|
108 |
+
// editor_css.getSession().on("change", function () {
|
109 |
+
// $('#wplc_custom_css').val( editor_css.getSession().getValue() );
|
110 |
+
// });
|
111 |
|
112 |
var editor_html = ace.edit( 'wplc_custom_html_editor' );
|
113 |
editor_html.$blockScrolling = Infinity;
|
languages/wplivechat-fa_IR.mo
CHANGED
Binary file
|
languages/wplivechat-fa_IR.po
CHANGED
@@ -2,20 +2,19 @@ msgid ""
|
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: WP Live Chat Support\n"
|
4 |
"POT-Creation-Date: 2019-05-03 12:59+0300\n"
|
5 |
-
"PO-Revision-Date: 2019-05-
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: \n"
|
8 |
"Language: fa_IR\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"X-Generator: Poedit 2.0.
|
13 |
"X-Poedit-Basepath: ../..\n"
|
14 |
"X-Poedit-WPHeader: wp-live-chat-support.php\n"
|
15 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
16 |
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
-
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;
|
18 |
-
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
19 |
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
20 |
"X-Poedit-SearchPath-0: wp-live-chat-support\n"
|
21 |
"X-Poedit-SearchPath-1: wp-live-chat-support-pro\n"
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: WP Live Chat Support\n"
|
4 |
"POT-Creation-Date: 2019-05-03 12:59+0300\n"
|
5 |
+
"PO-Revision-Date: 2019-05-28 08:39+0200\n"
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: \n"
|
8 |
"Language: fa_IR\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 2.0.4\n"
|
13 |
"X-Poedit-Basepath: ../..\n"
|
14 |
"X-Poedit-WPHeader: wp-live-chat-support.php\n"
|
15 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
16 |
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
+
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;"
|
|
|
18 |
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
19 |
"X-Poedit-SearchPath-0: wp-live-chat-support\n"
|
20 |
"X-Poedit-SearchPath-1: wp-live-chat-support-pro\n"
|
languages/wplivechat-pt_BR.mo
CHANGED
Binary file
|
languages/wplivechat-pt_BR.po
CHANGED
@@ -3,7 +3,7 @@ msgstr ""
|
|
3 |
"Project-Id-Version: wplivechat\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
"POT-Creation-Date: 2019-05-03 12:59+0300\n"
|
6 |
-
"PO-Revision-Date: 2019-05-
|
7 |
"Last-Translator: saison <atendimento@saisondigital.com.br>\n"
|
8 |
"Language-Team: \n"
|
9 |
"Language: pt_BR\n"
|
@@ -12,12 +12,11 @@ msgstr ""
|
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
14 |
"X-Poedit-SourceCharset: UTF-8\n"
|
15 |
-
"X-Generator: Poedit 2.0.
|
16 |
"X-Poedit-KeywordsList: _:1;gettext:1;dgettext:2;ngettext:1,2;dngettext:2,3;"
|
17 |
"__:1;_e:1;_c:1;_n:1,2;_n_noop:1,2;_nc:1,2;__ngettext:1,2;__ngettext_noop:1,2;"
|
18 |
"_x:1,2c;_ex:1,2c;_nx:1,2,4c;_nx_noop:1,2,3c;_n_js:1,2;_nx_js:1,2,3c;"
|
19 |
-
"
|
20 |
-
"esc_html_x:1,2c;comments_number_link:2,3;t:1;st:1;trans:1;transChoice:1,2\n"
|
21 |
"X-Poedit-Basepath: ../..\n"
|
22 |
"X-Loco-Target-Locale: pt_BR\n"
|
23 |
"X-Poedit-SearchPath-0: wp-live-chat-support\n"
|
3 |
"Project-Id-Version: wplivechat\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
"POT-Creation-Date: 2019-05-03 12:59+0300\n"
|
6 |
+
"PO-Revision-Date: 2019-05-28 08:40+0200\n"
|
7 |
"Last-Translator: saison <atendimento@saisondigital.com.br>\n"
|
8 |
"Language-Team: \n"
|
9 |
"Language: pt_BR\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
14 |
"X-Poedit-SourceCharset: UTF-8\n"
|
15 |
+
"X-Generator: Poedit 2.0.4\n"
|
16 |
"X-Poedit-KeywordsList: _:1;gettext:1;dgettext:2;ngettext:1,2;dngettext:2,3;"
|
17 |
"__:1;_e:1;_c:1;_n:1,2;_n_noop:1,2;_nc:1,2;__ngettext:1,2;__ngettext_noop:1,2;"
|
18 |
"_x:1,2c;_ex:1,2c;_nx:1,2,4c;_nx_noop:1,2,3c;_n_js:1,2;_nx_js:1,2,3c;"
|
19 |
+
"comments_number_link:2,3;t:1;st:1;trans:1;transChoice:1,2\n"
|
|
|
20 |
"X-Poedit-Basepath: ../..\n"
|
21 |
"X-Loco-Target-Locale: pt_BR\n"
|
22 |
"X-Poedit-SearchPath-0: wp-live-chat-support\n"
|
modules/advanced_features.php
CHANGED
@@ -50,6 +50,15 @@ function wplc_beta_settings_tab_content() {
|
|
50 |
?>
|
51 |
<table class="wp-list-table wplc_list_table widefat fixed striped pages">
|
52 |
<tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
<tr>
|
54 |
<td width="250" valign="top">
|
55 |
<label for="wplc_use_node_server"><?php _e("Chat server token","wplivechat"); ?> <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('Security token for accessing chats on the node server. Changing this will remove current chats', 'wplivechat'); ?>"></i></label>
|
@@ -80,6 +89,10 @@ function wplc_beta_settings_tab_content() {
|
|
80 |
<td width="250" valign="top"></td>
|
81 |
<td valign="top">
|
82 |
<span class='update-nag' style='margin-top:0; font-size:12px; border-color: #0180bc ;'><strong><?php _e("Did you know?", "wplivechat"); ?></strong><br> <?php _e('You can copy this node server token to multiple sites in order to manage more than one domain from a single chat dashboard','wplivechat'); ?></span>
|
|
|
|
|
|
|
|
|
83 |
</td>
|
84 |
</tr>
|
85 |
</tbody>
|
@@ -107,7 +120,7 @@ add_filter("wplc_settings_save_filter_hook", "wplc_beta_settings_save_hooked", 1
|
|
107 |
*/
|
108 |
function wplc_beta_settings_save_hooked($wplc_data){
|
109 |
|
110 |
-
$wplc_data['wplc_use_node_server'] = '
|
111 |
|
112 |
if (isset($_POST['wplc_node_token_input'])) {
|
113 |
$wplc_node_new_token = sanitize_text_field($_POST['wplc_node_token_input']);
|
50 |
?>
|
51 |
<table class="wp-list-table wplc_list_table widefat fixed striped pages">
|
52 |
<tbody>
|
53 |
+
<tr>
|
54 |
+
<td width="250" valign="top">
|
55 |
+
<label for="wplc_use_node_server"><?php _e("Use our server to handle chats","wplivechat"); ?> <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('Disabling this will result in the plugin reverting back to using the legacy chat dashboard.', 'wplivechat'); ?>"></i></label>
|
56 |
+
</td>
|
57 |
+
<td valign="top">
|
58 |
+
<input type="checkbox" value="1" name="wplc_use_node_server" <?php if (isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == '1') { echo "checked"; } ?>>
|
59 |
+
<small><em><?php _e("Disabling this will revert the chat dashboard back to the legacy version.", "wplivechat"); ?></em></small>
|
60 |
+
</td>
|
61 |
+
</tr>
|
62 |
<tr>
|
63 |
<td width="250" valign="top">
|
64 |
<label for="wplc_use_node_server"><?php _e("Chat server token","wplivechat"); ?> <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('Security token for accessing chats on the node server. Changing this will remove current chats', 'wplivechat'); ?>"></i></label>
|
89 |
<td width="250" valign="top"></td>
|
90 |
<td valign="top">
|
91 |
<span class='update-nag' style='margin-top:0; font-size:12px; border-color: #0180bc ;'><strong><?php _e("Did you know?", "wplivechat"); ?></strong><br> <?php _e('You can copy this node server token to multiple sites in order to manage more than one domain from a single chat dashboard','wplivechat'); ?></span>
|
92 |
+
<br><br>
|
93 |
+
<p class='update-nag'>
|
94 |
+
<?php _e('Please note: The use of a local servers will be deprecated in our next major release.', 'wplivechat'); ?>
|
95 |
+
</p>
|
96 |
</td>
|
97 |
</tr>
|
98 |
</tbody>
|
120 |
*/
|
121 |
function wplc_beta_settings_save_hooked($wplc_data){
|
122 |
|
123 |
+
if (isset($_POST['wplc_use_node_server'])) { $wplc_data['wplc_use_node_server'] = intval($_POST['wplc_use_node_server']); }
|
124 |
|
125 |
if (isset($_POST['wplc_node_token_input'])) {
|
126 |
$wplc_node_new_token = sanitize_text_field($_POST['wplc_node_token_input']);
|
modules/advanced_tools.php
CHANGED
@@ -260,11 +260,8 @@ function wplc_at_export_settings_mrg(){
|
|
260 |
"WPLC_BANNED_IP_ADDRESSES",
|
261 |
"wplc_advanced_settings",
|
262 |
"WPLC_POWERED_BY",
|
263 |
-
"WPLC_CUSTOM_CSS",
|
264 |
-
"WPLC_CUSTOM_JS",
|
265 |
"WPLC_DOC_SUGG_SETTINGS",
|
266 |
"WPLC_ACBC_SETTINGS",
|
267 |
-
"WPLC_ENCRYPT_SETTINGS",
|
268 |
"WPLC_INEX_SETTINGS",
|
269 |
"WPLC_AUTO_RESPONDER_SETTINGS",
|
270 |
"WPLC_ET_SETTINGS",
|
260 |
"WPLC_BANNED_IP_ADDRESSES",
|
261 |
"wplc_advanced_settings",
|
262 |
"WPLC_POWERED_BY",
|
|
|
|
|
263 |
"WPLC_DOC_SUGG_SETTINGS",
|
264 |
"WPLC_ACBC_SETTINGS",
|
|
|
265 |
"WPLC_INEX_SETTINGS",
|
266 |
"WPLC_AUTO_RESPONDER_SETTINGS",
|
267 |
"WPLC_ET_SETTINGS",
|
readme.txt
CHANGED
@@ -209,6 +209,9 @@ If the live chat box still does not appear on your website, please go through th
|
|
209 |
|
210 |
|
211 |
== Upgrade Notice ==
|
|
|
|
|
|
|
212 |
= 8.0.31 =
|
213 |
It is highly recommended that you upgrade to WP Live Chat Support version 8.0.30 for security reasons.
|
214 |
|
@@ -268,6 +271,17 @@ We have patched the PHPMailer vulnerability. Please update to version 7.0.02.
|
|
268 |
|
269 |
|
270 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
= 8.0.31 - 2019-05-30 - High priority =
|
272 |
* Additional sanitization and security cleanup
|
273 |
* Added upgrade check to clear custom JS prior to version 8.0.31
|
209 |
|
210 |
|
211 |
== Upgrade Notice ==
|
212 |
+
= 8.0.32 =
|
213 |
+
It is highly recommended that you upgrade to WP Live Chat Support version 8.0.30 for security reasons.
|
214 |
+
|
215 |
= 8.0.31 =
|
216 |
It is highly recommended that you upgrade to WP Live Chat Support version 8.0.30 for security reasons.
|
217 |
|
271 |
|
272 |
|
273 |
== Changelog ==
|
274 |
+
= 8.0.32 - 2019-05-28 - High priority =
|
275 |
+
* Removed references to esc_attr within PO file configuration
|
276 |
+
* Remove Custom Scripts area (including JS and CSS)
|
277 |
+
* Remove handlers for Custom Scripts
|
278 |
+
* Added back the AES and Crypto Helper classes to support backwards compat encryption/decryption of messages
|
279 |
+
* Added supporting encryption/decryption functions
|
280 |
+
* Added a dismissable notice explaining the deprecation of local encryption and local server usage
|
281 |
+
* Restored the ability to enable/disable encryption
|
282 |
+
* Restored the ability to enable/disable the use of local servers
|
283 |
+
* Fixed bug where Ace library was still trying to initialize custom JS and CSS boxes
|
284 |
+
|
285 |
= 8.0.31 - 2019-05-30 - High priority =
|
286 |
* Additional sanitization and security cleanup
|
287 |
* Added upgrade check to clear custom JS prior to version 8.0.31
|
wp-live-chat-support.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Live Chat Support
|
4 |
Plugin URI: http://www.wp-livechat.com
|
5 |
Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support.
|
6 |
-
Version: 8.0.
|
7 |
Author: WP-LiveChat
|
8 |
Author URI: http://www.wp-livechat.com
|
9 |
Text Domain: wplivechat
|
@@ -11,6 +11,17 @@
|
|
11 |
*/
|
12 |
|
13 |
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
* 8.0.31 - 2019-05-30 - High priority
|
15 |
* Additional sanitization and security cleanup
|
16 |
* Added upgrade check to clear custom JS prior to version 8.0.31
|
@@ -19,7 +30,7 @@
|
|
19 |
* Fixed issue with GUID not being generated after re-activation
|
20 |
* Fixed issue with escape loop in settings area
|
21 |
* Removed setting to disable remote servers
|
22 |
-
* Removed local encryption functionality, every chat message is using HTTPS secure connection
|
23 |
* Removed AES and CryptoHelpers as these are no longer used
|
24 |
* Removed manual inclusion of SMTP and PHPMailer
|
25 |
* Removed mail type setting, along with SMTP options
|
@@ -280,6 +291,12 @@ require_once (plugin_dir_path(__FILE__) . "modules/api/wplc-api.php");
|
|
280 |
require_once (plugin_dir_path(__FILE__) . "modules/cta_animations.php");
|
281 |
require_once (plugin_dir_path(__FILE__) . "modules/advanced_tools.php");
|
282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
// Gutenberg Blocks
|
284 |
require_once (plugin_dir_path(__FILE__) . "includes/blocks/wplc-chat-box/index.php");
|
285 |
require_once (plugin_dir_path(__FILE__) . "includes/blocks/wplc-inline-chat-box/index.php");
|
@@ -406,9 +423,10 @@ function wplc_version_control() {
|
|
406 |
* Added for security cleanup prior to version 8.0.31
|
407 |
*/
|
408 |
if( isset( $current_version )){
|
409 |
-
if(intval(str_replace('.', '', $current_version)) < 8031){
|
410 |
-
// Remove all custom JS if previous version was less than 8.0.31
|
411 |
-
update_option( "WPLC_CUSTOM_JS", '
|
|
|
412 |
}
|
413 |
}
|
414 |
|
@@ -541,6 +559,11 @@ function wplc_hook_control_remove_transient() {
|
|
541 |
function wplc_check_guid() {
|
542 |
$guid=get_option('WPLC_GUID');
|
543 |
$guid_fqdn=get_option('WPLC_GUID_URL');
|
|
|
|
|
|
|
|
|
|
|
544 |
if (empty($guid) || $guid_fqdn!=get_option('siteurl')) { // guid not assigned or fqdn is changed since last assignment
|
545 |
$data_array = array(
|
546 |
'method' => 'POST',
|
@@ -643,6 +666,12 @@ if (!function_exists("wplc_first_run_check")) {
|
|
643 |
update_option("WPLC_CHOOSE_ACCEPTING",$choose_array);
|
644 |
update_option("WPLC_CHOOSE_FIRST_RUN",true);
|
645 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
646 |
|
647 |
if (!get_option("WPLC_INEX_FIRST_RUN")) {
|
648 |
$wplc_inex_data['wplc_exclude_from_pages'] = "";
|
@@ -3967,6 +3996,7 @@ function wplc_head() {
|
|
3967 |
$wplc_choose_data = get_option("WPLC_CHOOSE_SETTINGS");
|
3968 |
if(isset($_POST['wplc_auto_online'])){ $wplc_choose_data['wplc_auto_online'] = sanitize_text_field($_POST['wplc_auto_online']);} else { $wplc_choose_data['wplc_auto_online'] = 0; }
|
3969 |
|
|
|
3970 |
|
3971 |
if (isset($_POST['wplc_include_on_pages'])) { $wplc_inex_data['wplc_include_on_pages'] = sanitize_text_field($_POST['wplc_include_on_pages']); }
|
3972 |
if (isset($_POST['wplc_exclude_from_pages'])) { $wplc_inex_data['wplc_exclude_from_pages'] = sanitize_text_field($_POST['wplc_exclude_from_pages']); }
|
@@ -4829,108 +4859,6 @@ function wplc_custom_scripts_scripts(){
|
|
4829 |
|
4830 |
}
|
4831 |
|
4832 |
-
add_filter( "wplc_filter_setting_tabs", "wplc_custom_scripts_tab" );
|
4833 |
-
/**
|
4834 |
-
* Adds a tab for the custom scripts
|
4835 |
-
* @param array $array current array that is made available to us
|
4836 |
-
* @return array our tabs array has been added to the array
|
4837 |
-
*/
|
4838 |
-
function wplc_custom_scripts_tab( $array ){
|
4839 |
-
|
4840 |
-
$array['custom-scripts'] = array(
|
4841 |
-
'href' => '#wplc-custom-scripts',
|
4842 |
-
'icon' => 'fa fa-pencil',
|
4843 |
-
'label' => __("Custom Scripts", "wplivechat")
|
4844 |
-
);
|
4845 |
-
|
4846 |
-
return $array;
|
4847 |
-
}
|
4848 |
-
|
4849 |
-
add_action( "wplc_hook_settings_page_more_tabs", "wplc_custom_scripts_content" );
|
4850 |
-
/**
|
4851 |
-
* Adds the tab content to the settings page to allow the user to add custom CSS & JS
|
4852 |
-
* @return string
|
4853 |
-
*/
|
4854 |
-
function wplc_custom_scripts_content(){
|
4855 |
-
|
4856 |
-
$wplc_custom_css = get_option( "WPLC_CUSTOM_CSS" );
|
4857 |
-
$wplc_custom_js = get_option( "WPLC_CUSTOM_JS" );
|
4858 |
-
|
4859 |
-
$content = "";
|
4860 |
-
|
4861 |
-
$content .= "<div id='wplc-custom-scripts'>";
|
4862 |
-
|
4863 |
-
$content .= "<h2>".__("Custom Scripts", "wplivechat")."</h2>";
|
4864 |
-
$content .= "<table class='form-table'>";
|
4865 |
-
|
4866 |
-
$content .= "<tr>";
|
4867 |
-
$content .= "<td width='300'>".__("Custom CSS", "wplivechat")."</td>";
|
4868 |
-
$content .= "<td><div id='wplc_custom_css_editor'></div><textarea name='wplc_custom_css' id='wplc_custom_css' style='display: none;' data-editor='css' rows='12'>".strip_tags(stripslashes( $wplc_custom_css ))."</textarea></td>";
|
4869 |
-
$content .= "</tr>";
|
4870 |
-
|
4871 |
-
$content .= "<tr>";
|
4872 |
-
$content .= "<td width='300'>".__("Custom JS", "wplivechat")."</td>";
|
4873 |
-
$content .= "<td valign='middle'><div id='wplc_custom_js_editor'></div><textarea name='wplc_custom_js' id='wplc_custom_js' style='display: none;' data-editor='javascript' rows='12'>".( stripslashes( $wplc_custom_js ))."</textarea></td>";
|
4874 |
-
$content .= "</tr>";
|
4875 |
-
|
4876 |
-
$content .= "</table>";
|
4877 |
-
|
4878 |
-
$content .= "</div>";
|
4879 |
-
|
4880 |
-
echo $content;
|
4881 |
-
|
4882 |
-
}
|
4883 |
-
|
4884 |
-
add_action( "wplc_hook_head", "wplc_custom_scripts_save" );
|
4885 |
-
/**
|
4886 |
-
* Saves the custom scripts into the options table
|
4887 |
-
* @return void
|
4888 |
-
*/
|
4889 |
-
|
4890 |
-
function wplc_custom_scripts_save(){
|
4891 |
-
|
4892 |
-
if( isset( $_POST['wplc_save_settings'] ) ){
|
4893 |
-
if (current_user_can('manage_options')) {
|
4894 |
-
if( isset( $_POST['wplc_custom_css'] ) ){
|
4895 |
-
update_option( "WPLC_CUSTOM_CSS", strip_tags($_POST['wplc_custom_css']) );
|
4896 |
-
}
|
4897 |
-
|
4898 |
-
if( isset( $_POST['wplc_custom_js'] ) ){
|
4899 |
-
update_option( "WPLC_CUSTOM_JS", strip_tags($_POST['wplc_custom_js']) );
|
4900 |
-
}
|
4901 |
-
}else {
|
4902 |
-
wp_die(__("You do not have permission do perform this action", "wplivechat"));
|
4903 |
-
}
|
4904 |
-
}
|
4905 |
-
|
4906 |
-
}
|
4907 |
-
|
4908 |
-
add_action( "wp_head", "wplc_custom_scripts_frontend" );
|
4909 |
-
/**
|
4910 |
-
* Display the custom scripts on the front end of the site
|
4911 |
-
* @return string
|
4912 |
-
*/
|
4913 |
-
function wplc_custom_scripts_frontend(){
|
4914 |
-
|
4915 |
-
$wplc_custom_css = get_option( "WPLC_CUSTOM_CSS" );
|
4916 |
-
$wplc_custom_js = get_option( "WPLC_CUSTOM_JS" );
|
4917 |
-
|
4918 |
-
if( $wplc_custom_css ){
|
4919 |
-
echo "<!-- WPLC Custom CSS -->";
|
4920 |
-
echo "<style>";
|
4921 |
-
echo stripslashes( $wplc_custom_css );
|
4922 |
-
echo "</style>";
|
4923 |
-
}
|
4924 |
-
|
4925 |
-
if( $wplc_custom_js ){
|
4926 |
-
echo "<!-- WPLC Custom JS -->";
|
4927 |
-
echo "<script>";
|
4928 |
-
echo stripslashes( $wplc_custom_js );
|
4929 |
-
echo "</script>";
|
4930 |
-
}
|
4931 |
-
|
4932 |
-
}
|
4933 |
-
|
4934 |
add_filter( "wplc_offline_message_subject_filter", "wplc_change_offline_message", 10, 1 );
|
4935 |
/**
|
4936 |
* Adds a filter to change the email address to the user's preference
|
@@ -5422,3 +5350,32 @@ function wplc_features_admin_js() {
|
|
5422 |
wp_enqueue_script('wplc-admin-features');
|
5423 |
}
|
5424 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Plugin Name: WP Live Chat Support
|
4 |
Plugin URI: http://www.wp-livechat.com
|
5 |
Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support.
|
6 |
+
Version: 8.0.32
|
7 |
Author: WP-LiveChat
|
8 |
Author URI: http://www.wp-livechat.com
|
9 |
Text Domain: wplivechat
|
11 |
*/
|
12 |
|
13 |
/*
|
14 |
+
* 8.0.32 - 2019-05-28 - High priority
|
15 |
+
* Removed references to esc_attr within PO file configuration
|
16 |
+
* Remove Custom Scripts area (including JS and CSS)
|
17 |
+
* Remove handlers for Custom Scripts
|
18 |
+
* Added back the AES and Crypto Helper classes to support backwards compat encryption/decryption of messages
|
19 |
+
* Added supporting encryption/decryption functions
|
20 |
+
* Added a dismissable notice explaining the deprecation of local encryption and local server usage
|
21 |
+
* Restored the ability to enable/disable encryption
|
22 |
+
* Restored the ability to enable/disable the use of local servers
|
23 |
+
* Fixed bug where Ace library was still trying to initialize custom JS and CSS boxes
|
24 |
+
*
|
25 |
* 8.0.31 - 2019-05-30 - High priority
|
26 |
* Additional sanitization and security cleanup
|
27 |
* Added upgrade check to clear custom JS prior to version 8.0.31
|
30 |
* Fixed issue with GUID not being generated after re-activation
|
31 |
* Fixed issue with escape loop in settings area
|
32 |
* Removed setting to disable remote servers
|
33 |
+
* Removed local encryption functionality, every chat message is using HTTPS secure connection
|
34 |
* Removed AES and CryptoHelpers as these are no longer used
|
35 |
* Removed manual inclusion of SMTP and PHPMailer
|
36 |
* Removed mail type setting, along with SMTP options
|
291 |
require_once (plugin_dir_path(__FILE__) . "modules/cta_animations.php");
|
292 |
require_once (plugin_dir_path(__FILE__) . "modules/advanced_tools.php");
|
293 |
|
294 |
+
/*
|
295 |
+
* Added back for backwards compat decrypt
|
296 |
+
*/
|
297 |
+
if (class_exists("AES")) { } else { require( 'includes/aes_fast.php'); }
|
298 |
+
if (class_exists("cryptoHelpers")) { } else { require( 'includes/cryptoHelpers.php'); }
|
299 |
+
|
300 |
// Gutenberg Blocks
|
301 |
require_once (plugin_dir_path(__FILE__) . "includes/blocks/wplc-chat-box/index.php");
|
302 |
require_once (plugin_dir_path(__FILE__) . "includes/blocks/wplc-inline-chat-box/index.php");
|
423 |
* Added for security cleanup prior to version 8.0.31
|
424 |
*/
|
425 |
if( isset( $current_version )){
|
426 |
+
if(intval(str_replace('.', '', $current_version)) < 8031 || intval(str_replace('.', '', $current_version)) < 8032){
|
427 |
+
// Remove all custom JS if previous version was less than 8.0.31 or 8.0.32
|
428 |
+
update_option( "WPLC_CUSTOM_JS", '');
|
429 |
+
update_option( "WPLC_CUSTOM_CSS", '');
|
430 |
}
|
431 |
}
|
432 |
|
559 |
function wplc_check_guid() {
|
560 |
$guid=get_option('WPLC_GUID');
|
561 |
$guid_fqdn=get_option('WPLC_GUID_URL');
|
562 |
+
$guid_lastcheck=intval(get_option('WPLC_GUID_CHECK'));
|
563 |
+
if (empty($guid_lastcheck) || time()-$guid_lastcheck>604800) { // check at least once per week to ensure guid is updated properly
|
564 |
+
$guid='';
|
565 |
+
update_option('WPLC_GUID_CHECK', time());
|
566 |
+
}
|
567 |
if (empty($guid) || $guid_fqdn!=get_option('siteurl')) { // guid not assigned or fqdn is changed since last assignment
|
568 |
$data_array = array(
|
569 |
'method' => 'POST',
|
666 |
update_option("WPLC_CHOOSE_ACCEPTING",$choose_array);
|
667 |
update_option("WPLC_CHOOSE_FIRST_RUN",true);
|
668 |
}
|
669 |
+
|
670 |
+
if (!get_option("WPLC_ENCRYPT_FIRST_RUN")) {
|
671 |
+
$wplc_encrypt_data['wplc_enable_encryption'] = 0;
|
672 |
+
update_option('WPLC_ENCRYPT_SETTINGS', $wplc_encrypt_data);
|
673 |
+
update_option("WPLC_ENCRYPT_FIRST_RUN",true);
|
674 |
+
}
|
675 |
|
676 |
if (!get_option("WPLC_INEX_FIRST_RUN")) {
|
677 |
$wplc_inex_data['wplc_exclude_from_pages'] = "";
|
3996 |
$wplc_choose_data = get_option("WPLC_CHOOSE_SETTINGS");
|
3997 |
if(isset($_POST['wplc_auto_online'])){ $wplc_choose_data['wplc_auto_online'] = sanitize_text_field($_POST['wplc_auto_online']);} else { $wplc_choose_data['wplc_auto_online'] = 0; }
|
3998 |
|
3999 |
+
if (isset($_POST['wplc_enable_encryption'])) {$wplc_encrypt_data['wplc_enable_encryption'] = intval($_POST['wplc_enable_encryption']);} else {$wplc_encrypt_data['wplc_enable_encryption'] = 0;}
|
4000 |
|
4001 |
if (isset($_POST['wplc_include_on_pages'])) { $wplc_inex_data['wplc_include_on_pages'] = sanitize_text_field($_POST['wplc_include_on_pages']); }
|
4002 |
if (isset($_POST['wplc_exclude_from_pages'])) { $wplc_inex_data['wplc_exclude_from_pages'] = sanitize_text_field($_POST['wplc_exclude_from_pages']); }
|
4859 |
|
4860 |
}
|
4861 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4862 |
add_filter( "wplc_offline_message_subject_filter", "wplc_change_offline_message", 10, 1 );
|
4863 |
/**
|
4864 |
* Adds a filter to change the email address to the user's preference
|
5350 |
wp_enqueue_script('wplc-admin-features');
|
5351 |
}
|
5352 |
|
5353 |
+
add_action('admin_notices', 'wplc_encryption_deprecated_notice');
|
5354 |
+
/**
|
5355 |
+
* Notice of doom
|
5356 |
+
*/
|
5357 |
+
function wplc_encryption_deprecated_notice(){
|
5358 |
+
if(isset($_GET['wplc_encryption_dismiss_notice'])){
|
5359 |
+
if(wp_verify_nonce($_GET['wplc_dismiss_nonce'], 'wplc_encrypt_note_nonce')){
|
5360 |
+
update_option('WPLC_ENCRYPT_DEPREC_NOTICE_DISMISSED', 'true');
|
5361 |
+
}
|
5362 |
+
}
|
5363 |
+
|
5364 |
+
if(isset($_GET['page'])){
|
5365 |
+
if($_GET['page'] === 'wplivechat-menu-settings'){
|
5366 |
+
$encrypt_deprec_notice_dismissed = get_option('WPLC_ENCRYPT_DEPREC_NOTICE_DISMISSED', false);
|
5367 |
+
|
5368 |
+
if($encrypt_deprec_notice_dismissed === false || $encrypt_deprec_notice_dismissed === 'false'){
|
5369 |
+
$dismiss_nonce = wp_create_nonce('wplc_encrypt_note_nonce');
|
5370 |
+
$encrypt_note = __('Please note, local message encryption and local server options will be deprecated in the next major release. All encryption and message delivery will handled by our external servers in future.', 'wplivechat');
|
5371 |
+
|
5372 |
+
$output = "<div class='update-nag' style='margin-bottom: 5px;'>";
|
5373 |
+
$output .= "<strong>" . __("Deprecation Notice - Message Encryption & Local Server", "wplivechat") . "</strong><br>";
|
5374 |
+
$output .= "<p>" . $encrypt_note . "</p>";
|
5375 |
+
$output .= "<a class='button' href='?page=" . htmlspecialchars(sanitize_text_field($_GET['page'])) ."&wplc_encryption_dismiss_notice=true&wplc_dismiss_nonce=$dismiss_nonce'>" . __("Dismiss", "wplivechat") . "</a>";
|
5376 |
+
$output .= "</div>";
|
5377 |
+
echo $output;
|
5378 |
+
}
|
5379 |
+
}
|
5380 |
+
}
|
5381 |
+
}
|