@@ -213,6 +213,10 @@ discard block |
||
213 | 213 | return array($cipherKey, $macKey, $iv); |
214 | 214 | } |
215 | 215 | |
216 | + /** |
|
217 | + * @param string $a |
|
218 | + * @param string $b |
|
219 | + */ |
|
216 | 220 | function hash_equals($a, $b) { |
217 | 221 | $key = openssl_random_pseudo_bytes(128); |
218 | 222 | return hash_hmac('sha512', $a, $key) === hash_hmac('sha512', $b, $key); |
@@ -250,7 +254,7 @@ discard block |
||
250 | 254 | /** |
251 | 255 | * Pad the data with a random char chosen by the pad amount. |
252 | 256 | * |
253 | - * @param $data |
|
257 | + * @param string $data |
|
254 | 258 | * @return string |
255 | 259 | */ |
256 | 260 | protected function pad($data) { |
@@ -266,8 +270,8 @@ discard block |
||
266 | 270 | /** |
267 | 271 | * Unpad the the data |
268 | 272 | * |
269 | - * @param $data |
|
270 | - * @return bool|string |
|
273 | + * @param string $data |
|
274 | + * @return false|string |
|
271 | 275 | */ |
272 | 276 | protected function unpad($data) { |
273 | 277 | $length = $this->getKeySize(); |
@@ -284,7 +288,7 @@ discard block |
||
284 | 288 | * Encrypt a credential |
285 | 289 | * |
286 | 290 | * @param array|Credential $credential the credential to decrypt |
287 | - * @return Credential|array |
|
291 | + * @return string |
|
288 | 292 | */ |
289 | 293 | public function decryptCredential($credential) { |
290 | 294 | |
@@ -380,7 +384,7 @@ discard block |
||
380 | 384 | /** |
381 | 385 | * Decrypt a file |
382 | 386 | * |
383 | - * @param File|array $file |
|
387 | + * @param File $file |
|
384 | 388 | * @return File|array |
385 | 389 | */ |
386 | 390 |
@@ -103,7 +103,7 @@ |
||
103 | 103 | $setting = $settings->getAppSetting('server_side_encryption'); |
104 | 104 | $this->cipher = $setting['cipher']; |
105 | 105 | $this->mode = $setting['mode']; |
106 | - $this->rounds = (int)100; |
|
106 | + $this->rounds = (int) 100; |
|
107 | 107 | $this->server_key = \OC::$server->getConfig()->getSystemValue('passwordsalt', ''); |
108 | 108 | ini_set('memory_limit', '1024M'); |
109 | 109 | } |
@@ -272,7 +272,9 @@ |
||
272 | 272 | protected function unpad($data) { |
273 | 273 | $length = $this->getKeySize(); |
274 | 274 | $last = ord($data[strlen($data) - 1]); |
275 | - if ($last > $length) return false; |
|
275 | + if ($last > $length) { |
|
276 | + return false; |
|
277 | + } |
|
276 | 278 | if (substr($data, -1 * $last) !== str_repeat(chr($last), $last)) { |
277 | 279 | return false; |
278 | 280 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @param null $user_id |
62 | 62 | * @return CredentialRevision[] |
63 | 63 | */ |
64 | - public function getRevisions($credential_id, $user_id = null){ |
|
64 | + public function getRevisions($credential_id, $user_id = null) { |
|
65 | 65 | $result = $this->credentialRevisionMapper->getRevisions($credential_id, $user_id); |
66 | - foreach ($result as $index => $revision){ |
|
66 | + foreach ($result as $index => $revision) { |
|
67 | 67 | $c = json_decode(base64_decode($revision->getCredentialData()), true); |
68 | 68 | $result[$index] = $revision->jsonSerialize(); |
69 | 69 | $result[$index]['credential_data'] = $this->encryptService->decryptCredential($c); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param null $user_id |
78 | 78 | * @return CredentialRevision |
79 | 79 | */ |
80 | - public function getRevision($credential_id, $user_id = null){ |
|
80 | + public function getRevision($credential_id, $user_id = null) { |
|
81 | 81 | $revision = $this->credentialRevisionMapper->getRevision($credential_id, $user_id); |
82 | 82 | $c = json_decode(base64_decode($revision->getCredentialData()), true); |
83 | 83 | $revision->setCredentialData($this->encryptService->decryptCredential($c)); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param $user_id |
91 | 91 | * @return CredentialRevision |
92 | 92 | */ |
93 | - public function deleteRevision($revision_id, $user_id){ |
|
93 | + public function deleteRevision($revision_id, $user_id) { |
|
94 | 94 | return $this->credentialRevisionMapper->deleteRevision($revision_id, $user_id); |
95 | 95 | } |
96 | 96 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param CredentialRevision $credentialRevision |
100 | 100 | * @return CredentialRevision |
101 | 101 | */ |
102 | - public function updateRevision(CredentialRevision $credentialRevision){ |
|
102 | + public function updateRevision(CredentialRevision $credentialRevision) { |
|
103 | 103 | $credential_data = $credentialRevision->getCredentialData(); |
104 | 104 | $credential_data = json_decode(base64_decode($credential_data), true); |
105 | 105 | $credential_data = base64_encode(json_encode($this->encryptService->encryptCredential($credential_data))); |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @param null $user_id |
62 | 62 | * @return CredentialRevision[] |
63 | 63 | */ |
64 | - public function getRevisions($credential_id, $user_id = null){ |
|
64 | + public function getRevisions($credential_id, $user_id = null) { |
|
65 | 65 | $result = $this->credentialRevisionMapper->getRevisions($credential_id, $user_id); |
66 | - foreach ($result as $index => $revision){ |
|
66 | + foreach ($result as $index => $revision) { |
|
67 | 67 | $c = json_decode(base64_decode($revision->getCredentialData()), true); |
68 | 68 | $result[$index] = $revision->jsonSerialize(); |
69 | 69 | $result[$index]['credential_data'] = $this->encryptService->decryptCredential($c); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param null $user_id |
78 | 78 | * @return CredentialRevision |
79 | 79 | */ |
80 | - public function getRevision($credential_id, $user_id = null){ |
|
80 | + public function getRevision($credential_id, $user_id = null) { |
|
81 | 81 | $revision = $this->credentialRevisionMapper->getRevision($credential_id, $user_id); |
82 | 82 | $c = json_decode(base64_decode($revision->getCredentialData()), true); |
83 | 83 | $revision->setCredentialData($this->encryptService->decryptCredential($c)); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param $user_id |
91 | 91 | * @return CredentialRevision |
92 | 92 | */ |
93 | - public function deleteRevision($revision_id, $user_id){ |
|
93 | + public function deleteRevision($revision_id, $user_id) { |
|
94 | 94 | return $this->credentialRevisionMapper->deleteRevision($revision_id, $user_id); |
95 | 95 | } |
96 | 96 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param CredentialRevision $credentialRevision |
100 | 100 | * @return CredentialRevision |
101 | 101 | */ |
102 | - public function updateRevision(CredentialRevision $credentialRevision){ |
|
102 | + public function updateRevision(CredentialRevision $credentialRevision) { |
|
103 | 103 | $credential_data = $credentialRevision->getCredentialData(); |
104 | 104 | $credential_data = json_decode(base64_decode($credential_data), true); |
105 | 105 | $credential_data = base64_encode(json_encode($this->encryptService->encryptCredential($credential_data))); |