Completed
Push — development ( 6a24df...5afdf5 )
by Nils
07:52
created
includes/libraries/phpcrypt/ciphers/3Way.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
         $key = array_map("parent::str2Dec", $key);
141 141
 
142 142
         // determine which round constant to use
143
-        if($this->operation() == parent::ENCRYPT)
143
+        if ($this->operation() == parent::ENCRYPT)
144 144
             $rcon = self::$_rcon_enc;
145 145
         else
146 146
             $rcon = self::$_rcon_dec;
147 147
 
148
-        if($this->operation() == parent::DECRYPT)
148
+        if ($this->operation() == parent::DECRYPT)
149 149
         {
150 150
             $this->theta($key);
151 151
             $this->invertBits($key);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         }
154 154
 
155 155
         // 3Way uses 11 rounds
156
-        for($i = 0; $i < self::ROUNDS; ++$i)
156
+        for ($i = 0; $i < self::ROUNDS; ++$i)
157 157
         {
158 158
             $data[0] = parent::uInt32($data[0] ^ $key[0] ^ ($rcon[$i] << 16));
159 159
             $data[1] = parent::uInt32($data[1] ^ $key[1]);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
         $this->theta($data);
170 170
 
171
-        if($this->operation() == parent::DECRYPT)
171
+        if ($this->operation() == parent::DECRYPT)
172 172
             $this->invertBits($data);
173 173
 
174 174
         // assemble the three 32 bit parts back to a 96 bit string
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/Skipjack.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     {
270 270
         $w = str_split($bytes, 2);
271 271
 
272
-        if($this->operation() == parent::ENCRYPT)
272
+        if ($this->operation() == parent::ENCRYPT)
273 273
         {
274 274
             /*
275 275
 			 * Set the new W3 as the old W2
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
         $key = $this->key();
334 334
         $pos = 0;
335 335
 
336
-        for($i = 0; $i < 128; ++$i)
336
+        for ($i = 0; $i < 128; ++$i)
337 337
         {
338
-            if($pos == $key_bytes)
338
+            if ($pos == $key_bytes)
339 339
                 $pos = 0;
340 340
 
341 341
             $this->expanded_key .= $key[$pos];
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/Cipher.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function operation($op = 0)
152 152
     {
153
-        if($op == self::ENCRYPT || $op == self::DECRYPT)
153
+        if ($op == self::ENCRYPT || $op == self::DECRYPT)
154 154
             $this->operation = $op;
155 155
 
156 156
         return $this->operation;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function name($name = "")
166 166
     {
167
-        if($name != "")
167
+        if ($name != "")
168 168
             $this->cipher_name = $name;
169 169
 
170 170
         return $this->cipher_name;
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function blockSize($bytes = 0)
181 181
     {
182
-        if($bytes > 0)
182
+        if ($bytes > 0)
183 183
             $this->block_size = $bytes;
184 184
 
185 185
         // in some cases a blockSize is not set, such as stream ciphers.
186 186
         // so just return 0 for the block size
187
-        if(!isset($this->block_size))
187
+        if (!isset($this->block_size))
188 188
             return 0;
189 189
 
190 190
         return $this->block_size;
@@ -217,27 +217,27 @@  discard block
 block discarded – undo
217 217
      */
218 218
     public function key($key = "", $req_sz = 0)
219 219
     {
220
-        if($key != "" && $key != null)
220
+        if ($key != "" && $key != null)
221 221
         {
222 222
             // in the case where the key is changed changed after
223 223
             // creating a new Cipher object and the $req_sz was not
224 224
             // given, we need to make sure the new key meets the size
225 225
             // requirements. This can be determined from the $this->key_len
226 226
             // member set from the previous key
227
-            if($this->key_len > 0 && $req_sz == 0)
227
+            if ($this->key_len > 0 && $req_sz == 0)
228 228
                 $req_sz = $this->key_len;
229 229
             else
230 230
                 $this->key_len = strlen($key);
231 231
 
232
-            if($req_sz > 0)
232
+            if ($req_sz > 0)
233 233
             {
234
-                if($this->key_len > $req_sz)
234
+                if ($this->key_len > $req_sz)
235 235
                 {
236 236
                     // shorten the key length
237 237
                     $key = substr($key, 0, $req_sz);
238 238
                     $this->key_len = $req_sz;
239 239
                 }
240
-                else if($this->key_len < $req_sz)
240
+                else if ($this->key_len < $req_sz)
241 241
                 {
242 242
                     // send a notice that the key was too small
243 243
                     // NEVER PAD THE KEY, THIS WOULD BE INSECURE!!!!!
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/CFB.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         parent::__construct(PHP_Crypt::MODE_CFB, $cipher);
49 49
 
50 50
         // this works with only block Ciphers
51
-        if($cipher->type() != Cipher::BLOCK)
51
+        if ($cipher->type() != Cipher::BLOCK)
52 52
             trigger_error("CFB mode requires a block cipher", E_USER_WARNING);
53 53
     }
54 54
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function encrypt(&$text)
74 74
     {
75 75
         $max = strlen($text);
76
-        for($i = 0; $i < $max; ++$i)
76
+        for ($i = 0; $i < $max; ++$i)
77 77
         {
78 78
             // copy the register, and then encrypt it
79 79
             $this->enc_register = $this->register;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     public function decrypt(&$text)
101 101
     {
102 102
         $max = strlen($text);
103
-        for($i = 0; $i < $max; ++$i)
103
+        for ($i = 0; $i < $max; ++$i)
104 104
         {
105 105
             $this->enc_register = $this->register;
106 106
             $this->cipher->encrypt($this->enc_register);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/NOFB.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         parent::__construct(PHP_Crypt::MODE_NOFB, $cipher);
50 50
 
51 51
         // this works with only block Ciphers
52
-        if($cipher->type() != Cipher::BLOCK)
52
+        if ($cipher->type() != Cipher::BLOCK)
53 53
             trigger_error("NOFB mode requires a block cipher", E_USER_WARNING);
54 54
     }
55 55
 
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
         $blocksz = $this->cipher->blockSize();
78 78
 
79 79
         $max = $len / $blocksz;
80
-        for($i = 0; $i < $max; ++$i)
80
+        for ($i = 0; $i < $max; ++$i)
81 81
         {
82 82
             // current position in the text
83 83
             $pos = $i * $blocksz;
84 84
 
85 85
             // make sure we don't extend past the length of $text
86 86
             $byte_len = $blocksz;
87
-            if(($pos + $blocksz) > $len)
87
+            if (($pos + $blocksz) > $len)
88 88
                 $byte_len -= ($pos + $blocksz) - $len;
89 89
 
90 90
             // encrypt the register
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
             // now grab a block of text and a block of from the register, and XOR them
95 95
             $block = substr($text, $pos, $byte_len);
96
-            for($j = 0; $j < $byte_len; ++$j)
96
+            for ($j = 0; $j < $byte_len; ++$j)
97 97
                 $block[$j] = $block[$j] ^ $this->enc_register[$j];
98 98
 
99 99
             // replace the plain text block with encrypted text
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
         $blocksz = $this->cipher->blockSize();
121 121
 
122 122
         $max = $len / $blocksz;
123
-        for($i = 0; $i < $max; ++$i)
123
+        for ($i = 0; $i < $max; ++$i)
124 124
         {
125 125
             // current position within $text
126 126
             $pos = $i * $blocksz;
127 127
 
128 128
             // make sure we don't extend past the length of $text
129 129
             $byte_len = $blocksz;
130
-            if(($pos + $byte_len) > $len)
130
+            if (($pos + $byte_len) > $len)
131 131
                 $byte_len -= ($pos + $byte_len) - $len;
132 132
 
133 133
             // encrypt the register
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
             // now grab a block of text and xor with the register
142 142
             $block = substr($text, $pos, $byte_len);
143
-            for($j = 0; $j < $byte_len; ++$j)
143
+            for ($j = 0; $j < $byte_len; ++$j)
144 144
                 $block[$j] = $block[$j] ^ $this->enc_register[$j];
145 145
 
146 146
             // replace the encrypted block with plain text
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/CTR.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         parent::__construct(PHP_CRYPT::MODE_CTR, $cipher);
49 49
 
50 50
         // this works with only block Ciphers
51
-        if($cipher->type() != Cipher::BLOCK)
51
+        if ($cipher->type() != Cipher::BLOCK)
52 52
             trigger_error("CTR mode requires a block cipher", E_USER_WARNING);
53 53
     }
54 54
 
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
         $blocksz = $this->cipher->blockSize();
77 77
 
78 78
         $max = $len / $blocksz;
79
-        for($i = 0; $i < $max; ++$i)
79
+        for ($i = 0; $i < $max; ++$i)
80 80
         {
81 81
             // get the current position in $text
82 82
             $pos = $i * $blocksz;
83 83
 
84 84
             // make sure we don't extend past the length of $text
85 85
             $byte_len = $blocksz;
86
-            if(($pos + $byte_len) > $len)
86
+            if (($pos + $byte_len) > $len)
87 87
                 $byte_len -= ($pos + $byte_len) - $len;
88 88
 
89 89
             // encrypt the register
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
             $block = substr($text, $pos, $byte_len);
95 95
 
96 96
             // xor the block
97
-            for($j = 0; $j < $byte_len; ++$j)
97
+            for ($j = 0; $j < $byte_len; ++$j)
98 98
                 $block[$j] = $block[$j] ^ $this->enc_register[$j];
99 99
 
100 100
             // replace the plain text block with the encrypted block
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
         $blocksz = $this->cipher->blockSize();
121 121
 
122 122
         $max = $len / $blocksz;
123
-        for($i = 0; $i < $max; ++$i)
123
+        for ($i = 0; $i < $max; ++$i)
124 124
         {
125 125
             // get the current position in $text
126 126
             $pos = $i * $blocksz;
127 127
 
128 128
             // make sure we don't extend past the length of $text
129 129
             $byte_len = $blocksz;
130
-            if(($pos + $byte_len) > $len)
130
+            if (($pos + $byte_len) > $len)
131 131
                 $byte_len -= ($pos + $byte_len) - $len;
132 132
 
133 133
             // encrypt the register
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             $block = substr($text, $pos, $byte_len);
139 139
 
140 140
             // xor the block with the register (which contains the IV)
141
-            for($j = 0; $j < $byte_len; ++$j)
141
+            for ($j = 0; $j < $byte_len; ++$j)
142 142
                 $block[$j] = $block[$j] ^ $this->enc_register[$j];
143 143
 
144 144
             // replace the encrypted block with the plain text
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
 
185 185
         // starting at the last byte, loop through each byte until
186 186
         // we find one that can be incremented
187
-        for($i = $pos; $i >= 0; --$i)
187
+        for ($i = $pos; $i >= 0; --$i)
188 188
         {
189 189
             // if we reached the last byte, set it to 0x00, then
190 190
             // loop one more time to increment the next byte
191
-            if(ord($this->register[$i]) == 0xff)
191
+            if (ord($this->register[$i]) == 0xff)
192 192
                 $this->register[$i] = chr(0x00);
193 193
             else
194 194
             {
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/Stream.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
         parent::__construct1(PHP_Crypt::MODE_STREAM, $cipher);
52 52
 
53 53
         // this works with only stream Ciphers
54
-        if($cipher->type() != Cipher::STREAM)
54
+        if ($cipher->type() != Cipher::STREAM)
55 55
             trigger_error("Stream mode requires a stream cipher", E_USER_WARNING);
56 56
     }
57 57
 
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/PCBC.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         parent::__construct(PHP_Crypt::MODE_PCBC, $cipher);
49 49
 
50 50
         // this works with only block Ciphers
51
-        if($cipher->type() != Cipher::BLOCK)
51
+        if ($cipher->type() != Cipher::BLOCK)
52 52
             trigger_error("PCBC mode requires a block cipher", E_USER_WARNING);
53 53
     }
54 54
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $blocksz = $this->cipher->blockSize();
77 77
 
78 78
         $max = strlen($text) / $blocksz;
79
-        for($i = 0; $i < $max; ++$i)
79
+        for ($i = 0; $i < $max; ++$i)
80 80
         {
81 81
             // current position in the text
82 82
             $pos = $i * $blocksz;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             $plain_block = $block;
87 87
 
88 88
             // xor the register with plain text
89
-            for($j = 0; $j < $blocksz; ++$j)
89
+            for ($j = 0; $j < $blocksz; ++$j)
90 90
                 $block[$j] = $this->register[$j] ^ $block[$j];
91 91
 
92 92
             // encrypt the block creating the cipher text
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
             // xor the encrypted block with the plain text block to create
96 96
             // the register in the next round
97
-            for($j = 0; $j < $blocksz; ++$j)
97
+            for ($j = 0; $j < $blocksz; ++$j)
98 98
                 $this->register[$j] = $block[$j] ^ $plain_block[$j];
99 99
 
100 100
             // copy the encrypted block back to $text
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $blocksz = $this->cipher->blockSize();
117 117
 
118 118
         $max = strlen($text) / $blocksz;
119
-        for($i = 0; $i < $max; ++$i)
119
+        for ($i = 0; $i < $max; ++$i)
120 120
         {
121 121
             // current position in the text
122 122
             $pos = $i * $blocksz;
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 
131 131
             // xor the decrypted block with the register, to create
132 132
             // the plain text block
133
-            for($j = 0; $j < $blocksz; ++$j)
133
+            for ($j = 0; $j < $blocksz; ++$j)
134 134
                 $block[$j] = $this->register[$j] ^ $block[$j];
135 135
 
136 136
             // now xor the $enc_block with the unencrypted $block
137
-            for($j = 0; $j < $blocksz; ++$j)
137
+            for ($j = 0; $j < $blocksz; ++$j)
138 138
                 $this->register[$j] = $block[$j] ^ $enc_block[$j];
139 139
 
140 140
             // copy the plain text block back to $text
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/OFB.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         parent::__construct(PHP_Crypt::MODE_OFB, $cipher);
49 49
 
50 50
         // this works with only block Ciphers
51
-        if($cipher->type() != Cipher::BLOCK)
51
+        if ($cipher->type() != Cipher::BLOCK)
52 52
             trigger_error("OFB mode requires a block cipher", E_USER_WARNING);
53 53
     }
54 54
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function encrypt(&$text)
74 74
     {
75 75
         $max = strlen($text);
76
-        for($i = 0; $i < $max; ++$i)
76
+        for ($i = 0; $i < $max; ++$i)
77 77
         {
78 78
             $this->enc_register = $this->register;
79 79
             $this->cipher->encrypt($this->enc_register);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     public function decrypt(&$text)
98 98
     {
99 99
         $max = strlen($text);
100
-        for($i = 0; $i < $max; ++$i)
100
+        for ($i = 0; $i < $max; ++$i)
101 101
         {
102 102
             $this->enc_register = $this->register;
103 103
             $this->cipher->encrypt($this->enc_register);
Please login to merge, or discard this patch.