Completed
Push — development ( dcab98...fd35b5 )
by Nils
07:48
created
includes/libraries/phpcrypt/Padding.php 1 patch
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -67,8 +67,9 @@  discard block
 block discarded – undo
67 67
     {
68 68
         // if the size of padding is not greater than 1
69 69
         // just return true, no padding will be done
70
-        if (!($bytes > 0))
71
-            return true;
70
+        if (!($bytes > 0)) {
71
+                    return true;
72
+        }
72 73
 
73 74
         switch ($type)
74 75
         {
@@ -196,11 +197,11 @@  discard block
 block discarded – undo
196 197
         $pos = strlen($text) - 1;
197 198
         $c = ord($text[$pos]);
198 199
 
199
-        if ($c == 0)
200
-            return true;
201
-        else if ($c == 1)
202
-            $text = substr($text, 0, -1);
203
-        else
200
+        if ($c == 0) {
201
+                    return true;
202
+        } else if ($c == 1) {
203
+                    $text = substr($text, 0, -1);
204
+        } else
204 205
         {
205 206
             // the total null bytes are 1 less than the value of the final byte
206 207
             $nc = $c - 1;
@@ -226,8 +227,9 @@  discard block
 block discarded – undo
226 227
         // create the random pad bytes, we do one less than
227 228
         // needed because the last byte is reserved for the
228 229
         // number of padded bytes
229
-        for ($i = 0; $i < ($bytes - 1); ++$i)
230
-            $text .= chr(mt_rand(0, 255));
230
+        for ($i = 0; $i < ($bytes - 1); ++$i) {
231
+                    $text .= chr(mt_rand(0, 255));
232
+        }
231 233
 
232 234
         // add the byte to indicate the padding length
233 235
         $text .= chr($bytes);
@@ -248,8 +250,9 @@  discard block
 block discarded – undo
248 250
 
249 251
         // if we got a null byte at the end of the string,
250 252
         // just return
251
-        if ($c == 0)
252
-            return true;
253
+        if ($c == 0) {
254
+                    return true;
255
+        }
253 256
 
254 257
         $text = substr($text, 0, $c);
255 258
         return true;
@@ -285,8 +288,9 @@  discard block
 block discarded – undo
285 288
         $pos = strlen($text) - 1;
286 289
         $c = ord($text[$pos]);
287 290
 
288
-        if ($c == 0)
289
-            return true;
291
+        if ($c == 0) {
292
+                    return true;
293
+        }
290 294
 
291 295
         $text = preg_replace('/'.preg_quote(chr($c)).'{'.$c.'}$/', "", $text);
292 296
         return true;
@@ -309,8 +313,9 @@  discard block
 block discarded – undo
309 313
 
310 314
         // if we are only padding one byte, then 0x80 is all we need
311 315
         // else we follow up with null bytes
312
-        if ($bytes > 1)
313
-            $text = str_pad($text, ($len - 1), chr(0), STR_PAD_RIGHT);
316
+        if ($bytes > 1) {
317
+                    $text = str_pad($text, ($len - 1), chr(0), STR_PAD_RIGHT);
318
+        }
314 319
 
315 320
         return true;
316 321
     }
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/Skipjack.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -99,17 +99,21 @@  discard block
 block discarded – undo
99 99
             $pos = (4 * $i) - 4;
100 100
             $subkey = substr($this->expanded_key, $pos, 4);
101 101
 
102
-            if ($i >= 1 && $i <= 8)
103
-                $this->ruleA($text, $subkey, $i);
102
+            if ($i >= 1 && $i <= 8) {
103
+                            $this->ruleA($text, $subkey, $i);
104
+            }
104 105
 
105
-            if ($i >= 9 && $i <= 16)
106
-                $this->ruleB($text, $subkey, $i);
106
+            if ($i >= 9 && $i <= 16) {
107
+                            $this->ruleB($text, $subkey, $i);
108
+            }
107 109
 
108
-            if ($i >= 17 && $i <= 24)
109
-                $this->ruleA($text, $subkey, $i);
110
+            if ($i >= 17 && $i <= 24) {
111
+                            $this->ruleA($text, $subkey, $i);
112
+            }
110 113
 
111
-            if ($i >= 25 && $i <= 32)
112
-                $this->ruleB($text, $subkey, $i);
114
+            if ($i >= 25 && $i <= 32) {
115
+                            $this->ruleB($text, $subkey, $i);
116
+            }
113 117
         }
114 118
 
115 119
         return true;
@@ -130,17 +134,21 @@  discard block
 block discarded – undo
130 134
             $pos = ($i - 1) * 4;
131 135
             $subkey = substr($this->expanded_key, $pos, 4);
132 136
 
133
-            if ($i <= 32 && $i >= 25)
134
-                $this->ruleB($text, $subkey, $i);
137
+            if ($i <= 32 && $i >= 25) {
138
+                            $this->ruleB($text, $subkey, $i);
139
+            }
135 140
 
136
-            if ($i <= 24 && $i >= 17)
137
-                $this->ruleA($text, $subkey, $i);
141
+            if ($i <= 24 && $i >= 17) {
142
+                            $this->ruleA($text, $subkey, $i);
143
+            }
138 144
 
139
-            if ($i <= 16 && $i >= 9)
140
-                $this->ruleB($text, $subkey, $i);
145
+            if ($i <= 16 && $i >= 9) {
146
+                            $this->ruleB($text, $subkey, $i);
147
+            }
141 148
 
142
-            if ($i <= 8 && $i >= 1)
143
-                $this->ruleA($text, $subkey, $i);
149
+            if ($i <= 8 && $i >= 1) {
150
+                            $this->ruleA($text, $subkey, $i);
151
+            }
144 152
         }
145 153
 
146 154
         return true;
@@ -334,8 +342,9 @@  discard block
 block discarded – undo
334 342
 
335 343
         for ($i = 0; $i < 128; ++$i)
336 344
         {
337
-            if ($pos == $key_bytes)
338
-                $pos = 0;
345
+            if ($pos == $key_bytes) {
346
+                            $pos = 0;
347
+            }
339 348
 
340 349
             $this->expanded_key .= $key[$pos];
341 350
             ++$pos;
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/3DES.php 1 patch
Braces   +22 added lines, -13 removed lines patch added patch discarded remove patch
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
     {
62 62
         $key_len = strlen($key);
63 63
 
64
-        if ($key_len == 8 || $key_len == 16)
65
-            $key = self::expandKey($key, $key_len);
66
-        else if ($key_len < self::BYTES_KEY)
64
+        if ($key_len == 8 || $key_len == 16) {
65
+                    $key = self::expandKey($key, $key_len);
66
+        } else if ($key_len < self::BYTES_KEY)
67 67
         {
68 68
             $msg  = PHP_Crypt::CIPHER_3DES." requires an 8, 16, or 24 byte key. ";
69 69
             $msg .= "$key_len bytes received.";
@@ -109,10 +109,13 @@  discard block
 block discarded – undo
109 109
             $key = substr($this->key(), ($i * 8), $blocksz);
110 110
             $this->keyPermutation($key);
111 111
 
112
-            if ($i % 2) // round 1
112
+            if ($i % 2) {
113
+                // round 1
113 114
                 $this->operation(parent::DECRYPT);
114
-            else // rounds 0 and 2
115
+            } else {
116
+                // rounds 0 and 2
115 117
                 $this->operation(parent::ENCRYPT);
118
+            }
116 119
 
117 120
             $this->des($text);
118 121
         }
@@ -138,10 +141,13 @@  discard block
 block discarded – undo
138 141
             $key = substr($this->key(), ($i * 8), $blocksz);
139 142
             $this->keyPermutation($key);
140 143
 
141
-            if ($i % 2) // round 1
144
+            if ($i % 2) {
145
+                // round 1
142 146
                 $this->operation(parent::ENCRYPT);
143
-            else // round 0 and 2
147
+            } else {
148
+                // round 0 and 2
144 149
                 $this->operation(parent::DECRYPT);
150
+            }
145 151
 
146 152
             $this->des($text);
147 153
         }
@@ -210,8 +216,9 @@  discard block
 block discarded – undo
210 216
             // of these.
211 217
             $CnDn = array_merge($c[$i], $d[$i]);
212 218
             $this->sub_keys[$i - 1] = "";
213
-            for ($j = 0; $j < 48; ++$j)
214
-                $this->sub_keys[$i - 1] .= $CnDn[parent::$_pc2[$j] - 1];
219
+            for ($j = 0; $j < 48; ++$j) {
220
+                            $this->sub_keys[$i - 1] .= $CnDn[parent::$_pc2[$j] - 1];
221
+            }
215 222
         }
216 223
 
217 224
         // the sub_keys are created, we are done with the key permutation
@@ -235,13 +242,15 @@  discard block
 block discarded – undo
235 242
     {
236 243
         // if we were given an 8 byte key, repeat it
237 244
         // 3 times to produce a 24 byte key
238
-        if ($len == 8)
239
-            $key = str_repeat($key, 3);
245
+        if ($len == 8) {
246
+                    $key = str_repeat($key, 3);
247
+        }
240 248
 
241 249
         // if we were given a 16 byte key, add the first
242 250
         // 8 bytes to the end of the key to produce 24 bytes
243
-        if ($len == 16)
244
-            $key .= substr($key, 0, 8);
251
+        if ($len == 16) {
252
+                    $key .= substr($key, 0, 8);
253
+        }
245 254
 
246 255
         // return the key
247 256
         return $key;
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/Blowfish.php 1 patch
Braces   +13 added lines, -16 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
         {
80 80
             $key = substr($key, 0, 56);
81 81
             $keylen = 56;
82
-        }
83
-        else if ($keylen < 1)
82
+        } else if ($keylen < 1)
84 83
         {
85 84
             $msg = "No key given. The key must be between 1 - 56 bytes.";
86 85
             trigger_error($msg, E_USER_WARNING);
@@ -148,10 +147,11 @@  discard block
 block discarded – undo
148 147
 
149 148
         for ($i = 0; $i < 16; ++$i)
150 149
         {
151
-            if ($this->operation() == parent::ENCRYPT)
152
-                $xl ^= self::$_p[$i];
153
-            else
154
-                $xl ^= self::$_p[17 - $i];
150
+            if ($this->operation() == parent::ENCRYPT) {
151
+                            $xl ^= self::$_p[$i];
152
+            } else {
153
+                            $xl ^= self::$_p[17 - $i];
154
+            }
155 155
 
156 156
             // perform F() on the left half, and XOR with the right half
157 157
             $xr = $this->F($xl) ^ $xr;
@@ -242,23 +242,19 @@  discard block
 block discarded – undo
242 242
             {
243 243
                 self::$_p[$i] = $z0;
244 244
                 self::$_p[$i + 1] = $z1;
245
-            }
246
-            else if ($i >= 18 && $i < 274)
245
+            } else if ($i >= 18 && $i < 274)
247 246
             {
248 247
                 self::$_sbox1[$i - 18] = $z0;
249 248
                 self::$_sbox1[$i - 18 + 1] = $z1;
250
-            }
251
-            else if ($i >= 274 && $i < 530)
249
+            } else if ($i >= 274 && $i < 530)
252 250
             {
253 251
                 self::$_sbox2[$i - 274] = $z0;
254 252
                 self::$_sbox2[$i - 274 + 1] = $z1;
255
-            }
256
-            else if ($i >= 530 && $i < 786)
253
+            } else if ($i >= 530 && $i < 786)
257 254
             {
258 255
                 self::$_sbox3[$i - 530] = $z0;
259 256
                 self::$_sbox3[$i - 530 + 1] = $z1;
260
-            }
261
-            else if ($i >= 786 && $i < 1042)
257
+            } else if ($i >= 786 && $i < 1042)
262 258
             {
263 259
                 self::$_sbox4[$i - 786] = $z0;
264 260
                 self::$_sbox4[$i - 786 + 1] = $z1;
@@ -283,8 +279,9 @@  discard block
 block discarded – undo
283 279
      */
284 280
     private function keyChunk($size = 1, $reset = false)
285 281
     {
286
-        if ($reset || $this->key_pos >= $this->keySize())
287
-            $this->key_pos = 0;
282
+        if ($reset || $this->key_pos >= $this->keySize()) {
283
+                    $this->key_pos = 0;
284
+        }
288 285
 
289 286
         $bytes = substr($this->key(), $this->key_pos, $size);
290 287
         $len = strlen($bytes);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/Enigma.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -158,8 +158,9 @@  discard block
 block discarded – undo
158 158
                 $this->n1 = 0;
159 159
                 $this->n2++;
160 160
 
161
-                if ($this->n2 == self::ROTORSZ)
162
-                    $this->n2 = 0;
161
+                if ($this->n2 == self::ROTORSZ) {
162
+                                    $this->n2 = 0;
163
+                }
163 164
 
164 165
                 $this->nr2 = $this->n2;
165 166
             }
@@ -189,12 +190,14 @@  discard block
 block discarded – undo
189 190
         $klen = $this->keySize();
190 191
 
191 192
         // get the key to exactly 13 bytes if it's less than 13
192
-        if ($klen < 13)
193
-            $this->xkey = str_pad($this->xkey, 13, chr(0), STR_PAD_RIGHT);
193
+        if ($klen < 13) {
194
+                    $this->xkey = str_pad($this->xkey, 13, chr(0), STR_PAD_RIGHT);
195
+        }
194 196
 
195 197
         $seed = 123;
196
-        for ($i = 0; $i < 13; ++$i)
197
-            $seed = parent::sInt32($seed) * ord($this->xkey[$i]) + $i;
198
+        for ($i = 0; $i < 13; ++$i) {
199
+                    $seed = parent::sInt32($seed) * ord($this->xkey[$i]) + $i;
200
+        }
198 201
 
199 202
         // sets $t1 and $deck
200 203
         for ($i = 0; $i < self::ROTORSZ; ++$i)
@@ -223,12 +226,14 @@  discard block
 block discarded – undo
223 226
             $temp = $this->t1[$k];
224 227
             $this->t1[$k] = $this->t1[$ic];
225 228
             $this->t1[$ic] = $temp;
226
-            if ($this->t3[$k] != 0)
227
-                continue;
229
+            if ($this->t3[$k] != 0) {
230
+                            continue;
231
+            }
228 232
 
229 233
             $ic = ($random & self::MASK) % $k;
230
-            while ($this->t3[$ic] != 0)
231
-                $ic = ($ic + 1) % $k;
234
+            while ($this->t3[$ic] != 0) {
235
+                            $ic = ($ic + 1) % $k;
236
+            }
232 237
 
233 238
             $this->t3[$k] = $ic;
234 239
             $this->t3[$ic] = $k;
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/RC2.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -276,8 +276,9 @@  discard block
 block discarded – undo
276 276
         $len = $this->keySize();
277 277
 
278 278
         // the max length of the key is 128 bytes
279
-        if ($len > 128)
280
-            $this->xkey = substr($this->xkey, 0, 128);
279
+        if ($len > 128) {
280
+                    $this->xkey = substr($this->xkey, 0, 128);
281
+        }
281 282
 
282 283
         // now expanded the rest of the key to 128 bytes, using the sbox
283 284
         for ($i = $len; $i < 128; ++$i)
@@ -288,8 +289,9 @@  discard block
 block discarded – undo
288 289
 
289 290
             // the sbox is only 255 bytes, so if we extend past that
290 291
             // we need to modulo 256 so we have a valid position
291
-            if ($pos > 255)
292
-                $pos -= 256;
292
+            if ($pos > 255) {
293
+                            $pos -= 256;
294
+            }
293 295
 
294 296
             $this->xkey .= chr(self::$_sbox[$pos]);
295 297
         }
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/CAST128.php 1 patch
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -92,8 +92,7 @@  discard block
 block discarded – undo
92 92
         {
93 93
             $key = substr($key, 0, self::BYTES_KEY_MAX);
94 94
             $keylen = self::BYTES_KEY_MAX;
95
-        }
96
-        else if ($keylen < self::BYTES_KEY_MIN)
95
+        } else if ($keylen < self::BYTES_KEY_MIN)
97 96
         {
98 97
             $msg  = PHP_Crypt::CIPHER_CAST_128." requires a key size between ";
99 98
             $msg .= "5 - 16 bytes.";
@@ -341,8 +340,9 @@  discard block
 block discarded – undo
341 340
 
342 341
         // the max length of the key is 16 bytes, however if it is
343 342
         // less, pad it with null to get ito to 16 bytes
344
-        if ($this->keySize() < self::BYTES_KEY_MAX)
345
-            $x = str_pad($x, self::BYTES_KEY_MAX, "\0", STR_PAD_RIGHT);
343
+        if ($this->keySize() < self::BYTES_KEY_MAX) {
344
+                    $x = str_pad($x, self::BYTES_KEY_MAX, "\0", STR_PAD_RIGHT);
345
+        }
346 346
 
347 347
         /*
348 348
 		 * NOW FOR THE UGLY PART, THIS IS TAKEN FROM PAGE 3-4 OF
@@ -639,8 +639,9 @@  discard block
 block discarded – undo
639 639
 
640 640
         // there is 4kb in the s5 - s8 sboxes, which are not needed after we
641 641
         // create the subkeys, so free up the memory. unset() doesn't work here
642
-        for ($i = 5; $i <= 8; ++$i)
643
-            self::${"_s$i"} = null;
642
+        for ($i = 5; $i <= 8; ++$i) {
643
+                    self::${"_s$i"} = null;
644
+        }
644 645
     }
645 646
 
646 647
 
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/Rijndael.php 1 patch
Braces   +103 added lines, -77 removed lines patch added patch discarded remove patch
@@ -188,12 +188,13 @@  discard block
 block discarded – undo
188 188
         // if the key and block size is 16, do 10 rounds
189 189
         // if the key or block size is 24, and neither is longer than 24, do 12 rounds
190 190
         // if either key or block size is 32, do 14 rounds
191
-        if ($key_sz == 16 && $blk_sz == 16)
192
-            $loops = 10;
193
-        else if (($key_sz == 24 || $blk_sz == 24) && $key_sz <= 24 && $blk_sz <= 24)
194
-            $loops = 12;
195
-        else if ($key_sz == 32 || $blk_sz == 32)
196
-            $loops = 14;
191
+        if ($key_sz == 16 && $blk_sz == 16) {
192
+                    $loops = 10;
193
+        } else if (($key_sz == 24 || $blk_sz == 24) && $key_sz <= 24 && $blk_sz <= 24) {
194
+                    $loops = 12;
195
+        } else if ($key_sz == 32 || $blk_sz == 32) {
196
+                    $loops = 14;
197
+        }
197 198
 
198 199
         // now begin the encryption
199 200
         $this->addRoundKey($text, 0);
@@ -204,8 +205,9 @@  discard block
 block discarded – undo
204 205
             $this->shiftRow($text);
205 206
 
206 207
             // the last iteration does not use mixColumn
207
-            if ($i < $loops)
208
-                $this->mixColumn($text);
208
+            if ($i < $loops) {
209
+                            $this->mixColumn($text);
210
+            }
209 211
 
210 212
             $this->addRoundKey($text, $i);
211 213
         }
@@ -232,12 +234,13 @@  discard block
 block discarded – undo
232 234
         // if the key and block size is 16, do 10 rounds
233 235
         // if the key or block size is 24, and neither is longer than 24, do 12 rounds
234 236
         // if either key or block size is 32, do 14 rounds
235
-        if ($key_sz == 16 && $blk_sz == 16)
236
-            $loops = 10;
237
-        else if (($key_sz == 24 || $blk_sz == 24) && $key_sz <= 24 && $blk_sz <= 24)
238
-            $loops = 12;
239
-        else if ($key_sz == 32 || $blk_sz == 32)
240
-            $loops = 14;
237
+        if ($key_sz == 16 && $blk_sz == 16) {
238
+                    $loops = 10;
239
+        } else if (($key_sz == 24 || $blk_sz == 24) && $key_sz <= 24 && $blk_sz <= 24) {
240
+                    $loops = 12;
241
+        } else if ($key_sz == 32 || $blk_sz == 32) {
242
+                    $loops = 14;
243
+        }
241 244
 
242 245
         // now begin the decryption
243 246
         $this->addRoundKey($text, 0);
@@ -249,8 +252,9 @@  discard block
 block discarded – undo
249 252
             $this->addRoundKey($text, $i);
250 253
 
251 254
             // the last iteration does not use mixColumn
252
-            if ($i < $loops)
253
-                $this->mixColumn($text);
255
+            if ($i < $loops) {
256
+                            $this->mixColumn($text);
257
+            }
254 258
         }
255 259
 
256 260
         return true;
@@ -280,8 +284,9 @@  discard block
 block discarded – undo
280 284
     protected function mixColumnMultiply($m, $byte)
281 285
     {
282 286
         // if multiplying by 1, then we just return the same number
283
-        if ($m == 0x01)
284
-            return $byte;
287
+        if ($m == 0x01) {
288
+                    return $byte;
289
+        }
285 290
 
286 291
         $hex = parent::dec2Hex($byte);
287 292
         $row = parent::hex2Dec($hex[0]);
@@ -289,28 +294,34 @@  discard block
 block discarded – undo
289 294
         $pos = ($row * 16) + $col;
290 295
 
291 296
         // multiply by 2 (comes from self::$_matrix_mult during encryption)
292
-        if ($m == 0x02)
293
-            return self::$_gm2[$pos];
297
+        if ($m == 0x02) {
298
+                    return self::$_gm2[$pos];
299
+        }
294 300
 
295 301
         // multiply by 3 (comes from self::$_matrix_mult during encryption)
296
-        if ($m == 0x03)
297
-            return self::$_gm3[$pos];
302
+        if ($m == 0x03) {
303
+                    return self::$_gm3[$pos];
304
+        }
298 305
 
299 306
         // multiply by 9 (comes from self::$_matrix_mult_inv during decryption)
300
-        if ($m == 0x09)
301
-            return self::$_gm9[$pos];
307
+        if ($m == 0x09) {
308
+                    return self::$_gm9[$pos];
309
+        }
302 310
 
303 311
         // multiply by 11 (comes from self::$_matrix_mult_inv during decryption)
304
-        if ($m == 0x0b)
305
-            return self::$_gm11[$pos];
312
+        if ($m == 0x0b) {
313
+                    return self::$_gm11[$pos];
314
+        }
306 315
 
307 316
         // multiply by 13 (comes from self::$_matrix_mult_inv during decryption)
308
-        if ($m == 0x0d)
309
-            return self::$_gm13[$pos];
317
+        if ($m == 0x0d) {
318
+                    return self::$_gm13[$pos];
319
+        }
310 320
 
311 321
         // multiply by 14 (comes from self::$_matrix_mult_inv during decryption)
312
-        if ($m == 0x0e)
313
-            return self::$_gm14[$pos];
322
+        if ($m == 0x0e) {
323
+                    return self::$_gm14[$pos];
324
+        }
314 325
     }
315 326
 
316 327
 
@@ -331,13 +342,15 @@  discard block
 block discarded – undo
331 342
         $ek_len = strlen($this->xkey);
332 343
         $len = $this->blockSize();
333 344
 
334
-        if ($this->operation() == parent::ENCRYPT)
335
-            $offset = $round * $len;
336
-        else
337
-            $offset = ($ek_len - ($round * $len)) - $len;
345
+        if ($this->operation() == parent::ENCRYPT) {
346
+                    $offset = $round * $len;
347
+        } else {
348
+                    $offset = ($ek_len - ($round * $len)) - $len;
349
+        }
338 350
 
339
-        for ($i = 0; $i < $len; ++$i)
340
-            $text[$i] = $text[$i] ^ $this->xkey[$offset + $i];
351
+        for ($i = 0; $i < $len; ++$i) {
352
+                    $text[$i] = $text[$i] ^ $this->xkey[$offset + $i];
353
+        }
341 354
     }
342 355
 
343 356
 
@@ -361,10 +374,12 @@  discard block
 block discarded – undo
361 374
             $pos = ($row * 16) + $col;
362 375
 
363 376
             // return the corresponding value from the sbox
364
-            if ($this->operation() == parent::ENCRYPT)
365
-                $text[$i] = chr(self::$_s[$pos]);
366
-            else // parent::DECRYPT uses the inverse sbox
377
+            if ($this->operation() == parent::ENCRYPT) {
378
+                            $text[$i] = chr(self::$_s[$pos]);
379
+            } else {
380
+                // parent::DECRYPT uses the inverse sbox
367 381
                 $text[$i] = chr(self::$_s_inv[$pos]);
382
+            }
368 383
         }
369 384
     }
370 385
 
@@ -381,10 +396,12 @@  discard block
 block discarded – undo
381 396
         $tmp = $t;
382 397
 
383 398
         // the matrix we use depends on if we are encrypting or decrypting
384
-        if ($this->operation() == parent::ENCRYPT)
385
-            $m = self::$_matrix_mult;
386
-        else // parent::DECRYPT
399
+        if ($this->operation() == parent::ENCRYPT) {
400
+                    $m = self::$_matrix_mult;
401
+        } else {
402
+            // parent::DECRYPT
387 403
             $m = self::$_matrix_mult_inv;
404
+        }
388 405
 
389 406
         // the number of rounds we make depends on the block size of the text
390 407
         // used during encryption/decryption
@@ -619,12 +636,13 @@  discard block
 block discarded – undo
619 636
      */
620 637
     protected function expandKey()
621 638
     {
622
-        if ($this->keySize() == 16)
623
-            return $this->expandKey128();
624
-        else if ($this->keySize() == 24)
625
-            return $this->expandKey192();
626
-        else if ($this->keySize() == 32)
627
-            return $this->expandKey256();
639
+        if ($this->keySize() == 16) {
640
+                    return $this->expandKey128();
641
+        } else if ($this->keySize() == 24) {
642
+                    return $this->expandKey192();
643
+        } else if ($this->keySize() == 32) {
644
+                    return $this->expandKey256();
645
+        }
628 646
     }
629 647
 
630 648
 
@@ -642,19 +660,22 @@  discard block
 block discarded – undo
642 660
 
643 661
         // the number of rounds we make depends on the block size of the text
644 662
         // used during encryption/decryption
645
-        if ($this->blockSize() == 16)
646
-            $max = 44;
647
-        if ($this->blockSize() == 24)
648
-            $max = 78;
649
-        if ($this->blockSize() == 32)
650
-            $max = 120;
663
+        if ($this->blockSize() == 16) {
664
+                    $max = 44;
665
+        }
666
+        if ($this->blockSize() == 24) {
667
+                    $max = 78;
668
+        }
669
+        if ($this->blockSize() == 32) {
670
+                    $max = 120;
671
+        }
651 672
 
652 673
         // 16 byte key expands to 176 bytes
653 674
         for ($i = 0; $i < $max; ++$i)
654 675
         {
655
-            if ($i >= 0 && $i <= 3)
656
-                $this->xkey .= $this->k($i * 4);
657
-            else if (($i % 4) == 0)
676
+            if ($i >= 0 && $i <= 3) {
677
+                            $this->xkey .= $this->k($i * 4);
678
+            } else if (($i % 4) == 0)
658 679
             {
659 680
                 // rotate the 4 bytes
660 681
                 $subword = $this->rotWord($this->ek(($i - 1) * 4));
@@ -701,19 +722,22 @@  discard block
 block discarded – undo
701 722
 
702 723
         // the number of rounds we make depends on the block size of the text
703 724
         // used during encryption/decryption
704
-        if ($this->blockSize() == 16)
705
-            $max = 52;
706
-        if ($this->blockSize() == 24)
707
-            $max = 78;
708
-        if ($this->blockSize() == 32)
709
-            $max = 120;
725
+        if ($this->blockSize() == 16) {
726
+                    $max = 52;
727
+        }
728
+        if ($this->blockSize() == 24) {
729
+                    $max = 78;
730
+        }
731
+        if ($this->blockSize() == 32) {
732
+                    $max = 120;
733
+        }
710 734
 
711 735
         // 24 byte key expands to 208 bytes
712 736
         for ($i = 0; $i < $max; ++$i)
713 737
         {
714
-            if ($i >= 0 && $i <= 5)
715
-                $this->xkey .= $this->k($i * 4);
716
-            else if (($i % 6) == 0)
738
+            if ($i >= 0 && $i <= 5) {
739
+                            $this->xkey .= $this->k($i * 4);
740
+            } else if (($i % 6) == 0)
717 741
             {
718 742
                 // rotate the 4 bytes
719 743
                 $subword = $this->rotWord($this->ek(($i - 1) * 4));
@@ -760,19 +784,22 @@  discard block
 block discarded – undo
760 784
 
761 785
         // the number of rounds we make depends on the block size of the text
762 786
         // used during encryption/decryption
763
-        if ($this->blockSize() == 16)
764
-            $max = 60;
765
-        if ($this->blockSize() == 24)
766
-            $max = 90;
767
-        if ($this->blockSize() == 32)
768
-            $max = 120;
787
+        if ($this->blockSize() == 16) {
788
+                    $max = 60;
789
+        }
790
+        if ($this->blockSize() == 24) {
791
+                    $max = 90;
792
+        }
793
+        if ($this->blockSize() == 32) {
794
+                    $max = 120;
795
+        }
769 796
 
770 797
         // 32 byte key expands to 240 bytes
771 798
         for ($i = 0; $i < $max; ++$i)
772 799
         {
773
-            if ($i >= 0 && $i <= 7)
774
-                $this->xkey .= $this->k($i * 4);
775
-            else if ($i % 8 == 0)
800
+            if ($i >= 0 && $i <= 7) {
801
+                            $this->xkey .= $this->k($i * 4);
802
+            } else if ($i % 8 == 0)
776 803
             {
777 804
                 // rotate the 4 bytes
778 805
                 $subword = $this->rotWord($this->ek(($i - 1) * 4));
@@ -791,8 +818,7 @@  discard block
 block discarded – undo
791 818
                 $h3 = parent::str2Hex($ek);
792 819
                 $res = parent::xorHex($h1, $h2, $h3);
793 820
                 $this->xkey .= parent::hex2Str($res);
794
-            }
795
-            else if ($i % 4 == 0)
821
+            } else if ($i % 4 == 0)
796 822
             {
797 823
                 // get the subsitution from the s-box
798 824
                 $subword = $this->ek(($i - 1) * 4);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/ciphers/SimpleXOR.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,8 +121,9 @@
 block discarded – undo
121 121
         {
122 122
             // if the current position in the key reaches the end of the key,
123 123
             // start over at position 0 of the key
124
-            if ($pos >= $this->keySize())
125
-                $pos = 0;
124
+            if ($pos >= $this->keySize()) {
125
+                            $pos = 0;
126
+            }
126 127
 
127 128
             $text[$i] = $text[$i] ^ $key[$pos];
128 129
             ++$pos;
Please login to merge, or discard this patch.