@@ -158,7 +158,7 @@ |
||
| 158 | 158 | |
| 159 | 159 | // if DUOSecurity enabled then changing PWD is not allowed |
| 160 | 160 | if (!isset($_SESSION['settings']['duo']) || $_SESSION['settings']['duo'] == 0) |
| 161 | - echo ' |
|
| 161 | + echo ' |
|
| 162 | 162 | <div id="div_change_password" style="display:none; padding:5px;" class="ui-widget ui-state-default"> |
| 163 | 163 | <div style="text-align:center;margin:5px;padding:3px;" id="change_pwd_complexPw" class="ui-widget ui-state-active ui-corner-all"></div> |
| 164 | 164 | <label for="new_pw" class="form_label">'.$LANG['index_new_pw'].' :</label> |
@@ -469,7 +469,7 @@ |
||
| 469 | 469 | } else { |
| 470 | 470 | // user said that database has not being used for an older version |
| 471 | 471 | // no old sk is available |
| 472 | - $tmp = mysqli_num_rows(mysqli_query( |
|
| 472 | + $tmp = mysqli_num_rows(mysqli_query( |
|
| 473 | 473 | $dbTmp, |
| 474 | 474 | "SELECT * FROM `".$var['tbl_prefix']."misc` WHERE type = 'admin' AND intitule = 'saltkey_ante_2127'" |
| 475 | 475 | )); |
@@ -6,15 +6,15 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class Aes |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * AES Cipher function: encrypt 'input' with Rijndael algorithm |
|
| 11 | - * |
|
| 12 | - * @param input message as byte-array (16 bytes) |
|
| 13 | - * @param w key schedule as 2D byte-array (Nr+1 x Nb bytes) - |
|
| 14 | - * generated from the cipher key by keyExpansion() |
|
| 15 | - * @return ciphertext as byte-array (16 bytes) |
|
| 16 | - */ |
|
| 17 | - public static function cipher($input, $w) { // main cipher function [é5.1] |
|
| 9 | + /** |
|
| 10 | + * AES Cipher function: encrypt 'input' with Rijndael algorithm |
|
| 11 | + * |
|
| 12 | + * @param input message as byte-array (16 bytes) |
|
| 13 | + * @param w key schedule as 2D byte-array (Nr+1 x Nb bytes) - |
|
| 14 | + * generated from the cipher key by keyExpansion() |
|
| 15 | + * @return ciphertext as byte-array (16 bytes) |
|
| 16 | + */ |
|
| 17 | + public static function cipher($input, $w) { // main cipher function [é5.1] |
|
| 18 | 18 | $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) |
| 19 | 19 | $Nr = count($w)/$Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys |
| 20 | 20 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | $state = self::addRoundKey($state, $w, 0, $Nb); |
| 25 | 25 | |
| 26 | 26 | for ($round=1; $round<$Nr; $round++) { // apply Nr rounds |
| 27 | - $state = self::subBytes($state, $Nb); |
|
| 28 | - $state = self::shiftRows($state, $Nb); |
|
| 29 | - $state = self::mixColumns($state, $Nb); |
|
| 30 | - $state = self::addRoundKey($state, $w, $round, $Nb); |
|
| 27 | + $state = self::subBytes($state, $Nb); |
|
| 28 | + $state = self::shiftRows($state, $Nb); |
|
| 29 | + $state = self::mixColumns($state, $Nb); |
|
| 30 | + $state = self::addRoundKey($state, $w, $round, $Nb); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | $state = self::subBytes($state, $Nb); |
@@ -38,59 +38,59 @@ discard block |
||
| 38 | 38 | for ($i=0; $i<4*$Nb; $i++) $output[$i] = $state[$i%4][floor($i/4)]; |
| 39 | 39 | |
| 40 | 40 | return $output; |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - private static function addRoundKey($state, $w, $rnd, $Nb) { // xor Round Key into state S [é5.1.4] |
|
| 43 | + private static function addRoundKey($state, $w, $rnd, $Nb) { // xor Round Key into state S [é5.1.4] |
|
| 44 | 44 | for ($r=0; $r<4; $r++) { |
| 45 | - for ($c=0; $c<$Nb; $c++) $state[$r][$c] ^= $w[$rnd*4+$c][$r]; |
|
| 45 | + for ($c=0; $c<$Nb; $c++) $state[$r][$c] ^= $w[$rnd*4+$c][$r]; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | return $state; |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - private static function subBytes($s, $Nb) { // apply SBox to state S [é5.1.1] |
|
| 51 | + private static function subBytes($s, $Nb) { // apply SBox to state S [é5.1.1] |
|
| 52 | 52 | for ($r=0; $r<4; $r++) { |
| 53 | - for ($c=0; $c<$Nb; $c++) $s[$r][$c] = self::$sBox[$s[$r][$c]]; |
|
| 53 | + for ($c=0; $c<$Nb; $c++) $s[$r][$c] = self::$sBox[$s[$r][$c]]; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | return $s; |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - private static function shiftRows($s, $Nb) { // shift row r of state S left by r bytes [é5.1.2] |
|
| 59 | + private static function shiftRows($s, $Nb) { // shift row r of state S left by r bytes [é5.1.2] |
|
| 60 | 60 | $t = array(4); |
| 61 | 61 | for ($r=1; $r<4; $r++) { |
| 62 | - for ($c=0; $c<4; $c++) $t[$c] = $s[$r][($c+$r)%$Nb]; // shift into temp copy |
|
| 63 | - for ($c=0; $c<4; $c++) $s[$r][$c] = $t[$c]; // and copy back |
|
| 62 | + for ($c=0; $c<4; $c++) $t[$c] = $s[$r][($c+$r)%$Nb]; // shift into temp copy |
|
| 63 | + for ($c=0; $c<4; $c++) $s[$r][$c] = $t[$c]; // and copy back |
|
| 64 | 64 | } // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES): |
| 65 | 65 | return $s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - private static function mixColumns($s, $Nb) { // combine bytes of each col of state S [é5.1.3] |
|
| 68 | + private static function mixColumns($s, $Nb) { // combine bytes of each col of state S [é5.1.3] |
|
| 69 | 69 | for ($c=0; $c<4; $c++) { |
| 70 | - $a = array(4); // 'a' is a copy of the current column from 's' |
|
| 71 | - $b = array(4); // 'b' is aé{02} in GF(2^8) |
|
| 72 | - for ($i=0; $i<4; $i++) { |
|
| 70 | + $a = array(4); // 'a' is a copy of the current column from 's' |
|
| 71 | + $b = array(4); // 'b' is aé{02} in GF(2^8) |
|
| 72 | + for ($i=0; $i<4; $i++) { |
|
| 73 | 73 | $a[$i] = $s[$i][$c]; |
| 74 | 74 | $b[$i] = $s[$i][$c]&0x80 ? $s[$i][$c]<<1 ^ 0x011b : $s[$i][$c]<<1; |
| 75 | - } |
|
| 76 | - // a[n] ^ b[n] is aé{03} in GF(2^8) |
|
| 77 | - $s[0][$c] = $b[0] ^ $a[1] ^ $b[1] ^ $a[2] ^ $a[3]; // 2*a0 + 3*a1 + a2 + a3 |
|
| 78 | - $s[1][$c] = $a[0] ^ $b[1] ^ $a[2] ^ $b[2] ^ $a[3]; // a0 * 2*a1 + 3*a2 + a3 |
|
| 79 | - $s[2][$c] = $a[0] ^ $a[1] ^ $b[2] ^ $a[3] ^ $b[3]; // a0 + a1 + 2*a2 + 3*a3 |
|
| 80 | - $s[3][$c] = $a[0] ^ $b[0] ^ $a[1] ^ $a[2] ^ $b[3]; // 3*a0 + a1 + a2 + 2*a3 |
|
| 75 | + } |
|
| 76 | + // a[n] ^ b[n] is aé{03} in GF(2^8) |
|
| 77 | + $s[0][$c] = $b[0] ^ $a[1] ^ $b[1] ^ $a[2] ^ $a[3]; // 2*a0 + 3*a1 + a2 + a3 |
|
| 78 | + $s[1][$c] = $a[0] ^ $b[1] ^ $a[2] ^ $b[2] ^ $a[3]; // a0 * 2*a1 + 3*a2 + a3 |
|
| 79 | + $s[2][$c] = $a[0] ^ $a[1] ^ $b[2] ^ $a[3] ^ $b[3]; // a0 + a1 + 2*a2 + 3*a3 |
|
| 80 | + $s[3][$c] = $a[0] ^ $b[0] ^ $a[1] ^ $a[2] ^ $b[3]; // 3*a0 + a1 + a2 + 2*a3 |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | return $s; |
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Key expansion for Rijndael cipher(): performs key expansion on cipher key |
|
| 88 | - * to generate a key schedule |
|
| 89 | - * |
|
| 90 | - * @param key cipher key byte-array (16 bytes) |
|
| 91 | - * @return key schedule as 2D byte-array (Nr+1 x Nb bytes) |
|
| 92 | - */ |
|
| 93 | - public static function keyExpansion($key) { // generate Key Schedule from Cipher Key [é5.2] |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Key expansion for Rijndael cipher(): performs key expansion on cipher key |
|
| 88 | + * to generate a key schedule |
|
| 89 | + * |
|
| 90 | + * @param key cipher key byte-array (16 bytes) |
|
| 91 | + * @return key schedule as 2D byte-array (Nr+1 x Nb bytes) |
|
| 92 | + */ |
|
| 93 | + public static function keyExpansion($key) { // generate Key Schedule from Cipher Key [é5.2] |
|
| 94 | 94 | $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) |
| 95 | 95 | $Nk = count($key)/4; // key length (in words): 4/6/8 for 128/192/256-bit keys |
| 96 | 96 | $Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys |
@@ -99,41 +99,41 @@ discard block |
||
| 99 | 99 | $temp = array(); |
| 100 | 100 | |
| 101 | 101 | for ($i=0; $i<$Nk; $i++) { |
| 102 | - $r = array($key[4*$i], $key[4*$i+1], $key[4*$i+2], $key[4*$i+3]); |
|
| 103 | - $w[$i] = $r; |
|
| 102 | + $r = array($key[4*$i], $key[4*$i+1], $key[4*$i+2], $key[4*$i+3]); |
|
| 103 | + $w[$i] = $r; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | for ($i=$Nk; $i<($Nb*($Nr+1)); $i++) { |
| 107 | - $w[$i] = array(); |
|
| 108 | - for ($t=0; $t<4; $t++) $temp[$t] = $w[$i-1][$t]; |
|
| 109 | - if ($i % $Nk == 0) { |
|
| 107 | + $w[$i] = array(); |
|
| 108 | + for ($t=0; $t<4; $t++) $temp[$t] = $w[$i-1][$t]; |
|
| 109 | + if ($i % $Nk == 0) { |
|
| 110 | 110 | $temp = self::subWord(self::rotWord($temp)); |
| 111 | 111 | for ($t=0; $t<4; $t++) $temp[$t] ^= self::$rCon[$i/$Nk][$t]; |
| 112 | - } elseif ($Nk > 6 && $i%$Nk == 4) { |
|
| 112 | + } elseif ($Nk > 6 && $i%$Nk == 4) { |
|
| 113 | 113 | $temp = self::subWord($temp); |
| 114 | - } |
|
| 115 | - for ($t=0; $t<4; $t++) $w[$i][$t] = $w[$i-$Nk][$t] ^ $temp[$t]; |
|
| 114 | + } |
|
| 115 | + for ($t=0; $t<4; $t++) $w[$i][$t] = $w[$i-$Nk][$t] ^ $temp[$t]; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | return $w; |
| 119 | - } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - private static function subWord($w) { // apply SBox to 4-byte word w |
|
| 121 | + private static function subWord($w) { // apply SBox to 4-byte word w |
|
| 122 | 122 | for ($i=0; $i<4; $i++) $w[$i] = self::$sBox[$w[$i]]; |
| 123 | 123 | |
| 124 | 124 | return $w; |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - private static function rotWord($w) { // rotate 4-byte word w left by one byte |
|
| 127 | + private static function rotWord($w) { // rotate 4-byte word w left by one byte |
|
| 128 | 128 | $tmp = $w[0]; |
| 129 | 129 | for ($i=0; $i<3; $i++) $w[$i] = $w[$i+1]; |
| 130 | 130 | $w[3] = $tmp; |
| 131 | 131 | |
| 132 | 132 | return $w; |
| 133 | - } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - // sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [é5.1.1] |
|
| 136 | - private static $sBox = array( |
|
| 135 | + // sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [é5.1.1] |
|
| 136 | + private static $sBox = array( |
|
| 137 | 137 | 0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76, |
| 138 | 138 | 0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0, |
| 139 | 139 | 0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15, |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | 0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf, |
| 152 | 152 | 0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16); |
| 153 | 153 | |
| 154 | - // rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [é5.2] |
|
| 155 | - private static $rCon = array( |
|
| 154 | + // rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [é5.2] |
|
| 155 | + private static $rCon = array( |
|
| 156 | 156 | array(0x00, 0x00, 0x00, 0x00), |
| 157 | 157 | array(0x01, 0x00, 0x00, 0x00), |
| 158 | 158 | array(0x02, 0x00, 0x00, 0x00), |
@@ -7,19 +7,19 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class AesCtr extends Aes |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Encrypt a text using AES encryption in Counter mode of operation |
|
| 12 | - * - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf |
|
| 13 | - * |
|
| 14 | - * Unicode multi-byte character safe |
|
| 15 | - * |
|
| 16 | - * @param plaintext source text to be encrypted |
|
| 17 | - * @param password the password to use to generate a key |
|
| 18 | - * @param nBits number of bits to be used in the key (128, 192, or 256) |
|
| 19 | - * @return encrypted text |
|
| 20 | - */ |
|
| 21 | - public static function encrypt($plaintext, $password, $nBits) |
|
| 22 | - { |
|
| 10 | + /** |
|
| 11 | + * Encrypt a text using AES encryption in Counter mode of operation |
|
| 12 | + * - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf |
|
| 13 | + * |
|
| 14 | + * Unicode multi-byte character safe |
|
| 15 | + * |
|
| 16 | + * @param plaintext source text to be encrypted |
|
| 17 | + * @param password the password to use to generate a key |
|
| 18 | + * @param nBits number of bits to be used in the key (128, 192, or 256) |
|
| 19 | + * @return encrypted text |
|
| 20 | + */ |
|
| 21 | + public static function encrypt($plaintext, $password, $nBits) |
|
| 22 | + { |
|
| 23 | 23 | $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES |
| 24 | 24 | if (!($nBits==128 || $nBits==192 || $nBits==256)) return ''; // standard allows 128/192/256 bit keys |
| 25 | 25 | // note PHP (5) gives us plaintext and password in UTF8 encoding! |
@@ -53,22 +53,22 @@ discard block |
||
| 53 | 53 | $ciphertxt = array(); // ciphertext as array of strings |
| 54 | 54 | |
| 55 | 55 | for ($b=0; $b<$blockCount; $b++) { |
| 56 | - // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) |
|
| 57 | - // done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB) |
|
| 58 | - for ($c=0; $c<4; $c++) $counterBlock[15-$c] = self::urs($b, $c*8) & 0xff; |
|
| 59 | - for ($c=0; $c<4; $c++) $counterBlock[15-$c-4] = self::urs($b/0x100000000, $c*8); |
|
| 56 | + // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) |
|
| 57 | + // done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB) |
|
| 58 | + for ($c=0; $c<4; $c++) $counterBlock[15-$c] = self::urs($b, $c*8) & 0xff; |
|
| 59 | + for ($c=0; $c<4; $c++) $counterBlock[15-$c-4] = self::urs($b/0x100000000, $c*8); |
|
| 60 | 60 | |
| 61 | - $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // -- encrypt counter block -- |
|
| 61 | + $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // -- encrypt counter block -- |
|
| 62 | 62 | |
| 63 | - // block size is reduced on final block |
|
| 64 | - $blockLength = $b<$blockCount-1 ? $blockSize : (strlen($plaintext)-1)%$blockSize+1; |
|
| 65 | - $cipherByte = array(); |
|
| 63 | + // block size is reduced on final block |
|
| 64 | + $blockLength = $b<$blockCount-1 ? $blockSize : (strlen($plaintext)-1)%$blockSize+1; |
|
| 65 | + $cipherByte = array(); |
|
| 66 | 66 | |
| 67 | - for ($i=0; $i<$blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte -- |
|
| 67 | + for ($i=0; $i<$blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte -- |
|
| 68 | 68 | $cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b*$blockSize+$i, 1)); |
| 69 | 69 | $cipherByte[$i] = chr($cipherByte[$i]); |
| 70 | - } |
|
| 71 | - $ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext |
|
| 70 | + } |
|
| 71 | + $ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // implode is more efficient than repeated string concatenation |
@@ -76,18 +76,18 @@ discard block |
||
| 76 | 76 | $ciphertext = base64_encode($ciphertext); |
| 77 | 77 | |
| 78 | 78 | return $ciphertext; |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Decrypt a text encrypted by AES in counter mode of operation |
|
| 83 | - * |
|
| 84 | - * @param ciphertext source text to be decrypted |
|
| 85 | - * @param password the password to use to generate a key |
|
| 86 | - * @param nBits number of bits to be used in the key (128, 192, or 256) |
|
| 87 | - * @return decrypted text |
|
| 88 | - */ |
|
| 89 | - public static function decrypt($ciphertext, $password, $nBits) |
|
| 90 | - { |
|
| 81 | + /** |
|
| 82 | + * Decrypt a text encrypted by AES in counter mode of operation |
|
| 83 | + * |
|
| 84 | + * @param ciphertext source text to be decrypted |
|
| 85 | + * @param password the password to use to generate a key |
|
| 86 | + * @param nBits number of bits to be used in the key (128, 192, or 256) |
|
| 87 | + * @return decrypted text |
|
| 88 | + */ |
|
| 89 | + public static function decrypt($ciphertext, $password, $nBits) |
|
| 90 | + { |
|
| 91 | 91 | $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES |
| 92 | 92 | if (!($nBits==128 || $nBits==192 || $nBits==256)) return ''; // standard allows 128/192/256 bit keys |
| 93 | 93 | $ciphertext = base64_decode($ciphertext); |
@@ -117,47 +117,47 @@ discard block |
||
| 117 | 117 | $plaintxt = array(); |
| 118 | 118 | |
| 119 | 119 | for ($b=0; $b<$nBlocks; $b++) { |
| 120 | - // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) |
|
| 121 | - for ($c=0; $c<4; $c++) $counterBlock[15-$c] = self::urs($b, $c*8) & 0xff; |
|
| 122 | - for ($c=0; $c<4; $c++) $counterBlock[15-$c-4] = self::urs(($b+1)/0x100000000-1, $c*8) & 0xff; |
|
| 120 | + // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) |
|
| 121 | + for ($c=0; $c<4; $c++) $counterBlock[15-$c] = self::urs($b, $c*8) & 0xff; |
|
| 122 | + for ($c=0; $c<4; $c++) $counterBlock[15-$c-4] = self::urs(($b+1)/0x100000000-1, $c*8) & 0xff; |
|
| 123 | 123 | |
| 124 | - $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // encrypt counter block |
|
| 124 | + $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // encrypt counter block |
|
| 125 | 125 | |
| 126 | - $plaintxtByte = array(); |
|
| 127 | - for ($i=0; $i<strlen($ciphertext[$b]); $i++) { |
|
| 126 | + $plaintxtByte = array(); |
|
| 127 | + for ($i=0; $i<strlen($ciphertext[$b]); $i++) { |
|
| 128 | 128 | // -- xor plaintext with ciphered counter byte-by-byte -- |
| 129 | 129 | $plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b],$i,1)); |
| 130 | 130 | $plaintxtByte[$i] = chr($plaintxtByte[$i]); |
| 131 | 131 | |
| 132 | - } |
|
| 133 | - $plaintxt[$b] = implode('', $plaintxtByte); |
|
| 132 | + } |
|
| 133 | + $plaintxt[$b] = implode('', $plaintxtByte); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // join array of blocks into single plaintext string |
| 137 | 137 | $plaintext = implode('',$plaintxt); |
| 138 | 138 | |
| 139 | 139 | return $plaintext; |
| 140 | - } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /* |
|
| 142 | + /* |
|
| 143 | 143 | * Unsigned right shift function, since PHP has neither >>> operator nor unsigned ints |
| 144 | 144 | * |
| 145 | 145 | * @param a number to be shifted (32-bit integer) |
| 146 | 146 | * @param b number of bits to shift a to the right (0..31) |
| 147 | 147 | * @return a right-shifted and zero-filled by b bits |
| 148 | 148 | */ |
| 149 | - private static function urs($a, $b) |
|
| 150 | - { |
|
| 149 | + private static function urs($a, $b) |
|
| 150 | + { |
|
| 151 | 151 | $a &= 0xffffffff; $b &= 0x1f; // (bounds check) |
| 152 | 152 | if ($a&0x80000000 && $b>0) { // if left-most bit set |
| 153 | - $a = ($a>>1) & 0x7fffffff; // right-shift one bit & clear left-most bit |
|
| 154 | - $a = $a >> ($b-1); // remaining right-shifts |
|
| 153 | + $a = ($a>>1) & 0x7fffffff; // right-shift one bit & clear left-most bit |
|
| 154 | + $a = $a >> ($b-1); // remaining right-shifts |
|
| 155 | 155 | } else { // otherwise |
| 156 | - $a = ($a>>$b); // use normal right-shift |
|
| 156 | + $a = ($a>>$b); // use normal right-shift |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | return $a; |
| 160 | - } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | 162 | } |
| 163 | 163 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
@@ -423,8 +423,8 @@ discard block |
||
| 423 | 423 | <h3>Step 2</h3> |
| 424 | 424 | <fieldset><legend>DataBase Informations</legend>'; |
| 425 | 425 | |
| 426 | - // check if all database info are available |
|
| 427 | - if ( |
|
| 426 | + // check if all database info are available |
|
| 427 | + if ( |
|
| 428 | 428 | isset($_SESSION['server']) && !empty($_SESSION['server']) |
| 429 | 429 | && isset($_SESSION['database']) && !empty($_SESSION['database']) |
| 430 | 430 | && isset($_SESSION['user']) && !empty($_SESSION['user']) |
@@ -437,15 +437,15 @@ discard block |
||
| 437 | 437 | The database information has been retreived from the settings file.<br> |
| 438 | 438 | If you need to change them, please edit file `/includes/config/settings.php` and relaunch the upgrade process. |
| 439 | 439 | </div>'; |
| 440 | - } else { |
|
| 440 | + } else { |
|
| 441 | 441 | echo ' |
| 442 | 442 | <div style=""> |
| 443 | 443 | The database information has not been retreived from the settings file.<br> |
| 444 | 444 | You need to adapt the file `/includes/config/settings.php` and relaunch the upgrade process. |
| 445 | 445 | </div>'; |
| 446 | - } |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | - echo ' |
|
| 448 | + echo ' |
|
| 449 | 449 | <a href="'.$protocol.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/') - 8).'/install/upgrade.php">Restart upgrade process</a> |
| 450 | 450 | </fieldset> |
| 451 | 451 | |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | </div>'; |
| 476 | 476 | |
| 477 | 477 | // teampass_version = 2.1.27 and no encrypt_key in db |
| 478 | - echo ' |
|
| 478 | + echo ' |
|
| 479 | 479 | <div id="no_encrypt_key" style="display:none;"> |
| 480 | 480 | <fieldset> |
| 481 | 481 | <legend>Database Origine</legend> |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | - * Encrypt a text using AES encryption in Counter mode of operation |
|
| 218 | - * - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf |
|
| 219 | - * |
|
| 220 | - * Unicode multi-byte character safe |
|
| 221 | - * |
|
| 222 | - * @param plaintext source text to be encrypted |
|
| 223 | - * @param password the password to use to generate a key |
|
| 224 | - * @param nBits number of bits to be used in the key (128, 192, or 256) |
|
| 225 | - * @return encrypted text |
|
| 226 | - */ |
|
| 217 | + * Encrypt a text using AES encryption in Counter mode of operation |
|
| 218 | + * - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf |
|
| 219 | + * |
|
| 220 | + * Unicode multi-byte character safe |
|
| 221 | + * |
|
| 222 | + * @param plaintext source text to be encrypted |
|
| 223 | + * @param password the password to use to generate a key |
|
| 224 | + * @param nBits number of bits to be used in the key (128, 192, or 256) |
|
| 225 | + * @return encrypted text |
|
| 226 | + */ |
|
| 227 | 227 | public static function encrypt($plaintext, $password, $nBits) |
| 228 | 228 | { |
| 229 | 229 | $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES |
@@ -298,13 +298,13 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | - * Decrypt a text encrypted by AES in counter mode of operation |
|
| 302 | - * |
|
| 303 | - * @param ciphertext source text to be decrypted |
|
| 304 | - * @param password the password to use to generate a key |
|
| 305 | - * @param nBits number of bits to be used in the key (128, 192, or 256) |
|
| 306 | - * @return decrypted text |
|
| 307 | - */ |
|
| 301 | + * Decrypt a text encrypted by AES in counter mode of operation |
|
| 302 | + * |
|
| 303 | + * @param ciphertext source text to be decrypted |
|
| 304 | + * @param password the password to use to generate a key |
|
| 305 | + * @param nBits number of bits to be used in the key (128, 192, or 256) |
|
| 306 | + * @return decrypted text |
|
| 307 | + */ |
|
| 308 | 308 | public static function decrypt($ciphertext, $password, $nBits) |
| 309 | 309 | { |
| 310 | 310 | $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | //DUTCH |
| 3 | 3 | if (!isset($_SESSION['settings']['cpassman_url'])) { |
| 4 | - $TeamPass_url = ''; |
|
| 4 | + $TeamPass_url = ''; |
|
| 5 | 5 | }else{ |
| 6 | - $TeamPass_url = $_SESSION['settings']['cpassman_url']; |
|
| 6 | + $TeamPass_url = $_SESSION['settings']['cpassman_url']; |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | //CHINESE |
| 3 | 3 | if (!isset($_SESSION['settings']['cpassman_url'])) { |
| 4 | - $TeamPass_url = ''; |
|
| 4 | + $TeamPass_url = ''; |
|
| 5 | 5 | }else{ |
| 6 | - $TeamPass_url = $_SESSION['settings']['cpassman_url']; |
|
| 6 | + $TeamPass_url = $_SESSION['settings']['cpassman_url']; |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | //FRENCH |
| 3 | 3 | if (!isset($_SESSION['settings']['cpassman_url'])) { |
| 4 | - $TeamPass_url = ''; |
|
| 4 | + $TeamPass_url = ''; |
|
| 5 | 5 | }else{ |
| 6 | - $TeamPass_url = $_SESSION['settings']['cpassman_url']; |
|
| 6 | + $TeamPass_url = $_SESSION['settings']['cpassman_url']; |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | |