Passed
Push — develop ( 63c666...4ff015 )
by Pieter van der
16:59
created
library/tiqr/Tiqr/StateStorage/Pdo.php 3 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,6 @@
 block discarded – undo
59 59
 );
60 60
 
61 61
 CREATE INDEX IF NOT EXISTS index_tiqrstate_expire ON tiqrstate (expire);
62
-
63 62
  * @see Tiqr_StateStorage::getStorage()
64 63
  * @see Tiqr_StateStorage_StateStorageInterface
65 64
  *
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
      */
118 118
     private function cleanExpired(): void {
119 119
         try {
120
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0");
120
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0");
121 121
             $sth->execute(array(time()));
122
-            $deletedRows=$sth->rowCount();
122
+            $deletedRows = $sth->rowCount();
123 123
             $this->logger->notice(
124 124
                 sprintf("Deleted %d expired keys", $deletedRows)
125 125
             );
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
     /**
136 136
      * @see Tiqr_StateStorage_StateStorageInterface::setValue()
137 137
      */
138
-    public function setValue(string $key, $value, int $expire=0): void
138
+    public function setValue(string $key, $value, int $expire = 0): void
139 139
     {
140 140
         if (empty($key)) {
141 141
             throw new InvalidArgumentException('Empty key not allowed');
142 142
         }
143
-        if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) {
143
+        if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) {
144 144
             $this->cleanExpired();
145 145
         }
146 146
         // REPLACE INTO is mysql dialect. Supported by sqlite as well.
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
         // $expire == 0 means never expire
155 155
         if ($expire != 0) {
156
-            $expire+=time();    // Store unix timestamp after which the key expires
156
+            $expire += time(); // Store unix timestamp after which the key expires
157 157
         }
158 158
         try {
159 159
             $sth->execute(array(serialize($value), $expire, $key));
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             throw new InvalidArgumentException('Empty key not allowed');
177 177
         }
178 178
         try {
179
-            $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
179
+            $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?");
180 180
             $sth->execute(array($key));
181 181
         }
182 182
         catch (Exception $e) {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         }
207 207
 
208 208
         try {
209
-            $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
209
+            $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
210 210
             $sth->execute(array($key, time()));
211 211
         }
212 212
         catch (Exception $e) {
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
         if (false === $result) {
221 221
             // Occurs normally
222 222
             $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key));
223
-            return NULL;    // Key not found
223
+            return NULL; // Key not found
224 224
         }
225
-        $result=unserialize($result, array('allowed_classes' => false));
225
+        $result = unserialize($result, array('allowed_classes' => false));
226 226
         if (false === $result) {
227 227
             throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key));
228 228
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -123,8 +123,7 @@  discard block
 block discarded – undo
123 123
             $this->logger->notice(
124 124
                 sprintf("Deleted %d expired keys", $deletedRows)
125 125
             );
126
-        }
127
-        catch (Exception $e) {
126
+        } catch (Exception $e) {
128 127
             $this->logger->error(
129 128
                 sprintf("Deleting expired keys failed: %s", $e->getMessage()),
130 129
                 array('exception', $e)
@@ -157,8 +156,7 @@  discard block
 block discarded – undo
157 156
         }
158 157
         try {
159 158
             $sth->execute(array(serialize($value), $expire, $key));
160
-        }
161
-        catch (Exception $e) {
159
+        } catch (Exception $e) {
162 160
             $this->logger->error(
163 161
                 sprintf('Unable to store key "%s" in PDO StateStorage', $key),
164 162
                 array('exception' => $e)
@@ -178,8 +176,7 @@  discard block
 block discarded – undo
178 176
         try {
179 177
             $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?");
180 178
             $sth->execute(array($key));
181
-        }
182
-        catch (Exception $e) {
179
+        } catch (Exception $e) {
183 180
             $this->logger->error(
184 181
                 sprintf('Error deleting key "%s" from PDO StateStorage', $key),
185 182
                 array('exception' => $e)
@@ -208,8 +205,7 @@  discard block
 block discarded – undo
208 205
         try {
209 206
             $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)');
210 207
             $sth->execute(array($key, time()));
211
-        }
212
-        catch (Exception $e) {
208
+        } catch (Exception $e) {
213 209
             $this->logger->error(
214 210
                 sprintf('Error getting value for key "%s" from PDO StateStorage', $key),
215 211
                 array('exception' => $e)
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
                 $password = $options['password'];
75 75
 
76 76
                 try {
77
-                    $handle = new PDO($dsn, $userName, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION) );
77
+                    $handle = new PDO($dsn, $userName, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
78 78
                 } catch (PDOException $e) {
79 79
                     $logger->error(
80 80
                         sprintf('Unable to establish a PDO connection. Error message from PDO: %s', $e->getMessage())
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
      *         ),
98 98
      *     )
99 99
      * );
100
- *
100
+     *
101 101
      *
102 102
      * @return Tiqr_UserSecretStorage_Interface
103 103
      * @throws RuntimeException If an unknown type is requested.
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@
 block discarded – undo
39 39
      * @return Tiqr_OcraService_Interface
40 40
      * @throws Exception An exception if an unknown orca service type is requested.
41 41
      */
42
-    public static function getOcraService(string $type="tiqr", array $options=array(), LoggerInterface $logger=null)
42
+    public static function getOcraService(string $type = "tiqr", array $options = array(), LoggerInterface $logger = null)
43 43
     {
44 44
         if (!$logger)
45
-            $logger=new \Psr\Log\NullLogger();
45
+            $logger = new \Psr\Log\NullLogger();
46 46
 
47 47
         switch ($type) {
48 48
             case "tiqr":
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@
 block discarded – undo
41 41
      */
42 42
     public static function getOcraService(string $type="tiqr", array $options=array(), LoggerInterface $logger=null)
43 43
     {
44
-        if (!$logger)
45
-            $logger=new \Psr\Log\NullLogger();
44
+        if (!$logger) {
45
+                    $logger=new \Psr\Log\NullLogger();
46
+        }
46 47
 
47 48
         switch ($type) {
48 49
             case "tiqr":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OATH/OCRAParser.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	private function parseOCRASuite($ocraSuite) {
47 47
 		if (!is_string($ocraSuite)) {
48
-			throw new Exception('OCRASuite not in string format: ' . var_export($ocraSuite, TRUE));
48
+			throw new Exception('OCRASuite not in string format: '.var_export($ocraSuite, TRUE));
49 49
 		}
50 50
 
51 51
 		$ocraSuite = strtoupper($ocraSuite);
@@ -53,54 +53,54 @@  discard block
 block discarded – undo
53 53
 
54 54
 		$s = explode(':', $ocraSuite);
55 55
 		if (count($s) != 3) {
56
-			throw new Exception('Invalid OCRASuite format: ' . var_export($ocraSuite, TRUE));
56
+			throw new Exception('Invalid OCRASuite format: '.var_export($ocraSuite, TRUE));
57 57
 		}
58 58
 
59 59
 		$algo = explode('-', $s[0]);
60 60
 		if (count($algo) != 2) {
61
-			throw new Exception('Invalid OCRA version: ' . var_export($s[0], TRUE));
61
+			throw new Exception('Invalid OCRA version: '.var_export($s[0], TRUE));
62 62
 		}
63 63
 
64 64
 		if ($algo[0] !== 'OCRA') {
65
-			throw new Exception('Unsupported OCRA algorithm: ' . var_export($algo[0], TRUE));
65
+			throw new Exception('Unsupported OCRA algorithm: '.var_export($algo[0], TRUE));
66 66
 		}
67 67
 
68 68
 		if ($algo[1] !== '1') {
69
-			throw new Exception('Unsupported OCRA version: ' . var_export($algo[1], TRUE));
69
+			throw new Exception('Unsupported OCRA version: '.var_export($algo[1], TRUE));
70 70
 		}
71 71
 		$this->OCRAVersion = $algo[1];
72 72
 
73 73
 		$cf = explode('-', $s[1]);
74 74
 		if (count($cf) != 3) {
75
-			throw new Exception('Invalid OCRA suite crypto function: ' . var_export($s[1], TRUE));
75
+			throw new Exception('Invalid OCRA suite crypto function: '.var_export($s[1], TRUE));
76 76
 		}
77 77
 
78 78
 		if ($cf[0] !== 'HOTP') {
79
-			throw new Exception('Unsupported OCRA suite crypto function: ' . var_export($cf[0], TRUE));
79
+			throw new Exception('Unsupported OCRA suite crypto function: '.var_export($cf[0], TRUE));
80 80
 		}
81 81
 		$this->CryptoFunctionType = $cf[0];
82 82
 
83 83
 		if (!array_key_exists($cf[1], $this->supportedHashFunctions)) {
84
-			throw new Exception('Unsupported hash function in OCRA suite crypto function: ' . var_export($cf[1], TRUE));
84
+			throw new Exception('Unsupported hash function in OCRA suite crypto function: '.var_export($cf[1], TRUE));
85 85
 		}
86 86
 		$this->CryptoFunctionHash = $cf[1];
87 87
 		$this->CryptoFunctionHashLength = $this->supportedHashFunctions[$cf[1]];
88 88
 
89 89
 		if (!preg_match('/^\d+$/', $cf[2]) || (($cf[2] < 4 || $cf[2] > 10) && $cf[2] != 0)) {
90
-			throw new Exception('Invalid OCRA suite crypto function truncation length: ' . var_export($cf[2], TRUE));
90
+			throw new Exception('Invalid OCRA suite crypto function truncation length: '.var_export($cf[2], TRUE));
91 91
 		}
92 92
 		$this->CryptoFunctionTruncation = intval($cf[2]);
93 93
 
94 94
 		$di = explode('-', $s[2]);
95 95
 		if (count($cf) == 0) {
96
-			throw new Exception('Invalid OCRA suite data input: ' . var_export($s[2], TRUE));
96
+			throw new Exception('Invalid OCRA suite data input: '.var_export($s[2], TRUE));
97 97
 		}
98 98
 
99 99
 		$data_input = array();
100
-		foreach($di as $elem) {
100
+		foreach ($di as $elem) {
101 101
 			$letter = $elem[0];
102 102
 			if (array_key_exists($letter, $data_input)) {
103
-				throw new Exception('Duplicate field in OCRA suite data input: ' . var_export($elem, TRUE));
103
+				throw new Exception('Duplicate field in OCRA suite data input: '.var_export($elem, TRUE));
104 104
 			}
105 105
 			$data_input[$letter] = 1;
106 106
 
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 				} elseif (preg_match('/^Q([AHN])(\d+)$/', $elem, $match)) {
113 113
 					$q_len = intval($match[2]);
114 114
 					if ($q_len < 4 || $q_len > 64) {
115
-						throw new Exception('Invalid OCRA suite data input question length: ' . var_export($q_len, TRUE));
115
+						throw new Exception('Invalid OCRA suite data input question length: '.var_export($q_len, TRUE));
116 116
 					}
117 117
 					$this->Q = TRUE;
118 118
 					$this->QType = $match[1];
119 119
 					$this->QLength = $q_len;
120 120
 				} else {
121
-					throw new Exception('Invalid OCRA suite data input question: ' . var_export($elem, TRUE));
121
+					throw new Exception('Invalid OCRA suite data input question: '.var_export($elem, TRUE));
122 122
 				}
123 123
 			} elseif ($letter === 'P') {
124 124
 				if (strlen($elem) == 1) {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				} else {
127 127
 					$p_algo = substr($elem, 1);
128 128
 					if (!array_key_exists($p_algo, $this->supportedHashFunctions)) {
129
-						throw new Exception('Unsupported OCRA suite PIN hash function: ' . var_export($elem, TRUE));
129
+						throw new Exception('Unsupported OCRA suite PIN hash function: '.var_export($elem, TRUE));
130 130
 					}
131 131
 					$this->P = TRUE;
132 132
 					$this->PType = $p_algo;
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 				} elseif (preg_match('/^S(\d+)$/', $elem, $match)) {
139 139
 					$s_len = intval($match[1]);
140 140
 					if ($s_len <= 0 || $s_len > 512) {
141
-						throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($s_len, TRUE));
141
+						throw new Exception('Invalid OCRA suite data input session information length: '.var_export($s_len, TRUE));
142 142
 					}
143 143
 
144 144
 					$this->S = TRUE;
145 145
 					$this->SLength = $s_len;
146 146
 				} else {
147
-					throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($elem, TRUE));
147
+					throw new Exception('Invalid OCRA suite data input session information length: '.var_export($elem, TRUE));
148 148
 				}
149 149
 			} elseif ($letter === 'T') {
150 150
 				if (strlen($elem) == 1) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 					preg_match_all('/(\d+)([HMS])/', $elem, $match);
154 154
 
155 155
 					if (count($match[1]) !== count(array_unique($match[2]))) {
156
-						throw new Exception('Duplicate definitions in OCRA suite data input timestamp: ' . var_export($elem, TRUE));
156
+						throw new Exception('Duplicate definitions in OCRA suite data input timestamp: '.var_export($elem, TRUE));
157 157
 					}
158 158
 
159 159
 					$length = 0;
@@ -161,21 +161,21 @@  discard block
 block discarded – undo
161 161
 						$length += intval($match[1][$i]) * $this->TPeriods[$match[2][$i]];
162 162
 					}
163 163
 					if ($length <= 0) {
164
-						throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
164
+						throw new Exception('Invalid OCRA suite data input timestamp: '.var_export($elem, TRUE));
165 165
 					}
166 166
 
167 167
 					$this->T = TRUE;
168 168
 					$this->TLength = $length;
169 169
 				} else {
170
-					throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
170
+					throw new Exception('Invalid OCRA suite data input timestamp: '.var_export($elem, TRUE));
171 171
 				}
172 172
 			} else {
173
-				throw new Exception('Unsupported OCRA suite data input field: ' . var_export($elem, TRUE));
173
+				throw new Exception('Unsupported OCRA suite data input field: '.var_export($elem, TRUE));
174 174
 			}
175 175
 		}
176 176
 
177 177
 		if (!$this->Q) {
178
-			throw new Exception('OCRA suite data input question not defined: ' . var_export($s[2], TRUE));
178
+			throw new Exception('OCRA suite data input question not defined: '.var_export($s[2], TRUE));
179 179
 		}
180 180
 	}
181 181
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
         $bytes = Tiqr_Random::randomBytes($q_length);
198 198
 
199
-		switch($q_type) {
199
+		switch ($q_type) {
200 200
 			case 'A':
201 201
 				$challenge = base64_encode($bytes);
202 202
 				$tr = implode("", unpack('H*', $bytes));
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 				$challenge = implode("", unpack('N*', $bytes));
210 210
 				break;
211 211
 			default:
212
-				throw new Exception('Unsupported OCRASuite challenge type: ' . var_export($q_type, TRUE));
212
+				throw new Exception('Unsupported OCRASuite challenge type: '.var_export($q_type, TRUE));
213 213
 				break;
214 214
 		}
215 215
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 			$result &= ($s1[$i] == $s2[$i]);
234 234
 		}
235 235
 
236
-		return (boolean)$result;
236
+		return (boolean) $result;
237 237
 	}
238 238
 
239 239
 }
Please login to merge, or discard this patch.
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -2,32 +2,32 @@  discard block
 block discarded – undo
2 2
 
3 3
 class OATH_OCRAParser {
4 4
 
5
-	private $OCRASuite = NULL;
5
+    private $OCRASuite = NULL;
6 6
 
7
-	private $OCRAVersion = NULL;
7
+    private $OCRAVersion = NULL;
8 8
 
9
-	private $CryptoFunctionType = NULL;
10
-	private $CryptoFunctionHash = NULL;
11
-	private $CryptoFunctionHashLength = NULL;
12
-	private $CryptoFunctionTruncation = NULL;
9
+    private $CryptoFunctionType = NULL;
10
+    private $CryptoFunctionHash = NULL;
11
+    private $CryptoFunctionHashLength = NULL;
12
+    private $CryptoFunctionTruncation = NULL;
13 13
 
14
-	private $C = FALSE;
15
-	private $Q = FALSE;
16
-	private $QType = 'N';
17
-	private $QLength = 8;
14
+    private $C = FALSE;
15
+    private $Q = FALSE;
16
+    private $QType = 'N';
17
+    private $QLength = 8;
18 18
 
19
-	private $P = FALSE;
20
-	private $PType = 'SHA1';
21
-	private $PLength = 20;
19
+    private $P = FALSE;
20
+    private $PType = 'SHA1';
21
+    private $PLength = 20;
22 22
 
23
-	private $S = FALSE;
24
-	private $SLength = 64;
23
+    private $S = FALSE;
24
+    private $SLength = 64;
25 25
 
26
-	private $T = FALSE;
27
-	private $TLength = 60; // 1M
28
-	private $TPeriods = array('H' => 3600, 'M' => 60, 'S' => 1);
26
+    private $T = FALSE;
27
+    private $TLength = 60; // 1M
28
+    private $TPeriods = array('H' => 3600, 'M' => 60, 'S' => 1);
29 29
 
30
-	private $supportedHashFunctions = array('SHA1' => 20, 'SHA256' => 32, 'SHA512' => 64);
30
+    private $supportedHashFunctions = array('SHA1' => 20, 'SHA256' => 32, 'SHA512' => 64);
31 31
 
32 32
 
33 33
     /**
@@ -35,149 +35,149 @@  discard block
 block discarded – undo
35 35
      * @throws Exception
36 36
      */
37 37
     public function __construct(String $ocraSuite) {
38
-		$this->parseOCRASuite($ocraSuite);
39
-	}
38
+        $this->parseOCRASuite($ocraSuite);
39
+    }
40 40
 
41
-	/**
42
-	 * Inspired by https://github.com/bdauvergne/python-oath
41
+    /**
42
+     * Inspired by https://github.com/bdauvergne/python-oath
43 43
      *
44 44
      * @throws Exception
45
-	 */
46
-	private function parseOCRASuite($ocraSuite) {
47
-		if (!is_string($ocraSuite)) {
48
-			throw new Exception('OCRASuite not in string format: ' . var_export($ocraSuite, TRUE));
49
-		}
50
-
51
-		$ocraSuite = strtoupper($ocraSuite);
52
-		$this->OCRASuite = $ocraSuite;
53
-
54
-		$s = explode(':', $ocraSuite);
55
-		if (count($s) != 3) {
56
-			throw new Exception('Invalid OCRASuite format: ' . var_export($ocraSuite, TRUE));
57
-		}
58
-
59
-		$algo = explode('-', $s[0]);
60
-		if (count($algo) != 2) {
61
-			throw new Exception('Invalid OCRA version: ' . var_export($s[0], TRUE));
62
-		}
63
-
64
-		if ($algo[0] !== 'OCRA') {
65
-			throw new Exception('Unsupported OCRA algorithm: ' . var_export($algo[0], TRUE));
66
-		}
67
-
68
-		if ($algo[1] !== '1') {
69
-			throw new Exception('Unsupported OCRA version: ' . var_export($algo[1], TRUE));
70
-		}
71
-		$this->OCRAVersion = $algo[1];
72
-
73
-		$cf = explode('-', $s[1]);
74
-		if (count($cf) != 3) {
75
-			throw new Exception('Invalid OCRA suite crypto function: ' . var_export($s[1], TRUE));
76
-		}
77
-
78
-		if ($cf[0] !== 'HOTP') {
79
-			throw new Exception('Unsupported OCRA suite crypto function: ' . var_export($cf[0], TRUE));
80
-		}
81
-		$this->CryptoFunctionType = $cf[0];
82
-
83
-		if (!array_key_exists($cf[1], $this->supportedHashFunctions)) {
84
-			throw new Exception('Unsupported hash function in OCRA suite crypto function: ' . var_export($cf[1], TRUE));
85
-		}
86
-		$this->CryptoFunctionHash = $cf[1];
87
-		$this->CryptoFunctionHashLength = $this->supportedHashFunctions[$cf[1]];
88
-
89
-		if (!preg_match('/^\d+$/', $cf[2]) || (($cf[2] < 4 || $cf[2] > 10) && $cf[2] != 0)) {
90
-			throw new Exception('Invalid OCRA suite crypto function truncation length: ' . var_export($cf[2], TRUE));
91
-		}
92
-		$this->CryptoFunctionTruncation = intval($cf[2]);
93
-
94
-		$di = explode('-', $s[2]);
95
-		if (count($cf) == 0) {
96
-			throw new Exception('Invalid OCRA suite data input: ' . var_export($s[2], TRUE));
97
-		}
98
-
99
-		$data_input = array();
100
-		foreach($di as $elem) {
101
-			$letter = $elem[0];
102
-			if (array_key_exists($letter, $data_input)) {
103
-				throw new Exception('Duplicate field in OCRA suite data input: ' . var_export($elem, TRUE));
104
-			}
105
-			$data_input[$letter] = 1;
106
-
107
-			if ($letter === 'C' && strlen($elem) == 1) {
108
-				$this->C = TRUE;
109
-			} elseif ($letter === 'Q') {
110
-				if (strlen($elem) == 1) {
111
-					$this->Q = TRUE;
112
-				} elseif (preg_match('/^Q([AHN])(\d+)$/', $elem, $match)) {
113
-					$q_len = intval($match[2]);
114
-					if ($q_len < 4 || $q_len > 64) {
115
-						throw new Exception('Invalid OCRA suite data input question length: ' . var_export($q_len, TRUE));
116
-					}
117
-					$this->Q = TRUE;
118
-					$this->QType = $match[1];
119
-					$this->QLength = $q_len;
120
-				} else {
121
-					throw new Exception('Invalid OCRA suite data input question: ' . var_export($elem, TRUE));
122
-				}
123
-			} elseif ($letter === 'P') {
124
-				if (strlen($elem) == 1) {
125
-					$this->P = TRUE;
126
-				} else {
127
-					$p_algo = substr($elem, 1);
128
-					if (!array_key_exists($p_algo, $this->supportedHashFunctions)) {
129
-						throw new Exception('Unsupported OCRA suite PIN hash function: ' . var_export($elem, TRUE));
130
-					}
131
-					$this->P = TRUE;
132
-					$this->PType = $p_algo;
133
-					$this->PLength = $this->supportedHashFunctions[$p_algo];
134
-				}
135
-			} elseif ($letter === 'S') {
136
-				if (strlen($elem) == 1) {
137
-					$this->S = TRUE;
138
-				} elseif (preg_match('/^S(\d+)$/', $elem, $match)) {
139
-					$s_len = intval($match[1]);
140
-					if ($s_len <= 0 || $s_len > 512) {
141
-						throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($s_len, TRUE));
142
-					}
143
-
144
-					$this->S = TRUE;
145
-					$this->SLength = $s_len;
146
-				} else {
147
-					throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($elem, TRUE));
148
-				}
149
-			} elseif ($letter === 'T') {
150
-				if (strlen($elem) == 1) {
151
-					$this->T = TRUE;
152
-				} elseif (preg_match('/^T(\d+[HMS])+$/', $elem)) {
153
-					preg_match_all('/(\d+)([HMS])/', $elem, $match);
154
-
155
-					if (count($match[1]) !== count(array_unique($match[2]))) {
156
-						throw new Exception('Duplicate definitions in OCRA suite data input timestamp: ' . var_export($elem, TRUE));
157
-					}
158
-
159
-					$length = 0;
160
-					for ($i = 0; $i < count($match[1]); $i++) {
161
-						$length += intval($match[1][$i]) * $this->TPeriods[$match[2][$i]];
162
-					}
163
-					if ($length <= 0) {
164
-						throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
165
-					}
166
-
167
-					$this->T = TRUE;
168
-					$this->TLength = $length;
169
-				} else {
170
-					throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
171
-				}
172
-			} else {
173
-				throw new Exception('Unsupported OCRA suite data input field: ' . var_export($elem, TRUE));
174
-			}
175
-		}
176
-
177
-		if (!$this->Q) {
178
-			throw new Exception('OCRA suite data input question not defined: ' . var_export($s[2], TRUE));
179
-		}
180
-	}
45
+     */
46
+    private function parseOCRASuite($ocraSuite) {
47
+        if (!is_string($ocraSuite)) {
48
+            throw new Exception('OCRASuite not in string format: ' . var_export($ocraSuite, TRUE));
49
+        }
50
+
51
+        $ocraSuite = strtoupper($ocraSuite);
52
+        $this->OCRASuite = $ocraSuite;
53
+
54
+        $s = explode(':', $ocraSuite);
55
+        if (count($s) != 3) {
56
+            throw new Exception('Invalid OCRASuite format: ' . var_export($ocraSuite, TRUE));
57
+        }
58
+
59
+        $algo = explode('-', $s[0]);
60
+        if (count($algo) != 2) {
61
+            throw new Exception('Invalid OCRA version: ' . var_export($s[0], TRUE));
62
+        }
63
+
64
+        if ($algo[0] !== 'OCRA') {
65
+            throw new Exception('Unsupported OCRA algorithm: ' . var_export($algo[0], TRUE));
66
+        }
67
+
68
+        if ($algo[1] !== '1') {
69
+            throw new Exception('Unsupported OCRA version: ' . var_export($algo[1], TRUE));
70
+        }
71
+        $this->OCRAVersion = $algo[1];
72
+
73
+        $cf = explode('-', $s[1]);
74
+        if (count($cf) != 3) {
75
+            throw new Exception('Invalid OCRA suite crypto function: ' . var_export($s[1], TRUE));
76
+        }
77
+
78
+        if ($cf[0] !== 'HOTP') {
79
+            throw new Exception('Unsupported OCRA suite crypto function: ' . var_export($cf[0], TRUE));
80
+        }
81
+        $this->CryptoFunctionType = $cf[0];
82
+
83
+        if (!array_key_exists($cf[1], $this->supportedHashFunctions)) {
84
+            throw new Exception('Unsupported hash function in OCRA suite crypto function: ' . var_export($cf[1], TRUE));
85
+        }
86
+        $this->CryptoFunctionHash = $cf[1];
87
+        $this->CryptoFunctionHashLength = $this->supportedHashFunctions[$cf[1]];
88
+
89
+        if (!preg_match('/^\d+$/', $cf[2]) || (($cf[2] < 4 || $cf[2] > 10) && $cf[2] != 0)) {
90
+            throw new Exception('Invalid OCRA suite crypto function truncation length: ' . var_export($cf[2], TRUE));
91
+        }
92
+        $this->CryptoFunctionTruncation = intval($cf[2]);
93
+
94
+        $di = explode('-', $s[2]);
95
+        if (count($cf) == 0) {
96
+            throw new Exception('Invalid OCRA suite data input: ' . var_export($s[2], TRUE));
97
+        }
98
+
99
+        $data_input = array();
100
+        foreach($di as $elem) {
101
+            $letter = $elem[0];
102
+            if (array_key_exists($letter, $data_input)) {
103
+                throw new Exception('Duplicate field in OCRA suite data input: ' . var_export($elem, TRUE));
104
+            }
105
+            $data_input[$letter] = 1;
106
+
107
+            if ($letter === 'C' && strlen($elem) == 1) {
108
+                $this->C = TRUE;
109
+            } elseif ($letter === 'Q') {
110
+                if (strlen($elem) == 1) {
111
+                    $this->Q = TRUE;
112
+                } elseif (preg_match('/^Q([AHN])(\d+)$/', $elem, $match)) {
113
+                    $q_len = intval($match[2]);
114
+                    if ($q_len < 4 || $q_len > 64) {
115
+                        throw new Exception('Invalid OCRA suite data input question length: ' . var_export($q_len, TRUE));
116
+                    }
117
+                    $this->Q = TRUE;
118
+                    $this->QType = $match[1];
119
+                    $this->QLength = $q_len;
120
+                } else {
121
+                    throw new Exception('Invalid OCRA suite data input question: ' . var_export($elem, TRUE));
122
+                }
123
+            } elseif ($letter === 'P') {
124
+                if (strlen($elem) == 1) {
125
+                    $this->P = TRUE;
126
+                } else {
127
+                    $p_algo = substr($elem, 1);
128
+                    if (!array_key_exists($p_algo, $this->supportedHashFunctions)) {
129
+                        throw new Exception('Unsupported OCRA suite PIN hash function: ' . var_export($elem, TRUE));
130
+                    }
131
+                    $this->P = TRUE;
132
+                    $this->PType = $p_algo;
133
+                    $this->PLength = $this->supportedHashFunctions[$p_algo];
134
+                }
135
+            } elseif ($letter === 'S') {
136
+                if (strlen($elem) == 1) {
137
+                    $this->S = TRUE;
138
+                } elseif (preg_match('/^S(\d+)$/', $elem, $match)) {
139
+                    $s_len = intval($match[1]);
140
+                    if ($s_len <= 0 || $s_len > 512) {
141
+                        throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($s_len, TRUE));
142
+                    }
143
+
144
+                    $this->S = TRUE;
145
+                    $this->SLength = $s_len;
146
+                } else {
147
+                    throw new Exception('Invalid OCRA suite data input session information length: ' . var_export($elem, TRUE));
148
+                }
149
+            } elseif ($letter === 'T') {
150
+                if (strlen($elem) == 1) {
151
+                    $this->T = TRUE;
152
+                } elseif (preg_match('/^T(\d+[HMS])+$/', $elem)) {
153
+                    preg_match_all('/(\d+)([HMS])/', $elem, $match);
154
+
155
+                    if (count($match[1]) !== count(array_unique($match[2]))) {
156
+                        throw new Exception('Duplicate definitions in OCRA suite data input timestamp: ' . var_export($elem, TRUE));
157
+                    }
158
+
159
+                    $length = 0;
160
+                    for ($i = 0; $i < count($match[1]); $i++) {
161
+                        $length += intval($match[1][$i]) * $this->TPeriods[$match[2][$i]];
162
+                    }
163
+                    if ($length <= 0) {
164
+                        throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
165
+                    }
166
+
167
+                    $this->T = TRUE;
168
+                    $this->TLength = $length;
169
+                } else {
170
+                    throw new Exception('Invalid OCRA suite data input timestamp: ' . var_export($elem, TRUE));
171
+                }
172
+            } else {
173
+                throw new Exception('Unsupported OCRA suite data input field: ' . var_export($elem, TRUE));
174
+            }
175
+        }
176
+
177
+        if (!$this->Q) {
178
+            throw new Exception('OCRA suite data input question not defined: ' . var_export($s[2], TRUE));
179
+        }
180
+    }
181 181
 
182 182
     /** Generate an OCRA challenge question according to the ocra suite specified in the constructor
183 183
      * @return String: The randomly generated OCRA question
@@ -190,50 +190,50 @@  discard block
 block discarded – undo
190 190
      * Note that the question string is the exact question string a specified in the OCRA strandard (RFC 6287)
191 191
      * The challenge is not yet hex encoded as expected by OCRA::generateOCRA()
192 192
      */
193
-	public function generateChallenge() : String {
194
-		$q_length = $this->QLength;
195
-		$q_type = $this->QType;
193
+    public function generateChallenge() : String {
194
+        $q_length = $this->QLength;
195
+        $q_type = $this->QType;
196 196
 
197 197
         $bytes = Tiqr_Random::randomBytes($q_length);
198 198
 
199
-		switch($q_type) {
200
-			case 'A':
201
-				$challenge = base64_encode($bytes);
202
-				$tr = implode("", unpack('H*', $bytes));
203
-				$challenge = rtrim(strtr($challenge, '+/', $tr), '=');
204
-				break;
205
-			case 'H':
206
-				$challenge = implode("", unpack('H*', $bytes));
207
-				break;
208
-			case 'N':
209
-				$challenge = implode("", unpack('N*', $bytes));
210
-				break;
211
-			default:
212
-				throw new Exception('Unsupported OCRASuite challenge type: ' . var_export($q_type, TRUE));
213
-				break;
214
-		}
215
-
216
-		$challenge = substr($challenge, 0, $q_length);
217
-
218
-		return $challenge;
219
-	}
220
-
221
-
222
-	/**
223
-	 * Constant time string comparison, see http://codahale.com/a-lesson-in-timing-attacks/
224
-	 */
225
-	public static function constEqual(string $s1, string $s2): bool {
226
-		if (strlen($s1) != strlen($s2)) {
227
-			return FALSE;
228
-		}
229
-
230
-		$result = TRUE;
231
-		$length = strlen($s1);
232
-		for ($i = 0; $i < $length; $i++) {
233
-			$result &= ($s1[$i] == $s2[$i]);
234
-		}
235
-
236
-		return (boolean)$result;
237
-	}
199
+        switch($q_type) {
200
+            case 'A':
201
+                $challenge = base64_encode($bytes);
202
+                $tr = implode("", unpack('H*', $bytes));
203
+                $challenge = rtrim(strtr($challenge, '+/', $tr), '=');
204
+                break;
205
+            case 'H':
206
+                $challenge = implode("", unpack('H*', $bytes));
207
+                break;
208
+            case 'N':
209
+                $challenge = implode("", unpack('N*', $bytes));
210
+                break;
211
+            default:
212
+                throw new Exception('Unsupported OCRASuite challenge type: ' . var_export($q_type, TRUE));
213
+                break;
214
+        }
215
+
216
+        $challenge = substr($challenge, 0, $q_length);
217
+
218
+        return $challenge;
219
+    }
220
+
221
+
222
+    /**
223
+     * Constant time string comparison, see http://codahale.com/a-lesson-in-timing-attacks/
224
+     */
225
+    public static function constEqual(string $s1, string $s2): bool {
226
+        if (strlen($s1) != strlen($s2)) {
227
+            return FALSE;
228
+        }
229
+
230
+        $result = TRUE;
231
+        $length = strlen($s1);
232
+        for ($i = 0; $i < $length; $i++) {
233
+            $result &= ($s1[$i] == $s2[$i]);
234
+        }
235
+
236
+        return (boolean)$result;
237
+    }
238 238
 
239 239
 }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/OcraService/Abstract.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
         $this->logger = $logger;
36 36
 
37 37
         // Set the OCRA suite
38
-        $this->_ocraSuite = $config['ocra.suite'] ?? 'OCRA-1:HOTP-SHA1-6:QH10-S';   // Use tiqr server default suite
38
+        $this->_ocraSuite = $config['ocra.suite'] ?? 'OCRA-1:HOTP-SHA1-6:QH10-S'; // Use tiqr server default suite
39 39
         $this->_ocraParser = new OATH_OCRAParser($this->_ocraSuite);
40 40
     }
41 41
 
Please login to merge, or discard this patch.
library/tiqr/Tiqr/DeviceStorage.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@
 block discarded – undo
40 40
      * @param LoggerInterface $logger
41 41
      * @throws Exception An exception if an unknown storage is requested.
42 42
      */
43
-    public static function getStorage(string $type="dummy", Array $options=array(), LoggerInterface $logger=null)
43
+    public static function getStorage(string $type = "dummy", Array $options = array(), LoggerInterface $logger = null)
44 44
     {
45 45
         if (!$logger)
46
-            $logger=new \Psr\Log\NullLogger();
46
+            $logger = new \Psr\Log\NullLogger();
47 47
 
48 48
         switch ($type) {
49 49
             case "dummy":
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@
 block discarded – undo
42 42
      */
43 43
     public static function getStorage(string $type="dummy", Array $options=array(), LoggerInterface $logger=null)
44 44
     {
45
-        if (!$logger)
46
-            $logger=new \Psr\Log\NullLogger();
45
+        if (!$logger) {
46
+                    $logger=new \Psr\Log\NullLogger();
47
+        }
47 48
 
48 49
         switch ($type) {
49 50
             case "dummy":
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage/UserSecretStorageTrait.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
         if ($prefix === $this->encryption->get_type()) {
55 55
             // Decrypt the secret if it is prefixed with the current encryption type
56 56
             // Remove the encryption type prefix before decrypting
57
-           return $this->encryption->decrypt( substr($encryptedSecret, $pos+1) );
57
+            return $this->encryption->decrypt( substr($encryptedSecret, $pos+1) );
58 58
         }
59 59
 
60 60
         // Check the decryption array for the encryption type to see if there is an encryption
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
         if ($prefix === $this->encryption->get_type()) {
55 55
             // Decrypt the secret if it is prefixed with the current encryption type
56 56
             // Remove the encryption type prefix before decrypting
57
-           return $this->encryption->decrypt( substr($encryptedSecret, $pos+1) );
57
+           return $this->encryption->decrypt(substr($encryptedSecret, $pos + 1));
58 58
         }
59 59
 
60 60
         // Check the decryption array for the encryption type to see if there is an encryption
61 61
         // instance defined for it. If so, use that to decrypt the secret.
62 62
         if (isset($this->decryption[$prefix])) {
63
-            return $this->decryption[$prefix]->decrypt( substr($encryptedSecret, $pos+1) );
63
+            return $this->decryption[$prefix]->decrypt(substr($encryptedSecret, $pos + 1));
64 64
         }
65 65
 
66 66
         $this->logger->error("Secret for user '$userId' is encrypted with unsupported encryption type '$prefix'");
@@ -77,6 +77,6 @@  discard block
 block discarded – undo
77 77
     {
78 78
         $encryptedSecret = $this->encryption->encrypt($secret);
79 79
         // Prefix the user secret with the encryption type
80
-        $this->setUserSecret($userId, $this->encryption->get_type() . ':' . $encryptedSecret);
80
+        $this->setUserSecret($userId, $this->encryption->get_type().':'.$encryptedSecret);
81 81
     }
82 82
 }
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage/Encryption.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
      *
39 39
      * @return Tiqr_UserSecretStorage_Encryption_Interface
40 40
      */
41
-    public static function getEncryption(LoggerInterface $logger, string $type="dummy", array $options=array()): Tiqr_UserSecretStorage_Encryption_Interface
41
+    public static function getEncryption(LoggerInterface $logger, string $type = "dummy", array $options = array()): Tiqr_UserSecretStorage_Encryption_Interface
42 42
     {
43 43
         $instance = null;
44 44
         $logger->info(sprintf('Using "%s" as UserSecretStorage encryption type', $type));
Please login to merge, or discard this patch.
library/tiqr/Tiqr/UserSecretStorage/Encryption/OpenSSL.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@
 block discarded – undo
160 160
     }
161 161
     
162 162
     /**
163
-      * Decrypts the given data.
163
+     * Decrypts the given data.
164 164
      *
165 165
      * @param string $data Data to decrypt.
166 166
      * @return string decrypted data
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -48,22 +48,22 @@  discard block
 block discarded – undo
48 48
     */
49 49
 
50 50
     private $_supportedCiphers = [
51
-        'aes-128-cbc' => [ 'tag' => false, 'key' => 16 ],
52
-        'aes-128-gcm' => [ 'tag' => true, 'key' => 16 ],
53
-        'aes-192-cbc' => [ 'tag' => false, 'key' => 24 ],
54
-        'aes-192-gcm' => [ 'tag' => true, 'key' => 24 ],
55
-        'aes-256-cbc' => [ 'tag' => false, 'key' => 32 ],
56
-        'aes-256-gcm' => [ 'tag' => true, 'key' => 32 ],
57
-        'chacha20' => [ 'tag' => false, 'key' => 32 ],
58
-        'camellia-128-cbc' => [ 'tag' => false, 'key' => 16 ],
59
-        'camellia-192-cbc' => [ 'tag' => false, 'key' => 24 ],
60
-        'camellia-256-cbc' => [ 'tag' => false, 'key' => 32 ],
61
-        'aria-128-cbc' => [ 'tag' => false, 'key' => 16 ],
62
-        'aria-128-gcm' => [ 'tag' => true, 'key' => 16 ],
63
-        'aria-192-cbc' => [ 'tag' => false, 'key' => 24 ],
64
-        'aria-192-gcm' => [ 'tag' => true, 'key' => 24 ],
65
-        'aria-256-cbc' => [ 'tag' => false, 'key' => 32 ],
66
-        'aria-256-gcm' => [ 'tag' => true, 'key' => 32 ],
51
+        'aes-128-cbc' => ['tag' => false, 'key' => 16],
52
+        'aes-128-gcm' => ['tag' => true, 'key' => 16],
53
+        'aes-192-cbc' => ['tag' => false, 'key' => 24],
54
+        'aes-192-gcm' => ['tag' => true, 'key' => 24],
55
+        'aes-256-cbc' => ['tag' => false, 'key' => 32],
56
+        'aes-256-gcm' => ['tag' => true, 'key' => 32],
57
+        'chacha20' => ['tag' => false, 'key' => 32],
58
+        'camellia-128-cbc' => ['tag' => false, 'key' => 16],
59
+        'camellia-192-cbc' => ['tag' => false, 'key' => 24],
60
+        'camellia-256-cbc' => ['tag' => false, 'key' => 32],
61
+        'aria-128-cbc' => ['tag' => false, 'key' => 16],
62
+        'aria-128-gcm' => ['tag' => true, 'key' => 16],
63
+        'aria-192-cbc' => ['tag' => false, 'key' => 24],
64
+        'aria-192-gcm' => ['tag' => true, 'key' => 24],
65
+        'aria-256-cbc' => ['tag' => false, 'key' => 32],
66
+        'aria-256-gcm' => ['tag' => true, 'key' => 32],
67 67
     ];
68 68
 
69 69
     /**
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         // A longer key is not a problem, but could indicate a configuration error
137 137
         $key_length = $this->_supportedCiphers[$this->_cipher]['key'];
138 138
         if (strlen($key) != $key_length) {
139
-            throw new RuntimeException("Invalid length of key with key_id '{$this->_key_id}' used with cipher '{$this->_cipher}', expected {$key_length} bytes, got " . strlen($key) . " bytes");
139
+            throw new RuntimeException("Invalid length of key with key_id '{$this->_key_id}' used with cipher '{$this->_cipher}', expected {$key_length} bytes, got ".strlen($key)." bytes");
140 140
         }
141 141
 
142 142
         // openssl_encrypt returns the ciphertext as a base64 encoded string, so we don't need to encode it again
143 143
         // The tag is returned as a binary string, but only if the cipher requires a tag
144
-        $tag='';
144
+        $tag = '';
145 145
         if ($this->_supportedCiphers[$this->_cipher]['tag']) {
146 146
             $encrypted = openssl_encrypt($data, $this->_cipher, $key, 0, $iv, $tag, '', 16);
147 147
         } else {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $tag = $this->_supportedCiphers[$this->_cipher]['tag'] ? $tag : '';
154 154
         // Return the encoded ciphertext, including the IV, tag and cipher
155 155
         // <cipher>:<key_id>:iv<>:<tag>:<ciphertext>
156
-        $encoded = $this->_cipher . ":" . $this->_key_id . ":" . base64_encode($iv) . ":" . base64_encode($tag) . ":" . $encrypted;
156
+        $encoded = $this->_cipher.":".$this->_key_id.":".base64_encode($iv).":".base64_encode($tag).":".$encrypted;
157 157
 
158 158
         return $encoded;
159 159
     }
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
         }
193 193
 
194 194
         // IV
195
-        $iv = base64_decode($split_data[2],true);
195
+        $iv = base64_decode($split_data[2], true);
196 196
         if ($iv === false) {
197 197
             throw new RuntimeException("Error decoding IV");
198 198
         }
199 199
 
200 200
         // Tag
201
-        $tag = base64_decode($split_data[3],true);
201
+        $tag = base64_decode($split_data[3], true);
202 202
         if ($tag === false) {
203 203
             throw new RuntimeException("Error decoding tag");
204 204
         }
205 205
         $ciphertext = $split_data[4];
206 206
 
207
-        $plaintext=openssl_decrypt($ciphertext, $cipher, $key, 0, $iv, $tag);
207
+        $plaintext = openssl_decrypt($ciphertext, $cipher, $key, 0, $iv, $tag);
208 208
         if ($plaintext === false) {
209 209
             throw new RuntimeException("Error decrypting data");
210 210
         }
Please login to merge, or discard this patch.