@@ -321,6 +321,7 @@ discard block |
||
321 | 321 | * SMTP CODE FAILURE: 451,554 |
322 | 322 | * SMTP CODE ERROR : 500,501,503,421 |
323 | 323 | * @access public |
324 | + * @param string $msg_data |
|
324 | 325 | * @return bool |
325 | 326 | */ |
326 | 327 | public function Data($msg_data) { |
@@ -488,6 +489,8 @@ discard block |
||
488 | 489 | /** |
489 | 490 | * Sends a HELO/EHLO command. |
490 | 491 | * @access private |
492 | + * @param string $hello |
|
493 | + * @param string $host |
|
491 | 494 | * @return bool |
492 | 495 | */ |
493 | 496 | private function SendHello($hello, $host) { |
@@ -528,6 +531,7 @@ discard block |
||
528 | 531 | * SMTP CODE SUCCESS: 552,451,452 |
529 | 532 | * SMTP CODE SUCCESS: 500,501,421 |
530 | 533 | * @access public |
534 | + * @param string $from |
|
531 | 535 | * @return bool |
532 | 536 | */ |
533 | 537 | public function Mail($from) { |
@@ -47,130 +47,130 @@ discard block |
||
47 | 47 | */ |
48 | 48 | |
49 | 49 | class SMTP { |
50 | - /** |
|
51 | - * SMTP server port |
|
52 | - * @var int |
|
53 | - */ |
|
54 | - public $SMTP_PORT = 25; |
|
55 | - |
|
56 | - /** |
|
57 | - * SMTP reply line ending |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - public $CRLF = "\r\n"; |
|
61 | - |
|
62 | - /** |
|
63 | - * Sets whether debugging is turned on |
|
64 | - * @var bool |
|
65 | - */ |
|
66 | - public $do_debug; // the level of debug to perform |
|
67 | - |
|
68 | - /** |
|
69 | - * Sets VERP use on/off (default is off) |
|
70 | - * @var bool |
|
71 | - */ |
|
72 | - public $do_verp = false; |
|
73 | - |
|
74 | - ///////////////////////////////////////////////// |
|
75 | - // PROPERTIES, PRIVATE AND PROTECTED |
|
76 | - ///////////////////////////////////////////////// |
|
77 | - |
|
78 | - private $smtp_conn; // the socket to the server |
|
79 | - private $error; // error if any on the last call |
|
80 | - private $helo_rply; // the reply the server sent to us for HELO |
|
81 | - |
|
82 | - /** |
|
83 | - * Initialize the class so that the data is in a known state. |
|
84 | - * @access public |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function __construct() { |
|
50 | + /** |
|
51 | + * SMTP server port |
|
52 | + * @var int |
|
53 | + */ |
|
54 | + public $SMTP_PORT = 25; |
|
55 | + |
|
56 | + /** |
|
57 | + * SMTP reply line ending |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + public $CRLF = "\r\n"; |
|
61 | + |
|
62 | + /** |
|
63 | + * Sets whether debugging is turned on |
|
64 | + * @var bool |
|
65 | + */ |
|
66 | + public $do_debug; // the level of debug to perform |
|
67 | + |
|
68 | + /** |
|
69 | + * Sets VERP use on/off (default is off) |
|
70 | + * @var bool |
|
71 | + */ |
|
72 | + public $do_verp = false; |
|
73 | + |
|
74 | + ///////////////////////////////////////////////// |
|
75 | + // PROPERTIES, PRIVATE AND PROTECTED |
|
76 | + ///////////////////////////////////////////////// |
|
77 | + |
|
78 | + private $smtp_conn; // the socket to the server |
|
79 | + private $error; // error if any on the last call |
|
80 | + private $helo_rply; // the reply the server sent to us for HELO |
|
81 | + |
|
82 | + /** |
|
83 | + * Initialize the class so that the data is in a known state. |
|
84 | + * @access public |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function __construct() { |
|
88 | 88 | $this->smtp_conn = 0; |
89 | 89 | $this->error = null; |
90 | 90 | $this->helo_rply = null; |
91 | 91 | |
92 | 92 | $this->do_debug = 0; |
93 | - } |
|
94 | - |
|
95 | - ///////////////////////////////////////////////// |
|
96 | - // CONNECTION FUNCTIONS |
|
97 | - ///////////////////////////////////////////////// |
|
98 | - |
|
99 | - /** |
|
100 | - * Connect to the server specified on the port specified. |
|
101 | - * If the port is not specified use the default SMTP_PORT. |
|
102 | - * If tval is specified then a connection will try and be |
|
103 | - * established with the server for that number of seconds. |
|
104 | - * If tval is not specified the default is 30 seconds to |
|
105 | - * try on the connection. |
|
106 | - * |
|
107 | - * SMTP CODE SUCCESS: 220 |
|
108 | - * SMTP CODE FAILURE: 421 |
|
109 | - * @access public |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function Connect($host, $port = 0, $tval = 30) { |
|
93 | + } |
|
94 | + |
|
95 | + ///////////////////////////////////////////////// |
|
96 | + // CONNECTION FUNCTIONS |
|
97 | + ///////////////////////////////////////////////// |
|
98 | + |
|
99 | + /** |
|
100 | + * Connect to the server specified on the port specified. |
|
101 | + * If the port is not specified use the default SMTP_PORT. |
|
102 | + * If tval is specified then a connection will try and be |
|
103 | + * established with the server for that number of seconds. |
|
104 | + * If tval is not specified the default is 30 seconds to |
|
105 | + * try on the connection. |
|
106 | + * |
|
107 | + * SMTP CODE SUCCESS: 220 |
|
108 | + * SMTP CODE FAILURE: 421 |
|
109 | + * @access public |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function Connect($host, $port = 0, $tval = 30) { |
|
113 | 113 | // set the error val to null so there is no confusion |
114 | 114 | $this->error = null; |
115 | 115 | |
116 | 116 | // make sure we are __not__ connected |
117 | 117 | if($this->connected()) { |
118 | - // already connected, generate error |
|
119 | - $this->error = array("error" => "Already connected to a server"); |
|
120 | - return false; |
|
118 | + // already connected, generate error |
|
119 | + $this->error = array("error" => "Already connected to a server"); |
|
120 | + return false; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | if(empty($port)) { |
124 | - $port = $this->SMTP_PORT; |
|
124 | + $port = $this->SMTP_PORT; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // connect to the smtp server |
128 | 128 | $this->smtp_conn = @fsockopen($host, // the host of the server |
129 | - $port, // the port to use |
|
130 | - $errno, // error number if any |
|
131 | - $errstr, // error message if any |
|
132 | - $tval); // give up after ? secs |
|
129 | + $port, // the port to use |
|
130 | + $errno, // error number if any |
|
131 | + $errstr, // error message if any |
|
132 | + $tval); // give up after ? secs |
|
133 | 133 | // verify we connected properly |
134 | 134 | if(empty($this->smtp_conn)) { |
135 | - $this->error = array("error" => "Failed to connect to server", |
|
136 | - "errno" => $errno, |
|
137 | - "errstr" => $errstr); |
|
138 | - if($this->do_debug >= 1) { |
|
135 | + $this->error = array("error" => "Failed to connect to server", |
|
136 | + "errno" => $errno, |
|
137 | + "errstr" => $errstr); |
|
138 | + if($this->do_debug >= 1) { |
|
139 | 139 | echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />'; |
140 | - } |
|
141 | - return false; |
|
140 | + } |
|
141 | + return false; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | // SMTP server can take longer to respond, give longer timeout for first read |
145 | 145 | // Windows does not have support for this timeout function |
146 | 146 | if(substr(PHP_OS, 0, 3) != "WIN") |
147 | - socket_set_timeout($this->smtp_conn, $tval, 0); |
|
147 | + socket_set_timeout($this->smtp_conn, $tval, 0); |
|
148 | 148 | |
149 | 149 | // get any announcement |
150 | 150 | $announce = $this->get_lines(); |
151 | 151 | |
152 | 152 | if($this->do_debug >= 2) { |
153 | - echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />'; |
|
153 | + echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | return true; |
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Initiate a TLS communication with the server. |
|
161 | - * |
|
162 | - * SMTP CODE 220 Ready to start TLS |
|
163 | - * SMTP CODE 501 Syntax error (no parameters allowed) |
|
164 | - * SMTP CODE 454 TLS not available due to temporary reason |
|
165 | - * @access public |
|
166 | - * @return bool success |
|
167 | - */ |
|
168 | - public function StartTLS() { |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Initiate a TLS communication with the server. |
|
161 | + * |
|
162 | + * SMTP CODE 220 Ready to start TLS |
|
163 | + * SMTP CODE 501 Syntax error (no parameters allowed) |
|
164 | + * SMTP CODE 454 TLS not available due to temporary reason |
|
165 | + * @access public |
|
166 | + * @return bool success |
|
167 | + */ |
|
168 | + public function StartTLS() { |
|
169 | 169 | $this->error = null; # to avoid confusion |
170 | 170 | |
171 | 171 | if(!$this->connected()) { |
172 | - $this->error = array("error" => "Called StartTLS() without being connected"); |
|
173 | - return false; |
|
172 | + $this->error = array("error" => "Called StartTLS() without being connected"); |
|
173 | + return false; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); |
@@ -179,35 +179,35 @@ discard block |
||
179 | 179 | $code = substr($rply,0,3); |
180 | 180 | |
181 | 181 | if($this->do_debug >= 2) { |
182 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
182 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | if($code != 220) { |
186 | - $this->error = |
|
187 | - array("error" => "STARTTLS not accepted from server", |
|
188 | - "smtp_code" => $code, |
|
189 | - "smtp_msg" => substr($rply,4)); |
|
190 | - if($this->do_debug >= 1) { |
|
186 | + $this->error = |
|
187 | + array("error" => "STARTTLS not accepted from server", |
|
188 | + "smtp_code" => $code, |
|
189 | + "smtp_msg" => substr($rply,4)); |
|
190 | + if($this->do_debug >= 1) { |
|
191 | 191 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
192 | - } |
|
193 | - return false; |
|
192 | + } |
|
193 | + return false; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | // Begin encrypted connection |
197 | 197 | if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
198 | - return false; |
|
198 | + return false; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return true; |
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Performs SMTP authentication. Must be run after running the |
|
206 | - * Hello() method. Returns true if successfully authenticated. |
|
207 | - * @access public |
|
208 | - * @return bool |
|
209 | - */ |
|
210 | - public function Authenticate($username, $password) { |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Performs SMTP authentication. Must be run after running the |
|
206 | + * Hello() method. Returns true if successfully authenticated. |
|
207 | + * @access public |
|
208 | + * @return bool |
|
209 | + */ |
|
210 | + public function Authenticate($username, $password) { |
|
211 | 211 | // Start authentication |
212 | 212 | fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); |
213 | 213 | |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | $code = substr($rply,0,3); |
216 | 216 | |
217 | 217 | if($code != 334) { |
218 | - $this->error = |
|
218 | + $this->error = |
|
219 | 219 | array("error" => "AUTH not accepted from server", |
220 | - "smtp_code" => $code, |
|
221 | - "smtp_msg" => substr($rply,4)); |
|
222 | - if($this->do_debug >= 1) { |
|
220 | + "smtp_code" => $code, |
|
221 | + "smtp_msg" => substr($rply,4)); |
|
222 | + if($this->do_debug >= 1) { |
|
223 | 223 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
224 | - } |
|
225 | - return false; |
|
224 | + } |
|
225 | + return false; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Send encoded username |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | $code = substr($rply,0,3); |
233 | 233 | |
234 | 234 | if($code != 334) { |
235 | - $this->error = |
|
235 | + $this->error = |
|
236 | 236 | array("error" => "Username not accepted from server", |
237 | - "smtp_code" => $code, |
|
238 | - "smtp_msg" => substr($rply,4)); |
|
239 | - if($this->do_debug >= 1) { |
|
237 | + "smtp_code" => $code, |
|
238 | + "smtp_msg" => substr($rply,4)); |
|
239 | + if($this->do_debug >= 1) { |
|
240 | 240 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
241 | - } |
|
242 | - return false; |
|
241 | + } |
|
242 | + return false; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | // Send encoded password |
@@ -249,87 +249,87 @@ discard block |
||
249 | 249 | $code = substr($rply,0,3); |
250 | 250 | |
251 | 251 | if($code != 235) { |
252 | - $this->error = |
|
252 | + $this->error = |
|
253 | 253 | array("error" => "Password not accepted from server", |
254 | - "smtp_code" => $code, |
|
255 | - "smtp_msg" => substr($rply,4)); |
|
256 | - if($this->do_debug >= 1) { |
|
254 | + "smtp_code" => $code, |
|
255 | + "smtp_msg" => substr($rply,4)); |
|
256 | + if($this->do_debug >= 1) { |
|
257 | 257 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
258 | - } |
|
259 | - return false; |
|
258 | + } |
|
259 | + return false; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | return true; |
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * Returns true if connected to a server otherwise false |
|
267 | - * @access public |
|
268 | - * @return bool |
|
269 | - */ |
|
270 | - public function Connected() { |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * Returns true if connected to a server otherwise false |
|
267 | + * @access public |
|
268 | + * @return bool |
|
269 | + */ |
|
270 | + public function Connected() { |
|
271 | 271 | if(!empty($this->smtp_conn)) { |
272 | - $sock_status = socket_get_status($this->smtp_conn); |
|
273 | - if($sock_status["eof"]) { |
|
272 | + $sock_status = socket_get_status($this->smtp_conn); |
|
273 | + if($sock_status["eof"]) { |
|
274 | 274 | // the socket is valid but we are not connected |
275 | 275 | if($this->do_debug >= 1) { |
276 | 276 | echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; |
277 | 277 | } |
278 | 278 | $this->Close(); |
279 | 279 | return false; |
280 | - } |
|
281 | - return true; // everything looks good |
|
280 | + } |
|
281 | + return true; // everything looks good |
|
282 | 282 | } |
283 | 283 | return false; |
284 | - } |
|
285 | - |
|
286 | - /** |
|
287 | - * Closes the socket and cleans up the state of the class. |
|
288 | - * It is not considered good to use this function without |
|
289 | - * first trying to use QUIT. |
|
290 | - * @access public |
|
291 | - * @return void |
|
292 | - */ |
|
293 | - public function Close() { |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | + * Closes the socket and cleans up the state of the class. |
|
288 | + * It is not considered good to use this function without |
|
289 | + * first trying to use QUIT. |
|
290 | + * @access public |
|
291 | + * @return void |
|
292 | + */ |
|
293 | + public function Close() { |
|
294 | 294 | $this->error = null; // so there is no confusion |
295 | 295 | $this->helo_rply = null; |
296 | 296 | if(!empty($this->smtp_conn)) { |
297 | - // close the connection and cleanup |
|
298 | - fclose($this->smtp_conn); |
|
299 | - $this->smtp_conn = 0; |
|
300 | - } |
|
301 | - } |
|
302 | - |
|
303 | - ///////////////////////////////////////////////// |
|
304 | - // SMTP COMMANDS |
|
305 | - ///////////////////////////////////////////////// |
|
306 | - |
|
307 | - /** |
|
308 | - * Issues a data command and sends the msg_data to the server |
|
309 | - * finializing the mail transaction. $msg_data is the message |
|
310 | - * that is to be send with the headers. Each header needs to be |
|
311 | - * on a single line followed by a <CRLF> with the message headers |
|
312 | - * and the message body being seperated by and additional <CRLF>. |
|
313 | - * |
|
314 | - * Implements rfc 821: DATA <CRLF> |
|
315 | - * |
|
316 | - * SMTP CODE INTERMEDIATE: 354 |
|
317 | - * [data] |
|
318 | - * <CRLF>.<CRLF> |
|
319 | - * SMTP CODE SUCCESS: 250 |
|
320 | - * SMTP CODE FAILURE: 552,554,451,452 |
|
321 | - * SMTP CODE FAILURE: 451,554 |
|
322 | - * SMTP CODE ERROR : 500,501,503,421 |
|
323 | - * @access public |
|
324 | - * @return bool |
|
325 | - */ |
|
326 | - public function Data($msg_data) { |
|
297 | + // close the connection and cleanup |
|
298 | + fclose($this->smtp_conn); |
|
299 | + $this->smtp_conn = 0; |
|
300 | + } |
|
301 | + } |
|
302 | + |
|
303 | + ///////////////////////////////////////////////// |
|
304 | + // SMTP COMMANDS |
|
305 | + ///////////////////////////////////////////////// |
|
306 | + |
|
307 | + /** |
|
308 | + * Issues a data command and sends the msg_data to the server |
|
309 | + * finializing the mail transaction. $msg_data is the message |
|
310 | + * that is to be send with the headers. Each header needs to be |
|
311 | + * on a single line followed by a <CRLF> with the message headers |
|
312 | + * and the message body being seperated by and additional <CRLF>. |
|
313 | + * |
|
314 | + * Implements rfc 821: DATA <CRLF> |
|
315 | + * |
|
316 | + * SMTP CODE INTERMEDIATE: 354 |
|
317 | + * [data] |
|
318 | + * <CRLF>.<CRLF> |
|
319 | + * SMTP CODE SUCCESS: 250 |
|
320 | + * SMTP CODE FAILURE: 552,554,451,452 |
|
321 | + * SMTP CODE FAILURE: 451,554 |
|
322 | + * SMTP CODE ERROR : 500,501,503,421 |
|
323 | + * @access public |
|
324 | + * @return bool |
|
325 | + */ |
|
326 | + public function Data($msg_data) { |
|
327 | 327 | $this->error = null; // so no confusion is caused |
328 | 328 | |
329 | 329 | if(!$this->connected()) { |
330 | - $this->error = array( |
|
331 | - "error" => "Called Data() without being connected"); |
|
332 | - return false; |
|
330 | + $this->error = array( |
|
331 | + "error" => "Called Data() without being connected"); |
|
332 | + return false; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | fputs($this->smtp_conn,"DATA" . $this->CRLF); |
@@ -338,18 +338,18 @@ discard block |
||
338 | 338 | $code = substr($rply,0,3); |
339 | 339 | |
340 | 340 | if($this->do_debug >= 2) { |
341 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
341 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if($code != 354) { |
345 | - $this->error = |
|
345 | + $this->error = |
|
346 | 346 | array("error" => "DATA command not accepted from server", |
347 | - "smtp_code" => $code, |
|
348 | - "smtp_msg" => substr($rply,4)); |
|
349 | - if($this->do_debug >= 1) { |
|
347 | + "smtp_code" => $code, |
|
348 | + "smtp_msg" => substr($rply,4)); |
|
349 | + if($this->do_debug >= 1) { |
|
350 | 350 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
351 | - } |
|
352 | - return false; |
|
351 | + } |
|
352 | + return false; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /* the server is ready to accept data! |
@@ -380,49 +380,49 @@ discard block |
||
380 | 380 | $field = substr($lines[0],0,strpos($lines[0],":")); |
381 | 381 | $in_headers = false; |
382 | 382 | if(!empty($field) && !strstr($field," ")) { |
383 | - $in_headers = true; |
|
383 | + $in_headers = true; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | $max_line_length = 998; // used below; set here for ease in change |
387 | 387 | |
388 | 388 | while(list(,$line) = @each($lines)) { |
389 | - $lines_out = null; |
|
390 | - if($line == "" && $in_headers) { |
|
389 | + $lines_out = null; |
|
390 | + if($line == "" && $in_headers) { |
|
391 | 391 | $in_headers = false; |
392 | - } |
|
393 | - // ok we need to break this line up into several smaller lines |
|
394 | - while(strlen($line) > $max_line_length) { |
|
392 | + } |
|
393 | + // ok we need to break this line up into several smaller lines |
|
394 | + while(strlen($line) > $max_line_length) { |
|
395 | 395 | $pos = strrpos(substr($line,0,$max_line_length)," "); |
396 | 396 | |
397 | 397 | // Patch to fix DOS attack |
398 | 398 | if(!$pos) { |
399 | - $pos = $max_line_length - 1; |
|
400 | - $lines_out[] = substr($line,0,$pos); |
|
401 | - $line = substr($line,$pos); |
|
399 | + $pos = $max_line_length - 1; |
|
400 | + $lines_out[] = substr($line,0,$pos); |
|
401 | + $line = substr($line,$pos); |
|
402 | 402 | } else { |
403 | - $lines_out[] = substr($line,0,$pos); |
|
404 | - $line = substr($line,$pos + 1); |
|
403 | + $lines_out[] = substr($line,0,$pos); |
|
404 | + $line = substr($line,$pos + 1); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /* if processing headers add a LWSP-char to the front of new line |
408 | 408 | * rfc 822 on long msg headers |
409 | 409 | */ |
410 | 410 | if($in_headers) { |
411 | - $line = "\t" . $line; |
|
411 | + $line = "\t" . $line; |
|
412 | 412 | } |
413 | - } |
|
414 | - $lines_out[] = $line; |
|
413 | + } |
|
414 | + $lines_out[] = $line; |
|
415 | 415 | |
416 | - // send the lines to the server |
|
417 | - while(list(,$line_out) = @each($lines_out)) { |
|
416 | + // send the lines to the server |
|
417 | + while(list(,$line_out) = @each($lines_out)) { |
|
418 | 418 | if(strlen($line_out) > 0) |
419 | 419 | { |
420 | - if(substr($line_out, 0, 1) == ".") { |
|
420 | + if(substr($line_out, 0, 1) == ".") { |
|
421 | 421 | $line_out = "." . $line_out; |
422 | - } |
|
422 | + } |
|
423 | 423 | } |
424 | 424 | fputs($this->smtp_conn,$line_out . $this->CRLF); |
425 | - } |
|
425 | + } |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | // message data has been sent |
@@ -432,111 +432,111 @@ discard block |
||
432 | 432 | $code = substr($rply,0,3); |
433 | 433 | |
434 | 434 | if($this->do_debug >= 2) { |
435 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
435 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | if($code != 250) { |
439 | - $this->error = |
|
439 | + $this->error = |
|
440 | 440 | array("error" => "DATA not accepted from server", |
441 | - "smtp_code" => $code, |
|
442 | - "smtp_msg" => substr($rply,4)); |
|
443 | - if($this->do_debug >= 1) { |
|
441 | + "smtp_code" => $code, |
|
442 | + "smtp_msg" => substr($rply,4)); |
|
443 | + if($this->do_debug >= 1) { |
|
444 | 444 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
445 | - } |
|
446 | - return false; |
|
445 | + } |
|
446 | + return false; |
|
447 | 447 | } |
448 | 448 | return true; |
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Sends the HELO command to the smtp server. |
|
453 | - * This makes sure that we and the server are in |
|
454 | - * the same known state. |
|
455 | - * |
|
456 | - * Implements from rfc 821: HELO <SP> <domain> <CRLF> |
|
457 | - * |
|
458 | - * SMTP CODE SUCCESS: 250 |
|
459 | - * SMTP CODE ERROR : 500, 501, 504, 421 |
|
460 | - * @access public |
|
461 | - * @return bool |
|
462 | - */ |
|
463 | - public function Hello($host = '') { |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Sends the HELO command to the smtp server. |
|
453 | + * This makes sure that we and the server are in |
|
454 | + * the same known state. |
|
455 | + * |
|
456 | + * Implements from rfc 821: HELO <SP> <domain> <CRLF> |
|
457 | + * |
|
458 | + * SMTP CODE SUCCESS: 250 |
|
459 | + * SMTP CODE ERROR : 500, 501, 504, 421 |
|
460 | + * @access public |
|
461 | + * @return bool |
|
462 | + */ |
|
463 | + public function Hello($host = '') { |
|
464 | 464 | $this->error = null; // so no confusion is caused |
465 | 465 | |
466 | 466 | if(!$this->connected()) { |
467 | - $this->error = array( |
|
467 | + $this->error = array( |
|
468 | 468 | "error" => "Called Hello() without being connected"); |
469 | - return false; |
|
469 | + return false; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | // if hostname for HELO was not specified send default |
473 | 473 | if(empty($host)) { |
474 | - // determine appropriate default to send to server |
|
475 | - $host = "localhost"; |
|
474 | + // determine appropriate default to send to server |
|
475 | + $host = "localhost"; |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | // Send extended hello first (RFC 2821) |
479 | 479 | if(!$this->SendHello("EHLO", $host)) { |
480 | - if(!$this->SendHello("HELO", $host)) { |
|
480 | + if(!$this->SendHello("HELO", $host)) { |
|
481 | 481 | return false; |
482 | - } |
|
482 | + } |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | return true; |
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * Sends a HELO/EHLO command. |
|
490 | - * @access private |
|
491 | - * @return bool |
|
492 | - */ |
|
493 | - private function SendHello($hello, $host) { |
|
486 | + } |
|
487 | + |
|
488 | + /** |
|
489 | + * Sends a HELO/EHLO command. |
|
490 | + * @access private |
|
491 | + * @return bool |
|
492 | + */ |
|
493 | + private function SendHello($hello, $host) { |
|
494 | 494 | fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); |
495 | 495 | |
496 | 496 | $rply = $this->get_lines(); |
497 | 497 | $code = substr($rply,0,3); |
498 | 498 | |
499 | 499 | if($this->do_debug >= 2) { |
500 | - echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; |
|
500 | + echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | if($code != 250) { |
504 | - $this->error = |
|
504 | + $this->error = |
|
505 | 505 | array("error" => $hello . " not accepted from server", |
506 | - "smtp_code" => $code, |
|
507 | - "smtp_msg" => substr($rply,4)); |
|
508 | - if($this->do_debug >= 1) { |
|
506 | + "smtp_code" => $code, |
|
507 | + "smtp_msg" => substr($rply,4)); |
|
508 | + if($this->do_debug >= 1) { |
|
509 | 509 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
510 | - } |
|
511 | - return false; |
|
510 | + } |
|
511 | + return false; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | $this->helo_rply = $rply; |
515 | 515 | |
516 | 516 | return true; |
517 | - } |
|
518 | - |
|
519 | - /** |
|
520 | - * Starts a mail transaction from the email address specified in |
|
521 | - * $from. Returns true if successful or false otherwise. If True |
|
522 | - * the mail transaction is started and then one or more Recipient |
|
523 | - * commands may be called followed by a Data command. |
|
524 | - * |
|
525 | - * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF> |
|
526 | - * |
|
527 | - * SMTP CODE SUCCESS: 250 |
|
528 | - * SMTP CODE SUCCESS: 552,451,452 |
|
529 | - * SMTP CODE SUCCESS: 500,501,421 |
|
530 | - * @access public |
|
531 | - * @return bool |
|
532 | - */ |
|
533 | - public function Mail($from) { |
|
517 | + } |
|
518 | + |
|
519 | + /** |
|
520 | + * Starts a mail transaction from the email address specified in |
|
521 | + * $from. Returns true if successful or false otherwise. If True |
|
522 | + * the mail transaction is started and then one or more Recipient |
|
523 | + * commands may be called followed by a Data command. |
|
524 | + * |
|
525 | + * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF> |
|
526 | + * |
|
527 | + * SMTP CODE SUCCESS: 250 |
|
528 | + * SMTP CODE SUCCESS: 552,451,452 |
|
529 | + * SMTP CODE SUCCESS: 500,501,421 |
|
530 | + * @access public |
|
531 | + * @return bool |
|
532 | + */ |
|
533 | + public function Mail($from) { |
|
534 | 534 | $this->error = null; // so no confusion is caused |
535 | 535 | |
536 | 536 | if(!$this->connected()) { |
537 | - $this->error = array( |
|
538 | - "error" => "Called Mail() without being connected"); |
|
539 | - return false; |
|
537 | + $this->error = array( |
|
538 | + "error" => "Called Mail() without being connected"); |
|
539 | + return false; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | $useVerp = ($this->do_verp ? "XVERP" : ""); |
@@ -546,40 +546,40 @@ discard block |
||
546 | 546 | $code = substr($rply,0,3); |
547 | 547 | |
548 | 548 | if($this->do_debug >= 2) { |
549 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
549 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | if($code != 250) { |
553 | - $this->error = |
|
553 | + $this->error = |
|
554 | 554 | array("error" => "MAIL not accepted from server", |
555 | - "smtp_code" => $code, |
|
556 | - "smtp_msg" => substr($rply,4)); |
|
557 | - if($this->do_debug >= 1) { |
|
555 | + "smtp_code" => $code, |
|
556 | + "smtp_msg" => substr($rply,4)); |
|
557 | + if($this->do_debug >= 1) { |
|
558 | 558 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
559 | - } |
|
560 | - return false; |
|
559 | + } |
|
560 | + return false; |
|
561 | 561 | } |
562 | 562 | return true; |
563 | - } |
|
564 | - |
|
565 | - /** |
|
566 | - * Sends the quit command to the server and then closes the socket |
|
567 | - * if there is no error or the $close_on_error argument is true. |
|
568 | - * |
|
569 | - * Implements from rfc 821: QUIT <CRLF> |
|
570 | - * |
|
571 | - * SMTP CODE SUCCESS: 221 |
|
572 | - * SMTP CODE ERROR : 500 |
|
573 | - * @access public |
|
574 | - * @return bool |
|
575 | - */ |
|
576 | - public function Quit($close_on_error = true) { |
|
563 | + } |
|
564 | + |
|
565 | + /** |
|
566 | + * Sends the quit command to the server and then closes the socket |
|
567 | + * if there is no error or the $close_on_error argument is true. |
|
568 | + * |
|
569 | + * Implements from rfc 821: QUIT <CRLF> |
|
570 | + * |
|
571 | + * SMTP CODE SUCCESS: 221 |
|
572 | + * SMTP CODE ERROR : 500 |
|
573 | + * @access public |
|
574 | + * @return bool |
|
575 | + */ |
|
576 | + public function Quit($close_on_error = true) { |
|
577 | 577 | $this->error = null; // so there is no confusion |
578 | 578 | |
579 | 579 | if(!$this->connected()) { |
580 | - $this->error = array( |
|
581 | - "error" => "Called Quit() without being connected"); |
|
582 | - return false; |
|
580 | + $this->error = array( |
|
581 | + "error" => "Called Quit() without being connected"); |
|
582 | + return false; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | // send the quit command to the server |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | $byemsg = $this->get_lines(); |
590 | 590 | |
591 | 591 | if($this->do_debug >= 2) { |
592 | - echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />'; |
|
592 | + echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />'; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | $rval = true; |
@@ -597,42 +597,42 @@ discard block |
||
597 | 597 | |
598 | 598 | $code = substr($byemsg,0,3); |
599 | 599 | if($code != 221) { |
600 | - // use e as a tmp var cause Close will overwrite $this->error |
|
601 | - $e = array("error" => "SMTP server rejected quit command", |
|
602 | - "smtp_code" => $code, |
|
603 | - "smtp_rply" => substr($byemsg,4)); |
|
604 | - $rval = false; |
|
605 | - if($this->do_debug >= 1) { |
|
600 | + // use e as a tmp var cause Close will overwrite $this->error |
|
601 | + $e = array("error" => "SMTP server rejected quit command", |
|
602 | + "smtp_code" => $code, |
|
603 | + "smtp_rply" => substr($byemsg,4)); |
|
604 | + $rval = false; |
|
605 | + if($this->do_debug >= 1) { |
|
606 | 606 | echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />'; |
607 | - } |
|
607 | + } |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | if(empty($e) || $close_on_error) { |
611 | - $this->Close(); |
|
611 | + $this->Close(); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | return $rval; |
615 | - } |
|
616 | - |
|
617 | - /** |
|
618 | - * Sends the command RCPT to the SMTP server with the TO: argument of $to. |
|
619 | - * Returns true if the recipient was accepted false if it was rejected. |
|
620 | - * |
|
621 | - * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> |
|
622 | - * |
|
623 | - * SMTP CODE SUCCESS: 250,251 |
|
624 | - * SMTP CODE FAILURE: 550,551,552,553,450,451,452 |
|
625 | - * SMTP CODE ERROR : 500,501,503,421 |
|
626 | - * @access public |
|
627 | - * @return bool |
|
628 | - */ |
|
629 | - public function Recipient($to) { |
|
615 | + } |
|
616 | + |
|
617 | + /** |
|
618 | + * Sends the command RCPT to the SMTP server with the TO: argument of $to. |
|
619 | + * Returns true if the recipient was accepted false if it was rejected. |
|
620 | + * |
|
621 | + * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> |
|
622 | + * |
|
623 | + * SMTP CODE SUCCESS: 250,251 |
|
624 | + * SMTP CODE FAILURE: 550,551,552,553,450,451,452 |
|
625 | + * SMTP CODE ERROR : 500,501,503,421 |
|
626 | + * @access public |
|
627 | + * @return bool |
|
628 | + */ |
|
629 | + public function Recipient($to) { |
|
630 | 630 | $this->error = null; // so no confusion is caused |
631 | 631 | |
632 | 632 | if(!$this->connected()) { |
633 | - $this->error = array( |
|
634 | - "error" => "Called Recipient() without being connected"); |
|
635 | - return false; |
|
633 | + $this->error = array( |
|
634 | + "error" => "Called Recipient() without being connected"); |
|
635 | + return false; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); |
@@ -641,41 +641,41 @@ discard block |
||
641 | 641 | $code = substr($rply,0,3); |
642 | 642 | |
643 | 643 | if($this->do_debug >= 2) { |
644 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
644 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | if($code != 250 && $code != 251) { |
648 | - $this->error = |
|
648 | + $this->error = |
|
649 | 649 | array("error" => "RCPT not accepted from server", |
650 | - "smtp_code" => $code, |
|
651 | - "smtp_msg" => substr($rply,4)); |
|
652 | - if($this->do_debug >= 1) { |
|
650 | + "smtp_code" => $code, |
|
651 | + "smtp_msg" => substr($rply,4)); |
|
652 | + if($this->do_debug >= 1) { |
|
653 | 653 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
654 | - } |
|
655 | - return false; |
|
654 | + } |
|
655 | + return false; |
|
656 | 656 | } |
657 | 657 | return true; |
658 | - } |
|
659 | - |
|
660 | - /** |
|
661 | - * Sends the RSET command to abort and transaction that is |
|
662 | - * currently in progress. Returns true if successful false |
|
663 | - * otherwise. |
|
664 | - * |
|
665 | - * Implements rfc 821: RSET <CRLF> |
|
666 | - * |
|
667 | - * SMTP CODE SUCCESS: 250 |
|
668 | - * SMTP CODE ERROR : 500,501,504,421 |
|
669 | - * @access public |
|
670 | - * @return bool |
|
671 | - */ |
|
672 | - public function Reset() { |
|
658 | + } |
|
659 | + |
|
660 | + /** |
|
661 | + * Sends the RSET command to abort and transaction that is |
|
662 | + * currently in progress. Returns true if successful false |
|
663 | + * otherwise. |
|
664 | + * |
|
665 | + * Implements rfc 821: RSET <CRLF> |
|
666 | + * |
|
667 | + * SMTP CODE SUCCESS: 250 |
|
668 | + * SMTP CODE ERROR : 500,501,504,421 |
|
669 | + * @access public |
|
670 | + * @return bool |
|
671 | + */ |
|
672 | + public function Reset() { |
|
673 | 673 | $this->error = null; // so no confusion is caused |
674 | 674 | |
675 | 675 | if(!$this->connected()) { |
676 | - $this->error = array( |
|
677 | - "error" => "Called Reset() without being connected"); |
|
678 | - return false; |
|
676 | + $this->error = array( |
|
677 | + "error" => "Called Reset() without being connected"); |
|
678 | + return false; |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | fputs($this->smtp_conn,"RSET" . $this->CRLF); |
@@ -684,46 +684,46 @@ discard block |
||
684 | 684 | $code = substr($rply,0,3); |
685 | 685 | |
686 | 686 | if($this->do_debug >= 2) { |
687 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
687 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | if($code != 250) { |
691 | - $this->error = |
|
691 | + $this->error = |
|
692 | 692 | array("error" => "RSET failed", |
693 | - "smtp_code" => $code, |
|
694 | - "smtp_msg" => substr($rply,4)); |
|
695 | - if($this->do_debug >= 1) { |
|
693 | + "smtp_code" => $code, |
|
694 | + "smtp_msg" => substr($rply,4)); |
|
695 | + if($this->do_debug >= 1) { |
|
696 | 696 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
697 | - } |
|
698 | - return false; |
|
697 | + } |
|
698 | + return false; |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | return true; |
702 | - } |
|
703 | - |
|
704 | - /** |
|
705 | - * Starts a mail transaction from the email address specified in |
|
706 | - * $from. Returns true if successful or false otherwise. If True |
|
707 | - * the mail transaction is started and then one or more Recipient |
|
708 | - * commands may be called followed by a Data command. This command |
|
709 | - * will send the message to the users terminal if they are logged |
|
710 | - * in and send them an email. |
|
711 | - * |
|
712 | - * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF> |
|
713 | - * |
|
714 | - * SMTP CODE SUCCESS: 250 |
|
715 | - * SMTP CODE SUCCESS: 552,451,452 |
|
716 | - * SMTP CODE SUCCESS: 500,501,502,421 |
|
717 | - * @access public |
|
718 | - * @return bool |
|
719 | - */ |
|
720 | - public function SendAndMail($from) { |
|
702 | + } |
|
703 | + |
|
704 | + /** |
|
705 | + * Starts a mail transaction from the email address specified in |
|
706 | + * $from. Returns true if successful or false otherwise. If True |
|
707 | + * the mail transaction is started and then one or more Recipient |
|
708 | + * commands may be called followed by a Data command. This command |
|
709 | + * will send the message to the users terminal if they are logged |
|
710 | + * in and send them an email. |
|
711 | + * |
|
712 | + * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF> |
|
713 | + * |
|
714 | + * SMTP CODE SUCCESS: 250 |
|
715 | + * SMTP CODE SUCCESS: 552,451,452 |
|
716 | + * SMTP CODE SUCCESS: 500,501,502,421 |
|
717 | + * @access public |
|
718 | + * @return bool |
|
719 | + */ |
|
720 | + public function SendAndMail($from) { |
|
721 | 721 | $this->error = null; // so no confusion is caused |
722 | 722 | |
723 | 723 | if(!$this->connected()) { |
724 | - $this->error = array( |
|
725 | - "error" => "Called SendAndMail() without being connected"); |
|
726 | - return false; |
|
724 | + $this->error = array( |
|
725 | + "error" => "Called SendAndMail() without being connected"); |
|
726 | + return false; |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); |
@@ -732,82 +732,82 @@ discard block |
||
732 | 732 | $code = substr($rply,0,3); |
733 | 733 | |
734 | 734 | if($this->do_debug >= 2) { |
735 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
735 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | if($code != 250) { |
739 | - $this->error = |
|
739 | + $this->error = |
|
740 | 740 | array("error" => "SAML not accepted from server", |
741 | - "smtp_code" => $code, |
|
742 | - "smtp_msg" => substr($rply,4)); |
|
743 | - if($this->do_debug >= 1) { |
|
741 | + "smtp_code" => $code, |
|
742 | + "smtp_msg" => substr($rply,4)); |
|
743 | + if($this->do_debug >= 1) { |
|
744 | 744 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
745 | - } |
|
746 | - return false; |
|
745 | + } |
|
746 | + return false; |
|
747 | 747 | } |
748 | 748 | return true; |
749 | - } |
|
750 | - |
|
751 | - /** |
|
752 | - * This is an optional command for SMTP that this class does not |
|
753 | - * support. This method is here to make the RFC821 Definition |
|
754 | - * complete for this class and __may__ be implimented in the future |
|
755 | - * |
|
756 | - * Implements from rfc 821: TURN <CRLF> |
|
757 | - * |
|
758 | - * SMTP CODE SUCCESS: 250 |
|
759 | - * SMTP CODE FAILURE: 502 |
|
760 | - * SMTP CODE ERROR : 500, 503 |
|
761 | - * @access public |
|
762 | - * @return bool |
|
763 | - */ |
|
764 | - public function Turn() { |
|
749 | + } |
|
750 | + |
|
751 | + /** |
|
752 | + * This is an optional command for SMTP that this class does not |
|
753 | + * support. This method is here to make the RFC821 Definition |
|
754 | + * complete for this class and __may__ be implimented in the future |
|
755 | + * |
|
756 | + * Implements from rfc 821: TURN <CRLF> |
|
757 | + * |
|
758 | + * SMTP CODE SUCCESS: 250 |
|
759 | + * SMTP CODE FAILURE: 502 |
|
760 | + * SMTP CODE ERROR : 500, 503 |
|
761 | + * @access public |
|
762 | + * @return bool |
|
763 | + */ |
|
764 | + public function Turn() { |
|
765 | 765 | $this->error = array("error" => "This method, TURN, of the SMTP ". |
766 | 766 | "is not implemented"); |
767 | 767 | if($this->do_debug >= 1) { |
768 | - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />'; |
|
768 | + echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />'; |
|
769 | 769 | } |
770 | 770 | return false; |
771 | - } |
|
772 | - |
|
773 | - /** |
|
774 | - * Get the current error |
|
775 | - * @access public |
|
776 | - * @return array |
|
777 | - */ |
|
778 | - public function getError() { |
|
771 | + } |
|
772 | + |
|
773 | + /** |
|
774 | + * Get the current error |
|
775 | + * @access public |
|
776 | + * @return array |
|
777 | + */ |
|
778 | + public function getError() { |
|
779 | 779 | return $this->error; |
780 | - } |
|
781 | - |
|
782 | - ///////////////////////////////////////////////// |
|
783 | - // INTERNAL FUNCTIONS |
|
784 | - ///////////////////////////////////////////////// |
|
785 | - |
|
786 | - /** |
|
787 | - * Read in as many lines as possible |
|
788 | - * either before eof or socket timeout occurs on the operation. |
|
789 | - * With SMTP we can tell if we have more lines to read if the |
|
790 | - * 4th character is '-' symbol. If it is a space then we don't |
|
791 | - * need to read anything else. |
|
792 | - * @access private |
|
793 | - * @return string |
|
794 | - */ |
|
795 | - private function get_lines() { |
|
780 | + } |
|
781 | + |
|
782 | + ///////////////////////////////////////////////// |
|
783 | + // INTERNAL FUNCTIONS |
|
784 | + ///////////////////////////////////////////////// |
|
785 | + |
|
786 | + /** |
|
787 | + * Read in as many lines as possible |
|
788 | + * either before eof or socket timeout occurs on the operation. |
|
789 | + * With SMTP we can tell if we have more lines to read if the |
|
790 | + * 4th character is '-' symbol. If it is a space then we don't |
|
791 | + * need to read anything else. |
|
792 | + * @access private |
|
793 | + * @return string |
|
794 | + */ |
|
795 | + private function get_lines() { |
|
796 | 796 | $data = ""; |
797 | 797 | while($str = @fgets($this->smtp_conn,515)) { |
798 | - if($this->do_debug >= 4) { |
|
798 | + if($this->do_debug >= 4) { |
|
799 | 799 | echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />'; |
800 | 800 | echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />'; |
801 | - } |
|
802 | - $data .= $str; |
|
803 | - if($this->do_debug >= 4) { |
|
801 | + } |
|
802 | + $data .= $str; |
|
803 | + if($this->do_debug >= 4) { |
|
804 | 804 | echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />'; |
805 | - } |
|
806 | - // if 4th character is a space, we are done reading, break the loop |
|
807 | - if(substr($str,3,1) == " ") { break; } |
|
805 | + } |
|
806 | + // if 4th character is a space, we are done reading, break the loop |
|
807 | + if(substr($str,3,1) == " ") { break; } |
|
808 | 808 | } |
809 | 809 | return $data; |
810 | - } |
|
810 | + } |
|
811 | 811 | |
812 | 812 | } |
813 | 813 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * Sets whether debugging is turned on |
64 | 64 | * @var bool |
65 | 65 | */ |
66 | - public $do_debug; // the level of debug to perform |
|
66 | + public $do_debug; // the level of debug to perform |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Sets VERP use on/off (default is off) |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ///////////////////////////////////////////////// |
77 | 77 | |
78 | 78 | private $smtp_conn; // the socket to the server |
79 | - private $error; // error if any on the last call |
|
79 | + private $error; // error if any on the last call |
|
80 | 80 | private $helo_rply; // the reply the server sent to us for HELO |
81 | 81 | |
82 | 82 | /** |
@@ -114,43 +114,43 @@ discard block |
||
114 | 114 | $this->error = null; |
115 | 115 | |
116 | 116 | // make sure we are __not__ connected |
117 | - if($this->connected()) { |
|
117 | + if ($this->connected()) { |
|
118 | 118 | // already connected, generate error |
119 | 119 | $this->error = array("error" => "Already connected to a server"); |
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | |
123 | - if(empty($port)) { |
|
123 | + if (empty($port)) { |
|
124 | 124 | $port = $this->SMTP_PORT; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // connect to the smtp server |
128 | - $this->smtp_conn = @fsockopen($host, // the host of the server |
|
129 | - $port, // the port to use |
|
130 | - $errno, // error number if any |
|
131 | - $errstr, // error message if any |
|
132 | - $tval); // give up after ? secs |
|
128 | + $this->smtp_conn = @fsockopen($host, // the host of the server |
|
129 | + $port, // the port to use |
|
130 | + $errno, // error number if any |
|
131 | + $errstr, // error message if any |
|
132 | + $tval); // give up after ? secs |
|
133 | 133 | // verify we connected properly |
134 | - if(empty($this->smtp_conn)) { |
|
134 | + if (empty($this->smtp_conn)) { |
|
135 | 135 | $this->error = array("error" => "Failed to connect to server", |
136 | 136 | "errno" => $errno, |
137 | 137 | "errstr" => $errstr); |
138 | - if($this->do_debug >= 1) { |
|
139 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />'; |
|
138 | + if ($this->do_debug >= 1) { |
|
139 | + echo "SMTP -> ERROR: ".$this->error["error"].": $errstr ($errno)".$this->CRLF.'<br />'; |
|
140 | 140 | } |
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | 144 | // SMTP server can take longer to respond, give longer timeout for first read |
145 | 145 | // Windows does not have support for this timeout function |
146 | - if(substr(PHP_OS, 0, 3) != "WIN") |
|
146 | + if (substr(PHP_OS, 0, 3) != "WIN") |
|
147 | 147 | socket_set_timeout($this->smtp_conn, $tval, 0); |
148 | 148 | |
149 | 149 | // get any announcement |
150 | 150 | $announce = $this->get_lines(); |
151 | 151 | |
152 | - if($this->do_debug >= 2) { |
|
153 | - echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />'; |
|
152 | + if ($this->do_debug >= 2) { |
|
153 | + echo "SMTP -> FROM SERVER:".$announce.$this->CRLF.'<br />'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | return true; |
@@ -168,33 +168,33 @@ discard block |
||
168 | 168 | public function StartTLS() { |
169 | 169 | $this->error = null; # to avoid confusion |
170 | 170 | |
171 | - if(!$this->connected()) { |
|
171 | + if (!$this->connected()) { |
|
172 | 172 | $this->error = array("error" => "Called StartTLS() without being connected"); |
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
176 | - fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); |
|
176 | + fputs($this->smtp_conn, "STARTTLS".$this->CRLF); |
|
177 | 177 | |
178 | 178 | $rply = $this->get_lines(); |
179 | - $code = substr($rply,0,3); |
|
179 | + $code = substr($rply, 0, 3); |
|
180 | 180 | |
181 | - if($this->do_debug >= 2) { |
|
182 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
181 | + if ($this->do_debug >= 2) { |
|
182 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
183 | 183 | } |
184 | 184 | |
185 | - if($code != 220) { |
|
185 | + if ($code != 220) { |
|
186 | 186 | $this->error = |
187 | 187 | array("error" => "STARTTLS not accepted from server", |
188 | 188 | "smtp_code" => $code, |
189 | - "smtp_msg" => substr($rply,4)); |
|
190 | - if($this->do_debug >= 1) { |
|
191 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
189 | + "smtp_msg" => substr($rply, 4)); |
|
190 | + if ($this->do_debug >= 1) { |
|
191 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
192 | 192 | } |
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Begin encrypted connection |
197 | - if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
197 | + if (!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | |
@@ -209,52 +209,52 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function Authenticate($username, $password) { |
211 | 211 | // Start authentication |
212 | - fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); |
|
212 | + fputs($this->smtp_conn, "AUTH LOGIN".$this->CRLF); |
|
213 | 213 | |
214 | 214 | $rply = $this->get_lines(); |
215 | - $code = substr($rply,0,3); |
|
215 | + $code = substr($rply, 0, 3); |
|
216 | 216 | |
217 | - if($code != 334) { |
|
217 | + if ($code != 334) { |
|
218 | 218 | $this->error = |
219 | 219 | array("error" => "AUTH not accepted from server", |
220 | 220 | "smtp_code" => $code, |
221 | - "smtp_msg" => substr($rply,4)); |
|
222 | - if($this->do_debug >= 1) { |
|
223 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
221 | + "smtp_msg" => substr($rply, 4)); |
|
222 | + if ($this->do_debug >= 1) { |
|
223 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
224 | 224 | } |
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // Send encoded username |
229 | - fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); |
|
229 | + fputs($this->smtp_conn, base64_encode($username).$this->CRLF); |
|
230 | 230 | |
231 | 231 | $rply = $this->get_lines(); |
232 | - $code = substr($rply,0,3); |
|
232 | + $code = substr($rply, 0, 3); |
|
233 | 233 | |
234 | - if($code != 334) { |
|
234 | + if ($code != 334) { |
|
235 | 235 | $this->error = |
236 | 236 | array("error" => "Username not accepted from server", |
237 | 237 | "smtp_code" => $code, |
238 | - "smtp_msg" => substr($rply,4)); |
|
239 | - if($this->do_debug >= 1) { |
|
240 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
238 | + "smtp_msg" => substr($rply, 4)); |
|
239 | + if ($this->do_debug >= 1) { |
|
240 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
241 | 241 | } |
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Send encoded password |
246 | - fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); |
|
246 | + fputs($this->smtp_conn, base64_encode($password).$this->CRLF); |
|
247 | 247 | |
248 | 248 | $rply = $this->get_lines(); |
249 | - $code = substr($rply,0,3); |
|
249 | + $code = substr($rply, 0, 3); |
|
250 | 250 | |
251 | - if($code != 235) { |
|
251 | + if ($code != 235) { |
|
252 | 252 | $this->error = |
253 | 253 | array("error" => "Password not accepted from server", |
254 | 254 | "smtp_code" => $code, |
255 | - "smtp_msg" => substr($rply,4)); |
|
256 | - if($this->do_debug >= 1) { |
|
257 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
255 | + "smtp_msg" => substr($rply, 4)); |
|
256 | + if ($this->do_debug >= 1) { |
|
257 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
258 | 258 | } |
259 | 259 | return false; |
260 | 260 | } |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * @return bool |
269 | 269 | */ |
270 | 270 | public function Connected() { |
271 | - if(!empty($this->smtp_conn)) { |
|
271 | + if (!empty($this->smtp_conn)) { |
|
272 | 272 | $sock_status = socket_get_status($this->smtp_conn); |
273 | - if($sock_status["eof"]) { |
|
273 | + if ($sock_status["eof"]) { |
|
274 | 274 | // the socket is valid but we are not connected |
275 | - if($this->do_debug >= 1) { |
|
276 | - echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; |
|
275 | + if ($this->do_debug >= 1) { |
|
276 | + echo "SMTP -> NOTICE:".$this->CRLF."EOF caught while checking if connected"; |
|
277 | 277 | } |
278 | 278 | $this->Close(); |
279 | 279 | return false; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | public function Close() { |
294 | 294 | $this->error = null; // so there is no confusion |
295 | 295 | $this->helo_rply = null; |
296 | - if(!empty($this->smtp_conn)) { |
|
296 | + if (!empty($this->smtp_conn)) { |
|
297 | 297 | // close the connection and cleanup |
298 | 298 | fclose($this->smtp_conn); |
299 | 299 | $this->smtp_conn = 0; |
@@ -326,28 +326,28 @@ discard block |
||
326 | 326 | public function Data($msg_data) { |
327 | 327 | $this->error = null; // so no confusion is caused |
328 | 328 | |
329 | - if(!$this->connected()) { |
|
329 | + if (!$this->connected()) { |
|
330 | 330 | $this->error = array( |
331 | 331 | "error" => "Called Data() without being connected"); |
332 | 332 | return false; |
333 | 333 | } |
334 | 334 | |
335 | - fputs($this->smtp_conn,"DATA" . $this->CRLF); |
|
335 | + fputs($this->smtp_conn, "DATA".$this->CRLF); |
|
336 | 336 | |
337 | 337 | $rply = $this->get_lines(); |
338 | - $code = substr($rply,0,3); |
|
338 | + $code = substr($rply, 0, 3); |
|
339 | 339 | |
340 | - if($this->do_debug >= 2) { |
|
341 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
340 | + if ($this->do_debug >= 2) { |
|
341 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
342 | 342 | } |
343 | 343 | |
344 | - if($code != 354) { |
|
344 | + if ($code != 354) { |
|
345 | 345 | $this->error = |
346 | 346 | array("error" => "DATA command not accepted from server", |
347 | 347 | "smtp_code" => $code, |
348 | - "smtp_msg" => substr($rply,4)); |
|
349 | - if($this->do_debug >= 1) { |
|
350 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
348 | + "smtp_msg" => substr($rply, 4)); |
|
349 | + if ($this->do_debug >= 1) { |
|
350 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
351 | 351 | } |
352 | 352 | return false; |
353 | 353 | } |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | */ |
365 | 365 | |
366 | 366 | // normalize the line breaks so we know the explode works |
367 | - $msg_data = str_replace("\r\n","\n",$msg_data); |
|
368 | - $msg_data = str_replace("\r","\n",$msg_data); |
|
369 | - $lines = explode("\n",$msg_data); |
|
367 | + $msg_data = str_replace("\r\n", "\n", $msg_data); |
|
368 | + $msg_data = str_replace("\r", "\n", $msg_data); |
|
369 | + $lines = explode("\n", $msg_data); |
|
370 | 370 | |
371 | 371 | /* we need to find a good way to determine is headers are |
372 | 372 | * in the msg_data or if it is a straight msg body |
@@ -377,71 +377,71 @@ discard block |
||
377 | 377 | * headers. |
378 | 378 | */ |
379 | 379 | |
380 | - $field = substr($lines[0],0,strpos($lines[0],":")); |
|
380 | + $field = substr($lines[0], 0, strpos($lines[0], ":")); |
|
381 | 381 | $in_headers = false; |
382 | - if(!empty($field) && !strstr($field," ")) { |
|
382 | + if (!empty($field) && !strstr($field, " ")) { |
|
383 | 383 | $in_headers = true; |
384 | 384 | } |
385 | 385 | |
386 | 386 | $max_line_length = 998; // used below; set here for ease in change |
387 | 387 | |
388 | - while(list(,$line) = @each($lines)) { |
|
388 | + while (list(,$line) = @each($lines)) { |
|
389 | 389 | $lines_out = null; |
390 | - if($line == "" && $in_headers) { |
|
390 | + if ($line == "" && $in_headers) { |
|
391 | 391 | $in_headers = false; |
392 | 392 | } |
393 | 393 | // ok we need to break this line up into several smaller lines |
394 | - while(strlen($line) > $max_line_length) { |
|
395 | - $pos = strrpos(substr($line,0,$max_line_length)," "); |
|
394 | + while (strlen($line) > $max_line_length) { |
|
395 | + $pos = strrpos(substr($line, 0, $max_line_length), " "); |
|
396 | 396 | |
397 | 397 | // Patch to fix DOS attack |
398 | - if(!$pos) { |
|
398 | + if (!$pos) { |
|
399 | 399 | $pos = $max_line_length - 1; |
400 | - $lines_out[] = substr($line,0,$pos); |
|
401 | - $line = substr($line,$pos); |
|
400 | + $lines_out[] = substr($line, 0, $pos); |
|
401 | + $line = substr($line, $pos); |
|
402 | 402 | } else { |
403 | - $lines_out[] = substr($line,0,$pos); |
|
404 | - $line = substr($line,$pos + 1); |
|
403 | + $lines_out[] = substr($line, 0, $pos); |
|
404 | + $line = substr($line, $pos + 1); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /* if processing headers add a LWSP-char to the front of new line |
408 | 408 | * rfc 822 on long msg headers |
409 | 409 | */ |
410 | - if($in_headers) { |
|
411 | - $line = "\t" . $line; |
|
410 | + if ($in_headers) { |
|
411 | + $line = "\t".$line; |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | $lines_out[] = $line; |
415 | 415 | |
416 | 416 | // send the lines to the server |
417 | - while(list(,$line_out) = @each($lines_out)) { |
|
418 | - if(strlen($line_out) > 0) |
|
417 | + while (list(,$line_out) = @each($lines_out)) { |
|
418 | + if (strlen($line_out) > 0) |
|
419 | 419 | { |
420 | - if(substr($line_out, 0, 1) == ".") { |
|
421 | - $line_out = "." . $line_out; |
|
420 | + if (substr($line_out, 0, 1) == ".") { |
|
421 | + $line_out = ".".$line_out; |
|
422 | 422 | } |
423 | 423 | } |
424 | - fputs($this->smtp_conn,$line_out . $this->CRLF); |
|
424 | + fputs($this->smtp_conn, $line_out.$this->CRLF); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | 428 | // message data has been sent |
429 | - fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); |
|
429 | + fputs($this->smtp_conn, $this->CRLF.".".$this->CRLF); |
|
430 | 430 | |
431 | 431 | $rply = $this->get_lines(); |
432 | - $code = substr($rply,0,3); |
|
432 | + $code = substr($rply, 0, 3); |
|
433 | 433 | |
434 | - if($this->do_debug >= 2) { |
|
435 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
434 | + if ($this->do_debug >= 2) { |
|
435 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
436 | 436 | } |
437 | 437 | |
438 | - if($code != 250) { |
|
438 | + if ($code != 250) { |
|
439 | 439 | $this->error = |
440 | 440 | array("error" => "DATA not accepted from server", |
441 | 441 | "smtp_code" => $code, |
442 | - "smtp_msg" => substr($rply,4)); |
|
443 | - if($this->do_debug >= 1) { |
|
444 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
442 | + "smtp_msg" => substr($rply, 4)); |
|
443 | + if ($this->do_debug >= 1) { |
|
444 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
445 | 445 | } |
446 | 446 | return false; |
447 | 447 | } |
@@ -463,21 +463,21 @@ discard block |
||
463 | 463 | public function Hello($host = '') { |
464 | 464 | $this->error = null; // so no confusion is caused |
465 | 465 | |
466 | - if(!$this->connected()) { |
|
466 | + if (!$this->connected()) { |
|
467 | 467 | $this->error = array( |
468 | 468 | "error" => "Called Hello() without being connected"); |
469 | 469 | return false; |
470 | 470 | } |
471 | 471 | |
472 | 472 | // if hostname for HELO was not specified send default |
473 | - if(empty($host)) { |
|
473 | + if (empty($host)) { |
|
474 | 474 | // determine appropriate default to send to server |
475 | 475 | $host = "localhost"; |
476 | 476 | } |
477 | 477 | |
478 | 478 | // Send extended hello first (RFC 2821) |
479 | - if(!$this->SendHello("EHLO", $host)) { |
|
480 | - if(!$this->SendHello("HELO", $host)) { |
|
479 | + if (!$this->SendHello("EHLO", $host)) { |
|
480 | + if (!$this->SendHello("HELO", $host)) { |
|
481 | 481 | return false; |
482 | 482 | } |
483 | 483 | } |
@@ -491,22 +491,22 @@ discard block |
||
491 | 491 | * @return bool |
492 | 492 | */ |
493 | 493 | private function SendHello($hello, $host) { |
494 | - fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); |
|
494 | + fputs($this->smtp_conn, $hello." ".$host.$this->CRLF); |
|
495 | 495 | |
496 | 496 | $rply = $this->get_lines(); |
497 | - $code = substr($rply,0,3); |
|
497 | + $code = substr($rply, 0, 3); |
|
498 | 498 | |
499 | - if($this->do_debug >= 2) { |
|
500 | - echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; |
|
499 | + if ($this->do_debug >= 2) { |
|
500 | + echo "SMTP -> FROM SERVER: ".$rply.$this->CRLF.'<br />'; |
|
501 | 501 | } |
502 | 502 | |
503 | - if($code != 250) { |
|
503 | + if ($code != 250) { |
|
504 | 504 | $this->error = |
505 | - array("error" => $hello . " not accepted from server", |
|
505 | + array("error" => $hello." not accepted from server", |
|
506 | 506 | "smtp_code" => $code, |
507 | - "smtp_msg" => substr($rply,4)); |
|
508 | - if($this->do_debug >= 1) { |
|
509 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
507 | + "smtp_msg" => substr($rply, 4)); |
|
508 | + if ($this->do_debug >= 1) { |
|
509 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
510 | 510 | } |
511 | 511 | return false; |
512 | 512 | } |
@@ -533,29 +533,29 @@ discard block |
||
533 | 533 | public function Mail($from) { |
534 | 534 | $this->error = null; // so no confusion is caused |
535 | 535 | |
536 | - if(!$this->connected()) { |
|
536 | + if (!$this->connected()) { |
|
537 | 537 | $this->error = array( |
538 | 538 | "error" => "Called Mail() without being connected"); |
539 | 539 | return false; |
540 | 540 | } |
541 | 541 | |
542 | 542 | $useVerp = ($this->do_verp ? "XVERP" : ""); |
543 | - fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); |
|
543 | + fputs($this->smtp_conn, "MAIL FROM:<".$from.">".$useVerp.$this->CRLF); |
|
544 | 544 | |
545 | 545 | $rply = $this->get_lines(); |
546 | - $code = substr($rply,0,3); |
|
546 | + $code = substr($rply, 0, 3); |
|
547 | 547 | |
548 | - if($this->do_debug >= 2) { |
|
549 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
548 | + if ($this->do_debug >= 2) { |
|
549 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
550 | 550 | } |
551 | 551 | |
552 | - if($code != 250) { |
|
552 | + if ($code != 250) { |
|
553 | 553 | $this->error = |
554 | 554 | array("error" => "MAIL not accepted from server", |
555 | 555 | "smtp_code" => $code, |
556 | - "smtp_msg" => substr($rply,4)); |
|
557 | - if($this->do_debug >= 1) { |
|
558 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
556 | + "smtp_msg" => substr($rply, 4)); |
|
557 | + if ($this->do_debug >= 1) { |
|
558 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
559 | 559 | } |
560 | 560 | return false; |
561 | 561 | } |
@@ -576,38 +576,38 @@ discard block |
||
576 | 576 | public function Quit($close_on_error = true) { |
577 | 577 | $this->error = null; // so there is no confusion |
578 | 578 | |
579 | - if(!$this->connected()) { |
|
579 | + if (!$this->connected()) { |
|
580 | 580 | $this->error = array( |
581 | 581 | "error" => "Called Quit() without being connected"); |
582 | 582 | return false; |
583 | 583 | } |
584 | 584 | |
585 | 585 | // send the quit command to the server |
586 | - fputs($this->smtp_conn,"quit" . $this->CRLF); |
|
586 | + fputs($this->smtp_conn, "quit".$this->CRLF); |
|
587 | 587 | |
588 | 588 | // get any good-bye messages |
589 | 589 | $byemsg = $this->get_lines(); |
590 | 590 | |
591 | - if($this->do_debug >= 2) { |
|
592 | - echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />'; |
|
591 | + if ($this->do_debug >= 2) { |
|
592 | + echo "SMTP -> FROM SERVER:".$byemsg.$this->CRLF.'<br />'; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | $rval = true; |
596 | 596 | $e = null; |
597 | 597 | |
598 | - $code = substr($byemsg,0,3); |
|
599 | - if($code != 221) { |
|
598 | + $code = substr($byemsg, 0, 3); |
|
599 | + if ($code != 221) { |
|
600 | 600 | // use e as a tmp var cause Close will overwrite $this->error |
601 | 601 | $e = array("error" => "SMTP server rejected quit command", |
602 | 602 | "smtp_code" => $code, |
603 | - "smtp_rply" => substr($byemsg,4)); |
|
603 | + "smtp_rply" => substr($byemsg, 4)); |
|
604 | 604 | $rval = false; |
605 | - if($this->do_debug >= 1) { |
|
606 | - echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />'; |
|
605 | + if ($this->do_debug >= 1) { |
|
606 | + echo "SMTP -> ERROR: ".$e["error"].": ".$byemsg.$this->CRLF.'<br />'; |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | - if(empty($e) || $close_on_error) { |
|
610 | + if (empty($e) || $close_on_error) { |
|
611 | 611 | $this->Close(); |
612 | 612 | } |
613 | 613 | |
@@ -629,28 +629,28 @@ discard block |
||
629 | 629 | public function Recipient($to) { |
630 | 630 | $this->error = null; // so no confusion is caused |
631 | 631 | |
632 | - if(!$this->connected()) { |
|
632 | + if (!$this->connected()) { |
|
633 | 633 | $this->error = array( |
634 | 634 | "error" => "Called Recipient() without being connected"); |
635 | 635 | return false; |
636 | 636 | } |
637 | 637 | |
638 | - fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); |
|
638 | + fputs($this->smtp_conn, "RCPT TO:<".$to.">".$this->CRLF); |
|
639 | 639 | |
640 | 640 | $rply = $this->get_lines(); |
641 | - $code = substr($rply,0,3); |
|
641 | + $code = substr($rply, 0, 3); |
|
642 | 642 | |
643 | - if($this->do_debug >= 2) { |
|
644 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
643 | + if ($this->do_debug >= 2) { |
|
644 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
645 | 645 | } |
646 | 646 | |
647 | - if($code != 250 && $code != 251) { |
|
647 | + if ($code != 250 && $code != 251) { |
|
648 | 648 | $this->error = |
649 | 649 | array("error" => "RCPT not accepted from server", |
650 | 650 | "smtp_code" => $code, |
651 | - "smtp_msg" => substr($rply,4)); |
|
652 | - if($this->do_debug >= 1) { |
|
653 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
651 | + "smtp_msg" => substr($rply, 4)); |
|
652 | + if ($this->do_debug >= 1) { |
|
653 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
654 | 654 | } |
655 | 655 | return false; |
656 | 656 | } |
@@ -672,28 +672,28 @@ discard block |
||
672 | 672 | public function Reset() { |
673 | 673 | $this->error = null; // so no confusion is caused |
674 | 674 | |
675 | - if(!$this->connected()) { |
|
675 | + if (!$this->connected()) { |
|
676 | 676 | $this->error = array( |
677 | 677 | "error" => "Called Reset() without being connected"); |
678 | 678 | return false; |
679 | 679 | } |
680 | 680 | |
681 | - fputs($this->smtp_conn,"RSET" . $this->CRLF); |
|
681 | + fputs($this->smtp_conn, "RSET".$this->CRLF); |
|
682 | 682 | |
683 | 683 | $rply = $this->get_lines(); |
684 | - $code = substr($rply,0,3); |
|
684 | + $code = substr($rply, 0, 3); |
|
685 | 685 | |
686 | - if($this->do_debug >= 2) { |
|
687 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
686 | + if ($this->do_debug >= 2) { |
|
687 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
688 | 688 | } |
689 | 689 | |
690 | - if($code != 250) { |
|
690 | + if ($code != 250) { |
|
691 | 691 | $this->error = |
692 | 692 | array("error" => "RSET failed", |
693 | 693 | "smtp_code" => $code, |
694 | - "smtp_msg" => substr($rply,4)); |
|
695 | - if($this->do_debug >= 1) { |
|
696 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
694 | + "smtp_msg" => substr($rply, 4)); |
|
695 | + if ($this->do_debug >= 1) { |
|
696 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
697 | 697 | } |
698 | 698 | return false; |
699 | 699 | } |
@@ -720,28 +720,28 @@ discard block |
||
720 | 720 | public function SendAndMail($from) { |
721 | 721 | $this->error = null; // so no confusion is caused |
722 | 722 | |
723 | - if(!$this->connected()) { |
|
723 | + if (!$this->connected()) { |
|
724 | 724 | $this->error = array( |
725 | 725 | "error" => "Called SendAndMail() without being connected"); |
726 | 726 | return false; |
727 | 727 | } |
728 | 728 | |
729 | - fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); |
|
729 | + fputs($this->smtp_conn, "SAML FROM:".$from.$this->CRLF); |
|
730 | 730 | |
731 | 731 | $rply = $this->get_lines(); |
732 | - $code = substr($rply,0,3); |
|
732 | + $code = substr($rply, 0, 3); |
|
733 | 733 | |
734 | - if($this->do_debug >= 2) { |
|
735 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
734 | + if ($this->do_debug >= 2) { |
|
735 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
736 | 736 | } |
737 | 737 | |
738 | - if($code != 250) { |
|
738 | + if ($code != 250) { |
|
739 | 739 | $this->error = |
740 | 740 | array("error" => "SAML not accepted from server", |
741 | 741 | "smtp_code" => $code, |
742 | - "smtp_msg" => substr($rply,4)); |
|
743 | - if($this->do_debug >= 1) { |
|
744 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
742 | + "smtp_msg" => substr($rply, 4)); |
|
743 | + if ($this->do_debug >= 1) { |
|
744 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
745 | 745 | } |
746 | 746 | return false; |
747 | 747 | } |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | public function Turn() { |
765 | 765 | $this->error = array("error" => "This method, TURN, of the SMTP ". |
766 | 766 | "is not implemented"); |
767 | - if($this->do_debug >= 1) { |
|
768 | - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />'; |
|
767 | + if ($this->do_debug >= 1) { |
|
768 | + echo "SMTP -> NOTICE: ".$this->error["error"].$this->CRLF.'<br />'; |
|
769 | 769 | } |
770 | 770 | return false; |
771 | 771 | } |
@@ -794,17 +794,17 @@ discard block |
||
794 | 794 | */ |
795 | 795 | private function get_lines() { |
796 | 796 | $data = ""; |
797 | - while($str = @fgets($this->smtp_conn,515)) { |
|
798 | - if($this->do_debug >= 4) { |
|
799 | - echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />'; |
|
800 | - echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />'; |
|
797 | + while ($str = @fgets($this->smtp_conn, 515)) { |
|
798 | + if ($this->do_debug >= 4) { |
|
799 | + echo "SMTP -> get_lines(): \$data was \"$data\"".$this->CRLF.'<br />'; |
|
800 | + echo "SMTP -> get_lines(): \$str is \"$str\"".$this->CRLF.'<br />'; |
|
801 | 801 | } |
802 | 802 | $data .= $str; |
803 | - if($this->do_debug >= 4) { |
|
804 | - echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />'; |
|
803 | + if ($this->do_debug >= 4) { |
|
804 | + echo "SMTP -> get_lines(): \$data is \"$data\"".$this->CRLF.'<br />'; |
|
805 | 805 | } |
806 | 806 | // if 4th character is a space, we are done reading, break the loop |
807 | - if(substr($str,3,1) == " ") { break; } |
|
807 | + if (substr($str, 3, 1) == " ") { break; } |
|
808 | 808 | } |
809 | 809 | return $data; |
810 | 810 | } |
@@ -143,8 +143,9 @@ |
||
143 | 143 | |
144 | 144 | // SMTP server can take longer to respond, give longer timeout for first read |
145 | 145 | // Windows does not have support for this timeout function |
146 | - if(substr(PHP_OS, 0, 3) != "WIN") |
|
147 | - socket_set_timeout($this->smtp_conn, $tval, 0); |
|
146 | + if(substr(PHP_OS, 0, 3) != "WIN") { |
|
147 | + socket_set_timeout($this->smtp_conn, $tval, 0); |
|
148 | + } |
|
148 | 149 | |
149 | 150 | // get any announcement |
150 | 151 | $announce = $this->get_lines(); |
@@ -172,6 +172,7 @@ discard block |
||
172 | 172 | * CRYPT_AES_MODE_ECB or CRYPT_AES_MODE_CBC. If not explictly set, CRYPT_AES_MODE_CBC will be used. |
173 | 173 | * |
174 | 174 | * @param optional Integer $mode |
175 | + * @param integer $mode |
|
175 | 176 | * @return Crypt_AES |
176 | 177 | * @access public |
177 | 178 | */ |
@@ -288,6 +289,7 @@ discard block |
||
288 | 289 | * @see Crypt_AES::decrypt() |
289 | 290 | * @access public |
290 | 291 | * @param String $plaintext |
292 | + * @return string |
|
291 | 293 | */ |
292 | 294 | function encrypt($plaintext) |
293 | 295 | { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | function Crypt_AES($mode = CRYPT_AES_MODE_CBC) |
179 | 179 | { |
180 | - if ( !defined('CRYPT_AES_MODE') ) { |
|
180 | + if (!defined('CRYPT_AES_MODE')) { |
|
181 | 181 | switch (true) { |
182 | 182 | case extension_loaded('mcrypt') && in_array('rijndael-128', mcrypt_list_algorithms()): |
183 | 183 | define('CRYPT_AES_MODE', CRYPT_AES_MODE_MCRYPT); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - switch ( CRYPT_AES_MODE ) { |
|
190 | + switch (CRYPT_AES_MODE) { |
|
191 | 191 | case CRYPT_AES_MODE_MCRYPT: |
192 | 192 | switch ($mode) { |
193 | 193 | case CRYPT_AES_MODE_ECB: |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | function setIV($iv) |
268 | 268 | { |
269 | 269 | parent::setIV($iv); |
270 | - if ( CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT ) { |
|
270 | + if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) { |
|
271 | 271 | $this->changed = true; |
272 | 272 | } |
273 | 273 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | function encrypt($plaintext) |
293 | 293 | { |
294 | - if ( CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT ) { |
|
294 | + if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) { |
|
295 | 295 | $this->_mcryptSetup(); |
296 | 296 | |
297 | 297 | // re: http://phpseclib.sourceforge.net/cfb-demo.phps |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | $max = 16 - $pos; |
309 | 309 | if ($len >= $max) { |
310 | 310 | $i = $max; |
311 | - $len-= $max; |
|
311 | + $len -= $max; |
|
312 | 312 | $pos = 0; |
313 | 313 | } else { |
314 | 314 | $i = $len; |
315 | - $pos+= $len; |
|
315 | + $pos += $len; |
|
316 | 316 | $len = 0; |
317 | 317 | } |
318 | 318 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -325,15 +325,15 @@ discard block |
||
325 | 325 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
326 | 326 | $this->enbuffer['enmcrypt_init'] = false; |
327 | 327 | } |
328 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 16)); |
|
328 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 16)); |
|
329 | 329 | $iv = substr($ciphertext, -16); |
330 | - $len%= 16; |
|
330 | + $len %= 16; |
|
331 | 331 | } else { |
332 | 332 | while ($len >= 16) { |
333 | 333 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 16); |
334 | - $ciphertext.= $iv; |
|
335 | - $len-= 16; |
|
336 | - $i+= 16; |
|
334 | + $ciphertext .= $iv; |
|
335 | + $len -= 16; |
|
336 | + $i += 16; |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $iv = mcrypt_generic($this->ecb, $iv); |
343 | 343 | $block = $iv ^ substr($plaintext, -$len); |
344 | 344 | $iv = substr_replace($iv, $block, 0, $len); |
345 | - $ciphertext.= $block; |
|
345 | + $ciphertext .= $block; |
|
346 | 346 | $pos = $len; |
347 | 347 | } |
348 | 348 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | function decrypt($ciphertext) |
378 | 378 | { |
379 | - if ( CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT ) { |
|
379 | + if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) { |
|
380 | 380 | $this->_mcryptSetup(); |
381 | 381 | |
382 | 382 | if ($this->mode == 'ncfb' && $this->continuousBuffer) { |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | $max = 16 - $pos; |
391 | 391 | if ($len >= $max) { |
392 | 392 | $i = $max; |
393 | - $len-= $max; |
|
393 | + $len -= $max; |
|
394 | 394 | $pos = 0; |
395 | 395 | } else { |
396 | 396 | $i = $len; |
397 | - $pos+= $len; |
|
397 | + $pos += $len; |
|
398 | 398 | $len = 0; |
399 | 399 | } |
400 | 400 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize |
@@ -403,13 +403,13 @@ discard block |
||
403 | 403 | } |
404 | 404 | if ($len >= 16) { |
405 | 405 | $cb = substr($ciphertext, $i, $len - $len % 16); |
406 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
406 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
407 | 407 | $iv = substr($cb, -16); |
408 | - $len%= 16; |
|
408 | + $len %= 16; |
|
409 | 409 | } |
410 | 410 | if ($len) { |
411 | 411 | $iv = mcrypt_generic($this->ecb, $iv); |
412 | - $plaintext.= $iv ^ substr($ciphertext, -$len); |
|
412 | + $plaintext .= $iv ^ substr($ciphertext, -$len); |
|
413 | 413 | $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); |
414 | 414 | $pos = $len; |
415 | 415 | } |
@@ -465,6 +465,7 @@ discard block |
||
465 | 465 | * If not explictly set, CRYPT_BLOWFISH_MODE_CBC will be used. |
466 | 466 | * |
467 | 467 | * @param optional Integer $mode |
468 | + * @param integer $mode |
|
468 | 469 | * @access public |
469 | 470 | */ |
470 | 471 | function Crypt_Blowfish($mode = CRYPT_BLOWFISH_MODE_CBC) |
@@ -959,6 +960,7 @@ discard block |
||
959 | 960 | * |
960 | 961 | * @see Crypt_Blowfish::_unpad() |
961 | 962 | * @access private |
963 | + * @param string $text |
|
962 | 964 | */ |
963 | 965 | function _pad($text) |
964 | 966 | { |
@@ -986,6 +988,7 @@ discard block |
||
986 | 988 | * |
987 | 989 | * @see Crypt_Blowfish::_pad() |
988 | 990 | * @access private |
991 | + * @param string $text |
|
989 | 992 | */ |
990 | 993 | function _unpad($text) |
991 | 994 | { |
@@ -625,13 +625,13 @@ |
||
625 | 625 | $l^= $p[++$i]; |
626 | 626 | $r^= ($sb_0[$l >> 24 & 0xff] + |
627 | 627 | $sb_1[$l >> 16 & 0xff] ^ |
628 | - $sb_2[$l >> 8 & 0xff]) + |
|
628 | + $sb_2[$l >> 8 & 0xff]) + |
|
629 | 629 | $sb_3[$l & 0xff]; |
630 | 630 | |
631 | 631 | $r^= $p[++$i]; |
632 | 632 | $l^= ($sb_0[$r >> 24 & 0xff] + |
633 | 633 | $sb_1[$r >> 16 & 0xff] ^ |
634 | - $sb_2[$r >> 8 & 0xff]) + |
|
634 | + $sb_2[$r >> 8 & 0xff]) + |
|
635 | 635 | $sb_3[$r & 0xff]; |
636 | 636 | |
637 | 637 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @access private |
279 | 279 | * @var array |
280 | 280 | */ |
281 | - var $sbox0 = array ( |
|
281 | + var $sbox0 = array( |
|
282 | 282 | 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, |
283 | 283 | 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, |
284 | 284 | 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | */ |
470 | 470 | function Crypt_Blowfish($mode = CRYPT_BLOWFISH_MODE_CBC) |
471 | 471 | { |
472 | - if ( !defined('CRYPT_BLOWFISH_MODE') ) { |
|
472 | + if (!defined('CRYPT_BLOWFISH_MODE')) { |
|
473 | 473 | switch (true) { |
474 | 474 | case extension_loaded('mcrypt') && in_array('blowfish', mcrypt_list_algorithms()): |
475 | 475 | define('CRYPT_BLOWFISH_MODE', CRYPT_BLOWFISH_MODE_MCRYPT); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | - switch ( CRYPT_BLOWFISH_MODE ) { |
|
482 | + switch (CRYPT_BLOWFISH_MODE) { |
|
483 | 483 | case CRYPT_BLOWFISH_MODE_MCRYPT: |
484 | 484 | switch ($mode) { |
485 | 485 | case CRYPT_BLOWFISH_MODE_ECB: |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | $datar = 0; |
591 | 591 | for ($i = 0; $i < 18; $i += 2) { |
592 | 592 | $this->_encryptBlock($datal, $datar); |
593 | - $this->bctx['p'][$i ] = $datal; |
|
593 | + $this->bctx['p'][$i] = $datal; |
|
594 | 594 | $this->bctx['p'][$i + 1] = $datar; |
595 | 595 | } |
596 | 596 | for ($i = 0; $i < 4; ++$i) { |
597 | 597 | for ($j = 0; $j < 256; $j += 2) { |
598 | 598 | $this->_encryptBlock($datal, $datar); |
599 | - $this->bctx['sb'][$i][$j ] = $datal; |
|
599 | + $this->bctx['sb'][$i][$j] = $datal; |
|
600 | 600 | $this->bctx['sb'][$i][$j + 1] = $datar; |
601 | 601 | } |
602 | 602 | } |
@@ -622,17 +622,17 @@ discard block |
||
622 | 622 | |
623 | 623 | $i = -1; |
624 | 624 | while ($i < 15) { |
625 | - $l^= $p[++$i]; |
|
626 | - $r^= ($sb_0[$l >> 24 & 0xff] + |
|
627 | - $sb_1[$l >> 16 & 0xff] ^ |
|
628 | - $sb_2[$l >> 8 & 0xff]) + |
|
629 | - $sb_3[$l & 0xff]; |
|
630 | - |
|
631 | - $r^= $p[++$i]; |
|
632 | - $l^= ($sb_0[$r >> 24 & 0xff] + |
|
633 | - $sb_1[$r >> 16 & 0xff] ^ |
|
634 | - $sb_2[$r >> 8 & 0xff]) + |
|
635 | - $sb_3[$r & 0xff]; |
|
625 | + $l ^= $p[++$i]; |
|
626 | + $r ^= ($sb_0[$l >> 24 & 0xff] + |
|
627 | + $sb_1[$l >> 16 & 0xff] ^ |
|
628 | + $sb_2[$l >> 8 & 0xff]) + |
|
629 | + $sb_3[$l & 0xff]; |
|
630 | + |
|
631 | + $r ^= $p[++$i]; |
|
632 | + $l ^= ($sb_0[$r >> 24 & 0xff] + |
|
633 | + $sb_1[$r >> 16 & 0xff] ^ |
|
634 | + $sb_2[$r >> 8 & 0xff]) + |
|
635 | + $sb_3[$r & 0xff]; |
|
636 | 636 | |
637 | 637 | } |
638 | 638 | $Xr = $l ^ $p[16]; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | |
657 | 657 | switch ($method) { |
658 | 658 | default: // 'pbkdf2' |
659 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
659 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
660 | 660 | if (!isset($hash)) { |
661 | 661 | $hash = 'sha1'; |
662 | 662 | } |
@@ -680,12 +680,12 @@ discard block |
||
680 | 680 | $hmac = new Crypt_Hash(); |
681 | 681 | $hmac->setHash($hash); |
682 | 682 | $hmac->setKey($password); |
683 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
683 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
684 | 684 | for ($j = 2; $j <= $count; $j++) { |
685 | 685 | $u = $hmac->hash($u); |
686 | - $f^= $u; |
|
686 | + $f ^= $u; |
|
687 | 687 | } |
688 | - $key.= $f; |
|
688 | + $key .= $f; |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | */ |
728 | 728 | function encrypt($plaintext) |
729 | 729 | { |
730 | - if ( CRYPT_BLOWFISH_MODE == CRYPT_BLOWFISH_MODE_MCRYPT ) { |
|
730 | + if (CRYPT_BLOWFISH_MODE == CRYPT_BLOWFISH_MODE_MCRYPT) { |
|
731 | 731 | if ($this->paddable) { |
732 | 732 | $plaintext = $this->_pad($plaintext); |
733 | 733 | } |
@@ -753,11 +753,11 @@ discard block |
||
753 | 753 | $max = 8 - $pos; |
754 | 754 | if ($len >= $max) { |
755 | 755 | $i = $max; |
756 | - $len-= $max; |
|
756 | + $len -= $max; |
|
757 | 757 | $pos = 0; |
758 | 758 | } else { |
759 | 759 | $i = $len; |
760 | - $pos+= $len; |
|
760 | + $pos += $len; |
|
761 | 761 | $len = 0; |
762 | 762 | } |
763 | 763 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -770,15 +770,15 @@ discard block |
||
770 | 770 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
771 | 771 | $this->enbuffer['enmcrypt_init'] = false; |
772 | 772 | } |
773 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
773 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
774 | 774 | $iv = substr($ciphertext, -8); |
775 | - $len%= 8; |
|
775 | + $len %= 8; |
|
776 | 776 | } else { |
777 | 777 | while ($len >= 8) { |
778 | 778 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 8); |
779 | - $ciphertext.= $iv; |
|
780 | - $len-= 8; |
|
781 | - $i+= 8; |
|
779 | + $ciphertext .= $iv; |
|
780 | + $len -= 8; |
|
781 | + $i += 8; |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 | } |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | $iv = mcrypt_generic($this->ecb, $iv); |
787 | 787 | $block = $iv ^ substr($plaintext, -$len); |
788 | 788 | $iv = substr_replace($iv, $block, 0, $len); |
789 | - $ciphertext.= $block; |
|
789 | + $ciphertext .= $block; |
|
790 | 790 | $pos = $len; |
791 | 791 | } |
792 | 792 | return $ciphertext; |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | */ |
819 | 819 | function decrypt($ciphertext) |
820 | 820 | { |
821 | - if ( CRYPT_BLOWFISH_MODE == CRYPT_BLOWFISH_MODE_MCRYPT ) { |
|
821 | + if (CRYPT_BLOWFISH_MODE == CRYPT_BLOWFISH_MODE_MCRYPT) { |
|
822 | 822 | if ($this->paddable) { |
823 | 823 | // we pad with chr(0) since that's what mcrypt_generic does. to quote from http://php.net/function.mcrypt-generic : |
824 | 824 | // "The data is padded with "\0" to make sure the length of the data is n * blocksize." |
@@ -846,11 +846,11 @@ discard block |
||
846 | 846 | $max = 8 - $pos; |
847 | 847 | if ($len >= $max) { |
848 | 848 | $i = $max; |
849 | - $len-= $max; |
|
849 | + $len -= $max; |
|
850 | 850 | $pos = 0; |
851 | 851 | } else { |
852 | 852 | $i = $len; |
853 | - $pos+= $len; |
|
853 | + $pos += $len; |
|
854 | 854 | $len = 0; |
855 | 855 | } |
856 | 856 | $plaintext = substr($iv, $orig_pos) ^ $ciphertext; |
@@ -858,13 +858,13 @@ discard block |
||
858 | 858 | } |
859 | 859 | if ($len >= 8) { |
860 | 860 | $cb = substr($ciphertext, $i, $len - $len % 8); |
861 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
861 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
862 | 862 | $iv = substr($cb, -8); |
863 | - $len%= 8; |
|
863 | + $len %= 8; |
|
864 | 864 | } |
865 | 865 | if ($len) { |
866 | 866 | $iv = mcrypt_generic($this->ecb, $iv); |
867 | - $plaintext.= $iv ^ substr($ciphertext, -$len); |
|
867 | + $plaintext .= $iv ^ substr($ciphertext, -$len); |
|
868 | 868 | $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); |
869 | 869 | $pos = $len; |
870 | 870 | } |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | function _generate_xor(&$iv) |
1033 | 1033 | { |
1034 | 1034 | $xor = $iv; |
1035 | - for ($j = 4; $j <= 8; $j+=4) { |
|
1035 | + for ($j = 4; $j <= 8; $j += 4) { |
|
1036 | 1036 | $temp = substr($iv, -$j, 4); |
1037 | 1037 | switch ($temp) { |
1038 | 1038 | case "\xFF\xFF\xFF\xFF": |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | */ |
1059 | 1059 | function inline_crypt_setup() |
1060 | 1060 | {/*{{{*/ |
1061 | - $lambda_functions =& Crypt_Blowfish::get_lambda_functions(); |
|
1061 | + $lambda_functions = & Crypt_Blowfish::get_lambda_functions(); |
|
1062 | 1062 | $block_size = 8; |
1063 | 1063 | $mode = $this->mode; |
1064 | 1064 | $code_hash = "$mode"; |
@@ -1075,8 +1075,8 @@ discard block |
||
1075 | 1075 | $l = $in[1]; |
1076 | 1076 | $r = $in[2]; |
1077 | 1077 | '; |
1078 | - for ($i = 0; $i < 16; $i+= 2) { |
|
1079 | - $_encryptBlock.= ' |
|
1078 | + for ($i = 0; $i < 16; $i += 2) { |
|
1079 | + $_encryptBlock .= ' |
|
1080 | 1080 | $l^= $p_'.($i).'; |
1081 | 1081 | $r^= ($sb_0[$l >> 24 & 0xff] + |
1082 | 1082 | $sb_1[$l >> 16 & 0xff] ^ |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | $sb_3[$r & 0xff]; |
1091 | 1091 | '; |
1092 | 1092 | } |
1093 | - $_encryptBlock.= ' |
|
1093 | + $_encryptBlock .= ' |
|
1094 | 1094 | $in = pack("N*", $r ^ $p_17, $l ^ $p_16); |
1095 | 1095 | '; |
1096 | 1096 | |
@@ -1101,8 +1101,8 @@ discard block |
||
1101 | 1101 | $r = $in[2]; |
1102 | 1102 | '; |
1103 | 1103 | |
1104 | - for ($i = 17; $i > 2; $i-= 2) { |
|
1105 | - $_decryptBlock.= ' |
|
1104 | + for ($i = 17; $i > 2; $i -= 2) { |
|
1105 | + $_decryptBlock .= ' |
|
1106 | 1106 | $l^= $p_'.($i).'; |
1107 | 1107 | $r^= ($sb_0[$l >> 24 & 0xff] + |
1108 | 1108 | $sb_1[$l >> 16 & 0xff] ^ |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | '; |
1118 | 1118 | } |
1119 | 1119 | |
1120 | - $_decryptBlock.= ' |
|
1120 | + $_decryptBlock .= ' |
|
1121 | 1121 | $in = pack("N*", $r ^ $p_0, $l ^ $p_1); |
1122 | 1122 | '; |
1123 | 1123 | |
@@ -1439,12 +1439,12 @@ discard block |
||
1439 | 1439 | break; |
1440 | 1440 | } |
1441 | 1441 | $fnc_head = '$action, &$self, $text'; |
1442 | - $fnc_body = $init_cryptBlock . 'if ($action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' }'; |
|
1442 | + $fnc_body = $init_cryptBlock.'if ($action == "encrypt") { '.$encrypt.' } else { '.$decrypt.' }'; |
|
1443 | 1443 | |
1444 | 1444 | if (function_exists('create_function') && is_callable('create_function')) { |
1445 | 1445 | $lambda_functions[$code_hash] = create_function($fnc_head, $fnc_body); |
1446 | 1446 | } else { |
1447 | - eval('function ' . ($lambda_functions[$code_hash] = 'f' . md5(microtime())) . '(' . $fnc_head . ') { ' . $fnc_body . ' }'); |
|
1447 | + eval('function '.($lambda_functions[$code_hash] = 'f'.md5(microtime())).'('.$fnc_head.') { '.$fnc_body.' }'); |
|
1448 | 1448 | } |
1449 | 1449 | } |
1450 | 1450 | $this->inline_crypt = $lambda_functions[$code_hash]; |
@@ -545,8 +545,7 @@ |
||
545 | 545 | |
546 | 546 | if (!$keylength) { |
547 | 547 | $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
548 | - } |
|
549 | - elseif ($keylength > 56) { |
|
548 | + } elseif ($keylength > 56) { |
|
550 | 549 | $key = substr($key, 0, 56); |
551 | 550 | } |
552 | 551 |
@@ -742,6 +742,7 @@ discard block |
||
742 | 742 | * CRYPT_DES_MODE_ECB or CRYPT_DES_MODE_CBC. If not explictly set, CRYPT_DES_MODE_CBC will be used. |
743 | 743 | * |
744 | 744 | * @param optional Integer $mode |
745 | + * @param integer $mode |
|
745 | 746 | * @return Crypt_DES |
746 | 747 | * @access public |
747 | 748 | */ |
@@ -1445,6 +1446,7 @@ discard block |
||
1445 | 1446 | * |
1446 | 1447 | * @see Crypt_DES::_unpad() |
1447 | 1448 | * @access private |
1449 | + * @param string $text |
|
1448 | 1450 | */ |
1449 | 1451 | function _pad($text) |
1450 | 1452 | { |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | if ($this->continuousBuffer) { |
1138 | 1138 | $this->encryptIV = $xor; |
1139 | 1139 | if ($start = strlen($plaintext) & 7) { |
1140 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1140 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1141 | 1141 | } |
1142 | 1142 | } |
1143 | 1143 | } |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | if ($this->continuousBuffer) { |
1333 | 1333 | $this->decryptIV = $xor; |
1334 | 1334 | if ($start = strlen($ciphertext) % 8) { |
1335 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1335 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1336 | 1336 | } |
1337 | 1337 | } |
1338 | 1338 | } |
@@ -1518,13 +1518,13 @@ discard block |
||
1518 | 1518 | $t = unpack('Nl/Nr', $block); |
1519 | 1519 | list($l, $r) = array($t['l'], $t['r']); |
1520 | 1520 | $block = ($shuffle[$ipmap[$r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
1521 | - ($shuffle[$ipmap[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
1522 | - ($shuffle[$ipmap[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
1523 | - ($shuffle[$ipmap[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
1524 | - ($shuffle[$ipmap[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
1525 | - ($shuffle[$ipmap[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
1526 | - ($shuffle[$ipmap[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
1527 | - ($shuffle[$ipmap[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
1521 | + ($shuffle[$ipmap[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
1522 | + ($shuffle[$ipmap[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
1523 | + ($shuffle[$ipmap[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
1524 | + ($shuffle[$ipmap[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
1525 | + ($shuffle[$ipmap[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
1526 | + ($shuffle[$ipmap[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
1527 | + ($shuffle[$ipmap[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
1528 | 1528 | |
1529 | 1529 | // Extract L0 and R0. |
1530 | 1530 | $t = unpack('Nl/Nr', $block); |
@@ -1540,9 +1540,9 @@ discard block |
||
1540 | 1540 | |
1541 | 1541 | // S-box indexing. |
1542 | 1542 | $t = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
1543 | - $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
|
1544 | - $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
1545 | - $sbox7[$b1 & 0x3F] ^ $sbox8[$b2 & 0x3F] ^ $l; |
|
1543 | + $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
|
1544 | + $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
1545 | + $sbox7[$b1 & 0x3F] ^ $sbox8[$b2 & 0x3F] ^ $l; |
|
1546 | 1546 | // end of "the Feistel (F) function" |
1547 | 1547 | |
1548 | 1548 | $l = $r; |
@@ -1551,13 +1551,13 @@ discard block |
||
1551 | 1551 | |
1552 | 1552 | // Perform the inverse IP permutation. |
1553 | 1553 | return ($shuffle[$invipmap[($l >> 24) & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
1554 | - ($shuffle[$invipmap[($r >> 24) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
1555 | - ($shuffle[$invipmap[($l >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
1556 | - ($shuffle[$invipmap[($r >> 16) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
1557 | - ($shuffle[$invipmap[($l >> 8) & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
1558 | - ($shuffle[$invipmap[($r >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
1559 | - ($shuffle[$invipmap[$l & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
1560 | - ($shuffle[$invipmap[$r & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
1554 | + ($shuffle[$invipmap[($r >> 24) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
1555 | + ($shuffle[$invipmap[($l >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
1556 | + ($shuffle[$invipmap[($r >> 16) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
1557 | + ($shuffle[$invipmap[($l >> 8) & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
1558 | + ($shuffle[$invipmap[($r >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
1559 | + ($shuffle[$invipmap[$l & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
1560 | + ($shuffle[$invipmap[$r & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | /** |
@@ -2025,13 +2025,13 @@ discard block |
||
2025 | 2025 | $t = unpack('Nl/Nr', $key); |
2026 | 2026 | list($l, $r) = array($t['l'], $t['r']); |
2027 | 2027 | $key = ($this->shuffle[$pc1map[$r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | |
2028 | - ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
2029 | - ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
|
2030 | - ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
|
2031 | - ($this->shuffle[$pc1map[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
2032 | - ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
2033 | - ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
|
2034 | - ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
|
2028 | + ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
2029 | + ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
|
2030 | + ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
|
2031 | + ($this->shuffle[$pc1map[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
2032 | + ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
2033 | + ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
|
2034 | + ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
|
2035 | 2035 | $key = unpack('Nc/Nd', $key); |
2036 | 2036 | $c = ($key['c'] >> 4) & 0x0FFFFFFF; |
2037 | 2037 | $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F); |
@@ -2045,9 +2045,9 @@ discard block |
||
2045 | 2045 | |
2046 | 2046 | // Perform the PC-2 transformation. |
2047 | 2047 | $cp = $pc2mapc1[$c >> 24] | $pc2mapc2[($c >> 16) & 0xFF] | |
2048 | - $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[$c & 0xFF]; |
|
2048 | + $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[$c & 0xFF]; |
|
2049 | 2049 | $dp = $pc2mapd1[$d >> 24] | $pc2mapd2[($d >> 16) & 0xFF] | |
2050 | - $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[$d & 0xFF]; |
|
2050 | + $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[$d & 0xFF]; |
|
2051 | 2051 | |
2052 | 2052 | // Reorder: odd bytes/even bytes. Push the result in key schedule. |
2053 | 2053 | $keys[] = array( |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | */ |
748 | 748 | function Crypt_DES($mode = CRYPT_DES_MODE_CBC) |
749 | 749 | { |
750 | - if ( !defined('CRYPT_DES_MODE') ) { |
|
750 | + if (!defined('CRYPT_DES_MODE')) { |
|
751 | 751 | switch (true) { |
752 | 752 | case extension_loaded('mcrypt') && in_array('des', mcrypt_list_algorithms()): |
753 | 753 | define('CRYPT_DES_MODE', CRYPT_DES_MODE_MCRYPT); |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
760 | - switch ( CRYPT_DES_MODE ) { |
|
760 | + switch (CRYPT_DES_MODE) { |
|
761 | 761 | case CRYPT_DES_MODE_MCRYPT: |
762 | 762 | switch ($mode) { |
763 | 763 | case CRYPT_DES_MODE_ECB: |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | */ |
824 | 824 | function setKey($key) |
825 | 825 | { |
826 | - $this->keys = ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) ? str_pad(substr($key, 0, 8), 8, chr(0)) : $this->_prepareKey($key); |
|
826 | + $this->keys = (CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT) ? str_pad(substr($key, 0, 8), 8, chr(0)) : $this->_prepareKey($key); |
|
827 | 827 | $this->enchanged = true; |
828 | 828 | $this->dechanged = true; |
829 | 829 | } |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | |
846 | 846 | switch ($method) { |
847 | 847 | default: // 'pbkdf2' |
848 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
848 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
849 | 849 | if (!isset($hash)) { |
850 | 850 | $hash = 'sha1'; |
851 | 851 | } |
@@ -869,12 +869,12 @@ discard block |
||
869 | 869 | $hmac = new Crypt_Hash(); |
870 | 870 | $hmac->setHash($hash); |
871 | 871 | $hmac->setKey($password); |
872 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
872 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
873 | 873 | for ($j = 2; $j <= $count; $j++) { |
874 | 874 | $u = $hmac->hash($u); |
875 | - $f^= $u; |
|
875 | + $f ^= $u; |
|
876 | 876 | } |
877 | - $key.= $f; |
|
877 | + $key .= $f; |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | function _generate_xor(&$iv) |
912 | 912 | { |
913 | 913 | $xor = $iv; |
914 | - for ($j = 4; $j <= 8; $j+=4) { |
|
914 | + for ($j = 4; $j <= 8; $j += 4) { |
|
915 | 915 | $temp = substr($iv, -$j, 4); |
916 | 916 | switch ($temp) { |
917 | 917 | case "\xFF\xFF\xFF\xFF": |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | $plaintext = $this->_pad($plaintext); |
954 | 954 | } |
955 | 955 | |
956 | - if ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) { |
|
956 | + if (CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT) { |
|
957 | 957 | if ($this->enchanged) { |
958 | 958 | mcrypt_generic_init($this->enmcrypt, $this->keys, $this->encryptIV); |
959 | 959 | if ($this->mode == 'ncfb') { |
@@ -975,11 +975,11 @@ discard block |
||
975 | 975 | $max = 8 - $pos; |
976 | 976 | if ($len >= $max) { |
977 | 977 | $i = $max; |
978 | - $len-= $max; |
|
978 | + $len -= $max; |
|
979 | 979 | $pos = 0; |
980 | 980 | } else { |
981 | 981 | $i = $len; |
982 | - $pos+= $len; |
|
982 | + $pos += $len; |
|
983 | 983 | $len = 0; |
984 | 984 | } |
985 | 985 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -992,15 +992,15 @@ discard block |
||
992 | 992 | mcrypt_generic_init($this->enmcrypt, $this->keys, $iv); |
993 | 993 | $this->enbuffer['enmcrypt_init'] = false; |
994 | 994 | } |
995 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
995 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
996 | 996 | $iv = substr($ciphertext, -8); |
997 | - $len%= 8; |
|
997 | + $len %= 8; |
|
998 | 998 | } else { |
999 | 999 | while ($len >= 8) { |
1000 | 1000 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 8); |
1001 | - $ciphertext.= $iv; |
|
1002 | - $len-= 8; |
|
1003 | - $i+= 8; |
|
1001 | + $ciphertext .= $iv; |
|
1002 | + $len -= 8; |
|
1003 | + $i += 8; |
|
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | } |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $iv = mcrypt_generic($this->ecb, $iv); |
1009 | 1009 | $block = $iv ^ substr($plaintext, -$len); |
1010 | 1010 | $iv = substr_replace($iv, $block, 0, $len); |
1011 | - $ciphertext.= $block; |
|
1011 | + $ciphertext .= $block; |
|
1012 | 1012 | $pos = $len; |
1013 | 1013 | } |
1014 | 1014 | return $ciphertext; |
@@ -1035,17 +1035,17 @@ discard block |
||
1035 | 1035 | $ciphertext = ''; |
1036 | 1036 | switch ($this->mode) { |
1037 | 1037 | case CRYPT_DES_MODE_ECB: |
1038 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
1039 | - $ciphertext.= $this->_processBlock(substr($plaintext, $i, 8), CRYPT_DES_ENCRYPT); |
|
1038 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
1039 | + $ciphertext .= $this->_processBlock(substr($plaintext, $i, 8), CRYPT_DES_ENCRYPT); |
|
1040 | 1040 | } |
1041 | 1041 | break; |
1042 | 1042 | case CRYPT_DES_MODE_CBC: |
1043 | 1043 | $xor = $this->encryptIV; |
1044 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
1044 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
1045 | 1045 | $block = substr($plaintext, $i, 8); |
1046 | 1046 | $block = $this->_processBlock($block ^ $xor, CRYPT_DES_ENCRYPT); |
1047 | 1047 | $xor = $block; |
1048 | - $ciphertext.= $block; |
|
1048 | + $ciphertext .= $block; |
|
1049 | 1049 | } |
1050 | 1050 | if ($this->continuousBuffer) { |
1051 | 1051 | $this->encryptIV = $xor; |
@@ -1054,25 +1054,25 @@ discard block |
||
1054 | 1054 | case CRYPT_DES_MODE_CTR: |
1055 | 1055 | $xor = $this->encryptIV; |
1056 | 1056 | if (strlen($buffer['encrypted'])) { |
1057 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
1057 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
1058 | 1058 | $block = substr($plaintext, $i, 8); |
1059 | 1059 | if (strlen($block) > strlen($buffer['encrypted'])) { |
1060 | - $buffer['encrypted'].= $this->_processBlock($this->_generate_xor($xor), CRYPT_DES_ENCRYPT); |
|
1060 | + $buffer['encrypted'] .= $this->_processBlock($this->_generate_xor($xor), CRYPT_DES_ENCRYPT); |
|
1061 | 1061 | } |
1062 | 1062 | $key = $this->_string_shift($buffer['encrypted']); |
1063 | - $ciphertext.= $block ^ $key; |
|
1063 | + $ciphertext .= $block ^ $key; |
|
1064 | 1064 | } |
1065 | 1065 | } else { |
1066 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
1066 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
1067 | 1067 | $block = substr($plaintext, $i, 8); |
1068 | 1068 | $key = $this->_processBlock($this->_generate_xor($xor), CRYPT_DES_ENCRYPT); |
1069 | - $ciphertext.= $block ^ $key; |
|
1069 | + $ciphertext .= $block ^ $key; |
|
1070 | 1070 | } |
1071 | 1071 | } |
1072 | 1072 | if ($this->continuousBuffer) { |
1073 | 1073 | $this->encryptIV = $xor; |
1074 | 1074 | if ($start = strlen($plaintext) & 7) { |
1075 | - $buffer['encrypted'] = substr($key, $start) . $buffer['encrypted']; |
|
1075 | + $buffer['encrypted'] = substr($key, $start).$buffer['encrypted']; |
|
1076 | 1076 | } |
1077 | 1077 | } |
1078 | 1078 | break; |
@@ -1091,11 +1091,11 @@ discard block |
||
1091 | 1091 | $max = 8 - $pos; |
1092 | 1092 | if ($len >= $max) { |
1093 | 1093 | $i = $max; |
1094 | - $len-= $max; |
|
1094 | + $len -= $max; |
|
1095 | 1095 | $pos = 0; |
1096 | 1096 | } else { |
1097 | 1097 | $i = $len; |
1098 | - $pos+= $len; |
|
1098 | + $pos += $len; |
|
1099 | 1099 | $len = 0; |
1100 | 1100 | } |
1101 | 1101 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -1103,41 +1103,41 @@ discard block |
||
1103 | 1103 | } |
1104 | 1104 | while ($len >= 8) { |
1105 | 1105 | $iv = $this->_processBlock($iv, CRYPT_DES_ENCRYPT) ^ substr($plaintext, $i, 8); |
1106 | - $ciphertext.= $iv; |
|
1107 | - $len-= 8; |
|
1108 | - $i+= 8; |
|
1106 | + $ciphertext .= $iv; |
|
1107 | + $len -= 8; |
|
1108 | + $i += 8; |
|
1109 | 1109 | } |
1110 | 1110 | if ($len) { |
1111 | 1111 | $iv = $this->_processBlock($iv, CRYPT_DES_ENCRYPT); |
1112 | 1112 | $block = $iv ^ substr($plaintext, $i); |
1113 | 1113 | $iv = substr_replace($iv, $block, 0, $len); |
1114 | - $ciphertext.= $block; |
|
1114 | + $ciphertext .= $block; |
|
1115 | 1115 | $pos = $len; |
1116 | 1116 | } |
1117 | 1117 | return $ciphertext; |
1118 | 1118 | case CRYPT_DES_MODE_OFB: |
1119 | 1119 | $xor = $this->encryptIV; |
1120 | 1120 | if (strlen($buffer['xor'])) { |
1121 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
1121 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
1122 | 1122 | $block = substr($plaintext, $i, 8); |
1123 | 1123 | if (strlen($block) > strlen($buffer['xor'])) { |
1124 | 1124 | $xor = $this->_processBlock($xor, CRYPT_DES_ENCRYPT); |
1125 | - $buffer['xor'].= $xor; |
|
1125 | + $buffer['xor'] .= $xor; |
|
1126 | 1126 | } |
1127 | 1127 | $key = $this->_string_shift($buffer['xor']); |
1128 | - $ciphertext.= $block ^ $key; |
|
1128 | + $ciphertext .= $block ^ $key; |
|
1129 | 1129 | } |
1130 | 1130 | } else { |
1131 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
1131 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
1132 | 1132 | $xor = $this->_processBlock($xor, CRYPT_DES_ENCRYPT); |
1133 | - $ciphertext.= substr($plaintext, $i, 8) ^ $xor; |
|
1133 | + $ciphertext .= substr($plaintext, $i, 8) ^ $xor; |
|
1134 | 1134 | } |
1135 | 1135 | $key = $xor; |
1136 | 1136 | } |
1137 | 1137 | if ($this->continuousBuffer) { |
1138 | 1138 | $this->encryptIV = $xor; |
1139 | 1139 | if ($start = strlen($plaintext) & 7) { |
1140 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1140 | + $buffer['xor'] = substr($key, $start).$buffer['xor']; |
|
1141 | 1141 | } |
1142 | 1142 | } |
1143 | 1143 | } |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | $ciphertext = str_pad($ciphertext, (strlen($ciphertext) + 7) & 0xFFFFFFF8, chr(0)); |
1163 | 1163 | } |
1164 | 1164 | |
1165 | - if ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) { |
|
1165 | + if (CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT) { |
|
1166 | 1166 | if ($this->dechanged) { |
1167 | 1167 | mcrypt_generic_init($this->demcrypt, $this->keys, $this->decryptIV); |
1168 | 1168 | if ($this->mode == 'ncfb') { |
@@ -1184,11 +1184,11 @@ discard block |
||
1184 | 1184 | $max = 8 - $pos; |
1185 | 1185 | if ($len >= $max) { |
1186 | 1186 | $i = $max; |
1187 | - $len-= $max; |
|
1187 | + $len -= $max; |
|
1188 | 1188 | $pos = 0; |
1189 | 1189 | } else { |
1190 | 1190 | $i = $len; |
1191 | - $pos+= $len; |
|
1191 | + $pos += $len; |
|
1192 | 1192 | $len = 0; |
1193 | 1193 | } |
1194 | 1194 | $plaintext = substr($iv, $orig_pos) ^ $ciphertext; |
@@ -1196,13 +1196,13 @@ discard block |
||
1196 | 1196 | } |
1197 | 1197 | if ($len >= 8) { |
1198 | 1198 | $cb = substr($ciphertext, $i, $len - $len % 8); |
1199 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
1199 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
1200 | 1200 | $iv = substr($cb, -8); |
1201 | - $len%= 8; |
|
1201 | + $len %= 8; |
|
1202 | 1202 | } |
1203 | 1203 | if ($len) { |
1204 | 1204 | $iv = mcrypt_generic($this->ecb, $iv); |
1205 | - $plaintext.= $iv ^ substr($ciphertext, -$len); |
|
1205 | + $plaintext .= $iv ^ substr($ciphertext, -$len); |
|
1206 | 1206 | $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); |
1207 | 1207 | $pos = $len; |
1208 | 1208 | } |
@@ -1230,15 +1230,15 @@ discard block |
||
1230 | 1230 | $plaintext = ''; |
1231 | 1231 | switch ($this->mode) { |
1232 | 1232 | case CRYPT_DES_MODE_ECB: |
1233 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
1234 | - $plaintext.= $this->_processBlock(substr($ciphertext, $i, 8), CRYPT_DES_DECRYPT); |
|
1233 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
1234 | + $plaintext .= $this->_processBlock(substr($ciphertext, $i, 8), CRYPT_DES_DECRYPT); |
|
1235 | 1235 | } |
1236 | 1236 | break; |
1237 | 1237 | case CRYPT_DES_MODE_CBC: |
1238 | 1238 | $xor = $this->decryptIV; |
1239 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
1239 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
1240 | 1240 | $block = substr($ciphertext, $i, 8); |
1241 | - $plaintext.= $this->_processBlock($block, CRYPT_DES_DECRYPT) ^ $xor; |
|
1241 | + $plaintext .= $this->_processBlock($block, CRYPT_DES_DECRYPT) ^ $xor; |
|
1242 | 1242 | $xor = $block; |
1243 | 1243 | } |
1244 | 1244 | if ($this->continuousBuffer) { |
@@ -1248,25 +1248,25 @@ discard block |
||
1248 | 1248 | case CRYPT_DES_MODE_CTR: |
1249 | 1249 | $xor = $this->decryptIV; |
1250 | 1250 | if (strlen($buffer['ciphertext'])) { |
1251 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
1251 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
1252 | 1252 | $block = substr($ciphertext, $i, 8); |
1253 | 1253 | if (strlen($block) > strlen($buffer['ciphertext'])) { |
1254 | - $buffer['ciphertext'].= $this->_processBlock($this->_generate_xor($xor), CRYPT_DES_ENCRYPT); |
|
1254 | + $buffer['ciphertext'] .= $this->_processBlock($this->_generate_xor($xor), CRYPT_DES_ENCRYPT); |
|
1255 | 1255 | } |
1256 | 1256 | $key = $this->_string_shift($buffer['ciphertext']); |
1257 | - $plaintext.= $block ^ $key; |
|
1257 | + $plaintext .= $block ^ $key; |
|
1258 | 1258 | } |
1259 | 1259 | } else { |
1260 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
1260 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
1261 | 1261 | $block = substr($ciphertext, $i, 8); |
1262 | 1262 | $key = $this->_processBlock($this->_generate_xor($xor), CRYPT_DES_ENCRYPT); |
1263 | - $plaintext.= $block ^ $key; |
|
1263 | + $plaintext .= $block ^ $key; |
|
1264 | 1264 | } |
1265 | 1265 | } |
1266 | 1266 | if ($this->continuousBuffer) { |
1267 | 1267 | $this->decryptIV = $xor; |
1268 | 1268 | if ($start = strlen($ciphertext) % 8) { |
1269 | - $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext']; |
|
1269 | + $buffer['ciphertext'] = substr($key, $start).$buffer['ciphertext']; |
|
1270 | 1270 | } |
1271 | 1271 | } |
1272 | 1272 | break; |
@@ -1285,11 +1285,11 @@ discard block |
||
1285 | 1285 | $max = 8 - $pos; |
1286 | 1286 | if ($len >= $max) { |
1287 | 1287 | $i = $max; |
1288 | - $len-= $max; |
|
1288 | + $len -= $max; |
|
1289 | 1289 | $pos = 0; |
1290 | 1290 | } else { |
1291 | 1291 | $i = $len; |
1292 | - $pos+= $len; |
|
1292 | + $pos += $len; |
|
1293 | 1293 | $len = 0; |
1294 | 1294 | } |
1295 | 1295 | $plaintext = substr($iv, $orig_pos) ^ $ciphertext; |
@@ -1298,14 +1298,14 @@ discard block |
||
1298 | 1298 | while ($len >= 8) { |
1299 | 1299 | $iv = $this->_processBlock($iv, CRYPT_DES_ENCRYPT); |
1300 | 1300 | $cb = substr($ciphertext, $i, 8); |
1301 | - $plaintext.= $iv ^ $cb; |
|
1301 | + $plaintext .= $iv ^ $cb; |
|
1302 | 1302 | $iv = $cb; |
1303 | - $len-= 8; |
|
1304 | - $i+= 8; |
|
1303 | + $len -= 8; |
|
1304 | + $i += 8; |
|
1305 | 1305 | } |
1306 | 1306 | if ($len) { |
1307 | 1307 | $iv = $this->_processBlock($iv, CRYPT_DES_ENCRYPT); |
1308 | - $plaintext.= $iv ^ substr($ciphertext, $i); |
|
1308 | + $plaintext .= $iv ^ substr($ciphertext, $i); |
|
1309 | 1309 | $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len); |
1310 | 1310 | $pos = $len; |
1311 | 1311 | } |
@@ -1313,26 +1313,26 @@ discard block |
||
1313 | 1313 | case CRYPT_DES_MODE_OFB: |
1314 | 1314 | $xor = $this->decryptIV; |
1315 | 1315 | if (strlen($buffer['xor'])) { |
1316 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
1316 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
1317 | 1317 | $block = substr($ciphertext, $i, 8); |
1318 | 1318 | if (strlen($block) > strlen($buffer['xor'])) { |
1319 | 1319 | $xor = $this->_processBlock($xor, CRYPT_DES_ENCRYPT); |
1320 | - $buffer['xor'].= $xor; |
|
1320 | + $buffer['xor'] .= $xor; |
|
1321 | 1321 | } |
1322 | 1322 | $key = $this->_string_shift($buffer['xor']); |
1323 | - $plaintext.= $block ^ $key; |
|
1323 | + $plaintext .= $block ^ $key; |
|
1324 | 1324 | } |
1325 | 1325 | } else { |
1326 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
1326 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
1327 | 1327 | $xor = $this->_processBlock($xor, CRYPT_DES_ENCRYPT); |
1328 | - $plaintext.= substr($ciphertext, $i, 8) ^ $xor; |
|
1328 | + $plaintext .= substr($ciphertext, $i, 8) ^ $xor; |
|
1329 | 1329 | } |
1330 | 1330 | $key = $xor; |
1331 | 1331 | } |
1332 | 1332 | if ($this->continuousBuffer) { |
1333 | 1333 | $this->decryptIV = $xor; |
1334 | 1334 | if ($start = strlen($ciphertext) % 8) { |
1335 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1335 | + $buffer['xor'] = substr($key, $start).$buffer['xor']; |
|
1336 | 1336 | } |
1337 | 1337 | } |
1338 | 1338 | } |
@@ -2100,7 +2100,7 @@ discard block |
||
2100 | 2100 | */ |
2101 | 2101 | function inline_crypt_setup($des_rounds = 1) |
2102 | 2102 | { |
2103 | - $lambda_functions =& Crypt_DES::get_lambda_functions(); |
|
2103 | + $lambda_functions = & Crypt_DES::get_lambda_functions(); |
|
2104 | 2104 | $block_size = 8; |
2105 | 2105 | $mode = $this->mode; |
2106 | 2106 | |
@@ -2139,7 +2139,7 @@ discard block |
||
2139 | 2139 | ($shuffle[$ipmap[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01") |
2140 | 2140 | ); |
2141 | 2141 | |
2142 | - '.'' /* Extract L0 and R0 */ .' |
|
2142 | + '.'' /* Extract L0 and R0 */.' |
|
2143 | 2143 | $l = $in[1]; |
2144 | 2144 | $r = $in[2]; |
2145 | 2145 | '; |
@@ -2153,19 +2153,19 @@ discard block |
||
2153 | 2153 | // Merge key schedule. |
2154 | 2154 | for ($i = 0; $i < 8; ++$i) { |
2155 | 2155 | $_cryptBlock .= ' |
2156 | - $b1 = (($' . $r . ' >> 3) & 0x1FFFFFFF) ^ ($' . $r . ' << 29) ^ $k_'.(++$ki).'; |
|
2157 | - $b2 = (($' . $r . ' >> 31) & 0x00000001) ^ ($' . $r . ' << 1) ^ $k_'.(++$ki).'; |
|
2158 | - $' . $l . ' = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
|
2156 | + $b1 = (($' . $r.' >> 3) & 0x1FFFFFFF) ^ ($'.$r.' << 29) ^ $k_'.(++$ki).'; |
|
2157 | + $b2 = (($' . $r.' >> 31) & 0x00000001) ^ ($'.$r.' << 1) ^ $k_'.(++$ki).'; |
|
2158 | + $' . $l.' = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
|
2159 | 2159 | $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
2160 | 2160 | $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
2161 | - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $' . $l . '; |
|
2161 | + $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $' . $l.'; |
|
2162 | 2162 | |
2163 | - $b1 = (($' . $l . ' >> 3) & 0x1FFFFFFF) ^ ($' . $l . ' << 29) ^ $k_'.(++$ki).'; |
|
2164 | - $b2 = (($' . $l . ' >> 31) & 0x00000001) ^ ($' . $l . ' << 1) ^ $k_'.(++$ki).'; |
|
2165 | - $' . $r . ' = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
|
2163 | + $b1 = (($' . $l.' >> 3) & 0x1FFFFFFF) ^ ($'.$l.' << 29) ^ $k_'.(++$ki).'; |
|
2164 | + $b2 = (($' . $l.' >> 31) & 0x00000001) ^ ($'.$l.' << 1) ^ $k_'.(++$ki).'; |
|
2165 | + $' . $r.' = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
|
2166 | 2166 | $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
2167 | 2167 | $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
2168 | - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $' . $r . '; |
|
2168 | + $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $' . $r.'; |
|
2169 | 2169 | '; |
2170 | 2170 | } |
2171 | 2171 | |
@@ -2177,21 +2177,21 @@ discard block |
||
2177 | 2177 | |
2178 | 2178 | // Perform the inverse IP permutation. |
2179 | 2179 | $_cryptBlock .= '$in = ( |
2180 | - ($shuffle[$invipmap[($' . $r . ' >> 24) & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
|
2181 | - ($shuffle[$invipmap[($' . $l . ' >> 24) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
2182 | - ($shuffle[$invipmap[($' . $r . ' >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
2183 | - ($shuffle[$invipmap[($' . $l . ' >> 16) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
2184 | - ($shuffle[$invipmap[($' . $r . ' >> 8) & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
2185 | - ($shuffle[$invipmap[($' . $l . ' >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
2186 | - ($shuffle[$invipmap[ $' . $r . ' & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
2187 | - ($shuffle[$invipmap[ $' . $l . ' & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01") |
|
2180 | + ($shuffle[$invipmap[($' . $r.' >> 24) & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
|
2181 | + ($shuffle[$invipmap[($' . $l.' >> 24) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
2182 | + ($shuffle[$invipmap[($' . $r.' >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
2183 | + ($shuffle[$invipmap[($' . $l.' >> 16) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
2184 | + ($shuffle[$invipmap[($' . $r.' >> 8) & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
2185 | + ($shuffle[$invipmap[($' . $l.' >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
2186 | + ($shuffle[$invipmap[ $' . $r.' & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
2187 | + ($shuffle[$invipmap[ $' . $l.' & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01") |
|
2188 | 2188 | ); |
2189 | 2189 | '; |
2190 | 2190 | |
2191 | 2191 | // Generating mode of operation code: |
2192 | 2192 | switch ($mode) { |
2193 | 2193 | case CRYPT_DES_MODE_ECB: |
2194 | - $encrypt = $init_cryptBlock . ' |
|
2194 | + $encrypt = $init_cryptBlock.' |
|
2195 | 2195 | extract($self->keys[CRYPT_DES_ENCRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2196 | 2196 | $ciphertext = ""; |
2197 | 2197 | $plaintext_len = strlen($text); |
@@ -2205,7 +2205,7 @@ discard block |
||
2205 | 2205 | return $ciphertext; |
2206 | 2206 | '; |
2207 | 2207 | |
2208 | - $decrypt = $init_cryptBlock . ' |
|
2208 | + $decrypt = $init_cryptBlock.' |
|
2209 | 2209 | extract($self->keys[CRYPT_DES_DECRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2210 | 2210 | $plaintext = ""; |
2211 | 2211 | $ciphertext_len = strlen($text); |
@@ -2220,7 +2220,7 @@ discard block |
||
2220 | 2220 | '; |
2221 | 2221 | break; |
2222 | 2222 | case CRYPT_DES_MODE_CBC: |
2223 | - $encrypt = $init_cryptBlock . ' |
|
2223 | + $encrypt = $init_cryptBlock.' |
|
2224 | 2224 | extract($self->keys[CRYPT_DES_ENCRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2225 | 2225 | $ciphertext = ""; |
2226 | 2226 | $plaintext_len = strlen($text); |
@@ -2240,7 +2240,7 @@ discard block |
||
2240 | 2240 | return $ciphertext; |
2241 | 2241 | '; |
2242 | 2242 | |
2243 | - $decrypt = $init_cryptBlock . ' |
|
2243 | + $decrypt = $init_cryptBlock.' |
|
2244 | 2244 | extract($self->keys[CRYPT_DES_DECRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2245 | 2245 | $plaintext = ""; |
2246 | 2246 | $ciphertext_len = strlen($text); |
@@ -2262,7 +2262,7 @@ discard block |
||
2262 | 2262 | '; |
2263 | 2263 | break; |
2264 | 2264 | case CRYPT_DES_MODE_CTR: |
2265 | - $encrypt = $init_cryptBlock . ' |
|
2265 | + $encrypt = $init_cryptBlock.' |
|
2266 | 2266 | extract($self->keys[CRYPT_DES_ENCRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2267 | 2267 | $ciphertext = ""; |
2268 | 2268 | $plaintext_len = strlen($text); |
@@ -2299,7 +2299,7 @@ discard block |
||
2299 | 2299 | return $ciphertext; |
2300 | 2300 | '; |
2301 | 2301 | |
2302 | - $decrypt = $init_cryptBlock . ' |
|
2302 | + $decrypt = $init_cryptBlock.' |
|
2303 | 2303 | extract($self->keys[CRYPT_DES_ENCRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2304 | 2304 | $plaintext = ""; |
2305 | 2305 | $ciphertext_len = strlen($text); |
@@ -2337,7 +2337,7 @@ discard block |
||
2337 | 2337 | '; |
2338 | 2338 | break; |
2339 | 2339 | case CRYPT_DES_MODE_CFB: |
2340 | - $encrypt = $init_cryptBlock . ' |
|
2340 | + $encrypt = $init_cryptBlock.' |
|
2341 | 2341 | extract($self->keys[CRYPT_DES_ENCRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2342 | 2342 | $ciphertext = ""; |
2343 | 2343 | $buffer = &$self->enbuffer; |
@@ -2386,7 +2386,7 @@ discard block |
||
2386 | 2386 | return $ciphertext; |
2387 | 2387 | '; |
2388 | 2388 | |
2389 | - $decrypt = $init_cryptBlock . ' |
|
2389 | + $decrypt = $init_cryptBlock.' |
|
2390 | 2390 | extract($self->keys[CRYPT_DES_ENCRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2391 | 2391 | $plaintext = ""; |
2392 | 2392 | $buffer = &$self->debuffer; |
@@ -2438,7 +2438,7 @@ discard block |
||
2438 | 2438 | '; |
2439 | 2439 | break; |
2440 | 2440 | case CRYPT_DES_MODE_OFB: |
2441 | - $encrypt = $init_cryptBlock . ' |
|
2441 | + $encrypt = $init_cryptBlock.' |
|
2442 | 2442 | extract($self->keys[CRYPT_DES_ENCRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2443 | 2443 | $ciphertext = ""; |
2444 | 2444 | $plaintext_len = strlen($text); |
@@ -2475,7 +2475,7 @@ discard block |
||
2475 | 2475 | return $ciphertext; |
2476 | 2476 | '; |
2477 | 2477 | |
2478 | - $decrypt = $init_cryptBlock . ' |
|
2478 | + $decrypt = $init_cryptBlock.' |
|
2479 | 2479 | extract($self->keys[CRYPT_DES_ENCRYPT_1DIM], EXTR_PREFIX_ALL, "k"); |
2480 | 2480 | $plaintext = ""; |
2481 | 2481 | $ciphertext_len = strlen($text); |
@@ -783,8 +783,7 @@ |
||
783 | 783 | * _sha256() adds multiple unsigned 32-bit integers. Since PHP doesn't support unsigned integers and since the |
784 | 784 | * possibility of overflow exists, care has to be taken. Math_BigInteger() could be used but this should be faster. |
785 | 785 | * |
786 | - * @param Integer $... |
|
787 | - * @return Integer |
|
786 | + * @return double |
|
788 | 787 | * @see _sha256() |
789 | 788 | * @access private |
790 | 789 | */ |
@@ -257,27 +257,27 @@ discard block |
||
257 | 257 | switch ($hash) { |
258 | 258 | case 'md2': |
259 | 259 | $this->b = 16; |
260 | - $this->hash = array($this, '_md2'); |
|
261 | - break; |
|
260 | + $this->hash = array($this, '_md2'); |
|
261 | + break; |
|
262 | 262 | case 'md5': |
263 | 263 | case 'md5-96': |
264 | 264 | $this->b = 64; |
265 | - $this->hash = array($this, '_md5'); |
|
266 | - break; |
|
265 | + $this->hash = array($this, '_md5'); |
|
266 | + break; |
|
267 | 267 | case 'sha256': |
268 | 268 | $this->b = 64; |
269 | - $this->hash = array($this, '_sha256'); |
|
270 | - break; |
|
269 | + $this->hash = array($this, '_sha256'); |
|
270 | + break; |
|
271 | 271 | case 'sha384': |
272 | 272 | case 'sha512': |
273 | 273 | $this->b = 128; |
274 | - $this->hash = array($this, '_sha512'); |
|
275 | - break; |
|
274 | + $this->hash = array($this, '_sha512'); |
|
275 | + break; |
|
276 | 276 | case 'sha1': |
277 | 277 | case 'sha1-96': |
278 | 278 | default: |
279 | 279 | $this->b = 64; |
280 | - $this->hash = array($this, '_sha1'); |
|
280 | + $this->hash = array($this, '_sha1'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | $this->ipad = str_repeat(chr(0x36), $this->b); |
@@ -378,24 +378,24 @@ discard block |
||
378 | 378 | function _md2($m) |
379 | 379 | { |
380 | 380 | static $s = array( |
381 | - 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, |
|
382 | - 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, |
|
383 | - 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, |
|
381 | + 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, |
|
382 | + 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, |
|
383 | + 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, |
|
384 | 384 | 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, |
385 | 385 | 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, |
386 | 386 | 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, |
387 | - 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, |
|
387 | + 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, |
|
388 | 388 | 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, |
389 | 389 | 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, |
390 | 390 | 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, |
391 | - 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, |
|
392 | - 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, |
|
391 | + 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, |
|
392 | + 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, |
|
393 | 393 | 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, |
394 | 394 | 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, |
395 | - 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, |
|
395 | + 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, |
|
396 | 396 | 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, |
397 | 397 | 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, |
398 | - 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 |
|
398 | + 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 |
|
399 | 399 | ); |
400 | 400 | |
401 | 401 | // Step 1. Append Padding Bytes |
@@ -494,11 +494,11 @@ discard block |
||
494 | 494 | // Extend the sixteen 32-bit words into sixty-four 32-bit words |
495 | 495 | for ($i = 16; $i < 64; $i++) { |
496 | 496 | $s0 = $this->_rightRotate($w[$i - 15], 7) ^ |
497 | - $this->_rightRotate($w[$i - 15], 18) ^ |
|
498 | - $this->_rightShift( $w[$i - 15], 3); |
|
497 | + $this->_rightRotate($w[$i - 15], 18) ^ |
|
498 | + $this->_rightShift( $w[$i - 15], 3); |
|
499 | 499 | $s1 = $this->_rightRotate($w[$i - 2], 17) ^ |
500 | - $this->_rightRotate($w[$i - 2], 19) ^ |
|
501 | - $this->_rightShift( $w[$i - 2], 10); |
|
500 | + $this->_rightRotate($w[$i - 2], 19) ^ |
|
501 | + $this->_rightShift( $w[$i - 2], 10); |
|
502 | 502 | $w[$i] = $this->_add($w[$i - 16], $s0, $w[$i - 7], $s1); |
503 | 503 | |
504 | 504 | } |
@@ -509,18 +509,18 @@ discard block |
||
509 | 509 | // Main loop |
510 | 510 | for ($i = 0; $i < 64; $i++) { |
511 | 511 | $s0 = $this->_rightRotate($a, 2) ^ |
512 | - $this->_rightRotate($a, 13) ^ |
|
513 | - $this->_rightRotate($a, 22); |
|
512 | + $this->_rightRotate($a, 13) ^ |
|
513 | + $this->_rightRotate($a, 22); |
|
514 | 514 | $maj = ($a & $b) ^ |
515 | - ($a & $c) ^ |
|
516 | - ($b & $c); |
|
515 | + ($a & $c) ^ |
|
516 | + ($b & $c); |
|
517 | 517 | $t2 = $this->_add($s0, $maj); |
518 | 518 | |
519 | 519 | $s1 = $this->_rightRotate($e, 6) ^ |
520 | - $this->_rightRotate($e, 11) ^ |
|
521 | - $this->_rightRotate($e, 25); |
|
520 | + $this->_rightRotate($e, 11) ^ |
|
521 | + $this->_rightRotate($e, 25); |
|
522 | 522 | $ch = ($e & $f) ^ |
523 | - ($this->_not($e) & $g); |
|
523 | + ($this->_not($e) & $g); |
|
524 | 524 | $t1 = $this->_add($h, $s1, $ch, $k[$i], $w[$i]); |
525 | 525 | |
526 | 526 | $h = $g; |
@@ -635,16 +635,16 @@ discard block |
||
635 | 635 | // Extend the sixteen 32-bit words into eighty 32-bit words |
636 | 636 | for ($i = 16; $i < 80; $i++) { |
637 | 637 | $temp = array( |
638 | - $w[$i - 15]->bitwise_rightRotate(1), |
|
639 | - $w[$i - 15]->bitwise_rightRotate(8), |
|
640 | - $w[$i - 15]->bitwise_rightShift(7) |
|
638 | + $w[$i - 15]->bitwise_rightRotate(1), |
|
639 | + $w[$i - 15]->bitwise_rightRotate(8), |
|
640 | + $w[$i - 15]->bitwise_rightShift(7) |
|
641 | 641 | ); |
642 | 642 | $s0 = $temp[0]->bitwise_xor($temp[1]); |
643 | 643 | $s0 = $s0->bitwise_xor($temp[2]); |
644 | 644 | $temp = array( |
645 | - $w[$i - 2]->bitwise_rightRotate(19), |
|
646 | - $w[$i - 2]->bitwise_rightRotate(61), |
|
647 | - $w[$i - 2]->bitwise_rightShift(6) |
|
645 | + $w[$i - 2]->bitwise_rightRotate(19), |
|
646 | + $w[$i - 2]->bitwise_rightRotate(61), |
|
647 | + $w[$i - 2]->bitwise_rightShift(6) |
|
648 | 648 | ); |
649 | 649 | $s1 = $temp[0]->bitwise_xor($temp[1]); |
650 | 650 | $s1 = $s1->bitwise_xor($temp[2]); |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * Toggles the mhash() implementation, which has been deprecated on PHP 5.3.0+. |
68 | 68 | */ |
69 | -define('CRYPT_HASH_MODE_MHASH', 2); |
|
69 | +define('CRYPT_HASH_MODE_MHASH', 2); |
|
70 | 70 | /** |
71 | 71 | * Toggles the hash() implementation, which works on PHP 5.1.2+. |
72 | 72 | */ |
73 | -define('CRYPT_HASH_MODE_HASH', 3); |
|
73 | +define('CRYPT_HASH_MODE_HASH', 3); |
|
74 | 74 | /**#@-*/ |
75 | 75 | |
76 | 76 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function Crypt_Hash($hash = 'sha1') |
147 | 147 | { |
148 | - if ( !defined('CRYPT_HASH_MODE') ) { |
|
148 | + if (!defined('CRYPT_HASH_MODE')) { |
|
149 | 149 | switch (true) { |
150 | 150 | case extension_loaded('hash'): |
151 | 151 | define('CRYPT_HASH_MODE', CRYPT_HASH_MODE_HASH); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $mode = CRYPT_HASH_MODE; |
219 | 219 | } |
220 | 220 | |
221 | - switch ( $mode ) { |
|
221 | + switch ($mode) { |
|
222 | 222 | case CRYPT_HASH_MODE_MHASH: |
223 | 223 | switch ($hash) { |
224 | 224 | case 'md5': |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $mode = is_array($this->hash) ? CRYPT_HASH_MODE_INTERNAL : CRYPT_HASH_MODE; |
297 | 297 | |
298 | 298 | if (!empty($this->key) || is_string($this->key)) { |
299 | - switch ( $mode ) { |
|
299 | + switch ($mode) { |
|
300 | 300 | case CRYPT_HASH_MODE_MHASH: |
301 | 301 | $output = mhash($this->hash, $text, $this->key); |
302 | 302 | break; |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | -- http://tools.ietf.org/html/rfc2104#section-2 */ |
311 | 311 | $key = strlen($this->key) > $this->b ? call_user_func($this->hash, $this->key) : $this->key; |
312 | 312 | |
313 | - $key = str_pad($key, $this->b, chr(0)); // step 1 |
|
314 | - $temp = $this->ipad ^ $key; // step 2 |
|
315 | - $temp .= $text; // step 3 |
|
316 | - $temp = call_user_func($this->hash, $temp); // step 4 |
|
317 | - $output = $this->opad ^ $key; // step 5 |
|
318 | - $output.= $temp; // step 6 |
|
313 | + $key = str_pad($key, $this->b, chr(0)); // step 1 |
|
314 | + $temp = $this->ipad ^ $key; // step 2 |
|
315 | + $temp .= $text; // step 3 |
|
316 | + $temp = call_user_func($this->hash, $temp); // step 4 |
|
317 | + $output = $this->opad ^ $key; // step 5 |
|
318 | + $output .= $temp; // step 6 |
|
319 | 319 | $output = call_user_func($this->hash, $output); // step 7 |
320 | 320 | } |
321 | 321 | } else { |
322 | - switch ( $mode ) { |
|
322 | + switch ($mode) { |
|
323 | 323 | case CRYPT_HASH_MODE_MHASH: |
324 | 324 | $output = mhash($this->hash, $text); |
325 | 325 | break; |
@@ -378,36 +378,36 @@ discard block |
||
378 | 378 | function _md2($m) |
379 | 379 | { |
380 | 380 | static $s = array( |
381 | - 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, |
|
382 | - 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, |
|
383 | - 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, |
|
384 | - 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, |
|
385 | - 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, |
|
386 | - 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, |
|
387 | - 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, |
|
388 | - 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, |
|
389 | - 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, |
|
390 | - 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, |
|
391 | - 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, |
|
392 | - 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, |
|
393 | - 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, |
|
394 | - 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, |
|
395 | - 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, |
|
396 | - 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, |
|
397 | - 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, |
|
398 | - 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 |
|
381 | + 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, |
|
382 | + 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, |
|
383 | + 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, |
|
384 | + 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, |
|
385 | + 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, |
|
386 | + 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, |
|
387 | + 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, |
|
388 | + 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, |
|
389 | + 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, |
|
390 | + 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, |
|
391 | + 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, |
|
392 | + 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, |
|
393 | + 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, |
|
394 | + 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, |
|
395 | + 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, |
|
396 | + 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, |
|
397 | + 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, |
|
398 | + 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 |
|
399 | 399 | ); |
400 | 400 | |
401 | 401 | // Step 1. Append Padding Bytes |
402 | 402 | $pad = 16 - (strlen($m) & 0xF); |
403 | - $m.= str_repeat(chr($pad), $pad); |
|
403 | + $m .= str_repeat(chr($pad), $pad); |
|
404 | 404 | |
405 | 405 | $length = strlen($m); |
406 | 406 | |
407 | 407 | // Step 2. Append Checksum |
408 | 408 | $c = str_repeat(chr(0), 16); |
409 | 409 | $l = chr(0); |
410 | - for ($i = 0; $i < $length; $i+= 16) { |
|
410 | + for ($i = 0; $i < $length; $i += 16) { |
|
411 | 411 | for ($j = 0; $j < 16; $j++) { |
412 | 412 | // RFC1319 incorrectly states that C[j] should be set to S[c xor L] |
413 | 413 | //$c[$j] = chr($s[ord($m[$i + $j] ^ $l)]); |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | $l = $c[$j]; |
417 | 417 | } |
418 | 418 | } |
419 | - $m.= $c; |
|
419 | + $m .= $c; |
|
420 | 420 | |
421 | - $length+= 16; |
|
421 | + $length += 16; |
|
422 | 422 | |
423 | 423 | // Step 3. Initialize MD Buffer |
424 | 424 | $x = str_repeat(chr(0), 48); |
425 | 425 | |
426 | 426 | // Step 4. Process Message in 16-Byte Blocks |
427 | - for ($i = 0; $i < $length; $i+= 16) { |
|
427 | + for ($i = 0; $i < $length; $i += 16) { |
|
428 | 428 | for ($j = 0; $j < 16; $j++) { |
429 | 429 | $x[$j + 16] = $m[$i + $j]; |
430 | 430 | $x[$j + 32] = $x[$j + 16] ^ $x[$j]; |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | // Pre-processing |
478 | 478 | $length = strlen($m); |
479 | 479 | // to round to nearest 56 mod 64, we'll add 64 - (length + (64 - 56)) % 64 |
480 | - $m.= str_repeat(chr(0), 64 - (($length + 8) & 0x3F)); |
|
480 | + $m .= str_repeat(chr(0), 64 - (($length + 8) & 0x3F)); |
|
481 | 481 | $m[$length] = chr(0x80); |
482 | 482 | // we don't support hashing strings 512MB long |
483 | - $m.= pack('N2', 0, $length << 3); |
|
483 | + $m .= pack('N2', 0, $length << 3); |
|
484 | 484 | |
485 | 485 | // Process the message in successive 512-bit chunks |
486 | 486 | $chunks = str_split($m, 64); |
@@ -493,12 +493,12 @@ discard block |
||
493 | 493 | |
494 | 494 | // Extend the sixteen 32-bit words into sixty-four 32-bit words |
495 | 495 | for ($i = 16; $i < 64; $i++) { |
496 | - $s0 = $this->_rightRotate($w[$i - 15], 7) ^ |
|
496 | + $s0 = $this->_rightRotate($w[$i - 15], 7) ^ |
|
497 | 497 | $this->_rightRotate($w[$i - 15], 18) ^ |
498 | - $this->_rightShift( $w[$i - 15], 3); |
|
498 | + $this->_rightShift($w[$i - 15], 3); |
|
499 | 499 | $s1 = $this->_rightRotate($w[$i - 2], 17) ^ |
500 | 500 | $this->_rightRotate($w[$i - 2], 19) ^ |
501 | - $this->_rightShift( $w[$i - 2], 10); |
|
501 | + $this->_rightShift($w[$i - 2], 10); |
|
502 | 502 | $w[$i] = $this->_add($w[$i - 16], $s0, $w[$i - 7], $s1); |
503 | 503 | |
504 | 504 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | // Main loop |
510 | 510 | for ($i = 0; $i < 64; $i++) { |
511 | - $s0 = $this->_rightRotate($a, 2) ^ |
|
511 | + $s0 = $this->_rightRotate($a, 2) ^ |
|
512 | 512 | $this->_rightRotate($a, 13) ^ |
513 | 513 | $this->_rightRotate($a, 22); |
514 | 514 | $maj = ($a & $b) ^ |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | ($b & $c); |
517 | 517 | $t2 = $this->_add($s0, $maj); |
518 | 518 | |
519 | - $s1 = $this->_rightRotate($e, 6) ^ |
|
519 | + $s1 = $this->_rightRotate($e, 6) ^ |
|
520 | 520 | $this->_rightRotate($e, 11) ^ |
521 | 521 | $this->_rightRotate($e, 25); |
522 | 522 | $ch = ($e & $f) ^ |
@@ -617,10 +617,10 @@ discard block |
||
617 | 617 | // Pre-processing |
618 | 618 | $length = strlen($m); |
619 | 619 | // to round to nearest 112 mod 128, we'll add 128 - (length + (128 - 112)) % 128 |
620 | - $m.= str_repeat(chr(0), 128 - (($length + 16) & 0x7F)); |
|
620 | + $m .= str_repeat(chr(0), 128 - (($length + 16) & 0x7F)); |
|
621 | 621 | $m[$length] = chr(0x80); |
622 | 622 | // we don't support hashing strings 512MB long |
623 | - $m.= pack('N4', 0, 0, 0, $length << 3); |
|
623 | + $m .= pack('N4', 0, 0, 0, $length << 3); |
|
624 | 624 | |
625 | 625 | // Process the message in successive 1024-bit chunks |
626 | 626 | $chunks = str_split($m, 128); |
@@ -724,10 +724,10 @@ discard block |
||
724 | 724 | |
725 | 725 | // Produce the final hash value (big-endian) |
726 | 726 | // (Crypt_Hash::hash() trims the output for hashes but not for HMACs. as such, we trim the output here) |
727 | - $temp = $hash[0]->toBytes() . $hash[1]->toBytes() . $hash[2]->toBytes() . $hash[3]->toBytes() . |
|
728 | - $hash[4]->toBytes() . $hash[5]->toBytes(); |
|
727 | + $temp = $hash[0]->toBytes().$hash[1]->toBytes().$hash[2]->toBytes().$hash[3]->toBytes(). |
|
728 | + $hash[4]->toBytes().$hash[5]->toBytes(); |
|
729 | 729 | if ($this->l != 48) { |
730 | - $temp.= $hash[6]->toBytes() . $hash[7]->toBytes(); |
|
730 | + $temp .= $hash[6]->toBytes().$hash[7]->toBytes(); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | return $temp; |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | $result = 0; |
799 | 799 | $arguments = func_get_args(); |
800 | 800 | foreach ($arguments as $argument) { |
801 | - $result+= $argument < 0 ? ($argument & 0x7FFFFFFF) + 0x80000000 : $argument; |
|
801 | + $result += $argument < 0 ? ($argument & 0x7FFFFFFF) + 0x80000000 : $argument; |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | return fmod($result, $mod); |
@@ -1456,6 +1456,7 @@ discard block |
||
1456 | 1456 | * |
1457 | 1457 | * @see Crypt_Rijndael::_unpad() |
1458 | 1458 | * @access private |
1459 | + * @param string $text |
|
1459 | 1460 | */ |
1460 | 1461 | function _pad($text) |
1461 | 1462 | { |
@@ -1483,6 +1484,7 @@ discard block |
||
1483 | 1484 | * |
1484 | 1485 | * @see Crypt_Rijndael::_pad() |
1485 | 1486 | * @access private |
1487 | + * @param string $text |
|
1486 | 1488 | */ |
1487 | 1489 | function _unpad($text) |
1488 | 1490 | { |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | if ($this->continuousBuffer) { |
918 | 918 | $this->encryptIV = $xor; |
919 | 919 | if ($start = strlen($plaintext) % $block_size) { |
920 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
920 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | } |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | if ($this->continuousBuffer) { |
1059 | 1059 | $this->decryptIV = $xor; |
1060 | 1060 | if ($start = strlen($ciphertext) % $block_size) { |
1061 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1061 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1062 | 1062 | } |
1063 | 1063 | } |
1064 | 1064 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | ($state[$j] & 0x00FF0000) ^ |
1138 | 1138 | ($state[$k] & 0x0000FF00) ^ |
1139 | 1139 | ($state[$l] & 0x000000FF) ^ |
1140 | - $w[$Nr][$i]; |
|
1140 | + $w[$Nr][$i]; |
|
1141 | 1141 | ++$i; |
1142 | 1142 | $j = ($j + 1) % $Nb; |
1143 | 1143 | $k = ($k + 1) % $Nb; |
@@ -1223,9 +1223,9 @@ discard block |
||
1223 | 1223 | while ($i < $Nb) { |
1224 | 1224 | $temp[$i] = $dw[0][$i] ^ |
1225 | 1225 | $this->_invSubWord(($state[$i] & 0xFF000000) | |
1226 | - ($state[$j] & 0x00FF0000) | |
|
1227 | - ($state[$k] & 0x0000FF00) | |
|
1228 | - ($state[$l] & 0x000000FF)); |
|
1226 | + ($state[$j] & 0x00FF0000) | |
|
1227 | + ($state[$k] & 0x0000FF00) | |
|
1228 | + ($state[$l] & 0x000000FF)); |
|
1229 | 1229 | ++$i; |
1230 | 1230 | $j = ($j + 1) % $Nb; |
1231 | 1231 | $k = ($k + 1) % $Nb; |
@@ -1393,9 +1393,9 @@ discard block |
||
1393 | 1393 | $sbox = $this->sbox; |
1394 | 1394 | |
1395 | 1395 | return $sbox[$word & 0x000000FF] | |
1396 | - ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
1397 | - ($sbox[$word >> 16 & 0x000000FF] << 16) | |
|
1398 | - ($sbox[$word >> 24 & 0x000000FF] << 24); |
|
1396 | + ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
1397 | + ($sbox[$word >> 16 & 0x000000FF] << 16) | |
|
1398 | + ($sbox[$word >> 24 & 0x000000FF] << 24); |
|
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | /** |
@@ -1408,9 +1408,9 @@ discard block |
||
1408 | 1408 | $isbox = $this->isbox; |
1409 | 1409 | |
1410 | 1410 | return $isbox[$word & 0x000000FF] | |
1411 | - ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
1412 | - ($isbox[$word >> 16 & 0x000000FF] << 16) | |
|
1413 | - ($isbox[$word >> 24 & 0x000000FF] << 24); |
|
1411 | + ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
1412 | + ($isbox[$word >> 16 & 0x000000FF] << 16) | |
|
1413 | + ($isbox[$word >> 24 & 0x000000FF] << 24); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | /** |
@@ -550,13 +550,13 @@ discard block |
||
550 | 550 | ); |
551 | 551 | |
552 | 552 | for ($i = 0; $i < 256; $i++) { |
553 | - $t2[] = (($t3[$i] << 8) & 0xFFFFFF00) | (($t3[$i] >> 24) & 0x000000FF); |
|
553 | + $t2[] = (($t3[$i] << 8) & 0xFFFFFF00) | (($t3[$i] >> 24) & 0x000000FF); |
|
554 | 554 | $t1[] = (($t3[$i] << 16) & 0xFFFF0000) | (($t3[$i] >> 16) & 0x0000FFFF); |
555 | - $t0[] = (($t3[$i] << 24) & 0xFF000000) | (($t3[$i] >> 8) & 0x00FFFFFF); |
|
555 | + $t0[] = (($t3[$i] << 24) & 0xFF000000) | (($t3[$i] >> 8) & 0x00FFFFFF); |
|
556 | 556 | |
557 | - $dt2[] = (($dt3[$i] << 8) & 0xFFFFFF00) | (($dt3[$i] >> 24) & 0x000000FF); |
|
557 | + $dt2[] = (($dt3[$i] << 8) & 0xFFFFFF00) | (($dt3[$i] >> 24) & 0x000000FF); |
|
558 | 558 | $dt1[] = (($dt3[$i] << 16) & 0xFFFF0000) | (($dt3[$i] >> 16) & 0x0000FFFF); |
559 | - $dt0[] = (($dt3[$i] << 24) & 0xFF000000) | (($dt3[$i] >> 8) & 0x00FFFFFF); |
|
559 | + $dt0[] = (($dt3[$i] << 24) & 0xFF000000) | (($dt3[$i] >> 8) & 0x00FFFFFF); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | // sbox for the S-Box substitution |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | |
680 | 680 | switch ($method) { |
681 | 681 | default: // 'pbkdf2' |
682 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
682 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
683 | 683 | if (!isset($hash)) { |
684 | 684 | $hash = 'sha1'; |
685 | 685 | } |
@@ -703,12 +703,12 @@ discard block |
||
703 | 703 | $hmac = new Crypt_Hash(); |
704 | 704 | $hmac->setHash($hash); |
705 | 705 | $hmac->setKey($password); |
706 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
706 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
707 | 707 | for ($j = 2; $j <= $count; $j++) { |
708 | 708 | $u = $hmac->hash($u); |
709 | - $f^= $u; |
|
709 | + $f ^= $u; |
|
710 | 710 | } |
711 | - $key.= $f; |
|
711 | + $key .= $f; |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
@@ -755,8 +755,8 @@ discard block |
||
755 | 755 | $block_size = $this->block_size; |
756 | 756 | $num_blocks = floor(($length + ($block_size - 1)) / $block_size); |
757 | 757 | for ($i = 0; $i < $num_blocks; $i++) { |
758 | - $xor.= $iv; |
|
759 | - for ($j = 4; $j <= $block_size; $j+=4) { |
|
758 | + $xor .= $iv; |
|
759 | + for ($j = 4; $j <= $block_size; $j += 4) { |
|
760 | 760 | $temp = substr($iv, -$j, 4); |
761 | 761 | switch ($temp) { |
762 | 762 | case "\xFF\xFF\xFF\xFF": |
@@ -812,17 +812,17 @@ discard block |
||
812 | 812 | $ciphertext = ''; |
813 | 813 | switch ($this->mode) { |
814 | 814 | case CRYPT_RIJNDAEL_MODE_ECB: |
815 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
816 | - $ciphertext.= $this->_encryptBlock(substr($plaintext, $i, $block_size)); |
|
815 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
816 | + $ciphertext .= $this->_encryptBlock(substr($plaintext, $i, $block_size)); |
|
817 | 817 | } |
818 | 818 | break; |
819 | 819 | case CRYPT_RIJNDAEL_MODE_CBC: |
820 | 820 | $xor = $this->encryptIV; |
821 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
821 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
822 | 822 | $block = substr($plaintext, $i, $block_size); |
823 | 823 | $block = $this->_encryptBlock($block ^ $xor); |
824 | 824 | $xor = $block; |
825 | - $ciphertext.= $block; |
|
825 | + $ciphertext .= $block; |
|
826 | 826 | } |
827 | 827 | if ($this->continuousBuffer) { |
828 | 828 | $this->encryptIV = $xor; |
@@ -831,25 +831,25 @@ discard block |
||
831 | 831 | case CRYPT_RIJNDAEL_MODE_CTR: |
832 | 832 | $xor = $this->encryptIV; |
833 | 833 | if (strlen($buffer['encrypted'])) { |
834 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
834 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
835 | 835 | $block = substr($plaintext, $i, $block_size); |
836 | 836 | if (strlen($block) > strlen($buffer['encrypted'])) { |
837 | - $buffer['encrypted'].= $this->_encryptBlock($this->_generate_xor($block_size, $xor)); |
|
837 | + $buffer['encrypted'] .= $this->_encryptBlock($this->_generate_xor($block_size, $xor)); |
|
838 | 838 | } |
839 | 839 | $key = $this->_string_shift($buffer['encrypted'], $block_size); |
840 | - $ciphertext.= $block ^ $key; |
|
840 | + $ciphertext .= $block ^ $key; |
|
841 | 841 | } |
842 | 842 | } else { |
843 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
843 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
844 | 844 | $block = substr($plaintext, $i, $block_size); |
845 | 845 | $key = $this->_encryptBlock($this->_generate_xor($block_size, $xor)); |
846 | - $ciphertext.= $block ^ $key; |
|
846 | + $ciphertext .= $block ^ $key; |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | if ($this->continuousBuffer) { |
850 | 850 | $this->encryptIV = $xor; |
851 | 851 | if ($start = strlen($plaintext) % $block_size) { |
852 | - $buffer['encrypted'] = substr($key, $start) . $buffer['encrypted']; |
|
852 | + $buffer['encrypted'] = substr($key, $start).$buffer['encrypted']; |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | break; |
@@ -870,11 +870,11 @@ discard block |
||
870 | 870 | $max = $block_size - $pos; |
871 | 871 | if ($len >= $max) { |
872 | 872 | $i = $max; |
873 | - $len-= $max; |
|
873 | + $len -= $max; |
|
874 | 874 | $pos = 0; |
875 | 875 | } else { |
876 | 876 | $i = $len; |
877 | - $pos+= $len; |
|
877 | + $pos += $len; |
|
878 | 878 | $len = 0; |
879 | 879 | } |
880 | 880 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize |
@@ -883,41 +883,41 @@ discard block |
||
883 | 883 | } |
884 | 884 | while ($len >= $block_size) { |
885 | 885 | $iv = $this->_encryptBlock($iv) ^ substr($plaintext, $i, $block_size); |
886 | - $ciphertext.= $iv; |
|
887 | - $len-= $block_size; |
|
888 | - $i+= $block_size; |
|
886 | + $ciphertext .= $iv; |
|
887 | + $len -= $block_size; |
|
888 | + $i += $block_size; |
|
889 | 889 | } |
890 | 890 | if ($len) { |
891 | 891 | $iv = $this->_encryptBlock($iv); |
892 | 892 | $block = $iv ^ substr($plaintext, $i); |
893 | 893 | $iv = substr_replace($iv, $block, 0, $len); |
894 | - $ciphertext.= $block; |
|
894 | + $ciphertext .= $block; |
|
895 | 895 | $pos = $len; |
896 | 896 | } |
897 | 897 | break; |
898 | 898 | case CRYPT_RIJNDAEL_MODE_OFB: |
899 | 899 | $xor = $this->encryptIV; |
900 | 900 | if (strlen($buffer['xor'])) { |
901 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
901 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
902 | 902 | $block = substr($plaintext, $i, $block_size); |
903 | 903 | if (strlen($block) > strlen($buffer['xor'])) { |
904 | 904 | $xor = $this->_encryptBlock($xor); |
905 | - $buffer['xor'].= $xor; |
|
905 | + $buffer['xor'] .= $xor; |
|
906 | 906 | } |
907 | 907 | $key = $this->_string_shift($buffer['xor'], $block_size); |
908 | - $ciphertext.= $block ^ $key; |
|
908 | + $ciphertext .= $block ^ $key; |
|
909 | 909 | } |
910 | 910 | } else { |
911 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
911 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
912 | 912 | $xor = $this->_encryptBlock($xor); |
913 | - $ciphertext.= substr($plaintext, $i, $block_size) ^ $xor; |
|
913 | + $ciphertext .= substr($plaintext, $i, $block_size) ^ $xor; |
|
914 | 914 | } |
915 | 915 | $key = $xor; |
916 | 916 | } |
917 | 917 | if ($this->continuousBuffer) { |
918 | 918 | $this->encryptIV = $xor; |
919 | 919 | if ($start = strlen($plaintext) % $block_size) { |
920 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
920 | + $buffer['xor'] = substr($key, $start).$buffer['xor']; |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | } |
@@ -955,15 +955,15 @@ discard block |
||
955 | 955 | $plaintext = ''; |
956 | 956 | switch ($this->mode) { |
957 | 957 | case CRYPT_RIJNDAEL_MODE_ECB: |
958 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
959 | - $plaintext.= $this->_decryptBlock(substr($ciphertext, $i, $block_size)); |
|
958 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
959 | + $plaintext .= $this->_decryptBlock(substr($ciphertext, $i, $block_size)); |
|
960 | 960 | } |
961 | 961 | break; |
962 | 962 | case CRYPT_RIJNDAEL_MODE_CBC: |
963 | 963 | $xor = $this->decryptIV; |
964 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
964 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
965 | 965 | $block = substr($ciphertext, $i, $block_size); |
966 | - $plaintext.= $this->_decryptBlock($block) ^ $xor; |
|
966 | + $plaintext .= $this->_decryptBlock($block) ^ $xor; |
|
967 | 967 | $xor = $block; |
968 | 968 | } |
969 | 969 | if ($this->continuousBuffer) { |
@@ -973,25 +973,25 @@ discard block |
||
973 | 973 | case CRYPT_RIJNDAEL_MODE_CTR: |
974 | 974 | $xor = $this->decryptIV; |
975 | 975 | if (strlen($buffer['ciphertext'])) { |
976 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
976 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
977 | 977 | $block = substr($ciphertext, $i, $block_size); |
978 | 978 | if (strlen($block) > strlen($buffer['ciphertext'])) { |
979 | - $buffer['ciphertext'].= $this->_encryptBlock($this->_generate_xor($block_size, $xor)); |
|
979 | + $buffer['ciphertext'] .= $this->_encryptBlock($this->_generate_xor($block_size, $xor)); |
|
980 | 980 | } |
981 | 981 | $key = $this->_string_shift($buffer['ciphertext'], $block_size); |
982 | - $plaintext.= $block ^ $key; |
|
982 | + $plaintext .= $block ^ $key; |
|
983 | 983 | } |
984 | 984 | } else { |
985 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
985 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
986 | 986 | $block = substr($ciphertext, $i, $block_size); |
987 | 987 | $key = $this->_encryptBlock($this->_generate_xor($block_size, $xor)); |
988 | - $plaintext.= $block ^ $key; |
|
988 | + $plaintext .= $block ^ $key; |
|
989 | 989 | } |
990 | 990 | } |
991 | 991 | if ($this->continuousBuffer) { |
992 | 992 | $this->decryptIV = $xor; |
993 | 993 | if ($start = strlen($ciphertext) % $block_size) { |
994 | - $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext']; |
|
994 | + $buffer['ciphertext'] = substr($key, $start).$buffer['ciphertext']; |
|
995 | 995 | } |
996 | 996 | } |
997 | 997 | break; |
@@ -1010,11 +1010,11 @@ discard block |
||
1010 | 1010 | $max = $block_size - $pos; |
1011 | 1011 | if ($len >= $max) { |
1012 | 1012 | $i = $max; |
1013 | - $len-= $max; |
|
1013 | + $len -= $max; |
|
1014 | 1014 | $pos = 0; |
1015 | 1015 | } else { |
1016 | 1016 | $i = $len; |
1017 | - $pos+= $len; |
|
1017 | + $pos += $len; |
|
1018 | 1018 | $len = 0; |
1019 | 1019 | } |
1020 | 1020 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize |
@@ -1024,14 +1024,14 @@ discard block |
||
1024 | 1024 | while ($len >= $block_size) { |
1025 | 1025 | $iv = $this->_encryptBlock($iv); |
1026 | 1026 | $cb = substr($ciphertext, $i, $block_size); |
1027 | - $plaintext.= $iv ^ $cb; |
|
1027 | + $plaintext .= $iv ^ $cb; |
|
1028 | 1028 | $iv = $cb; |
1029 | - $len-= $block_size; |
|
1030 | - $i+= $block_size; |
|
1029 | + $len -= $block_size; |
|
1030 | + $i += $block_size; |
|
1031 | 1031 | } |
1032 | 1032 | if ($len) { |
1033 | 1033 | $iv = $this->_encryptBlock($iv); |
1034 | - $plaintext.= $iv ^ substr($ciphertext, $i); |
|
1034 | + $plaintext .= $iv ^ substr($ciphertext, $i); |
|
1035 | 1035 | $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len); |
1036 | 1036 | $pos = $len; |
1037 | 1037 | } |
@@ -1039,26 +1039,26 @@ discard block |
||
1039 | 1039 | case CRYPT_RIJNDAEL_MODE_OFB: |
1040 | 1040 | $xor = $this->decryptIV; |
1041 | 1041 | if (strlen($buffer['xor'])) { |
1042 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
1042 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
1043 | 1043 | $block = substr($ciphertext, $i, $block_size); |
1044 | 1044 | if (strlen($block) > strlen($buffer['xor'])) { |
1045 | 1045 | $xor = $this->_encryptBlock($xor); |
1046 | - $buffer['xor'].= $xor; |
|
1046 | + $buffer['xor'] .= $xor; |
|
1047 | 1047 | } |
1048 | 1048 | $key = $this->_string_shift($buffer['xor'], $block_size); |
1049 | - $plaintext.= $block ^ $key; |
|
1049 | + $plaintext .= $block ^ $key; |
|
1050 | 1050 | } |
1051 | 1051 | } else { |
1052 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
1052 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
1053 | 1053 | $xor = $this->_encryptBlock($xor); |
1054 | - $plaintext.= substr($ciphertext, $i, $block_size) ^ $xor; |
|
1054 | + $plaintext .= substr($ciphertext, $i, $block_size) ^ $xor; |
|
1055 | 1055 | } |
1056 | 1056 | $key = $xor; |
1057 | 1057 | } |
1058 | 1058 | if ($this->continuousBuffer) { |
1059 | 1059 | $this->decryptIV = $xor; |
1060 | 1060 | if ($start = strlen($ciphertext) % $block_size) { |
1061 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1061 | + $buffer['xor'] = substr($key, $start).$buffer['xor']; |
|
1062 | 1062 | } |
1063 | 1063 | } |
1064 | 1064 | } |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | while ($i < $Nb) { |
1112 | 1112 | $temp[$i] = $t0[$state[$i] >> 24 & 0x000000FF] ^ |
1113 | 1113 | $t1[$state[$j] >> 16 & 0x000000FF] ^ |
1114 | - $t2[$state[$k] >> 8 & 0x000000FF] ^ |
|
1115 | - $t3[$state[$l] & 0x000000FF] ^ |
|
1114 | + $t2[$state[$k] >> 8 & 0x000000FF] ^ |
|
1115 | + $t3[$state[$l] & 0x000000FF] ^ |
|
1116 | 1116 | $w[$round][$i]; |
1117 | 1117 | ++$i; |
1118 | 1118 | $j = ($j + 1) % $Nb; |
@@ -1203,8 +1203,8 @@ discard block |
||
1203 | 1203 | while ($i < $Nb) { |
1204 | 1204 | $temp[$i] = $dt0[$state[$i] >> 24 & 0x000000FF] ^ |
1205 | 1205 | $dt1[$state[$j] >> 16 & 0x000000FF] ^ |
1206 | - $dt2[$state[$k] >> 8 & 0x000000FF] ^ |
|
1207 | - $dt3[$state[$l] & 0x000000FF] ^ |
|
1206 | + $dt2[$state[$k] >> 8 & 0x000000FF] ^ |
|
1207 | + $dt3[$state[$l] & 0x000000FF] ^ |
|
1208 | 1208 | $dw[$round][$i]; |
1209 | 1209 | ++$i; |
1210 | 1210 | $j = ($j + 1) % $Nb; |
@@ -1348,8 +1348,8 @@ discard block |
||
1348 | 1348 | $dw = $this->_subWord($this->w[$row][$j]); |
1349 | 1349 | $temp[$j] = $this->dt0[$dw >> 24 & 0x000000FF] ^ |
1350 | 1350 | $this->dt1[$dw >> 16 & 0x000000FF] ^ |
1351 | - $this->dt2[$dw >> 8 & 0x000000FF] ^ |
|
1352 | - $this->dt3[$dw & 0x000000FF]; |
|
1351 | + $this->dt2[$dw >> 8 & 0x000000FF] ^ |
|
1352 | + $this->dt3[$dw & 0x000000FF]; |
|
1353 | 1353 | $j++; |
1354 | 1354 | } |
1355 | 1355 | $this->dw[$row] = $temp; |
@@ -1392,8 +1392,8 @@ discard block |
||
1392 | 1392 | { |
1393 | 1393 | $sbox = $this->sbox; |
1394 | 1394 | |
1395 | - return $sbox[$word & 0x000000FF] | |
|
1396 | - ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
1395 | + return $sbox[$word & 0x000000FF] | |
|
1396 | + ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
1397 | 1397 | ($sbox[$word >> 16 & 0x000000FF] << 16) | |
1398 | 1398 | ($sbox[$word >> 24 & 0x000000FF] << 24); |
1399 | 1399 | } |
@@ -1407,8 +1407,8 @@ discard block |
||
1407 | 1407 | { |
1408 | 1408 | $isbox = $this->isbox; |
1409 | 1409 | |
1410 | - return $isbox[$word & 0x000000FF] | |
|
1411 | - ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
1410 | + return $isbox[$word & 0x000000FF] | |
|
1411 | + ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
1412 | 1412 | ($isbox[$word >> 16 & 0x000000FF] << 16) | |
1413 | 1413 | ($isbox[$word >> 24 & 0x000000FF] << 24); |
1414 | 1414 | } |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | // So here we are'nt under the same heavy timing-stress as we are in _de/encryptBlock() or de/encrypt(). |
1589 | 1589 | // However...the here generated function- $code, stored as php callback in $this->inline_crypt, must work as fast as even possible. |
1590 | 1590 | |
1591 | - $lambda_functions =& Crypt_Rijndael::get_lambda_functions(); |
|
1591 | + $lambda_functions = & Crypt_Rijndael::get_lambda_functions(); |
|
1592 | 1592 | $block_size = $this->block_size; |
1593 | 1593 | $mode = $this->mode; |
1594 | 1594 | |
@@ -1609,7 +1609,7 @@ discard block |
||
1609 | 1609 | $init_decryptBlock = 'extract($self->dw, EXTR_PREFIX_ALL, "dw");'; |
1610 | 1610 | } |
1611 | 1611 | |
1612 | - $code_hash = md5("$mode, $block_size, " . implode(',', $w)); |
|
1612 | + $code_hash = md5("$mode, $block_size, ".implode(',', $w)); |
|
1613 | 1613 | |
1614 | 1614 | if (!isset($lambda_functions[$code_hash])) { |
1615 | 1615 | $Nr = $this->Nr; |
@@ -1617,7 +1617,7 @@ discard block |
||
1617 | 1617 | $c = $this->c; |
1618 | 1618 | |
1619 | 1619 | // Generating encrypt code: |
1620 | - $init_encryptBlock.= ' |
|
1620 | + $init_encryptBlock .= ' |
|
1621 | 1621 | $t0 = $self->t0; |
1622 | 1622 | $t1 = $self->t1; |
1623 | 1623 | $t2 = $self->t2; |
@@ -1638,9 +1638,9 @@ discard block |
||
1638 | 1638 | for ($round = 1; $round < $Nr; ++$round) { |
1639 | 1639 | list($s, $e) = array($e, $s); |
1640 | 1640 | for ($i = 0; $i < $Nb; ++$i) { |
1641 | - $_encryptBlock.= |
|
1641 | + $_encryptBlock .= |
|
1642 | 1642 | '$'.$e.$i.' = |
1643 | - $t0[($'.$s.$i .' >> 24) & 0xff] ^ |
|
1643 | + $t0[($'.$s.$i.' >> 24) & 0xff] ^ |
|
1644 | 1644 | $t1[($'.$s.(($i + $c[1]) % $Nb).' >> 16) & 0xff] ^ |
1645 | 1645 | $t2[($'.$s.(($i + $c[2]) % $Nb).' >> 8) & 0xff] ^ |
1646 | 1646 | $t3[ $'.$s.(($i + $c[3]) % $Nb).' & 0xff] ^ |
@@ -1650,7 +1650,7 @@ discard block |
||
1650 | 1650 | |
1651 | 1651 | // Finalround: subWord + shiftRows + addRoundKey |
1652 | 1652 | for ($i = 0; $i < $Nb; ++$i) { |
1653 | - $_encryptBlock.= |
|
1653 | + $_encryptBlock .= |
|
1654 | 1654 | '$'.$e.$i.' = |
1655 | 1655 | $sbox[ $'.$e.$i.' & 0xff] | |
1656 | 1656 | ($sbox[($'.$e.$i.' >> 8) & 0xff] << 8) | |
@@ -1659,8 +1659,8 @@ discard block |
||
1659 | 1659 | } |
1660 | 1660 | $_encryptBlock .= '$in = pack("N*"'."\n"; |
1661 | 1661 | for ($i = 0; $i < $Nb; ++$i) { |
1662 | - $_encryptBlock.= ', |
|
1663 | - ($'.$e.$i .' & 0xFF000000) ^ |
|
1662 | + $_encryptBlock .= ', |
|
1663 | + ($'.$e.$i.' & 0xFF000000) ^ |
|
1664 | 1664 | ($'.$e.(($i + $c[1]) % $Nb).' & 0x00FF0000) ^ |
1665 | 1665 | ($'.$e.(($i + $c[2]) % $Nb).' & 0x0000FF00) ^ |
1666 | 1666 | ($'.$e.(($i + $c[3]) % $Nb).' & 0x000000FF) ^ |
@@ -1669,7 +1669,7 @@ discard block |
||
1669 | 1669 | $_encryptBlock .= ');'; |
1670 | 1670 | |
1671 | 1671 | // Generating decrypt code: |
1672 | - $init_decryptBlock.= ' |
|
1672 | + $init_decryptBlock .= ' |
|
1673 | 1673 | $dt0 = $self->dt0; |
1674 | 1674 | $dt1 = $self->dt1; |
1675 | 1675 | $dt2 = $self->dt2; |
@@ -1690,9 +1690,9 @@ discard block |
||
1690 | 1690 | for ($round = 1; $round < $Nr; ++$round) { |
1691 | 1691 | list($s, $e) = array($e, $s); |
1692 | 1692 | for ($i = 0; $i < $Nb; ++$i) { |
1693 | - $_decryptBlock.= |
|
1693 | + $_decryptBlock .= |
|
1694 | 1694 | '$'.$e.$i.' = |
1695 | - $dt0[($'.$s.$i .' >> 24) & 0xff] ^ |
|
1695 | + $dt0[($'.$s.$i.' >> 24) & 0xff] ^ |
|
1696 | 1696 | $dt1[($'.$s.(($Nb + $i - $c[1]) % $Nb).' >> 16) & 0xff] ^ |
1697 | 1697 | $dt2[($'.$s.(($Nb + $i - $c[2]) % $Nb).' >> 8) & 0xff] ^ |
1698 | 1698 | $dt3[ $'.$s.(($Nb + $i - $c[3]) % $Nb).' & 0xff] ^ |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | |
1703 | 1703 | // Finalround: subWord + shiftRows + addRoundKey |
1704 | 1704 | for ($i = 0; $i < $Nb; ++$i) { |
1705 | - $_decryptBlock.= |
|
1705 | + $_decryptBlock .= |
|
1706 | 1706 | '$'.$e.$i.' = |
1707 | 1707 | $isbox[ $'.$e.$i.' & 0xff] | |
1708 | 1708 | ($isbox[($'.$e.$i.' >> 8) & 0xff] << 8) | |
@@ -1711,8 +1711,8 @@ discard block |
||
1711 | 1711 | } |
1712 | 1712 | $_decryptBlock .= '$in = pack("N*"'."\n"; |
1713 | 1713 | for ($i = 0; $i < $Nb; ++$i) { |
1714 | - $_decryptBlock.= ', |
|
1715 | - ($'.$e.$i. ' & 0xFF000000) ^ |
|
1714 | + $_decryptBlock .= ', |
|
1715 | + ($'.$e.$i.' & 0xFF000000) ^ |
|
1716 | 1716 | ($'.$e.(($Nb + $i - $c[1]) % $Nb).' & 0x00FF0000) ^ |
1717 | 1717 | ($'.$e.(($Nb + $i - $c[2]) % $Nb).' & 0x0000FF00) ^ |
1718 | 1718 | ($'.$e.(($Nb + $i - $c[3]) % $Nb).' & 0x000000FF) ^ |
@@ -1723,7 +1723,7 @@ discard block |
||
1723 | 1723 | // Generating mode of operation code: |
1724 | 1724 | switch ($mode) { |
1725 | 1725 | case CRYPT_RIJNDAEL_MODE_ECB: |
1726 | - $encrypt = $init_encryptBlock . ' |
|
1726 | + $encrypt = $init_encryptBlock.' |
|
1727 | 1727 | $ciphertext = ""; |
1728 | 1728 | $text = $self->_pad($text); |
1729 | 1729 | $plaintext_len = strlen($text); |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | return $ciphertext; |
1738 | 1738 | '; |
1739 | 1739 | |
1740 | - $decrypt = $init_decryptBlock . ' |
|
1740 | + $decrypt = $init_decryptBlock.' |
|
1741 | 1741 | $plaintext = ""; |
1742 | 1742 | $text = str_pad($text, strlen($text) + ('.$block_size.' - strlen($text) % '.$block_size.') % '.$block_size.', chr(0)); |
1743 | 1743 | $ciphertext_len = strlen($text); |
@@ -1752,7 +1752,7 @@ discard block |
||
1752 | 1752 | '; |
1753 | 1753 | break; |
1754 | 1754 | case CRYPT_RIJNDAEL_MODE_CBC: |
1755 | - $encrypt = $init_encryptBlock . ' |
|
1755 | + $encrypt = $init_encryptBlock.' |
|
1756 | 1756 | $ciphertext = ""; |
1757 | 1757 | $text = $self->_pad($text); |
1758 | 1758 | $plaintext_len = strlen($text); |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | return $ciphertext; |
1773 | 1773 | '; |
1774 | 1774 | |
1775 | - $decrypt = $init_decryptBlock . ' |
|
1775 | + $decrypt = $init_decryptBlock.' |
|
1776 | 1776 | $plaintext = ""; |
1777 | 1777 | $text = str_pad($text, strlen($text) + ('.$block_size.' - strlen($text) % '.$block_size.') % '.$block_size.', chr(0)); |
1778 | 1778 | $ciphertext_len = strlen($text); |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | '; |
1795 | 1795 | break; |
1796 | 1796 | case CRYPT_RIJNDAEL_MODE_CTR: |
1797 | - $encrypt = $init_encryptBlock . ' |
|
1797 | + $encrypt = $init_encryptBlock.' |
|
1798 | 1798 | $ciphertext = ""; |
1799 | 1799 | $plaintext_len = strlen($text); |
1800 | 1800 | $xor = $self->encryptIV; |
@@ -1830,7 +1830,7 @@ discard block |
||
1830 | 1830 | return $ciphertext; |
1831 | 1831 | '; |
1832 | 1832 | |
1833 | - $decrypt = $init_encryptBlock . ' |
|
1833 | + $decrypt = $init_encryptBlock.' |
|
1834 | 1834 | $plaintext = ""; |
1835 | 1835 | $ciphertext_len = strlen($text); |
1836 | 1836 | $xor = $self->decryptIV; |
@@ -1867,7 +1867,7 @@ discard block |
||
1867 | 1867 | '; |
1868 | 1868 | break; |
1869 | 1869 | case CRYPT_RIJNDAEL_MODE_CFB: |
1870 | - $encrypt = $init_encryptBlock . ' |
|
1870 | + $encrypt = $init_encryptBlock.' |
|
1871 | 1871 | $ciphertext = ""; |
1872 | 1872 | $buffer = &$self->enbuffer; |
1873 | 1873 | |
@@ -1915,7 +1915,7 @@ discard block |
||
1915 | 1915 | return $ciphertext; |
1916 | 1916 | '; |
1917 | 1917 | |
1918 | - $decrypt = $init_encryptBlock . ' |
|
1918 | + $decrypt = $init_encryptBlock.' |
|
1919 | 1919 | $plaintext = ""; |
1920 | 1920 | $buffer = &$self->debuffer; |
1921 | 1921 | |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | '; |
1967 | 1967 | break; |
1968 | 1968 | case CRYPT_RIJNDAEL_MODE_OFB: |
1969 | - $encrypt = $init_encryptBlock . ' |
|
1969 | + $encrypt = $init_encryptBlock.' |
|
1970 | 1970 | $ciphertext = ""; |
1971 | 1971 | $plaintext_len = strlen($text); |
1972 | 1972 | $xor = $self->encryptIV; |
@@ -2002,7 +2002,7 @@ discard block |
||
2002 | 2002 | return $ciphertext; |
2003 | 2003 | '; |
2004 | 2004 | |
2005 | - $decrypt = $init_encryptBlock . ' |
|
2005 | + $decrypt = $init_encryptBlock.' |
|
2006 | 2006 | $plaintext = ""; |
2007 | 2007 | $ciphertext_len = strlen($text); |
2008 | 2008 | $xor = $self->decryptIV; |
@@ -677,7 +677,6 @@ discard block |
||
677 | 677 | * |
678 | 678 | * @access private |
679 | 679 | * @see setPrivateKeyFormat() |
680 | - * @param String $RSAPrivateKey |
|
681 | 680 | * @return String |
682 | 681 | */ |
683 | 682 | function _convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients) |
@@ -830,7 +829,6 @@ discard block |
||
830 | 829 | * |
831 | 830 | * @access private |
832 | 831 | * @see setPublicKeyFormat() |
833 | - * @param String $RSAPrivateKey |
|
834 | 832 | * @return String |
835 | 833 | */ |
836 | 834 | function _convertPublicKey($n, $e) |
@@ -1491,7 +1489,6 @@ discard block |
||
1491 | 1489 | * |
1492 | 1490 | * @see getPublicKey() |
1493 | 1491 | * @access public |
1494 | - * @param String $key |
|
1495 | 1492 | * @param Integer $type optional |
1496 | 1493 | */ |
1497 | 1494 | function getPublicKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) |
@@ -1514,7 +1511,6 @@ discard block |
||
1514 | 1511 | * |
1515 | 1512 | * @see getPublicKey() |
1516 | 1513 | * @access public |
1517 | - * @param String $key |
|
1518 | 1514 | * @param Integer $type optional |
1519 | 1515 | */ |
1520 | 1516 | function getPrivateKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) |
@@ -1538,8 +1534,7 @@ discard block |
||
1538 | 1534 | * |
1539 | 1535 | * @see getPrivateKey() |
1540 | 1536 | * @access private |
1541 | - * @param String $key |
|
1542 | - * @param Integer $type optional |
|
1537 | + * @param integer $mode |
|
1543 | 1538 | */ |
1544 | 1539 | function _getPrivatePublicKey($mode = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) |
1545 | 1540 | { |
@@ -1742,7 +1737,6 @@ discard block |
||
1742 | 1737 | * of the hash function Hash) and 0. |
1743 | 1738 | * |
1744 | 1739 | * @access public |
1745 | - * @param Integer $format |
|
1746 | 1740 | */ |
1747 | 1741 | function setSaltLength($sLen) |
1748 | 1742 | { |
@@ -1991,7 +1985,6 @@ discard block |
||
1991 | 1985 | * |
1992 | 1986 | * @access private |
1993 | 1987 | * @param String $mgfSeed |
1994 | - * @param Integer $mgfLen |
|
1995 | 1988 | * @return String |
1996 | 1989 | */ |
1997 | 1990 | function _mgf1($mgfSeed, $maskLen) |
@@ -2284,7 +2277,7 @@ discard block |
||
2284 | 2277 | * @param String $m |
2285 | 2278 | * @param String $em |
2286 | 2279 | * @param Integer $emBits |
2287 | - * @return String |
|
2280 | + * @return boolean |
|
2288 | 2281 | */ |
2289 | 2282 | function _emsa_pss_verify($m, $em, $emBits) |
2290 | 2283 | { |
@@ -2356,7 +2349,7 @@ discard block |
||
2356 | 2349 | * @access private |
2357 | 2350 | * @param String $m |
2358 | 2351 | * @param String $s |
2359 | - * @return String |
|
2352 | + * @return boolean |
|
2360 | 2353 | */ |
2361 | 2354 | function _rsassa_pss_verify($m, $s) |
2362 | 2355 | { |
@@ -2477,7 +2470,8 @@ discard block |
||
2477 | 2470 | * |
2478 | 2471 | * @access private |
2479 | 2472 | * @param String $m |
2480 | - * @return String |
|
2473 | + * @param string $s |
|
2474 | + * @return boolean |
|
2481 | 2475 | */ |
2482 | 2476 | function _rsassa_pkcs1_v1_5_verify($m, $s) |
2483 | 2477 | { |
@@ -2610,7 +2604,6 @@ discard block |
||
2610 | 2604 | * |
2611 | 2605 | * @see encrypt() |
2612 | 2606 | * @access public |
2613 | - * @param String $plaintext |
|
2614 | 2607 | * @return String |
2615 | 2608 | */ |
2616 | 2609 | function decrypt($ciphertext) |
@@ -703,15 +703,15 @@ discard block |
||
703 | 703 | return false; |
704 | 704 | } |
705 | 705 | return "<RSAKeyValue>\r\n" . |
706 | - ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
707 | - ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
708 | - ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
709 | - ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
710 | - ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
711 | - ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
712 | - ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
713 | - ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
714 | - '</RSAKeyValue>'; |
|
706 | + ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
707 | + ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
708 | + ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
709 | + ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
710 | + ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
711 | + ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
712 | + ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
713 | + ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
714 | + '</RSAKeyValue>'; |
|
715 | 715 | break; |
716 | 716 | case CRYPT_RSA_PRIVATE_FORMAT_PUTTY: |
717 | 717 | if ($num_primes != 2) { |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | strlen('ssh-rsa'), 'ssh-rsa', strlen($raw['publicExponent']), $raw['publicExponent'], strlen($raw['modulus']), $raw['modulus'] |
726 | 726 | ); |
727 | 727 | $source = pack('Na*Na*Na*Na*', |
728 | - strlen('ssh-rsa'), 'ssh-rsa', strlen($encryption), $encryption, |
|
729 | - strlen($this->comment), $this->comment, strlen($public), $public |
|
728 | + strlen('ssh-rsa'), 'ssh-rsa', strlen($encryption), $encryption, |
|
729 | + strlen($this->comment), $this->comment, strlen($public), $public |
|
730 | 730 | ); |
731 | 731 | $public = base64_encode($public); |
732 | 732 | $key.= "Public-Lines: " . ((strlen($public) + 32) >> 6) . "\r\n"; |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | $des->setIV($iv); |
811 | 811 | $iv = strtoupper(bin2hex($iv)); |
812 | 812 | $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
813 | - "Proc-Type: 4,ENCRYPTED\r\n" . |
|
814 | - "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
815 | - "\r\n" . |
|
816 | - chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
817 | - '-----END RSA PRIVATE KEY-----'; |
|
813 | + "Proc-Type: 4,ENCRYPTED\r\n" . |
|
814 | + "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
815 | + "\r\n" . |
|
816 | + chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
817 | + '-----END RSA PRIVATE KEY-----'; |
|
818 | 818 | } else { |
819 | 819 | $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
820 | - chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
821 | - '-----END RSA PRIVATE KEY-----'; |
|
820 | + chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
821 | + '-----END RSA PRIVATE KEY-----'; |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | return $RSAPrivateKey; |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | return array('e' => $e->copy(), 'n' => $n->copy()); |
844 | 844 | case CRYPT_RSA_PUBLIC_FORMAT_XML: |
845 | 845 | return "<RSAKeyValue>\r\n" . |
846 | - ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
847 | - ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
848 | - '</RSAKeyValue>'; |
|
846 | + ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
847 | + ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
848 | + '</RSAKeyValue>'; |
|
849 | 849 | break; |
850 | 850 | case CRYPT_RSA_PUBLIC_FORMAT_OPENSSH: |
851 | 851 | // from <http://tools.ietf.org/html/rfc4253#page-15>: |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | } |
885 | 885 | |
886 | 886 | $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
887 | - chunk_split(base64_encode($RSAPublicKey), 64) . |
|
888 | - '-----END PUBLIC KEY-----'; |
|
887 | + chunk_split(base64_encode($RSAPublicKey), 64) . |
|
888 | + '-----END PUBLIC KEY-----'; |
|
889 | 889 | |
890 | 890 | return $RSAPublicKey; |
891 | 891 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @see Crypt_RSA::setHash() |
101 | 101 | * @see Crypt_RSA::setMGFHash() |
102 | 102 | */ |
103 | -define('CRYPT_RSA_ENCRYPTION_OAEP', 1); |
|
103 | +define('CRYPT_RSA_ENCRYPTION_OAEP', 1); |
|
104 | 104 | /** |
105 | 105 | * Use PKCS#1 padding. |
106 | 106 | * |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @see Crypt_RSA::setSaltLength() |
125 | 125 | * @see Crypt_RSA::setMGFHash() |
126 | 126 | */ |
127 | -define('CRYPT_RSA_SIGNATURE_PSS', 1); |
|
127 | +define('CRYPT_RSA_SIGNATURE_PSS', 1); |
|
128 | 128 | /** |
129 | 129 | * Use the PKCS#1 scheme by default. |
130 | 130 | * |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * ASN1 Integer |
143 | 143 | */ |
144 | -define('CRYPT_RSA_ASN1_INTEGER', 2); |
|
144 | +define('CRYPT_RSA_ASN1_INTEGER', 2); |
|
145 | 145 | /** |
146 | 146 | * ASN1 Bit String |
147 | 147 | */ |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * Default openSSL configuration file. |
173 | 173 | */ |
174 | -define('CRYPT_RSA_OPENSSL_CONFIG', dirname(__FILE__) . '/../openssl.cnf'); |
|
174 | +define('CRYPT_RSA_OPENSSL_CONFIG', dirname(__FILE__).'/../openssl.cnf'); |
|
175 | 175 | |
176 | 176 | |
177 | 177 | /**#@+ |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | |
468 | 468 | $this->configFile = CRYPT_RSA_OPENSSL_CONFIG; |
469 | 469 | |
470 | - if ( !defined('CRYPT_RSA_MODE') ) { |
|
470 | + if (!defined('CRYPT_RSA_MODE')) { |
|
471 | 471 | switch (true) { |
472 | 472 | case extension_loaded('openssl') && version_compare(PHP_VERSION, '4.2.0', '>=') && file_exists($this->configFile): |
473 | 473 | define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_OPENSSL); |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | } |
519 | 519 | |
520 | 520 | // OpenSSL uses 65537 as the exponent and requires RSA keys be 384 bits minimum |
521 | - if ( CRYPT_RSA_MODE == CRYPT_RSA_MODE_OPENSSL && $bits >= 384 && CRYPT_RSA_EXPONENT == 65537) { |
|
521 | + if (CRYPT_RSA_MODE == CRYPT_RSA_MODE_OPENSSL && $bits >= 384 && CRYPT_RSA_EXPONENT == 65537) { |
|
522 | 522 | $config = array(); |
523 | 523 | if (isset($this->configFile)) { |
524 | 524 | $config['config'] = $this->configFile; |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | do { |
579 | 579 | for ($i = $i0; $i <= $num_primes; $i++) { |
580 | 580 | if ($timeout !== false) { |
581 | - $timeout-= time() - $start; |
|
581 | + $timeout -= time() - $start; |
|
582 | 582 | $start = time(); |
583 | 583 | if ($timeout <= 0) { |
584 | 584 | return array( |
@@ -702,15 +702,15 @@ discard block |
||
702 | 702 | if ($num_primes != 2) { |
703 | 703 | return false; |
704 | 704 | } |
705 | - return "<RSAKeyValue>\r\n" . |
|
706 | - ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
707 | - ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
708 | - ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
709 | - ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
710 | - ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
711 | - ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
712 | - ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
713 | - ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
705 | + return "<RSAKeyValue>\r\n". |
|
706 | + ' <Modulus>'.base64_encode($raw['modulus'])."</Modulus>\r\n". |
|
707 | + ' <Exponent>'.base64_encode($raw['publicExponent'])."</Exponent>\r\n". |
|
708 | + ' <P>'.base64_encode($raw['prime1'])."</P>\r\n". |
|
709 | + ' <Q>'.base64_encode($raw['prime2'])."</Q>\r\n". |
|
710 | + ' <DP>'.base64_encode($raw['exponent1'])."</DP>\r\n". |
|
711 | + ' <DQ>'.base64_encode($raw['exponent2'])."</DQ>\r\n". |
|
712 | + ' <InverseQ>'.base64_encode($raw['coefficient'])."</InverseQ>\r\n". |
|
713 | + ' <D>'.base64_encode($raw['privateExponent'])."</D>\r\n". |
|
714 | 714 | '</RSAKeyValue>'; |
715 | 715 | break; |
716 | 716 | case CRYPT_RSA_PRIVATE_FORMAT_PUTTY: |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | } |
720 | 720 | $key = "PuTTY-User-Key-File-2: ssh-rsa\r\nEncryption: "; |
721 | 721 | $encryption = (!empty($this->password) || is_string($this->password)) ? 'aes256-cbc' : 'none'; |
722 | - $key.= $encryption; |
|
723 | - $key.= "\r\nComment: " . $this->comment . "\r\n"; |
|
722 | + $key .= $encryption; |
|
723 | + $key .= "\r\nComment: ".$this->comment."\r\n"; |
|
724 | 724 | $public = pack('Na*Na*Na*', |
725 | 725 | strlen('ssh-rsa'), 'ssh-rsa', strlen($raw['publicExponent']), $raw['publicExponent'], strlen($raw['modulus']), $raw['modulus'] |
726 | 726 | ); |
@@ -729,18 +729,18 @@ discard block |
||
729 | 729 | strlen($this->comment), $this->comment, strlen($public), $public |
730 | 730 | ); |
731 | 731 | $public = base64_encode($public); |
732 | - $key.= "Public-Lines: " . ((strlen($public) + 32) >> 6) . "\r\n"; |
|
733 | - $key.= chunk_split($public, 64); |
|
732 | + $key .= "Public-Lines: ".((strlen($public) + 32) >> 6)."\r\n"; |
|
733 | + $key .= chunk_split($public, 64); |
|
734 | 734 | $private = pack('Na*Na*Na*Na*', |
735 | 735 | strlen($raw['privateExponent']), $raw['privateExponent'], strlen($raw['prime1']), $raw['prime1'], |
736 | 736 | strlen($raw['prime2']), $raw['prime2'], strlen($raw['coefficient']), $raw['coefficient'] |
737 | 737 | ); |
738 | 738 | if (empty($this->password) && !is_string($this->password)) { |
739 | - $source.= pack('Na*', strlen($private), $private); |
|
739 | + $source .= pack('Na*', strlen($private), $private); |
|
740 | 740 | $hashkey = 'putty-private-key-file-mac-key'; |
741 | 741 | } else { |
742 | - $private.= crypt_random_string(16 - (strlen($private) & 15)); |
|
743 | - $source.= pack('Na*', strlen($private), $private); |
|
742 | + $private .= crypt_random_string(16 - (strlen($private) & 15)); |
|
743 | + $source .= pack('Na*', strlen($private), $private); |
|
744 | 744 | if (!class_exists('Crypt_AES')) { |
745 | 745 | require_once('Crypt/AES.php'); |
746 | 746 | } |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | $symkey = ''; |
749 | 749 | while (strlen($symkey) < 32) { |
750 | 750 | $temp = pack('Na*', $sequence++, $this->password); |
751 | - $symkey.= pack('H*', sha1($temp)); |
|
751 | + $symkey .= pack('H*', sha1($temp)); |
|
752 | 752 | } |
753 | 753 | $symkey = substr($symkey, 0, 32); |
754 | 754 | $crypto = new Crypt_AES(); |
@@ -756,18 +756,18 @@ discard block |
||
756 | 756 | $crypto->setKey($symkey); |
757 | 757 | $crypto->disablePadding(); |
758 | 758 | $private = $crypto->encrypt($private); |
759 | - $hashkey = 'putty-private-key-file-mac-key' . $this->password; |
|
759 | + $hashkey = 'putty-private-key-file-mac-key'.$this->password; |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | $private = base64_encode($private); |
763 | - $key.= 'Private-Lines: ' . ((strlen($private) + 32) >> 6) . "\r\n"; |
|
764 | - $key.= chunk_split($private, 64); |
|
763 | + $key .= 'Private-Lines: '.((strlen($private) + 32) >> 6)."\r\n"; |
|
764 | + $key .= chunk_split($private, 64); |
|
765 | 765 | if (!class_exists('Crypt_Hash')) { |
766 | 766 | require_once('Crypt/Hash.php'); |
767 | 767 | } |
768 | 768 | $hash = new Crypt_Hash('sha1'); |
769 | 769 | $hash->setKey(pack('H*', sha1($hashkey))); |
770 | - $key.= 'Private-MAC: ' . bin2hex($hash->hash($source)) . "\r\n"; |
|
770 | + $key .= 'Private-MAC: '.bin2hex($hash->hash($source))."\r\n"; |
|
771 | 771 | |
772 | 772 | return $key; |
773 | 773 | default: // eg. CRYPT_RSA_PRIVATE_FORMAT_PKCS1 |
@@ -789,19 +789,19 @@ discard block |
||
789 | 789 | // coefficient INTEGER -- ti |
790 | 790 | // } |
791 | 791 | $OtherPrimeInfo = pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($primes[$i]->toBytes(true))), $primes[$i]->toBytes(true)); |
792 | - $OtherPrimeInfo.= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); |
|
793 | - $OtherPrimeInfo.= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); |
|
794 | - $OtherPrimeInfos.= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); |
|
792 | + $OtherPrimeInfo .= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); |
|
793 | + $OtherPrimeInfo .= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); |
|
794 | + $OtherPrimeInfos .= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); |
|
795 | 795 | } |
796 | - $RSAPrivateKey.= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); |
|
796 | + $RSAPrivateKey .= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | $RSAPrivateKey = pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); |
800 | 800 | |
801 | 801 | if (!empty($this->password) || is_string($this->password)) { |
802 | 802 | $iv = crypt_random_string(8); |
803 | - $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key |
|
804 | - $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); |
|
803 | + $symkey = pack('H*', md5($this->password.$iv)); // symkey is short for symmetric key |
|
804 | + $symkey .= substr(pack('H*', md5($symkey.$this->password.$iv)), 0, 8); |
|
805 | 805 | if (!class_exists('Crypt_TripleDES')) { |
806 | 806 | require_once('Crypt/TripleDES.php'); |
807 | 807 | } |
@@ -809,15 +809,15 @@ discard block |
||
809 | 809 | $des->setKey($symkey); |
810 | 810 | $des->setIV($iv); |
811 | 811 | $iv = strtoupper(bin2hex($iv)); |
812 | - $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
|
813 | - "Proc-Type: 4,ENCRYPTED\r\n" . |
|
814 | - "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
815 | - "\r\n" . |
|
816 | - chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
812 | + $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n". |
|
813 | + "Proc-Type: 4,ENCRYPTED\r\n". |
|
814 | + "DEK-Info: DES-EDE3-CBC,$iv\r\n". |
|
815 | + "\r\n". |
|
816 | + chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64). |
|
817 | 817 | '-----END RSA PRIVATE KEY-----'; |
818 | 818 | } else { |
819 | - $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
|
820 | - chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
819 | + $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n". |
|
820 | + chunk_split(base64_encode($RSAPrivateKey), 64). |
|
821 | 821 | '-----END RSA PRIVATE KEY-----'; |
822 | 822 | } |
823 | 823 | |
@@ -842,9 +842,9 @@ discard block |
||
842 | 842 | case CRYPT_RSA_PUBLIC_FORMAT_RAW: |
843 | 843 | return array('e' => $e->copy(), 'n' => $n->copy()); |
844 | 844 | case CRYPT_RSA_PUBLIC_FORMAT_XML: |
845 | - return "<RSAKeyValue>\r\n" . |
|
846 | - ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
847 | - ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
845 | + return "<RSAKeyValue>\r\n". |
|
846 | + ' <Modulus>'.base64_encode($modulus)."</Modulus>\r\n". |
|
847 | + ' <Exponent>'.base64_encode($publicExponent)."</Exponent>\r\n". |
|
848 | 848 | '</RSAKeyValue>'; |
849 | 849 | break; |
850 | 850 | case CRYPT_RSA_PUBLIC_FORMAT_OPENSSH: |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | // mpint e |
854 | 854 | // mpint n |
855 | 855 | $RSAPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus); |
856 | - $RSAPublicKey = 'ssh-rsa ' . base64_encode($RSAPublicKey) . ' ' . $this->comment; |
|
856 | + $RSAPublicKey = 'ssh-rsa '.base64_encode($RSAPublicKey).' '.$this->comment; |
|
857 | 857 | |
858 | 858 | return $RSAPublicKey; |
859 | 859 | default: // eg. CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW or CRYPT_RSA_PUBLIC_FORMAT_PKCS1 |
@@ -875,16 +875,16 @@ discard block |
||
875 | 875 | if ($this->publicKeyFormat == CRYPT_RSA_PUBLIC_FORMAT_PKCS1) { |
876 | 876 | // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption. |
877 | 877 | $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA |
878 | - $RSAPublicKey = chr(0) . $RSAPublicKey; |
|
879 | - $RSAPublicKey = chr(3) . $this->_encodeLength(strlen($RSAPublicKey)) . $RSAPublicKey; |
|
878 | + $RSAPublicKey = chr(0).$RSAPublicKey; |
|
879 | + $RSAPublicKey = chr(3).$this->_encodeLength(strlen($RSAPublicKey)).$RSAPublicKey; |
|
880 | 880 | |
881 | 881 | $RSAPublicKey = pack('Ca*a*', |
882 | - CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($rsaOID . $RSAPublicKey)), $rsaOID . $RSAPublicKey |
|
882 | + CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($rsaOID.$RSAPublicKey)), $rsaOID.$RSAPublicKey |
|
883 | 883 | ); |
884 | 884 | } |
885 | 885 | |
886 | - $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
|
887 | - chunk_split(base64_encode($RSAPublicKey), 64) . |
|
886 | + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n". |
|
887 | + chunk_split(base64_encode($RSAPublicKey), 64). |
|
888 | 888 | '-----END PUBLIC KEY-----'; |
889 | 889 | |
890 | 890 | return $RSAPublicKey; |
@@ -959,8 +959,8 @@ discard block |
||
959 | 959 | * OpenSSL is the de facto standard. It's utilized by OpenSSH and other projects */ |
960 | 960 | if (preg_match('#DEK-Info: (.+),(.+)#', $key, $matches)) { |
961 | 961 | $iv = pack('H*', trim($matches[2])); |
962 | - $symkey = pack('H*', md5($this->password . substr($iv, 0, 8))); // symkey is short for symmetric key |
|
963 | - $symkey.= pack('H*', md5($symkey . $this->password . substr($iv, 0, 8))); |
|
962 | + $symkey = pack('H*', md5($this->password.substr($iv, 0, 8))); // symkey is short for symmetric key |
|
963 | + $symkey .= pack('H*', md5($symkey.$this->password.substr($iv, 0, 8))); |
|
964 | 964 | $ciphertext = preg_replace('#.+(\r|\n|\r\n)\1|[\r\n]|-.+-| #s', '', $key); |
965 | 965 | $ciphertext = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $ciphertext) ? base64_decode($ciphertext) : false; |
966 | 966 | if ($ciphertext === false) { |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | xml_set_element_handler($xml, '_start_element_handler', '_stop_element_handler'); |
1180 | 1180 | xml_set_character_data_handler($xml, '_data_handler'); |
1181 | 1181 | // add <xml></xml> to account for "dangling" tags like <BitStrength>...</BitStrength> that are sometimes added |
1182 | - if (!xml_parse($xml, '<xml>' . $key . '</xml>')) { |
|
1182 | + if (!xml_parse($xml, '<xml>'.$key.'</xml>')) { |
|
1183 | 1183 | return false; |
1184 | 1184 | } |
1185 | 1185 | |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | $sequence = 0; |
1216 | 1216 | while (strlen($symkey) < 32) { |
1217 | 1217 | $temp = pack('Na*', $sequence++, $this->password); |
1218 | - $symkey.= pack('H*', sha1($temp)); |
|
1218 | + $symkey .= pack('H*', sha1($temp)); |
|
1219 | 1219 | } |
1220 | 1220 | $symkey = substr($symkey, 0, 32); |
1221 | 1221 | $crypto = new Crypt_AES(); |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | if (!isset($this->current) || is_object($this->current)) { |
1351 | 1351 | return; |
1352 | 1352 | } |
1353 | - $this->current.= trim($data); |
|
1353 | + $this->current .= trim($data); |
|
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | /** |
@@ -1583,8 +1583,8 @@ discard block |
||
1583 | 1583 | $max = str_repeat(chr(0xFF), $bytes); |
1584 | 1584 | $msb = $bits & 7; |
1585 | 1585 | if ($msb) { |
1586 | - $min = chr(1 << ($msb - 1)) . $min; |
|
1587 | - $max = chr((1 << $msb) - 1) . $max; |
|
1586 | + $min = chr(1 << ($msb - 1)).$min; |
|
1587 | + $max = chr((1 << $msb) - 1).$max; |
|
1588 | 1588 | } else { |
1589 | 1589 | $min[0] = chr(0x80); |
1590 | 1590 | } |
@@ -1608,8 +1608,8 @@ discard block |
||
1608 | 1608 | function _decodeLength(&$string) |
1609 | 1609 | { |
1610 | 1610 | $length = ord($this->_string_shift($string)); |
1611 | - if ( $length & 0x80 ) { // definite length, long form |
|
1612 | - $length&= 0x7F; |
|
1611 | + if ($length & 0x80) { // definite length, long form |
|
1612 | + $length &= 0x7F; |
|
1613 | 1613 | $temp = $this->_string_shift($string, $length); |
1614 | 1614 | list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); |
1615 | 1615 | } |
@@ -2002,7 +2002,7 @@ discard block |
||
2002 | 2002 | $count = ceil($maskLen / $this->mgfHLen); |
2003 | 2003 | for ($i = 0; $i < $count; $i++) { |
2004 | 2004 | $c = pack('N', $i); |
2005 | - $t.= $this->mgfHash->hash($mgfSeed . $c); |
|
2005 | + $t .= $this->mgfHash->hash($mgfSeed.$c); |
|
2006 | 2006 | } |
2007 | 2007 | |
2008 | 2008 | return substr($t, 0, $maskLen); |
@@ -2037,13 +2037,13 @@ discard block |
||
2037 | 2037 | |
2038 | 2038 | $lHash = $this->hash->hash($l); |
2039 | 2039 | $ps = str_repeat(chr(0), $this->k - $mLen - 2 * $this->hLen - 2); |
2040 | - $db = $lHash . $ps . chr(1) . $m; |
|
2040 | + $db = $lHash.$ps.chr(1).$m; |
|
2041 | 2041 | $seed = crypt_random_string($this->hLen); |
2042 | 2042 | $dbMask = $this->_mgf1($seed, $this->k - $this->hLen - 1); |
2043 | 2043 | $maskedDB = $db ^ $dbMask; |
2044 | 2044 | $seedMask = $this->_mgf1($maskedDB, $this->hLen); |
2045 | 2045 | $maskedSeed = $seed ^ $seedMask; |
2046 | - $em = chr(0) . $maskedSeed . $maskedDB; |
|
2046 | + $em = chr(0).$maskedSeed.$maskedDB; |
|
2047 | 2047 | |
2048 | 2048 | // RSA encryption |
2049 | 2049 | |
@@ -2158,7 +2158,7 @@ discard block |
||
2158 | 2158 | while (strlen($ps) != $psLen) { |
2159 | 2159 | $temp = crypt_random_string($psLen - strlen($ps)); |
2160 | 2160 | $temp = str_replace("\x00", '', $temp); |
2161 | - $ps.= $temp; |
|
2161 | + $ps .= $temp; |
|
2162 | 2162 | } |
2163 | 2163 | $type = 2; |
2164 | 2164 | // see the comments of _rsaes_pkcs1_v1_5_decrypt() to understand why this is being done |
@@ -2167,7 +2167,7 @@ discard block |
||
2167 | 2167 | // "The padding string PS shall consist of k-3-||D|| octets. ... for block type 01, they shall have value FF" |
2168 | 2168 | $ps = str_repeat("\xFF", $psLen); |
2169 | 2169 | } |
2170 | - $em = chr(0) . chr($type) . $ps . chr(0) . $m; |
|
2170 | + $em = chr(0).chr($type).$ps.chr(0).$m; |
|
2171 | 2171 | |
2172 | 2172 | // RSA encryption |
2173 | 2173 | $m = $this->_os2ip($em); |
@@ -2263,14 +2263,14 @@ discard block |
||
2263 | 2263 | } |
2264 | 2264 | |
2265 | 2265 | $salt = crypt_random_string($sLen); |
2266 | - $m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt; |
|
2266 | + $m2 = "\0\0\0\0\0\0\0\0".$mHash.$salt; |
|
2267 | 2267 | $h = $this->hash->hash($m2); |
2268 | 2268 | $ps = str_repeat(chr(0), $emLen - $sLen - $this->hLen - 2); |
2269 | - $db = $ps . chr(1) . $salt; |
|
2269 | + $db = $ps.chr(1).$salt; |
|
2270 | 2270 | $dbMask = $this->_mgf1($h, $emLen - $this->hLen - 1); |
2271 | 2271 | $maskedDB = $db ^ $dbMask; |
2272 | 2272 | $maskedDB[0] = ~chr(0xFF << ($emBits & 7)) & $maskedDB[0]; |
2273 | - $em = $maskedDB . $h . chr(0xBC); |
|
2273 | + $em = $maskedDB.$h.chr(0xBC); |
|
2274 | 2274 | |
2275 | 2275 | return $em; |
2276 | 2276 | } |
@@ -2317,7 +2317,7 @@ discard block |
||
2317 | 2317 | return false; |
2318 | 2318 | } |
2319 | 2319 | $salt = substr($db, $temp + 1); // should be $sLen long |
2320 | - $m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt; |
|
2320 | + $m2 = "\0\0\0\0\0\0\0\0".$mHash.$salt; |
|
2321 | 2321 | $h2 = $this->hash->hash($m2); |
2322 | 2322 | return $this->_equals($h, $h2); |
2323 | 2323 | } |
@@ -2425,7 +2425,7 @@ discard block |
||
2425 | 2425 | case 'sha512': |
2426 | 2426 | $t = pack('H*', '3051300d060960864801650304020305000440'); |
2427 | 2427 | } |
2428 | - $t.= $h; |
|
2428 | + $t .= $h; |
|
2429 | 2429 | $tLen = strlen($t); |
2430 | 2430 | |
2431 | 2431 | if ($emLen < $tLen + 11) { |
@@ -2586,7 +2586,7 @@ discard block |
||
2586 | 2586 | $plaintext = str_split($plaintext, $length); |
2587 | 2587 | $ciphertext = ''; |
2588 | 2588 | foreach ($plaintext as $m) { |
2589 | - $ciphertext.= $this->_rsaes_pkcs1_v1_5_encrypt($m); |
|
2589 | + $ciphertext .= $this->_rsaes_pkcs1_v1_5_encrypt($m); |
|
2590 | 2590 | } |
2591 | 2591 | return $ciphertext; |
2592 | 2592 | //case CRYPT_RSA_ENCRYPTION_OAEP: |
@@ -2599,7 +2599,7 @@ discard block |
||
2599 | 2599 | $plaintext = str_split($plaintext, $length); |
2600 | 2600 | $ciphertext = ''; |
2601 | 2601 | foreach ($plaintext as $m) { |
2602 | - $ciphertext.= $this->_rsaes_oaep_encrypt($m); |
|
2602 | + $ciphertext .= $this->_rsaes_oaep_encrypt($m); |
|
2603 | 2603 | } |
2604 | 2604 | return $ciphertext; |
2605 | 2605 | } |
@@ -2638,7 +2638,7 @@ discard block |
||
2638 | 2638 | if ($temp === false) { |
2639 | 2639 | return false; |
2640 | 2640 | } |
2641 | - $plaintext.= $temp; |
|
2641 | + $plaintext .= $temp; |
|
2642 | 2642 | } |
2643 | 2643 | |
2644 | 2644 | return $plaintext; |
@@ -98,6 +98,7 @@ discard block |
||
98 | 98 | * CRYPT_DES_MODE_ECB or CRYPT_DES_MODE_CBC. If not explictly set, CRYPT_DES_MODE_CBC will be used. |
99 | 99 | * |
100 | 100 | * @param optional Integer $mode |
101 | + * @param integer $mode |
|
101 | 102 | * @return Crypt_TripleDES |
102 | 103 | * @access public |
103 | 104 | */ |
@@ -318,6 +319,7 @@ discard block |
||
318 | 319 | * |
319 | 320 | * @access public |
320 | 321 | * @param String $plaintext |
322 | + * @return string |
|
321 | 323 | */ |
322 | 324 | function encrypt($plaintext) |
323 | 325 | { |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | if ($this->continuousBuffer) { |
539 | 539 | $this->encryptIV = $xor; |
540 | 540 | if ($start = strlen($plaintext) & 7) { |
541 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
541 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | } |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | if ($this->continuousBuffer) { |
758 | 758 | $this->decryptIV = $xor; |
759 | 759 | if ($start = strlen($ciphertext) & 7) { |
760 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
760 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | function Crypt_TripleDES($mode = CRYPT_DES_MODE_CBC) |
105 | 105 | { |
106 | - if ( !defined('CRYPT_DES_MODE') ) { |
|
106 | + if (!defined('CRYPT_DES_MODE')) { |
|
107 | 107 | switch (true) { |
108 | 108 | case extension_loaded('mcrypt') && in_array('tripledes', mcrypt_list_algorithms()): |
109 | 109 | define('CRYPT_DES_MODE', CRYPT_DES_MODE_MCRYPT); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | - if ( $mode == CRYPT_DES_MODE_3CBC ) { |
|
116 | + if ($mode == CRYPT_DES_MODE_3CBC) { |
|
117 | 117 | $this->mode = CRYPT_DES_MODE_3CBC; |
118 | 118 | $this->des = array( |
119 | 119 | new Crypt_DES(CRYPT_DES_MODE_CBC), |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | - switch ( CRYPT_DES_MODE ) { |
|
133 | + switch (CRYPT_DES_MODE) { |
|
134 | 134 | case CRYPT_DES_MODE_MCRYPT: |
135 | 135 | switch ($mode) { |
136 | 136 | case CRYPT_DES_MODE_ECB: |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | switch (true) { |
219 | 219 | case CRYPT_DES_MODE == CRYPT_DES_MODE_INTERNAL: |
220 | 220 | case $this->mode == CRYPT_DES_MODE_3CBC: |
221 | - $this->des[0]->setKey(substr($key, 0, 8)); |
|
222 | - $this->des[1]->setKey(substr($key, 8, 8)); |
|
221 | + $this->des[0]->setKey(substr($key, 0, 8)); |
|
222 | + $this->des[1]->setKey(substr($key, 8, 8)); |
|
223 | 223 | $this->des[2]->setKey(substr($key, 16, 8)); |
224 | 224 | |
225 | 225 | // Merge the three DES-1-dim-key-arrays for 3DES-inline-en/decrypting |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | switch ($method) { |
260 | 260 | default: // 'pbkdf2' |
261 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
261 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
262 | 262 | if (!isset($hash)) { |
263 | 263 | $hash = 'sha1'; |
264 | 264 | } |
@@ -281,12 +281,12 @@ discard block |
||
281 | 281 | $hmac = new Crypt_Hash(); |
282 | 282 | $hmac->setHash($hash); |
283 | 283 | $hmac->setKey($password); |
284 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
284 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
285 | 285 | for ($j = 2; $j <= $count; $j++) { |
286 | 286 | $u = $hmac->hash($u); |
287 | - $f^= $u; |
|
287 | + $f ^= $u; |
|
288 | 288 | } |
289 | - $key.= $f; |
|
289 | + $key .= $f; |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | return $ciphertext; |
333 | 333 | } |
334 | 334 | |
335 | - if ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) { |
|
335 | + if (CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT) { |
|
336 | 336 | if ($this->enchanged) { |
337 | 337 | mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); |
338 | 338 | if ($this->mode == 'ncfb') { |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | $max = 8 - $pos; |
355 | 355 | if ($len >= $max) { |
356 | 356 | $i = $max; |
357 | - $len-= $max; |
|
357 | + $len -= $max; |
|
358 | 358 | $pos = 0; |
359 | 359 | } else { |
360 | 360 | $i = $len; |
361 | - $pos+= $len; |
|
361 | + $pos += $len; |
|
362 | 362 | $len = 0; |
363 | 363 | } |
364 | 364 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -371,16 +371,16 @@ discard block |
||
371 | 371 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
372 | 372 | $this->enbuffer['enmcrypt_init'] = false; |
373 | 373 | } |
374 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
374 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
375 | 375 | $iv = substr($ciphertext, -8); |
376 | 376 | $i = strlen($ciphertext); |
377 | - $len%= 8; |
|
377 | + $len %= 8; |
|
378 | 378 | } else { |
379 | 379 | while ($len >= 8) { |
380 | 380 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 8); |
381 | - $ciphertext.= $iv; |
|
382 | - $len-= 8; |
|
383 | - $i+= 8; |
|
381 | + $ciphertext .= $iv; |
|
382 | + $len -= 8; |
|
383 | + $i += 8; |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $iv = mcrypt_generic($this->ecb, $iv); |
389 | 389 | $block = $iv ^ substr($plaintext, $i); |
390 | 390 | $iv = substr_replace($iv, $block, 0, $len); |
391 | - $ciphertext.= $block; |
|
391 | + $ciphertext .= $block; |
|
392 | 392 | $pos = $len; |
393 | 393 | } |
394 | 394 | return $ciphertext; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | $ciphertext = ''; |
420 | 420 | switch ($this->mode) { |
421 | 421 | case CRYPT_DES_MODE_ECB: |
422 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
422 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
423 | 423 | $block = substr($plaintext, $i, 8); |
424 | 424 | // all of these _processBlock calls could, in theory, be put in a function - say Crypt_TripleDES::_ede_encrypt() or something. |
425 | 425 | // only problem with that: it would slow encryption and decryption down. $this->des would have to be called every time that |
@@ -430,18 +430,18 @@ discard block |
||
430 | 430 | $block = $des[0]->_processBlock($block, CRYPT_DES_ENCRYPT); |
431 | 431 | $block = $des[1]->_processBlock($block, CRYPT_DES_DECRYPT); |
432 | 432 | $block = $des[2]->_processBlock($block, CRYPT_DES_ENCRYPT); |
433 | - $ciphertext.= $block; |
|
433 | + $ciphertext .= $block; |
|
434 | 434 | } |
435 | 435 | break; |
436 | 436 | case CRYPT_DES_MODE_CBC: |
437 | 437 | $xor = $this->encryptIV; |
438 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
438 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
439 | 439 | $block = substr($plaintext, $i, 8) ^ $xor; |
440 | 440 | $block = $des[0]->_processBlock($block, CRYPT_DES_ENCRYPT); |
441 | 441 | $block = $des[1]->_processBlock($block, CRYPT_DES_DECRYPT); |
442 | 442 | $block = $des[2]->_processBlock($block, CRYPT_DES_ENCRYPT); |
443 | 443 | $xor = $block; |
444 | - $ciphertext.= $block; |
|
444 | + $ciphertext .= $block; |
|
445 | 445 | } |
446 | 446 | if ($this->continuousBuffer) { |
447 | 447 | $this->encryptIV = $xor; |
@@ -450,41 +450,41 @@ discard block |
||
450 | 450 | case CRYPT_DES_MODE_CTR: |
451 | 451 | $xor = $this->encryptIV; |
452 | 452 | if (strlen($buffer['encrypted'])) { |
453 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
453 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
454 | 454 | $block = substr($plaintext, $i, 8); |
455 | 455 | if (strlen($block) > strlen($buffer['encrypted'])) { |
456 | 456 | $key = $this->_generate_xor($xor); |
457 | 457 | $key = $des[0]->_processBlock($key, CRYPT_DES_ENCRYPT); |
458 | 458 | $key = $des[1]->_processBlock($key, CRYPT_DES_DECRYPT); |
459 | 459 | $key = $des[2]->_processBlock($key, CRYPT_DES_ENCRYPT); |
460 | - $buffer['encrypted'].= $key; |
|
460 | + $buffer['encrypted'] .= $key; |
|
461 | 461 | } |
462 | 462 | $key = $this->_string_shift($buffer['encrypted']); |
463 | - $ciphertext.= $block ^ $key; |
|
463 | + $ciphertext .= $block ^ $key; |
|
464 | 464 | } |
465 | 465 | } else { |
466 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
466 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
467 | 467 | $block = substr($plaintext, $i, 8); |
468 | 468 | $key = $this->_generate_xor($xor); |
469 | 469 | $key = $des[0]->_processBlock($key, CRYPT_DES_ENCRYPT); |
470 | 470 | $key = $des[1]->_processBlock($key, CRYPT_DES_DECRYPT); |
471 | 471 | $key = $des[2]->_processBlock($key, CRYPT_DES_ENCRYPT); |
472 | - $ciphertext.= $block ^ $key; |
|
472 | + $ciphertext .= $block ^ $key; |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | if ($this->continuousBuffer) { |
476 | 476 | $this->encryptIV = $xor; |
477 | 477 | if ($start = strlen($plaintext) & 7) { |
478 | - $buffer['encrypted'] = substr($key, $start) . $buffer['encrypted']; |
|
478 | + $buffer['encrypted'] = substr($key, $start).$buffer['encrypted']; |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | break; |
482 | 482 | case CRYPT_DES_MODE_CFB: |
483 | 483 | if (strlen($buffer['xor'])) { |
484 | 484 | $ciphertext = $plaintext ^ $buffer['xor']; |
485 | - $iv = $buffer['encrypted'] . $ciphertext; |
|
485 | + $iv = $buffer['encrypted'].$ciphertext; |
|
486 | 486 | $start = strlen($ciphertext); |
487 | - $buffer['encrypted'].= $ciphertext; |
|
487 | + $buffer['encrypted'] .= $ciphertext; |
|
488 | 488 | $buffer['xor'] = substr($buffer['xor'], strlen($ciphertext)); |
489 | 489 | } else { |
490 | 490 | $ciphertext = ''; |
@@ -492,11 +492,11 @@ discard block |
||
492 | 492 | $start = 0; |
493 | 493 | } |
494 | 494 | |
495 | - for ($i = $start; $i < strlen($plaintext); $i+=8) { |
|
495 | + for ($i = $start; $i < strlen($plaintext); $i += 8) { |
|
496 | 496 | $block = substr($plaintext, $i, 8); |
497 | 497 | $iv = $des[0]->_processBlock($iv, CRYPT_DES_ENCRYPT); |
498 | 498 | $iv = $des[1]->_processBlock($iv, CRYPT_DES_DECRYPT); |
499 | - $xor= $des[2]->_processBlock($iv, CRYPT_DES_ENCRYPT); |
|
499 | + $xor = $des[2]->_processBlock($iv, CRYPT_DES_ENCRYPT); |
|
500 | 500 | |
501 | 501 | $iv = $block ^ $xor; |
502 | 502 | if ($continuousBuffer && strlen($iv) != 8) { |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | 'xor' => substr($xor, strlen($iv)) |
506 | 506 | ); |
507 | 507 | } |
508 | - $ciphertext.= $iv; |
|
508 | + $ciphertext .= $iv; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | if ($this->continuousBuffer) { |
@@ -515,30 +515,30 @@ discard block |
||
515 | 515 | case CRYPT_DES_MODE_OFB: |
516 | 516 | $xor = $this->encryptIV; |
517 | 517 | if (strlen($buffer['xor'])) { |
518 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
518 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
519 | 519 | $block = substr($plaintext, $i, 8); |
520 | 520 | if (strlen($block) > strlen($buffer['xor'])) { |
521 | 521 | $xor = $des[0]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
522 | 522 | $xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT); |
523 | 523 | $xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
524 | - $buffer['xor'].= $xor; |
|
524 | + $buffer['xor'] .= $xor; |
|
525 | 525 | } |
526 | 526 | $key = $this->_string_shift($buffer['xor']); |
527 | - $ciphertext.= $block ^ $key; |
|
527 | + $ciphertext .= $block ^ $key; |
|
528 | 528 | } |
529 | 529 | } else { |
530 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
530 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
531 | 531 | $xor = $des[0]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
532 | 532 | $xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT); |
533 | 533 | $xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
534 | - $ciphertext.= substr($plaintext, $i, 8) ^ $xor; |
|
534 | + $ciphertext .= substr($plaintext, $i, 8) ^ $xor; |
|
535 | 535 | } |
536 | 536 | $key = $xor; |
537 | 537 | } |
538 | 538 | if ($this->continuousBuffer) { |
539 | 539 | $this->encryptIV = $xor; |
540 | 540 | if ($start = strlen($plaintext) & 7) { |
541 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
541 | + $buffer['xor'] = substr($key, $start).$buffer['xor']; |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | $ciphertext = str_pad($ciphertext, (strlen($ciphertext) + 7) & 0xFFFFFFF8, chr(0)); |
567 | 567 | } |
568 | 568 | |
569 | - if ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) { |
|
569 | + if (CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT) { |
|
570 | 570 | if ($this->dechanged) { |
571 | 571 | mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); |
572 | 572 | if ($this->mode == 'ncfb') { |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | $max = 8 - $pos; |
589 | 589 | if ($len >= $max) { |
590 | 590 | $i = $max; |
591 | - $len-= $max; |
|
591 | + $len -= $max; |
|
592 | 592 | $pos = 0; |
593 | 593 | } else { |
594 | 594 | $i = $len; |
595 | - $pos+= $len; |
|
595 | + $pos += $len; |
|
596 | 596 | $len = 0; |
597 | 597 | } |
598 | 598 | $plaintext = substr($iv, $orig_pos) ^ $ciphertext; |
@@ -600,14 +600,14 @@ discard block |
||
600 | 600 | } |
601 | 601 | if ($len >= 8) { |
602 | 602 | $cb = substr($ciphertext, $i, $len - $len % 8); |
603 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
603 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
604 | 604 | $iv = substr($cb, -8); |
605 | - $len%= 8; |
|
605 | + $len %= 8; |
|
606 | 606 | } |
607 | 607 | if ($len) { |
608 | 608 | $iv = mcrypt_generic($this->ecb, $iv); |
609 | 609 | $cb = substr($ciphertext, -$len); |
610 | - $plaintext.= $iv ^ $cb; |
|
610 | + $plaintext .= $iv ^ $cb; |
|
611 | 611 | $iv = substr_replace($iv, $cb, 0, $len); |
612 | 612 | $pos = $len; |
613 | 613 | } |
@@ -639,22 +639,22 @@ discard block |
||
639 | 639 | $plaintext = ''; |
640 | 640 | switch ($this->mode) { |
641 | 641 | case CRYPT_DES_MODE_ECB: |
642 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
642 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
643 | 643 | $block = substr($ciphertext, $i, 8); |
644 | 644 | $block = $des[2]->_processBlock($block, CRYPT_DES_DECRYPT); |
645 | 645 | $block = $des[1]->_processBlock($block, CRYPT_DES_ENCRYPT); |
646 | 646 | $block = $des[0]->_processBlock($block, CRYPT_DES_DECRYPT); |
647 | - $plaintext.= $block; |
|
647 | + $plaintext .= $block; |
|
648 | 648 | } |
649 | 649 | break; |
650 | 650 | case CRYPT_DES_MODE_CBC: |
651 | 651 | $xor = $this->decryptIV; |
652 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
652 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
653 | 653 | $orig = $block = substr($ciphertext, $i, 8); |
654 | 654 | $block = $des[2]->_processBlock($block, CRYPT_DES_DECRYPT); |
655 | 655 | $block = $des[1]->_processBlock($block, CRYPT_DES_ENCRYPT); |
656 | 656 | $block = $des[0]->_processBlock($block, CRYPT_DES_DECRYPT); |
657 | - $plaintext.= $block ^ $xor; |
|
657 | + $plaintext .= $block ^ $xor; |
|
658 | 658 | $xor = $orig; |
659 | 659 | } |
660 | 660 | if ($this->continuousBuffer) { |
@@ -664,39 +664,39 @@ discard block |
||
664 | 664 | case CRYPT_DES_MODE_CTR: |
665 | 665 | $xor = $this->decryptIV; |
666 | 666 | if (strlen($buffer['ciphertext'])) { |
667 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
667 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
668 | 668 | $block = substr($ciphertext, $i, 8); |
669 | 669 | if (strlen($block) > strlen($buffer['ciphertext'])) { |
670 | 670 | $key = $this->_generate_xor($xor); |
671 | 671 | $key = $des[0]->_processBlock($key, CRYPT_DES_ENCRYPT); |
672 | 672 | $key = $des[1]->_processBlock($key, CRYPT_DES_DECRYPT); |
673 | 673 | $key = $des[2]->_processBlock($key, CRYPT_DES_ENCRYPT); |
674 | - $buffer['ciphertext'].= $key; |
|
674 | + $buffer['ciphertext'] .= $key; |
|
675 | 675 | } |
676 | 676 | $key = $this->_string_shift($buffer['ciphertext']); |
677 | - $plaintext.= $block ^ $key; |
|
677 | + $plaintext .= $block ^ $key; |
|
678 | 678 | } |
679 | 679 | } else { |
680 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
680 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
681 | 681 | $block = substr($ciphertext, $i, 8); |
682 | 682 | $key = $this->_generate_xor($xor); |
683 | 683 | $key = $des[0]->_processBlock($key, CRYPT_DES_ENCRYPT); |
684 | 684 | $key = $des[1]->_processBlock($key, CRYPT_DES_DECRYPT); |
685 | 685 | $key = $des[2]->_processBlock($key, CRYPT_DES_ENCRYPT); |
686 | - $plaintext.= $block ^ $key; |
|
686 | + $plaintext .= $block ^ $key; |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | if ($this->continuousBuffer) { |
690 | 690 | $this->decryptIV = $xor; |
691 | 691 | if ($start = strlen($plaintext) & 7) { |
692 | - $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext']; |
|
692 | + $buffer['ciphertext'] = substr($key, $start).$buffer['ciphertext']; |
|
693 | 693 | } |
694 | 694 | } |
695 | 695 | break; |
696 | 696 | case CRYPT_DES_MODE_CFB: |
697 | 697 | if (strlen($buffer['ciphertext'])) { |
698 | 698 | $plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext'])); |
699 | - $buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext)); |
|
699 | + $buffer['ciphertext'] .= substr($ciphertext, 0, strlen($plaintext)); |
|
700 | 700 | if (strlen($buffer['ciphertext']) != 8) { |
701 | 701 | $block = $this->decryptIV; |
702 | 702 | } else { |
@@ -715,11 +715,11 @@ discard block |
||
715 | 715 | $start = 0; |
716 | 716 | } |
717 | 717 | |
718 | - for ($i = $start; $i < strlen($ciphertext); $i+=8) { |
|
718 | + for ($i = $start; $i < strlen($ciphertext); $i += 8) { |
|
719 | 719 | $block = substr($ciphertext, $i, 8); |
720 | - $plaintext.= $block ^ $xor; |
|
720 | + $plaintext .= $block ^ $xor; |
|
721 | 721 | if ($continuousBuffer && strlen($block) != 8) { |
722 | - $buffer['ciphertext'].= $block; |
|
722 | + $buffer['ciphertext'] .= $block; |
|
723 | 723 | $block = $xor; |
724 | 724 | } else if (strlen($block) == 8) { |
725 | 725 | $xor = $des[0]->_processBlock($block, CRYPT_DES_ENCRYPT); |
@@ -734,30 +734,30 @@ discard block |
||
734 | 734 | case CRYPT_DES_MODE_OFB: |
735 | 735 | $xor = $this->decryptIV; |
736 | 736 | if (strlen($buffer['xor'])) { |
737 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
737 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
738 | 738 | $block = substr($ciphertext, $i, 8); |
739 | 739 | if (strlen($block) > strlen($buffer['xor'])) { |
740 | 740 | $xor = $des[0]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
741 | 741 | $xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT); |
742 | 742 | $xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
743 | - $buffer['xor'].= $xor; |
|
743 | + $buffer['xor'] .= $xor; |
|
744 | 744 | } |
745 | 745 | $key = $this->_string_shift($buffer['xor']); |
746 | - $plaintext.= $block ^ $key; |
|
746 | + $plaintext .= $block ^ $key; |
|
747 | 747 | } |
748 | 748 | } else { |
749 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
749 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
750 | 750 | $xor = $des[0]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
751 | 751 | $xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT); |
752 | 752 | $xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
753 | - $plaintext.= substr($ciphertext, $i, 8) ^ $xor; |
|
753 | + $plaintext .= substr($ciphertext, $i, 8) ^ $xor; |
|
754 | 754 | } |
755 | 755 | $key = $xor; |
756 | 756 | } |
757 | 757 | if ($this->continuousBuffer) { |
758 | 758 | $this->decryptIV = $xor; |
759 | 759 | if ($start = strlen($ciphertext) & 7) { |
760 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
760 | + $buffer['xor'] = substr($key, $start).$buffer['xor']; |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
@@ -563,6 +563,7 @@ discard block |
||
563 | 563 | * If not explictly set, CRYPT_TWOFISH_MODE_CBC will be used. |
564 | 564 | * |
565 | 565 | * @param optional Integer $mode |
566 | + * @param integer $mode |
|
566 | 567 | * @access public |
567 | 568 | */ |
568 | 569 | function Crypt_Twofish($mode = CRYPT_TWOFISH_MODE_CBC) |
@@ -1072,6 +1073,7 @@ discard block |
||
1072 | 1073 | * |
1073 | 1074 | * @see Crypt_Twofish::_unpad() |
1074 | 1075 | * @access private |
1076 | + * @param string $text |
|
1075 | 1077 | */ |
1076 | 1078 | function _pad($text) |
1077 | 1079 | { |
@@ -1099,6 +1101,7 @@ discard block |
||
1099 | 1101 | * |
1100 | 1102 | * @see Crypt_Twofish::_pad() |
1101 | 1103 | * @access private |
1104 | + * @param string $text |
|
1102 | 1105 | */ |
1103 | 1106 | function _unpad($text) |
1104 | 1107 | { |
@@ -678,13 +678,13 @@ discard block |
||
678 | 678 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[3], $le_longs[4]); |
679 | 679 | for ($i = 0, $j = 1; $i < 40; $i+= 2,$j+= 2) { |
680 | 680 | $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ |
681 | - $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
|
682 | - $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
|
683 | - $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
|
681 | + $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
|
682 | + $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
|
683 | + $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
|
684 | 684 | $B = $m0[$q0[$q0[$j] ^ $key[13]] ^ $key[5]] ^ |
685 | - $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^ |
|
686 | - $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
|
687 | - $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
|
685 | + $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^ |
|
686 | + $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
|
687 | + $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
|
688 | 688 | $B = ($B << 8) | ($B >> 24 & 0xff); |
689 | 689 | $K[] = $A+= $B; |
690 | 690 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -702,13 +702,13 @@ discard block |
||
702 | 702 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[5], $le_longs[6]); |
703 | 703 | for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
704 | 704 | $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
705 | - $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
706 | - $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
707 | - $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
705 | + $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
706 | + $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
707 | + $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
708 | 708 | $B = $m0[$q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ |
709 | - $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
710 | - $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
711 | - $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
709 | + $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
710 | + $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
711 | + $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
712 | 712 | $B = ($B << 8) | ($B >> 24 & 0xff); |
713 | 713 | $K[] = $A+= $B; |
714 | 714 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -727,13 +727,13 @@ discard block |
||
727 | 727 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[7], $le_longs[8]); |
728 | 728 | for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
729 | 729 | $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
730 | - $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
731 | - $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
732 | - $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
730 | + $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
731 | + $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
732 | + $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
733 | 733 | $B = $m0[$q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ |
734 | - $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
735 | - $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
736 | - $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
734 | + $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
735 | + $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
736 | + $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
737 | 737 | $B = ($B << 8) | ($B >> 24 & 0xff); |
738 | 738 | $K[] = $A+= $B; |
739 | 739 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @var Array |
277 | 277 | * @access private |
278 | 278 | */ |
279 | - var $q0 = array ( |
|
279 | + var $q0 = array( |
|
280 | 280 | 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, |
281 | 281 | 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, |
282 | 282 | 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @var Array |
318 | 318 | * @access private |
319 | 319 | */ |
320 | - var $q1 = array ( |
|
320 | + var $q1 = array( |
|
321 | 321 | 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, |
322 | 322 | 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, |
323 | 323 | 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @var Array |
359 | 359 | * @access private |
360 | 360 | */ |
361 | - var $m0 = array ( |
|
361 | + var $m0 = array( |
|
362 | 362 | 0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8, |
363 | 363 | 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, |
364 | 364 | 0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1, |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @var Array |
400 | 400 | * @access private |
401 | 401 | */ |
402 | - var $m1 = array ( |
|
402 | + var $m1 = array( |
|
403 | 403 | 0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4, |
404 | 404 | 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, |
405 | 405 | 0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141, |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @var Array |
441 | 441 | * @access private |
442 | 442 | */ |
443 | - var $m2 = array ( |
|
443 | + var $m2 = array( |
|
444 | 444 | 0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA, |
445 | 445 | 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, |
446 | 446 | 0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783, |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | * @var Array |
482 | 482 | * @access private |
483 | 483 | */ |
484 | - var $m3 = array ( |
|
484 | + var $m3 = array( |
|
485 | 485 | 0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF, |
486 | 486 | 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, |
487 | 487 | 0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77, |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | */ |
568 | 568 | function Crypt_Twofish($mode = CRYPT_TWOFISH_MODE_CBC) |
569 | 569 | { |
570 | - if ( !defined('CRYPT_TWOFISH_MODE') ) { |
|
570 | + if (!defined('CRYPT_TWOFISH_MODE')) { |
|
571 | 571 | switch (true) { |
572 | 572 | case extension_loaded('mcrypt') && in_array('twofish', mcrypt_list_algorithms()): |
573 | 573 | define('CRYPT_TWOFISH_MODE', CRYPT_TWOFISH_MODE_MCRYPT); |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
580 | - switch ( CRYPT_TWOFISH_MODE ) { |
|
580 | + switch (CRYPT_TWOFISH_MODE) { |
|
581 | 581 | case CRYPT_TWOFISH_MODE_MCRYPT: |
582 | 582 | switch ($mode) { |
583 | 583 | case CRYPT_TWOFISH_MODE_ECB: |
@@ -640,13 +640,13 @@ discard block |
||
640 | 640 | $keylength = strlen($key); |
641 | 641 | switch (true) { |
642 | 642 | case $keylength <= 16: |
643 | - $key.= str_repeat("\0", 16 - $keylength); |
|
643 | + $key .= str_repeat("\0", 16 - $keylength); |
|
644 | 644 | break; |
645 | 645 | case $keylength <= 24: |
646 | - $key.= str_repeat("\0", 24 - $keylength); |
|
646 | + $key .= str_repeat("\0", 24 - $keylength); |
|
647 | 647 | break; |
648 | 648 | case $keylength <= 32: |
649 | - $key.= str_repeat("\0", 32 - $keylength); |
|
649 | + $key .= str_repeat("\0", 32 - $keylength); |
|
650 | 650 | break; |
651 | 651 | default: |
652 | 652 | $key = substr($key, 0, 32); |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | case 16: |
677 | 677 | list ($s7, $s6, $s5, $s4) = $this->mds_rem($le_longs[1], $le_longs[2]); |
678 | 678 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[3], $le_longs[4]); |
679 | - for ($i = 0, $j = 1; $i < 40; $i+= 2,$j+= 2) { |
|
680 | - $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ |
|
679 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
680 | + $A = $m0[$q0[$q0[$i] ^ $key[9]] ^ $key[1]] ^ |
|
681 | 681 | $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
682 | 682 | $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
683 | 683 | $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
@@ -686,8 +686,8 @@ discard block |
||
686 | 686 | $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
687 | 687 | $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
688 | 688 | $B = ($B << 8) | ($B >> 24 & 0xff); |
689 | - $K[] = $A+= $B; |
|
690 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
689 | + $K[] = $A += $B; |
|
690 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
691 | 691 | } |
692 | 692 | for ($i = 0; $i < 256; ++$i) { |
693 | 693 | $S0[$i] = $m0[$q0[$q0[$i] ^ $s4] ^ $s0]; |
@@ -700,8 +700,8 @@ discard block |
||
700 | 700 | list ($sb, $sa, $s9, $s8) = $this->mds_rem($le_longs[1], $le_longs[2]); |
701 | 701 | list ($s7, $s6, $s5, $s4) = $this->mds_rem($le_longs[3], $le_longs[4]); |
702 | 702 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[5], $le_longs[6]); |
703 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
704 | - $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
|
703 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
704 | + $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[9]] ^ $key[1]] ^ |
|
705 | 705 | $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
706 | 706 | $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
707 | 707 | $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
@@ -710,8 +710,8 @@ discard block |
||
710 | 710 | $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
711 | 711 | $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
712 | 712 | $B = ($B << 8) | ($B >> 24 & 0xff); |
713 | - $K[] = $A+= $B; |
|
714 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
713 | + $K[] = $A += $B; |
|
714 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
715 | 715 | } |
716 | 716 | for ($i = 0; $i < 256; ++$i) { |
717 | 717 | $S0[$i] = $m0[$q0[$q0[$q1[$i] ^ $s8] ^ $s4] ^ $s0]; |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | list ($sb, $sa, $s9, $s8) = $this->mds_rem($le_longs[3], $le_longs[4]); |
726 | 726 | list ($s7, $s6, $s5, $s4) = $this->mds_rem($le_longs[5], $le_longs[6]); |
727 | 727 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[7], $le_longs[8]); |
728 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
729 | - $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
|
728 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
729 | + $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[9]] ^ $key[1]] ^ |
|
730 | 730 | $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
731 | 731 | $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
732 | 732 | $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
@@ -735,8 +735,8 @@ discard block |
||
735 | 735 | $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
736 | 736 | $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
737 | 737 | $B = ($B << 8) | ($B >> 24 & 0xff); |
738 | - $K[] = $A+= $B; |
|
739 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
738 | + $K[] = $A += $B; |
|
739 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
740 | 740 | } |
741 | 741 | for ($i = 0; $i < 256; ++$i) { |
742 | 742 | $S0[$i] = $m0[$q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] ^ $s0]; |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | |
771 | 771 | switch ($method) { |
772 | 772 | default: // 'pbkdf2' |
773 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
773 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
774 | 774 | if (!isset($hash)) { |
775 | 775 | $hash = 'sha1'; |
776 | 776 | } |
@@ -793,12 +793,12 @@ discard block |
||
793 | 793 | $hmac = new Crypt_Hash(); |
794 | 794 | $hmac->setHash($hash); |
795 | 795 | $hmac->setKey($password); |
796 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
796 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
797 | 797 | for ($j = 2; $j <= $count; ++$j) { |
798 | 798 | $u = $hmac->hash($u); |
799 | - $f^= $u; |
|
799 | + $f ^= $u; |
|
800 | 800 | } |
801 | - $key.= $f; |
|
801 | + $key .= $f; |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | */ |
841 | 841 | function encrypt($plaintext) |
842 | 842 | { |
843 | - if ( CRYPT_TWOFISH_MODE == CRYPT_TWOFISH_MODE_MCRYPT ) { |
|
843 | + if (CRYPT_TWOFISH_MODE == CRYPT_TWOFISH_MODE_MCRYPT) { |
|
844 | 844 | if ($this->paddable) { |
845 | 845 | $plaintext = $this->_pad($plaintext); |
846 | 846 | } |
@@ -866,11 +866,11 @@ discard block |
||
866 | 866 | $max = 16 - $pos; |
867 | 867 | if ($len >= $max) { |
868 | 868 | $i = $max; |
869 | - $len-= $max; |
|
869 | + $len -= $max; |
|
870 | 870 | $pos = 0; |
871 | 871 | } else { |
872 | 872 | $i = $len; |
873 | - $pos+= $len; |
|
873 | + $pos += $len; |
|
874 | 874 | $len = 0; |
875 | 875 | } |
876 | 876 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -883,15 +883,15 @@ discard block |
||
883 | 883 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
884 | 884 | $this->enbuffer['enmcrypt_init'] = false; |
885 | 885 | } |
886 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 16)); |
|
886 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 16)); |
|
887 | 887 | $iv = substr($ciphertext, -16); |
888 | - $len%= 16; |
|
888 | + $len %= 16; |
|
889 | 889 | } else { |
890 | 890 | while ($len >= 16) { |
891 | 891 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 16); |
892 | - $ciphertext.= $iv; |
|
893 | - $len-= 16; |
|
894 | - $i+= 16; |
|
892 | + $ciphertext .= $iv; |
|
893 | + $len -= 16; |
|
894 | + $i += 16; |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | } |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | $iv = mcrypt_generic($this->ecb, $iv); |
900 | 900 | $block = $iv ^ substr($plaintext, -$len); |
901 | 901 | $iv = substr_replace($iv, $block, 0, $len); |
902 | - $ciphertext.= $block; |
|
902 | + $ciphertext .= $block; |
|
903 | 903 | $pos = $len; |
904 | 904 | } |
905 | 905 | return $ciphertext; |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | */ |
932 | 932 | function decrypt($ciphertext) |
933 | 933 | { |
934 | - if ( CRYPT_TWOFISH_MODE == CRYPT_TWOFISH_MODE_MCRYPT ) { |
|
934 | + if (CRYPT_TWOFISH_MODE == CRYPT_TWOFISH_MODE_MCRYPT) { |
|
935 | 935 | if ($this->paddable) { |
936 | 936 | // we pad with chr(0) since that's what mcrypt_generic does. to quote from http://php.net/function.mcrypt-generic : |
937 | 937 | // "The data is padded with "\0" to make sure the length of the data is n * blocksize." |
@@ -959,11 +959,11 @@ discard block |
||
959 | 959 | $max = 16 - $pos; |
960 | 960 | if ($len >= $max) { |
961 | 961 | $i = $max; |
962 | - $len-= $max; |
|
962 | + $len -= $max; |
|
963 | 963 | $pos = 0; |
964 | 964 | } else { |
965 | 965 | $i = $len; |
966 | - $pos+= $len; |
|
966 | + $pos += $len; |
|
967 | 967 | $len = 0; |
968 | 968 | } |
969 | 969 | $plaintext = substr($iv, $orig_pos) ^ $ciphertext; |
@@ -971,13 +971,13 @@ discard block |
||
971 | 971 | } |
972 | 972 | if ($len >= 16) { |
973 | 973 | $cb = substr($ciphertext, $i, $len - $len % 16); |
974 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
974 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
975 | 975 | $iv = substr($cb, -16); |
976 | - $len%= 16; |
|
976 | + $len %= 16; |
|
977 | 977 | } |
978 | 978 | if ($len) { |
979 | 979 | $iv = mcrypt_generic($this->ecb, $iv); |
980 | - $plaintext.= $iv ^ substr($ciphertext, -$len); |
|
980 | + $plaintext .= $iv ^ substr($ciphertext, -$len); |
|
981 | 981 | $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); |
982 | 982 | $pos = $len; |
983 | 983 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | function _generate_xor(&$iv) |
1146 | 1146 | { |
1147 | 1147 | $xor = $iv; |
1148 | - for ($j = 4; $j <= 16; $j+=4) { |
|
1148 | + for ($j = 4; $j <= 16; $j += 4) { |
|
1149 | 1149 | $temp = substr($iv, -$j, 4); |
1150 | 1150 | switch ($temp) { |
1151 | 1151 | case "\xFF\xFF\xFF\xFF": |
@@ -1181,32 +1181,32 @@ discard block |
||
1181 | 1181 | |
1182 | 1182 | // Shift the others up. |
1183 | 1183 | $B = ($B << 8) | (0xff & ($A >> 24)); |
1184 | - $A<<= 8; |
|
1184 | + $A <<= 8; |
|
1185 | 1185 | |
1186 | 1186 | $u = $t << 1; |
1187 | 1187 | |
1188 | 1188 | // Subtract the modular polynomial on overflow. |
1189 | 1189 | if ($t & 0x80) { |
1190 | - $u^= 0x14d; |
|
1190 | + $u ^= 0x14d; |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | // Remove t * (a * x^2 + 1). |
1194 | 1194 | $B ^= $t ^ ($u << 16); |
1195 | 1195 | |
1196 | 1196 | // Form u = a*t + t/a = t*(a + 1/a). |
1197 | - $u^= 0x7fffffff & ($t >> 1); |
|
1197 | + $u ^= 0x7fffffff & ($t >> 1); |
|
1198 | 1198 | |
1199 | 1199 | // Add the modular polynomial on underflow. |
1200 | - if ($t & 0x01) $u^= 0xa6 ; |
|
1200 | + if ($t & 0x01) $u ^= 0xa6; |
|
1201 | 1201 | |
1202 | 1202 | // Remove t * (a + 1/a) * (x^3 + x). |
1203 | - $B^= ($u << 24) | ($u << 8); |
|
1203 | + $B ^= ($u << 24) | ($u << 8); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | return array( |
1207 | 1207 | 0xff & $B >> 24, |
1208 | 1208 | 0xff & $B >> 16, |
1209 | - 0xff & $B >> 8, |
|
1209 | + 0xff & $B >> 8, |
|
1210 | 1210 | 0xff & $B); |
1211 | 1211 | } |
1212 | 1212 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | function inline_crypt_setup() |
1219 | 1219 | { |
1220 | - $lambda_functions =& Crypt_Twofish::get_lambda_functions(); |
|
1220 | + $lambda_functions = & Crypt_Twofish::get_lambda_functions(); |
|
1221 | 1221 | $block_size = 16; |
1222 | 1222 | $mode = $this->mode; |
1223 | 1223 | $code_hash = "$mode"; |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | $R3 = $K_3 ^ $in[4]; |
1241 | 1241 | '; |
1242 | 1242 | for ($ki = 7, $i = 0; $i < 8; ++$i) { |
1243 | - $_encryptBlock.= ' |
|
1243 | + $_encryptBlock .= ' |
|
1244 | 1244 | $t0 = $S0[ $R0 & 0xff] ^ |
1245 | 1245 | $S1[($R0 >> 8) & 0xff] ^ |
1246 | 1246 | $S2[($R0 >> 16) & 0xff] ^ |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + $K_'.(++$ki).'); |
1267 | 1267 | '; |
1268 | 1268 | } |
1269 | - $_encryptBlock.= ' |
|
1269 | + $_encryptBlock .= ' |
|
1270 | 1270 | $in = pack("V4", $K_4 ^ $R2, |
1271 | 1271 | $K_5 ^ $R3, |
1272 | 1272 | $K_6 ^ $R0, |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | $R3 = $K_7 ^ $in[4]; |
1283 | 1283 | '; |
1284 | 1284 | for ($ki = 40, $i = 0; $i < 8; ++$i) { |
1285 | - $_decryptBlock.= ' |
|
1285 | + $_decryptBlock .= ' |
|
1286 | 1286 | $t0 = $S0[$R0 & 0xff] ^ |
1287 | 1287 | $S1[$R0 >> 8 & 0xff] ^ |
1288 | 1288 | $S2[$R0 >> 16 & 0xff] ^ |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + $K_'.(--$ki).'); |
1309 | 1309 | '; |
1310 | 1310 | } |
1311 | - $_decryptBlock.= ' |
|
1311 | + $_decryptBlock .= ' |
|
1312 | 1312 | $in = pack("V4", $K_0 ^ $R2, |
1313 | 1313 | $K_1 ^ $R3, |
1314 | 1314 | $K_2 ^ $R0, |
@@ -1635,12 +1635,12 @@ discard block |
||
1635 | 1635 | break; |
1636 | 1636 | } |
1637 | 1637 | $fnc_head = '$action, &$self, $text'; |
1638 | - $fnc_body = $init_cryptBlock . 'if ($action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' }'; |
|
1638 | + $fnc_body = $init_cryptBlock.'if ($action == "encrypt") { '.$encrypt.' } else { '.$decrypt.' }'; |
|
1639 | 1639 | |
1640 | 1640 | if (function_exists('create_function') && is_callable('create_function')) { |
1641 | 1641 | $lambda_functions[$code_hash] = create_function($fnc_head, $fnc_body); |
1642 | 1642 | } else { |
1643 | - eval('function ' . ($lambda_functions[$code_hash] = 'f' . md5(microtime())) . '(' . $fnc_head . ') { ' . $fnc_body . ' }'); |
|
1643 | + eval('function '.($lambda_functions[$code_hash] = 'f'.md5(microtime())).'('.$fnc_head.') { '.$fnc_body.' }'); |
|
1644 | 1644 | } |
1645 | 1645 | } |
1646 | 1646 | $this->inline_crypt = $lambda_functions[$code_hash]; |
@@ -1197,7 +1197,9 @@ |
||
1197 | 1197 | $u^= 0x7fffffff & ($t >> 1); |
1198 | 1198 | |
1199 | 1199 | // Add the modular polynomial on underflow. |
1200 | - if ($t & 0x01) $u^= 0xa6 ; |
|
1200 | + if ($t & 0x01) { |
|
1201 | + $u^= 0xa6 ; |
|
1202 | + } |
|
1201 | 1203 | |
1202 | 1204 | // Remove t * (a + 1/a) * (x^3 + x). |
1203 | 1205 | $B^= ($u << 24) | ($u << 8); |