@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $this->assertNotNull($message); |
| 58 | 58 | $this->assertTrue($message instanceof TextMessage); |
| 59 | - if($message instanceof TextMessage) { |
|
| 59 | + if ($message instanceof TextMessage) { |
|
| 60 | 60 | $this->assertEquals($message->getText(), 'Dies ist eine Testnachricht. äöü'); |
| 61 | 61 | } |
| 62 | 62 | }); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | public function testDerivePublicKey() { |
| 95 | - $this->doTest(function(CryptTool $cryptTool, $prefix){ |
|
| 95 | + $this->doTest(function(CryptTool $cryptTool, $prefix) { |
|
| 96 | 96 | $publicKey = $cryptTool->derivePublicKey($cryptTool->hex2bin(Common::getPrivateKey(Constants::myPrivateKey))); |
| 97 | 97 | $myPublicKey = $cryptTool->hex2bin(Common::getPublicKey(Constants::myPublicKey)); |
| 98 | 98 | |
@@ -165,15 +165,15 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | // test different strings when comparing and get time needed |
| 167 | 167 | $result = []; |
| 168 | - foreach(array( |
|
| 169 | - 'length' => [$string1, $string1 . 'a'], |
|
| 168 | + foreach (array( |
|
| 169 | + 'length' => [$string1, $string1.'a'], |
|
| 170 | 170 | 'diff' => [$string1, $string2], |
| 171 | 171 | 'same' => [$string1, $string1] |
| 172 | 172 | ) as $testName => $strings) { |
| 173 | 173 | $timeStart = microtime(true); |
| 174 | 174 | $comparisonResult = $cryptTool->stringCompare($strings[0], $strings[1]); |
| 175 | 175 | $timeEnd = microtime(true); |
| 176 | - $timeElapsed = $timeEnd - $timeStart; |
|
| 176 | + $timeElapsed = $timeEnd-$timeStart; |
|
| 177 | 177 | |
| 178 | 178 | // echo $prefix.': '.$humanDescr[$testName].': '.$timeElapsed.'; result: '.$comparisonResult.PHP_EOL; |
| 179 | 179 | $result[$testName] = [$timeElapsed, $comparisonResult]; |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | // check timings |
| 190 | 190 | echo 'Timing test results with '.$prefix.':'.PHP_EOL; |
| 191 | - $timingRatio = $result['diff'][0] / $result['same'][0]; |
|
| 192 | - $absoluteDifference = abs($result['diff'][0] - $result['same'][0]); |
|
| 191 | + $timingRatio = $result['diff'][0]/$result['same'][0]; |
|
| 192 | + $absoluteDifference = abs($result['diff'][0]-$result['same'][0]); |
|
| 193 | 193 | echo 'timing ratio: '.$timingRatio.PHP_EOL; |
| 194 | 194 | echo 'absolute difference: '.$absoluteDifference.PHP_EOL; |
| 195 | 195 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function testRemoveVar() { |
| 210 | 210 | $this->doTest(function(CryptTool $cryptTool, $prefix) { |
| 211 | - foreach(array( |
|
| 211 | + foreach (array( |
|
| 212 | 212 | 'hex' => Constants::myPrivateKeyExtract, |
| 213 | 213 | 'bin' => $cryptTool->hex2bin(Constants::myPrivateKeyExtract) |
| 214 | 214 | ) as $key => $testVar) { |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | private function doTest(\Closure $c) { |
| 225 | - foreach(array( |
|
| 225 | + foreach (array( |
|
| 226 | 226 | 'Salt' => CryptTool::createInstance(CryptTool::TYPE_SALT), |
| 227 | 227 | 'Sodium' => CryptTool::createInstance(CryptTool::TYPE_SODIUM) |
| 228 | 228 | ) as $key => $instance) { |
| 229 | 229 | |
| 230 | - if($instance === null) { |
|
| 230 | + if ($instance === null) { |
|
| 231 | 231 | echo $key.": could not instance crypt tool\n"; |
| 232 | 232 | break; |
| 233 | 233 | } |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | if ($tlsCipher = $this->setting->getTlsOption(ConnectionSettings::tlsOptionCipher, null)) { |
| 205 | - if(true === is_string($tlsCipher)) { |
|
| 205 | + if (true === is_string($tlsCipher)) { |
|
| 206 | 206 | $options[CURLOPT_SSL_CIPHER_LIST] = $tlsCipher; |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | if ($pinnedKey = $this->setting->getTlsOption(ConnectionSettings::tlsOptionPinnedKey, Constants::DEFAULT_PINNED_KEY)) { |
| 210 | - if(true === is_string($pinnedKey)) { |
|
| 210 | + if (true === is_string($pinnedKey)) { |
|
| 211 | 211 | $options[CURLOPT_PINNEDPUBLICKEY] = $pinnedKey; |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | return $this->call($command->getPath(), |
| 240 | 240 | $this->createDefaultOptions($progress), |
| 241 | 241 | $params, |
| 242 | - function ($httpCode, $response) use ($command) { |
|
| 242 | + function($httpCode, $response) use ($command) { |
|
| 243 | 243 | return $command->parseResult($httpCode, $response); |
| 244 | 244 | }); |
| 245 | 245 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $options[CURLOPT_HTTPHEADER] = array( |
| 258 | 258 | 'Content-Type: application/x-www-form-urlencoded'); |
| 259 | 259 | |
| 260 | - return $this->call($command->getPath(), $options, null, function ($httpCode, $response) use ($command) { |
|
| 260 | + return $this->call($command->getPath(), $options, null, function($httpCode, $response) use ($command) { |
|
| 261 | 261 | return $command->parseResult($httpCode, $response); |
| 262 | 262 | }); |
| 263 | 263 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | 'blob' => $command->getData() |
| 278 | 278 | ); |
| 279 | 279 | |
| 280 | - return $this->call($command->getPath(), $options, $params, function ($httpCode, $response) use ($command) { |
|
| 280 | + return $this->call($command->getPath(), $options, $params, function($httpCode, $response) use ($command) { |
|
| 281 | 281 | return $command->parseResult($httpCode, $response); |
| 282 | 282 | }); |
| 283 | 283 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | $response = curl_exec($session); |
| 306 | 306 | if (false === $response) { |
| 307 | - throw new Exception($path . ' ' . curl_error($session)); |
|
| 307 | + throw new Exception($path.' '.curl_error($session)); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | $httpCode = curl_getinfo($session, CURLINFO_HTTP_CODE); |
@@ -49,20 +49,20 @@ |
||
| 49 | 49 | $this->host = $host; |
| 50 | 50 | |
| 51 | 51 | // TLS options |
| 52 | - if(null !== $tlsOptions && is_array($tlsOptions)) { |
|
| 53 | - if(true === array_key_exists(self::tlsOptionForceHttps, $tlsOptions)) { |
|
| 52 | + if (null !== $tlsOptions && is_array($tlsOptions)) { |
|
| 53 | + if (true === array_key_exists(self::tlsOptionForceHttps, $tlsOptions)) { |
|
| 54 | 54 | $this->tlsOptions[self::tlsOptionForceHttps] = $tlsOptions[self::tlsOptionForceHttps] === true; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if(true === array_key_exists(self::tlsOptionVersion, $tlsOptions)) { |
|
| 57 | + if (true === array_key_exists(self::tlsOptionVersion, $tlsOptions)) { |
|
| 58 | 58 | $this->tlsOptions[self::tlsOptionVersion] = $tlsOptions[self::tlsOptionVersion]; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if(true === array_key_exists(self::tlsOptionCipher, $tlsOptions)) { |
|
| 61 | + if (true === array_key_exists(self::tlsOptionCipher, $tlsOptions)) { |
|
| 62 | 62 | $this->tlsOptions[self::tlsOptionCipher] = $tlsOptions[self::tlsOptionCipher]; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if(true === array_key_exists(self::tlsOptionPinnedKey, $tlsOptions)) { |
|
| 65 | + if (true === array_key_exists(self::tlsOptionPinnedKey, $tlsOptions)) { |
|
| 66 | 66 | $this->tlsOptions[self::tlsOptionPinnedKey] = $tlsOptions[self::tlsOptionPinnedKey]; |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -2,11 +2,11 @@ discard block |
||
| 2 | 2 | require_once("Salt/autoload.php"); |
| 3 | 3 | |
| 4 | 4 | //define possibly missing constants |
| 5 | -defined('CURL_SSLVERSION_DEFAULT') || define('CURL_SSLVERSION_DEFAULT', 0); |
|
| 6 | -defined('CURL_SSLVERSION_TLSv1') || define('CURL_SSLVERSION_TLSv1', 1); |
|
| 7 | -defined('CURL_SSLVERSION_TLSv1_1') || define('CURL_SSLVERSION_TLSv1_1', 5); |
|
| 8 | -defined('CURL_SSLVERSION_TLSv1_2') || define('CURL_SSLVERSION_TLSv1_2', 6); |
|
| 9 | -defined('CURLOPT_PINNEDPUBLICKEY') || define('CURLOPT_PINNEDPUBLICKEY', 10230); |
|
| 5 | +defined('CURL_SSLVERSION_DEFAULT') || define('CURL_SSLVERSION_DEFAULT', 0); |
|
| 6 | +defined('CURL_SSLVERSION_TLSv1') || define('CURL_SSLVERSION_TLSv1', 1); |
|
| 7 | +defined('CURL_SSLVERSION_TLSv1_1') || define('CURL_SSLVERSION_TLSv1_1', 5); |
|
| 8 | +defined('CURL_SSLVERSION_TLSv1_2') || define('CURL_SSLVERSION_TLSv1_2', 6); |
|
| 9 | +defined('CURLOPT_PINNEDPUBLICKEY') || define('CURLOPT_PINNEDPUBLICKEY', 10230); |
|
| 10 | 10 | |
| 11 | 11 | //define autoloader |
| 12 | 12 | $d = dirname(__FILE__); |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | $fileName = ''; |
| 17 | 17 | if ($lastNsPos = strrpos($className, '\\')) { |
| 18 | 18 | $namespace = substr($className, 0, $lastNsPos); |
| 19 | - $className = substr($className, $lastNsPos + 1); |
|
| 20 | - $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; |
|
| 19 | + $className = substr($className, $lastNsPos+1); |
|
| 20 | + $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR; |
|
| 21 | 21 | } |
| 22 | - $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
| 22 | + $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; |
|
| 23 | 23 | |
| 24 | - if(true === file_exists( $d.'/'.$fileName)) { |
|
| 24 | + if (true === file_exists($d.'/'.$fileName)) { |
|
| 25 | 25 | require $d.'/'.$fileName; |
| 26 | 26 | } |
| 27 | 27 | }); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | define('MSGAPI_SDK_VERSION', $sdkVersion); |
| 31 | 31 | $cryptTool = Threema\MsgApi\Tools\CryptTool::getInstance(); |
| 32 | 32 | |
| 33 | -if(null === $cryptTool) { |
|
| 33 | +if (null === $cryptTool) { |
|
| 34 | 34 | throw new \Threema\Core\Exception("no supported crypt-tool"); |
| 35 | 35 | } |
| 36 | 36 | |