Completed
Push — development ( 6a24df...5afdf5 )
by Nils
07:52
created
includes/libraries/phpcrypt/modes/NOFB.php 2 patches
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.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -49,8 +49,9 @@  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)
53
-            trigger_error("NOFB mode requires a block cipher", E_USER_WARNING);
52
+        if($cipher->type() != Cipher::BLOCK) {
53
+                    trigger_error("NOFB mode requires a block cipher", E_USER_WARNING);
54
+        }
54 55
     }
55 56
 
56 57
 
@@ -84,8 +85,9 @@  discard block
 block discarded – undo
84 85
 
85 86
             // make sure we don't extend past the length of $text
86 87
             $byte_len = $blocksz;
87
-            if(($pos + $blocksz) > $len)
88
-                $byte_len -= ($pos + $blocksz) - $len;
88
+            if(($pos + $blocksz) > $len) {
89
+                            $byte_len -= ($pos + $blocksz) - $len;
90
+            }
89 91
 
90 92
             // encrypt the register
91 93
             $this->enc_register = $this->register;
@@ -93,8 +95,9 @@  discard block
 block discarded – undo
93 95
 
94 96
             // now grab a block of text and a block of from the register, and XOR them
95 97
             $block = substr($text, $pos, $byte_len);
96
-            for($j = 0; $j < $byte_len; ++$j)
97
-                $block[$j] = $block[$j] ^ $this->enc_register[$j];
98
+            for($j = 0; $j < $byte_len; ++$j) {
99
+                            $block[$j] = $block[$j] ^ $this->enc_register[$j];
100
+            }
98 101
 
99 102
             // replace the plain text block with encrypted text
100 103
             $text = substr_replace($text, $block, $pos, $byte_len);
@@ -127,8 +130,9 @@  discard block
 block discarded – undo
127 130
 
128 131
             // make sure we don't extend past the length of $text
129 132
             $byte_len = $blocksz;
130
-            if(($pos + $byte_len) > $len)
131
-                $byte_len -= ($pos + $byte_len) - $len;
133
+            if(($pos + $byte_len) > $len) {
134
+                            $byte_len -= ($pos + $byte_len) - $len;
135
+            }
132 136
 
133 137
             // encrypt the register
134 138
             $this->enc_register = $this->register;
@@ -140,8 +144,9 @@  discard block
 block discarded – undo
140 144
 
141 145
             // now grab a block of text and xor with the register
142 146
             $block = substr($text, $pos, $byte_len);
143
-            for($j = 0; $j < $byte_len; ++$j)
144
-                $block[$j] = $block[$j] ^ $this->enc_register[$j];
147
+            for($j = 0; $j < $byte_len; ++$j) {
148
+                            $block[$j] = $block[$j] ^ $this->enc_register[$j];
149
+            }
145 150
 
146 151
             // replace the encrypted block with plain text
147 152
             $text = substr_replace($text, $block, $pos, $byte_len);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/CTR.php 2 patches
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.
Braces   +18 added lines, -13 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  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)
52
-            trigger_error("CTR mode requires a block cipher", E_USER_WARNING);
51
+        if($cipher->type() != Cipher::BLOCK) {
52
+                    trigger_error("CTR mode requires a block cipher", E_USER_WARNING);
53
+        }
53 54
     }
54 55
 
55 56
 
@@ -83,8 +84,9 @@  discard block
 block discarded – undo
83 84
 
84 85
             // make sure we don't extend past the length of $text
85 86
             $byte_len = $blocksz;
86
-            if(($pos + $byte_len) > $len)
87
-                $byte_len -= ($pos + $byte_len) - $len;
87
+            if(($pos + $byte_len) > $len) {
88
+                            $byte_len -= ($pos + $byte_len) - $len;
89
+            }
88 90
 
89 91
             // encrypt the register
90 92
             $this->enc_register = $this->register;
@@ -94,8 +96,9 @@  discard block
 block discarded – undo
94 96
             $block = substr($text, $pos, $byte_len);
95 97
 
96 98
             // xor the block
97
-            for($j = 0; $j < $byte_len; ++$j)
98
-                $block[$j] = $block[$j] ^ $this->enc_register[$j];
99
+            for($j = 0; $j < $byte_len; ++$j) {
100
+                            $block[$j] = $block[$j] ^ $this->enc_register[$j];
101
+            }
99 102
 
100 103
             // replace the plain text block with the encrypted block
101 104
             $text = substr_replace($text, $block, $pos, $byte_len);
@@ -127,8 +130,9 @@  discard block
 block discarded – undo
127 130
 
128 131
             // make sure we don't extend past the length of $text
129 132
             $byte_len = $blocksz;
130
-            if(($pos + $byte_len) > $len)
131
-                $byte_len -= ($pos + $byte_len) - $len;
133
+            if(($pos + $byte_len) > $len) {
134
+                            $byte_len -= ($pos + $byte_len) - $len;
135
+            }
132 136
 
133 137
             // encrypt the register
134 138
             $this->enc_register = $this->register;
@@ -138,8 +142,9 @@  discard block
 block discarded – undo
138 142
             $block = substr($text, $pos, $byte_len);
139 143
 
140 144
             // xor the block with the register (which contains the IV)
141
-            for($j = 0; $j < $byte_len; ++$j)
142
-                $block[$j] = $block[$j] ^ $this->enc_register[$j];
145
+            for($j = 0; $j < $byte_len; ++$j) {
146
+                            $block[$j] = $block[$j] ^ $this->enc_register[$j];
147
+            }
143 148
 
144 149
             // replace the encrypted block with the plain text
145 150
             $text = substr_replace($text, $block, $pos, $byte_len);
@@ -188,9 +193,9 @@  discard block
 block discarded – undo
188 193
         {
189 194
             // if we reached the last byte, set it to 0x00, then
190 195
             // loop one more time to increment the next byte
191
-            if(ord($this->register[$i]) == 0xff)
192
-                $this->register[$i] = chr(0x00);
193
-            else
196
+            if(ord($this->register[$i]) == 0xff) {
197
+                            $this->register[$i] = chr(0x00);
198
+            } else
194 199
             {
195 200
                 // now increment the byte by 1
196 201
                 $this->register[$i] = chr(ord($this->register[$i]) + 1);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/Stream.php 2 patches
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.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@
 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)
55
-            trigger_error("Stream mode requires a stream cipher", E_USER_WARNING);
54
+        if($cipher->type() != Cipher::STREAM) {
55
+                    trigger_error("Stream mode requires a stream cipher", E_USER_WARNING);
56
+        }
56 57
     }
57 58
 
58 59
 
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/PCBC.php 2 patches
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.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  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)
52
-            trigger_error("PCBC mode requires a block cipher", E_USER_WARNING);
51
+        if($cipher->type() != Cipher::BLOCK) {
52
+                    trigger_error("PCBC mode requires a block cipher", E_USER_WARNING);
53
+        }
53 54
     }
54 55
 
55 56
 
@@ -86,16 +87,18 @@  discard block
 block discarded – undo
86 87
             $plain_block = $block;
87 88
 
88 89
             // xor the register with plain text
89
-            for($j = 0; $j < $blocksz; ++$j)
90
-                $block[$j] = $this->register[$j] ^ $block[$j];
90
+            for($j = 0; $j < $blocksz; ++$j) {
91
+                            $block[$j] = $this->register[$j] ^ $block[$j];
92
+            }
91 93
 
92 94
             // encrypt the block creating the cipher text
93 95
             $this->cipher->encrypt($block);
94 96
 
95 97
             // xor the encrypted block with the plain text block to create
96 98
             // the register in the next round
97
-            for($j = 0; $j < $blocksz; ++$j)
98
-                $this->register[$j] = $block[$j] ^ $plain_block[$j];
99
+            for($j = 0; $j < $blocksz; ++$j) {
100
+                            $this->register[$j] = $block[$j] ^ $plain_block[$j];
101
+            }
99 102
 
100 103
             // copy the encrypted block back to $text
101 104
             $text = substr_replace($text, $block, $pos, $blocksz);
@@ -130,12 +133,14 @@  discard block
 block discarded – undo
130 133
 
131 134
             // xor the decrypted block with the register, to create
132 135
             // the plain text block
133
-            for($j = 0; $j < $blocksz; ++$j)
134
-                $block[$j] = $this->register[$j] ^ $block[$j];
136
+            for($j = 0; $j < $blocksz; ++$j) {
137
+                            $block[$j] = $this->register[$j] ^ $block[$j];
138
+            }
135 139
 
136 140
             // now xor the $enc_block with the unencrypted $block
137
-            for($j = 0; $j < $blocksz; ++$j)
138
-                $this->register[$j] = $block[$j] ^ $enc_block[$j];
141
+            for($j = 0; $j < $blocksz; ++$j) {
142
+                            $this->register[$j] = $block[$j] ^ $enc_block[$j];
143
+            }
139 144
 
140 145
             // copy the plain text block back to $text
141 146
             $text = substr_replace($text, $block, $pos, $blocksz);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/OFB.php 2 patches
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.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@
 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)
52
-            trigger_error("OFB mode requires a block cipher", E_USER_WARNING);
51
+        if($cipher->type() != Cipher::BLOCK) {
52
+                    trigger_error("OFB mode requires a block cipher", E_USER_WARNING);
53
+        }
53 54
     }
54 55
 
55 56
 
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/NCFB.php 2 patches
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_NCFB, $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("NCFB mode requires a block cipher", E_USER_WARNING);
53 53
     }
54 54
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         // if $len is less than blockSize() this will still work, as even
81 81
         // a fraction is greater than 0
82 82
         $max = $len / $blocksz;
83
-        for($i = 0; $i < $max; ++$i)
83
+        for ($i = 0; $i < $max; ++$i)
84 84
         {
85 85
             // current position in the text
86 86
             $pos = $i * $blocksz;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             // make sure we don't extend past the length of $text
89 89
             $byte_len = $blocksz;
90 90
 
91
-            if(($pos + $byte_len) > $len)
91
+            if (($pos + $byte_len) > $len)
92 92
                 $byte_len -= ($pos + $byte_len) - $len;
93 93
 
94 94
             // encrypt the register
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             $block = substr($text, $pos, $byte_len);
100 100
 
101 101
             // xor the block
102
-            for($j = 0; $j < $byte_len; ++$j)
102
+            for ($j = 0; $j < $byte_len; ++$j)
103 103
                 $block[$j] = $block[$j] ^ $this->enc_register[$j];
104 104
 
105 105
             // replace the plain text block with the encrypted block
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
         // if $len is less than blockSize() this will still work, as even
129 129
         // a fraction is greater than 0
130 130
         $max = $len / $blocksz;
131
-        for($i = 0; $i < $max; ++$i)
131
+        for ($i = 0; $i < $max; ++$i)
132 132
         {
133 133
             // get the current position in text
134 134
             $pos = $i * $blocksz;
135 135
 
136 136
             // make sure we don't extend past the length of $text
137 137
             $byte_len = $blocksz;
138
-            if(($pos + $byte_len) > $len)
138
+            if (($pos + $byte_len) > $len)
139 139
                 $byte_len -= ($pos + $byte_len) - $len;
140 140
 
141 141
             // encrypt the register
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $this->register = $block;
148 148
 
149 149
             // xor the block
150
-            for($j = 0; $j < $byte_len; ++$j)
150
+            for ($j = 0; $j < $byte_len; ++$j)
151 151
                 $block[$j] = $block[$j] ^ $this->enc_register[$j];
152 152
 
153 153
             // replace the encrypted block with the plain text block
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
         parent::__construct(PHP_Crypt::MODE_NCFB, $cipher);
49 49
 
50 50
         // this works with only block Ciphers
51
-        if($cipher->type() != Cipher::BLOCK)
52
-            trigger_error("NCFB mode requires a block cipher", E_USER_WARNING);
51
+        if($cipher->type() != Cipher::BLOCK) {
52
+                    trigger_error("NCFB mode requires a block cipher", E_USER_WARNING);
53
+        }
53 54
     }
54 55
 
55 56
 
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
             // make sure we don't extend past the length of $text
89 90
             $byte_len = $blocksz;
90 91
 
91
-            if(($pos + $byte_len) > $len)
92
-                $byte_len -= ($pos + $byte_len) - $len;
92
+            if(($pos + $byte_len) > $len) {
93
+                            $byte_len -= ($pos + $byte_len) - $len;
94
+            }
93 95
 
94 96
             // encrypt the register
95 97
             $this->enc_register = $this->register;
@@ -99,8 +101,9 @@  discard block
 block discarded – undo
99 101
             $block = substr($text, $pos, $byte_len);
100 102
 
101 103
             // xor the block
102
-            for($j = 0; $j < $byte_len; ++$j)
103
-                $block[$j] = $block[$j] ^ $this->enc_register[$j];
104
+            for($j = 0; $j < $byte_len; ++$j) {
105
+                            $block[$j] = $block[$j] ^ $this->enc_register[$j];
106
+            }
104 107
 
105 108
             // replace the plain text block with the encrypted block
106 109
             $text = substr_replace($text, $block, $pos, $byte_len);
@@ -135,8 +138,9 @@  discard block
 block discarded – undo
135 138
 
136 139
             // make sure we don't extend past the length of $text
137 140
             $byte_len = $blocksz;
138
-            if(($pos + $byte_len) > $len)
139
-                $byte_len -= ($pos + $byte_len) - $len;
141
+            if(($pos + $byte_len) > $len) {
142
+                            $byte_len -= ($pos + $byte_len) - $len;
143
+            }
140 144
 
141 145
             // encrypt the register
142 146
             $this->enc_register = $this->register;
@@ -147,8 +151,9 @@  discard block
 block discarded – undo
147 151
             $this->register = $block;
148 152
 
149 153
             // xor the block
150
-            for($j = 0; $j < $byte_len; ++$j)
151
-                $block[$j] = $block[$j] ^ $this->enc_register[$j];
154
+            for($j = 0; $j < $byte_len; ++$j) {
155
+                            $block[$j] = $block[$j] ^ $this->enc_register[$j];
156
+            }
152 157
 
153 158
             // replace the encrypted block with the plain text block
154 159
             $text = substr_replace($text, $block, $pos, $byte_len);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/CBC.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         parent::__construct(PHP_Crypt::MODE_CBC, $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("CBC mode requires a block cipher", E_USER_WARNING);
53 53
     }
54 54
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $blocksz = $this->cipher->blockSize();
84 84
 
85 85
         $max = strlen($text) / $blocksz;
86
-        for($i = 0; $i < $max; ++$i)
86
+        for ($i = 0; $i < $max; ++$i)
87 87
         {
88 88
             // get the current position in $text
89 89
             $pos = $i * $blocksz;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             $block = substr($text, $pos, $blocksz);
93 93
 
94 94
             // xor the block with the register
95
-            for($j = 0; $j < $blocksz; ++$j)
95
+            for ($j = 0; $j < $blocksz; ++$j)
96 96
                 $block[$j] = $block[$j] ^ $this->register[$j];
97 97
 
98 98
             // encrypt the block, and save it back to the register
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         $blocksz = $this->cipher->blockSize();
127 127
 
128 128
         $max = strlen($text) / $blocksz;
129
-        for($i = 0; $i < $max; ++$i)
129
+        for ($i = 0; $i < $max; ++$i)
130 130
         {
131 131
             // get the current position in $text
132 132
             $pos = $i * $blocksz;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             $this->cipher->decrypt($block);
140 140
 
141 141
             // xor the block with the register
142
-            for($j = 0; $j < $blocksz; ++$j)
142
+            for ($j = 0; $j < $blocksz; ++$j)
143 143
                 $block[$j] = $block[$j] ^ $this->register[$j];
144 144
 
145 145
             // replace the block of cipher text with plain text
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
         parent::__construct(PHP_Crypt::MODE_CBC, $cipher);
49 49
 
50 50
         // this works with only block Ciphers
51
-        if($cipher->type() != Cipher::BLOCK)
52
-            trigger_error("CBC mode requires a block cipher", E_USER_WARNING);
51
+        if($cipher->type() != Cipher::BLOCK) {
52
+                    trigger_error("CBC mode requires a block cipher", E_USER_WARNING);
53
+        }
53 54
     }
54 55
 
55 56
 
@@ -92,8 +93,9 @@  discard block
 block discarded – undo
92 93
             $block = substr($text, $pos, $blocksz);
93 94
 
94 95
             // xor the block with the register
95
-            for($j = 0; $j < $blocksz; ++$j)
96
-                $block[$j] = $block[$j] ^ $this->register[$j];
96
+            for($j = 0; $j < $blocksz; ++$j) {
97
+                            $block[$j] = $block[$j] ^ $this->register[$j];
98
+            }
97 99
 
98 100
             // encrypt the block, and save it back to the register
99 101
             $this->cipher->encrypt($block);
@@ -139,8 +141,9 @@  discard block
 block discarded – undo
139 141
             $this->cipher->decrypt($block);
140 142
 
141 143
             // xor the block with the register
142
-            for($j = 0; $j < $blocksz; ++$j)
143
-                $block[$j] = $block[$j] ^ $this->register[$j];
144
+            for($j = 0; $j < $blocksz; ++$j) {
145
+                            $block[$j] = $block[$j] ^ $this->register[$j];
146
+            }
144 147
 
145 148
             // replace the block of cipher text with plain text
146 149
             $text = substr_replace($text, $block, $pos, $blocksz);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/ECB.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -36,106 +36,106 @@
 block discarded – undo
36 36
  */
37 37
 class Mode_ECB extends Mode
38 38
 {
39
-	/**
40
-	 * Constructor
41
-	 * Sets the cipher object that will be used for encryption
42
-	 *
43
-	 * @param object $cipher one of the phpCrypt encryption cipher objects
44
-	 * @return void
45
-	 */
46
-	public function __construct($cipher)
47
-	{
48
-		parent::__construct(PHP_Crypt::MODE_ECB, $cipher);
49
-
50
-		// this works with only block Ciphers
51
-		if ($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("ECB mode requires a block cipher", E_USER_WARNING);
53
-	}
54
-
55
-
56
-	/**
57
-	 * Destructor
58
-	 *
59
-	 * @return void
60
-	 */
61
-	public function __destruct()
62
-	{
63
-		parent::__destruct();
64
-	}
65
-
66
-
67
-	/**
68
-	 * Encrypts an the entire string $plain_text using the cipher passed
69
-	 * to the constructor in ECB mode
70
-	 *
71
-	 * @param string $text The string to be encrypted in ECB mode
72
-	 * @return boolean Returns true
73
-	 */
74
-	public function encrypt(&$text)
75
-	{
76
-		$this->pad($text);
77
-		$blocksz = $this->cipher->blockSize();
78
-
79
-		$max = strlen($text) / $blocksz;
80
-		for ($i = 0; $i < $max; ++$i)
81
-		{
82
-			// get the current position within $text
83
-			$pos = $i * $blocksz;
84
-
85
-			// grab a block of text
86
-			$block = substr($text, $pos, $blocksz);
87
-
88
-			// encrypt the block
89
-			$this->cipher->encrypt($block);
90
-
91
-			// replace the plain text with the cipher text
92
-			$text = substr_replace($text, $block, $pos, $blocksz);
93
-		}
94
-
95
-		return true;
96
-	}
97
-
98
-
99
-	/**
100
-	 * Decrypts an the entire string $plain_text using the cipher passed
101
-	 * to the constructor in ECB mode
102
-	 *
103
-	 * @param string $text The string to be decrypted in ECB mode
104
-	 * @return boolean Returns true
105
-	 */
106
-	public function decrypt(&$text)
107
-	{
108
-		$blocksz = $this->cipher->blockSize();
109
-
110
-		$max = strlen($text) / $blocksz;
111
-		for ($i = 0; $i < $max; ++$i)
112
-		{
113
-			// get the current position within $text
114
-			$pos = $i * $blocksz;
115
-
116
-			// get a block of cipher text
117
-			$block = substr($text, $pos, $blocksz);
118
-
119
-			// decrypt the block
120
-			$this->cipher->decrypt($block);
121
-
122
-			// replace the block of cipher text with plain text
123
-			$text = substr_replace($text, $block, $pos, $blocksz);
124
-		}
125
-
126
-		$this->strip($text);
127
-		return true;
128
-	}
129
-
130
-
131
-	/**
132
-	 * This mode does not require an IV
133
-	 *
134
-	 * @return boolean Returns false
135
-	 */
136
-	public function requiresIV()
137
-	{
138
-		return false;
139
-	}
39
+    /**
40
+     * Constructor
41
+     * Sets the cipher object that will be used for encryption
42
+     *
43
+     * @param object $cipher one of the phpCrypt encryption cipher objects
44
+     * @return void
45
+     */
46
+    public function __construct($cipher)
47
+    {
48
+        parent::__construct(PHP_Crypt::MODE_ECB, $cipher);
49
+
50
+        // this works with only block Ciphers
51
+        if ($cipher->type() != Cipher::BLOCK)
52
+            trigger_error("ECB mode requires a block cipher", E_USER_WARNING);
53
+    }
54
+
55
+
56
+    /**
57
+     * Destructor
58
+     *
59
+     * @return void
60
+     */
61
+    public function __destruct()
62
+    {
63
+        parent::__destruct();
64
+    }
65
+
66
+
67
+    /**
68
+     * Encrypts an the entire string $plain_text using the cipher passed
69
+     * to the constructor in ECB mode
70
+     *
71
+     * @param string $text The string to be encrypted in ECB mode
72
+     * @return boolean Returns true
73
+     */
74
+    public function encrypt(&$text)
75
+    {
76
+        $this->pad($text);
77
+        $blocksz = $this->cipher->blockSize();
78
+
79
+        $max = strlen($text) / $blocksz;
80
+        for ($i = 0; $i < $max; ++$i)
81
+        {
82
+            // get the current position within $text
83
+            $pos = $i * $blocksz;
84
+
85
+            // grab a block of text
86
+            $block = substr($text, $pos, $blocksz);
87
+
88
+            // encrypt the block
89
+            $this->cipher->encrypt($block);
90
+
91
+            // replace the plain text with the cipher text
92
+            $text = substr_replace($text, $block, $pos, $blocksz);
93
+        }
94
+
95
+        return true;
96
+    }
97
+
98
+
99
+    /**
100
+     * Decrypts an the entire string $plain_text using the cipher passed
101
+     * to the constructor in ECB mode
102
+     *
103
+     * @param string $text The string to be decrypted in ECB mode
104
+     * @return boolean Returns true
105
+     */
106
+    public function decrypt(&$text)
107
+    {
108
+        $blocksz = $this->cipher->blockSize();
109
+
110
+        $max = strlen($text) / $blocksz;
111
+        for ($i = 0; $i < $max; ++$i)
112
+        {
113
+            // get the current position within $text
114
+            $pos = $i * $blocksz;
115
+
116
+            // get a block of cipher text
117
+            $block = substr($text, $pos, $blocksz);
118
+
119
+            // decrypt the block
120
+            $this->cipher->decrypt($block);
121
+
122
+            // replace the block of cipher text with plain text
123
+            $text = substr_replace($text, $block, $pos, $blocksz);
124
+        }
125
+
126
+        $this->strip($text);
127
+        return true;
128
+    }
129
+
130
+
131
+    /**
132
+     * This mode does not require an IV
133
+     *
134
+     * @return boolean Returns false
135
+     */
136
+    public function requiresIV()
137
+    {
138
+        return false;
139
+    }
140 140
 }
141 141
 ?>
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_ECB, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if ($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("ECB mode requires a block cipher", E_USER_WARNING);
51
+		if ($cipher->type() != Cipher::BLOCK) {
52
+					trigger_error("ECB mode requires a block cipher", E_USER_WARNING);
53
+		}
53 54
 	}
54 55
 
55 56
 
Please login to merge, or discard this patch.
includes/libraries/csrfp/libs/csrf/csrfprotector.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -262,8 +262,9 @@  discard block
 block discarded – undo
262 262
          */
263 263
         private static function failedValidationAction()
264 264
         {
265
-            if (!file_exists(__DIR__."/../".self::$config['logDirectory']))
266
-                throw new logDirectoryNotFoundException("OWASP CSRFProtector: Log Directory Not Found!");
265
+            if (!file_exists(__DIR__."/../".self::$config['logDirectory'])) {
266
+                            throw new logDirectoryNotFoundException("OWASP CSRFProtector: Log Directory Not Found!");
267
+            }
267 268
 
268 269
             //call the logging function
269 270
             static::logCSRFattack();
@@ -522,8 +523,9 @@  discard block
 block discarded – undo
522 523
             foreach (self::$config['verifyGetFor'] as $key => $value) {
523 524
                 $value = str_replace(array('/', '*'), array('\/', '(.*)'), $value);
524 525
                 preg_match('/'.$value.'/', self::getCurrentUrl(), $output);
525
-                if (count($output) > 0)
526
-                    return false;
526
+                if (count($output) > 0) {
527
+                                    return false;
528
+                }
527 529
             }
528 530
             return true;
529 531
         }
Please login to merge, or discard this patch.