@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @note This method should never be called for users using client side encryption |
| 143 | 143 | * @param array $params |
| 144 | - * @return bool |
|
| 144 | + * @return boolean|null |
|
| 145 | 145 | */ |
| 146 | 146 | public function login($params) { |
| 147 | 147 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * If the password can't be changed within ownCloud, than update the key password in advance. |
| 200 | 200 | * |
| 201 | 201 | * @param array $params : uid, password |
| 202 | - * @return bool |
|
| 202 | + * @return boolean|null |
|
| 203 | 203 | */ |
| 204 | 204 | public function preSetPassphrase($params) { |
| 205 | 205 | if (App::isEnabled('encryption')) { |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * Change a user's encryption passphrase |
| 217 | 217 | * |
| 218 | 218 | * @param array $params keys: uid, password |
| 219 | - * @return bool |
|
| 219 | + * @return boolean|null |
|
| 220 | 220 | */ |
| 221 | 221 | public function setPassphrase($params) { |
| 222 | 222 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * @param string $plainContent |
| 148 | 148 | * @param string $passPhrase |
| 149 | - * @return bool|string |
|
| 149 | + * @return false|string |
|
| 150 | 150 | * @throws GenericEncryptionException |
| 151 | 151 | */ |
| 152 | 152 | public function symmetricEncryptFileContent($plainContent, $passPhrase) { |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * @param $data |
|
| 276 | + * @param string $data |
|
| 277 | 277 | * @return string |
| 278 | 278 | */ |
| 279 | 279 | private function addPadding($data) { |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param string $privateKey |
| 327 | 327 | * @param string $password |
| 328 | 328 | * @param string $uid for regular users, empty for system keys |
| 329 | - * @return bool|string |
|
| 329 | + * @return false|string |
|
| 330 | 330 | */ |
| 331 | 331 | public function encryptPrivateKey($privateKey, $password, $uid = '') { |
| 332 | 332 | $cipher = $this->getCipher(); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param string $privateKey |
| 344 | 344 | * @param string $password |
| 345 | 345 | * @param string $uid for regular users, empty for system keys |
| 346 | - * @return bool|string |
|
| 346 | + * @return false|string |
|
| 347 | 347 | */ |
| 348 | 348 | public function decryptPrivateKey($privateKey, $password = '', $uid = '') { |
| 349 | 349 | |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | /** |
| 387 | 387 | * check if it is a valid private key |
| 388 | 388 | * |
| 389 | - * @param $plainKey |
|
| 389 | + * @param string $plainKey |
|
| 390 | 390 | * @return bool |
| 391 | 391 | */ |
| 392 | 392 | protected function isValidPrivateKey($plainKey) { |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
| 405 | - * @param $keyFileContents |
|
| 405 | + * @param string $keyFileContents |
|
| 406 | 406 | * @param string $passPhrase |
| 407 | 407 | * @param string $cipher |
| 408 | 408 | * @return string |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * remove padding |
| 425 | 425 | * |
| 426 | 426 | * @param $padded |
| 427 | - * @return bool|string |
|
| 427 | + * @return string|false |
|
| 428 | 428 | */ |
| 429 | 429 | private function removePadding($padded) { |
| 430 | 430 | if (substr($padded, -2) === 'xx') { |
@@ -436,8 +436,8 @@ discard block |
||
| 436 | 436 | /** |
| 437 | 437 | * split iv from encrypted content |
| 438 | 438 | * |
| 439 | - * @param $catFile |
|
| 440 | - * @return array |
|
| 439 | + * @param string|false $catFile |
|
| 440 | + * @return string |
|
| 441 | 441 | */ |
| 442 | 442 | private function splitIv($catFile) { |
| 443 | 443 | // Fetch encryption metadata from end of file |
@@ -457,8 +457,8 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
| 460 | - * @param $encryptedContent |
|
| 461 | - * @param $iv |
|
| 460 | + * @param string $encryptedContent |
|
| 461 | + * @param string $iv |
|
| 462 | 462 | * @param string $passPhrase |
| 463 | 463 | * @param string $cipher |
| 464 | 464 | * @return string |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
| 482 | - * @param $data |
|
| 482 | + * @param string $data |
|
| 483 | 483 | * @return array |
| 484 | 484 | */ |
| 485 | 485 | protected function parseHeader($data) { |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | * @param $encKeyFile |
| 552 | 552 | * @param $shareKey |
| 553 | 553 | * @param $privateKey |
| 554 | - * @return mixed |
|
| 554 | + * @return string |
|
| 555 | 555 | * @throws MultiKeyDecryptException |
| 556 | 556 | */ |
| 557 | 557 | public function multiKeyDecrypt($encKeyFile, $shareKey, $privateKey) { |
@@ -34,7 +34,6 @@ |
||
| 34 | 34 | use OCP\Encryption\Exceptions\GenericEncryptionException; |
| 35 | 35 | use OCP\IConfig; |
| 36 | 36 | use OCP\ILogger; |
| 37 | -use OCP\IUser; |
|
| 38 | 37 | use OCP\IUserSession; |
| 39 | 38 | |
| 40 | 39 | class Crypt { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * encrypt data |
| 248 | 248 | * |
| 249 | 249 | * @param string $data you want to encrypt |
| 250 | - * @return mixed encrypted data |
|
| 250 | + * @return string encrypted data |
|
| 251 | 251 | */ |
| 252 | 252 | public function encrypt($data) { |
| 253 | 253 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * decrypt data |
| 313 | 313 | * |
| 314 | 314 | * @param string $data you want to decrypt |
| 315 | - * @return mixed decrypted data |
|
| 315 | + * @return string decrypted data |
|
| 316 | 316 | * @throws DecryptionFailedException |
| 317 | 317 | */ |
| 318 | 318 | public function decrypt($data) { |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * @param $userId |
| 283 | - * @param $key |
|
| 283 | + * @param string $key |
|
| 284 | 284 | * @return bool |
| 285 | 285 | */ |
| 286 | 286 | public function setPrivateKey($userId, $key) { |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | /** |
| 367 | 367 | * @param $userId |
| 368 | - * @return mixed |
|
| 368 | + * @return string |
|
| 369 | 369 | * @throws PrivateKeyMissingException |
| 370 | 370 | */ |
| 371 | 371 | public function getPrivateKey($userId) { |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | - * @param $path |
|
| 382 | + * @param string $path |
|
| 383 | 383 | * @param $uid |
| 384 | 384 | * @return string |
| 385 | 385 | */ |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | /** |
| 413 | 413 | * get the encrypted file key |
| 414 | 414 | * |
| 415 | - * @param $path |
|
| 415 | + * @param string $path |
|
| 416 | 416 | * @return string |
| 417 | 417 | */ |
| 418 | 418 | public function getEncryptedFileKey($path) { |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | /** |
| 511 | - * @param $purpose |
|
| 511 | + * @param string $purpose |
|
| 512 | 512 | * @param bool $timestamp |
| 513 | 513 | * @param bool $includeUserKeys |
| 514 | 514 | */ |
@@ -534,13 +534,16 @@ discard block |
||
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /** |
| 537 | - * @param $uid |
|
| 537 | + * @param string $uid |
|
| 538 | 538 | * @return bool |
| 539 | 539 | */ |
| 540 | 540 | private function deletePrivateKey($uid) { |
| 541 | 541 | return $this->keyStorage->deleteUserKey($uid, $this->privateKeyId, Encryption::ID); |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | + /** |
|
| 545 | + * @param string $path |
|
| 546 | + */ |
|
| 544 | 547 | public function deleteAllFileKeys($path) { |
| 545 | 548 | return $this->keyStorage->deleteAllFileKeys($path); |
| 546 | 549 | } |
@@ -237,7 +237,7 @@ |
||
| 237 | 237 | /** |
| 238 | 238 | * rename system wide public key |
| 239 | 239 | * |
| 240 | - * @param $privateKey private key for which we want to rename the corresponding public key |
|
| 240 | + * @param string $privateKey private key for which we want to rename the corresponding public key |
|
| 241 | 241 | */ |
| 242 | 242 | private function renameSystemPublicKey($privateKey) { |
| 243 | 243 | $publicKey = substr($privateKey,0 , strrpos($privateKey, '.privateKey')) . '.publicKey'; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * @param $recoveryKeyId |
| 106 | - * @param $password |
|
| 106 | + * @param string $password |
|
| 107 | 107 | * @return bool |
| 108 | 108 | */ |
| 109 | 109 | public function enableAdminRecovery($password) { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | - * @param $recoveryPassword |
|
| 147 | + * @param string $recoveryPassword |
|
| 148 | 148 | * @return bool |
| 149 | 149 | */ |
| 150 | 150 | public function disableAdminRecovery($recoveryPassword) { |
@@ -212,6 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | 214 | * add recovery key to all encrypted files |
| 215 | + * @param string $path |
|
| 215 | 216 | */ |
| 216 | 217 | private function addRecoveryKeys($path) { |
| 217 | 218 | $dirContent = $this->view->getDirectoryContent($path); |
@@ -239,6 +240,7 @@ discard block |
||
| 239 | 240 | |
| 240 | 241 | /** |
| 241 | 242 | * remove recovery key to all encrypted files |
| 243 | + * @param string $path |
|
| 242 | 244 | */ |
| 243 | 245 | private function removeRecoveryKeys($path) { |
| 244 | 246 | $dirContent = $this->view->getDirectoryContent($path); |
@@ -62,6 +62,9 @@ discard block |
||
| 62 | 62 | $this->moduleId = \OCA\Encryption\Crypto\Encryption::ID; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + /** |
|
| 66 | + * @param string $uid |
|
| 67 | + */ |
|
| 65 | 68 | protected function createDummyShareKeys($uid) { |
| 66 | 69 | $this->loginAsUser($uid); |
| 67 | 70 | |
@@ -89,6 +92,9 @@ discard block |
||
| 89 | 92 | } |
| 90 | 93 | } |
| 91 | 94 | |
| 95 | + /** |
|
| 96 | + * @param string $uid |
|
| 97 | + */ |
|
| 92 | 98 | protected function createDummyUserKeys($uid) { |
| 93 | 99 | $this->loginAsUser($uid); |
| 94 | 100 | |
@@ -98,6 +104,9 @@ discard block |
||
| 98 | 104 | $this->view->file_put_contents('/files_encryption/public_keys/' . $uid . '.publicKey', 'publicKey'); |
| 99 | 105 | } |
| 100 | 106 | |
| 107 | + /** |
|
| 108 | + * @param string $uid |
|
| 109 | + */ |
|
| 101 | 110 | protected function createDummyFileKeys($uid) { |
| 102 | 111 | $this->loginAsUser($uid); |
| 103 | 112 | |
@@ -111,6 +120,9 @@ discard block |
||
| 111 | 120 | $this->view->file_put_contents($uid . '/files_encryption/keys/folder2/file.2.1/fileKey' , 'data'); |
| 112 | 121 | } |
| 113 | 122 | |
| 123 | + /** |
|
| 124 | + * @param string $uid |
|
| 125 | + */ |
|
| 114 | 126 | protected function createDummyFiles($uid) { |
| 115 | 127 | $this->loginAsUser($uid); |
| 116 | 128 | |
@@ -124,6 +136,9 @@ discard block |
||
| 124 | 136 | $this->view->file_put_contents($uid . '/files/folder2/file.2.1/fileKey' , 'data'); |
| 125 | 137 | } |
| 126 | 138 | |
| 139 | + /** |
|
| 140 | + * @param string $uid |
|
| 141 | + */ |
|
| 127 | 142 | protected function createDummyFilesInTrash($uid) { |
| 128 | 143 | $this->loginAsUser($uid); |
| 129 | 144 | |
@@ -239,6 +254,9 @@ discard block |
||
| 239 | 254 | |
| 240 | 255 | } |
| 241 | 256 | |
| 257 | + /** |
|
| 258 | + * @param string $uid |
|
| 259 | + */ |
|
| 242 | 260 | protected function verifyFilesInTrash($uid) { |
| 243 | 261 | $this->loginAsUser($uid); |
| 244 | 262 | |
@@ -266,6 +284,9 @@ discard block |
||
| 266 | 284 | ); |
| 267 | 285 | } |
| 268 | 286 | |
| 287 | + /** |
|
| 288 | + * @param string $uid |
|
| 289 | + */ |
|
| 269 | 290 | protected function verifyNewKeyPath($uid) { |
| 270 | 291 | // private key |
| 271 | 292 | if ($uid !== '') { |
@@ -394,6 +415,11 @@ discard block |
||
| 394 | 415 | |
| 395 | 416 | } |
| 396 | 417 | |
| 418 | + /** |
|
| 419 | + * @param string $table |
|
| 420 | + * @param string $appid |
|
| 421 | + * @param integer $expected |
|
| 422 | + */ |
|
| 397 | 423 | public function verifyDB($table, $appid, $expected) { |
| 398 | 424 | /** @var \OCP\IDBConnection $connection */ |
| 399 | 425 | $connection = \OC::$server->getDatabaseConnection(); |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | * |
| 128 | 128 | * @NoAdminRequired |
| 129 | 129 | * |
| 130 | - * @param array|string $tagName tag name to filter by |
|
| 130 | + * @param string[] $tagName tag name to filter by |
|
| 131 | 131 | * @return DataResponse |
| 132 | 132 | */ |
| 133 | 133 | public function getFilesByTag($tagName) { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @param string $text |
| 161 | 161 | * @param IL10N $l |
| 162 | 162 | * @param array $params |
| 163 | - * @return bool|string |
|
| 163 | + * @return string|false |
|
| 164 | 164 | */ |
| 165 | 165 | protected function translateLong($text, IL10N $l, array $params) { |
| 166 | 166 | switch ($text) { |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param string $text |
| 193 | 193 | * @param IL10N $l |
| 194 | 194 | * @param array $params |
| 195 | - * @return bool|string |
|
| 195 | + * @return string|false |
|
| 196 | 196 | */ |
| 197 | 197 | protected function translateShort($text, IL10N $l, array $params) { |
| 198 | 198 | switch ($text) { |