Completed
Push — master ( 36f793...6cdf09 )
by
unknown
42:22 queued 15:32
created
lib/private/Encryption/DecryptAll.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function decryptAll(InputInterface $input, OutputInterface $output, string $user = ''): bool {
40 40
 		if ($user !== '' && $this->userManager->userExists($user) === false) {
41
-			$output->writeln('User "' . $user . '" does not exist. Please check the username and try again');
41
+			$output->writeln('User "'.$user.'" does not exist. Please check the username and try again');
42 42
 			return false;
43 43
 		}
44 44
 
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 			$output->writeln('Files for following users couldn\'t be decrypted, ');
59 59
 			$output->writeln('maybe the user is not set up in a way that supports this operation: ');
60 60
 			foreach ($this->failed as $uid => $paths) {
61
-				$output->writeln('    ' . $uid);
61
+				$output->writeln('    '.$uid);
62 62
 				foreach ($paths as $path) {
63
-					$output->writeln('        ' . $path);
63
+					$output->writeln('        '.$path);
64 64
 				}
65 65
 			}
66 66
 			$output->writeln('');
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 			/** @var IEncryptionModule $module */
80 80
 			$module = call_user_func($moduleDesc['callback']);
81 81
 			$output->writeln('');
82
-			$output->writeln('Prepare "' . $module->getDisplayName() . '"');
82
+			$output->writeln('Prepare "'.$module->getDisplayName().'"');
83 83
 			$output->writeln('');
84 84
 			if ($module->prepareDecryptAll($input, $output, $user) === false) {
85
-				$output->writeln('Module "' . $moduleDesc['displayName'] . '" does not support the functionality to decrypt all files again or the initialization of the module failed!');
85
+				$output->writeln('Module "'.$moduleDesc['displayName'].'" does not support the functionality to decrypt all files again or the initialization of the module failed!');
86 86
 				return false;
87 87
 			}
88 88
 		}
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	protected function decryptUsersFiles(string $uid, ProgressBar $progress, string $userCount): void {
153 153
 		$this->setupUserFS($uid);
154 154
 		$directories = [];
155
-		$directories[] = '/' . $uid . '/files';
155
+		$directories[] = '/'.$uid.'/files';
156 156
 
157 157
 		while ($root = array_pop($directories)) {
158 158
 			$content = $this->rootView->getDirectoryContent($root);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 				if ($file->getStorage()->instanceOfStorage('OCA\Files_Sharing\SharedStorage')) {
162 162
 					continue;
163 163
 				}
164
-				$path = $root . '/' . $file['name'];
164
+				$path = $root.'/'.$file['name'];
165 165
 				if ($this->rootView->is_dir($path)) {
166 166
 					$directories[] = $path;
167 167
 					continue;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		}
202 202
 
203 203
 		$source = $path;
204
-		$target = $path . '.decrypted.' . $this->getTimestamp();
204
+		$target = $path.'.decrypted.'.$this->getTimestamp();
205 205
 
206 206
 		try {
207 207
 			$this->rootView->copy($source, $target);
Please login to merge, or discard this patch.
lib/private/Encryption/Update.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * hook after file was shared
35 35
 	 */
36
-	public function postShared(OCPFile|Folder $node): void {
36
+	public function postShared(OCPFile | Folder $node): void {
37 37
 		$this->update($node);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * hook after file was unshared
42 42
 	 */
43
-	public function postUnshared(OCPFile|Folder $node): void {
43
+	public function postUnshared(OCPFile | Folder $node): void {
44 44
 		$this->update($node);
45 45
 	}
46 46
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * inform encryption module that a file was restored from the trash bin,
49 49
 	 * e.g. to update the encryption keys
50 50
 	 */
51
-	public function postRestore(OCPFile|Folder $node): void {
51
+	public function postRestore(OCPFile | Folder $node): void {
52 52
 		$this->update($node);
53 53
 	}
54 54
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * inform encryption module that a file was renamed,
57 57
 	 * e.g. to update the encryption keys
58 58
 	 */
59
-	public function postRename(OCPFile|Folder $source, OCPFile|Folder $target): void {
59
+	public function postRename(OCPFile | Folder $source, OCPFile | Folder $target): void {
60 60
 		if (dirname($source->getPath()) !== dirname($target->getPath())) {
61 61
 			$this->update($target);
62 62
 		}
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @throws \InvalidArgumentException
69 69
 	 */
70
-	protected function getOwnerPath(OCPFile|Folder $node): string {
70
+	protected function getOwnerPath(OCPFile | Folder $node): string {
71 71
 		$owner = $node->getOwner()?->getUID();
72 72
 		if ($owner === null) {
73
-			throw new InvalidArgumentException('No owner found for ' . $node->getId());
73
+			throw new InvalidArgumentException('No owner found for '.$node->getId());
74 74
 		}
75
-		$view = new View('/' . $owner . '/files');
75
+		$view = new View('/'.$owner.'/files');
76 76
 		try {
77 77
 			$path = $view->getPath($node->getId());
78 78
 		} catch (NotFoundException $e) {
79
-			throw new InvalidArgumentException('No file found for ' . $node->getId(), previous:$e);
79
+			throw new InvalidArgumentException('No file found for '.$node->getId(), previous:$e);
80 80
 		}
81
-		return '/' . $owner . '/files/' . $path;
81
+		return '/'.$owner.'/files/'.$path;
82 82
 	}
83 83
 
84 84
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param string $path relative to data/
88 88
 	 * @throws Exceptions\ModuleDoesNotExistsException
89 89
 	 */
90
-	public function update(OCPFile|Folder $node): void {
90
+	public function update(OCPFile | Folder $node): void {
91 91
 		$encryptionModule = $this->encryptionManager->getEncryptionModule();
92 92
 
93 93
 		// if the encryption module doesn't encrypt the files on a per-user basis
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 				$encryptionModule->update($file, '', $usersSharing);
111 111
 			} catch (GenericEncryptionException $e) {
112 112
 				// If the update of an individual file fails e.g. due to a corrupt key we should continue the operation and just log the failure
113
-				$this->logger->error('Failed to update encryption module for ' . $file, [ 'exception' => $e ]);
113
+				$this->logger->error('Failed to update encryption module for '.$file, ['exception' => $e]);
114 114
 			}
115 115
 		}
116 116
 	}
Please login to merge, or discard this patch.
apps/encryption/lib/KeyManager.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$this->recoveryKeyId = $this->config->getAppValue('encryption',
43 43
 			'recoveryKeyId');
44 44
 		if (empty($this->recoveryKeyId)) {
45
-			$this->recoveryKeyId = 'recoveryKey_' . substr(md5((string)time()), 0, 8);
45
+			$this->recoveryKeyId = 'recoveryKey_'.substr(md5((string) time()), 0, 8);
46 46
 			$this->config->setAppValue('encryption',
47 47
 				'recoveryKeyId',
48 48
 				$this->recoveryKeyId);
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 		$this->publicShareKeyId = $this->config->getAppValue('encryption',
52 52
 			'publicShareKeyId');
53 53
 		if (empty($this->publicShareKeyId)) {
54
-			$this->publicShareKeyId = 'pubShare_' . substr(md5((string)time()), 0, 8);
54
+			$this->publicShareKeyId = 'pubShare_'.substr(md5((string) time()), 0, 8);
55 55
 			$this->config->setAppValue('encryption', 'publicShareKeyId', $this->publicShareKeyId);
56 56
 		}
57 57
 
58 58
 		$this->masterKeyId = $this->config->getAppValue('encryption',
59 59
 			'masterKeyId');
60 60
 		if (empty($this->masterKeyId)) {
61
-			$this->masterKeyId = 'master_' . substr(md5((string)time()), 0, 8);
61
+			$this->masterKeyId = 'master_'.substr(md5((string) time()), 0, 8);
62 62
 			$this->config->setAppValue('encryption', 'masterKeyId', $this->masterKeyId);
63 63
 		}
64 64
 
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
 
78 78
 				// Save public key
79 79
 				$this->keyStorage->setSystemUserKey(
80
-					$this->publicShareKeyId . '.' . $this->publicKeyId, $keyPair['publicKey'],
80
+					$this->publicShareKeyId.'.'.$this->publicKeyId, $keyPair['publicKey'],
81 81
 					Encryption::ID);
82 82
 
83 83
 				// Encrypt private key empty passphrase
84 84
 				$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], '');
85 85
 				$header = $this->crypt->generateHeader();
86
-				$this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey);
86
+				$this->setSystemPrivateKey($this->publicShareKeyId, $header.$encryptedKey);
87 87
 			} catch (\Throwable $e) {
88 88
 				$this->lockingProvider->releaseLock('encryption-generateSharedKey', ILockingProvider::LOCK_EXCLUSIVE);
89 89
 				throw $e;
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 
114 114
 				// Save public key
115 115
 				$this->keyStorage->setSystemUserKey(
116
-					$this->masterKeyId . '.' . $this->publicKeyId, $keyPair['publicKey'],
116
+					$this->masterKeyId.'.'.$this->publicKeyId, $keyPair['publicKey'],
117 117
 					Encryption::ID);
118 118
 
119 119
 				// Encrypt private key with system password
120 120
 				$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $this->getMasterKeyPassword(), $this->masterKeyId);
121 121
 				$header = $this->crypt->generateHeader();
122
-				$this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey);
122
+				$this->setSystemPrivateKey($this->masterKeyId, $header.$encryptedKey);
123 123
 			} catch (\Throwable $e) {
124 124
 				$this->lockingProvider->releaseLock('encryption-generateMasterKey', ILockingProvider::LOCK_EXCLUSIVE);
125 125
 				throw $e;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @return string
162 162
 	 */
163 163
 	public function getRecoveryKey() {
164
-		return $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.' . $this->publicKeyId, Encryption::ID);
164
+		return $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.'.$this->publicKeyId, Encryption::ID);
165 165
 	}
166 166
 
167 167
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @return bool
179 179
 	 */
180 180
 	public function checkRecoveryPassword($password) {
181
-		$recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.' . $this->privateKeyId, Encryption::ID);
181
+		$recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.'.$this->privateKeyId, Encryption::ID);
182 182
 		$decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $password);
183 183
 
184 184
 		if ($decryptedRecoveryKey) {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		$header = $this->crypt->generateHeader();
203 203
 
204 204
 		if ($encryptedKey) {
205
-			$this->setPrivateKey($uid, $header . $encryptedKey);
205
+			$this->setPrivateKey($uid, $header.$encryptedKey);
206 206
 			return true;
207 207
 		}
208 208
 		return false;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	public function setRecoveryKey($password, $keyPair) {
217 217
 		// Save Public Key
218 218
 		$this->keyStorage->setSystemUserKey($this->getRecoveryKeyId()
219
-			. '.' . $this->publicKeyId,
219
+			. '.'.$this->publicKeyId,
220 220
 			$keyPair['publicKey'],
221 221
 			Encryption::ID);
222 222
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		$header = $this->crypt->generateHeader();
225 225
 
226 226
 		if ($encryptedKey) {
227
-			$this->setSystemPrivateKey($this->getRecoveryKeyId(), $header . $encryptedKey);
227
+			$this->setSystemPrivateKey($this->getRecoveryKeyId(), $header.$encryptedKey);
228 228
 			return true;
229 229
 		}
230 230
 		return false;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @return boolean
285 285
 	 */
286 286
 	public function setShareKey($path, $uid, $key) {
287
-		$keyId = $uid . '.' . $this->shareKeyId;
287
+		$keyId = $uid.'.'.$this->shareKeyId;
288 288
 		return $this->keyStorage->setFileKey($path, $keyId, $key, Encryption::ID);
289 289
 	}
290 290
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 			return false;
316 316
 		} catch (\Exception $e) {
317 317
 			$this->logger->warning(
318
-				'Could not decrypt the private key from user "' . $uid . '"" during login. Assume password change on the user back-end.',
318
+				'Could not decrypt the private key from user "'.$uid.'"" during login. Assume password change on the user back-end.',
319 319
 				[
320 320
 					'app' => 'encryption',
321 321
 					'exception' => $e,
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 			// use public share key for public links
379 379
 			$uid = $this->getPublicShareKeyId();
380 380
 			$shareKey = $this->getShareKey($path, $uid);
381
-			$privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.' . $this->privateKeyId, Encryption::ID);
381
+			$privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.'.$this->privateKeyId, Encryption::ID);
382 382
 			$privateKey = $this->crypt->decryptPrivateKey($privateKey);
383 383
 		} else {
384 384
 			$uid = $this->keyUid;
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	public function deleteShareKey($path, $keyId) {
457 457
 		return $this->keyStorage->deleteFileKey(
458 458
 			$path,
459
-			$keyId . '.' . $this->shareKeyId,
459
+			$keyId.'.'.$this->shareKeyId,
460 460
 			Encryption::ID);
461 461
 	}
462 462
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @return mixed
468 468
 	 */
469 469
 	public function getShareKey($path, $uid) {
470
-		$keyId = $uid . '.' . $this->shareKeyId;
470
+		$keyId = $uid.'.'.$this->shareKeyId;
471 471
 		return $this->keyStorage->getFileKey($path, $keyId, Encryption::ID);
472 472
 	}
473 473
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 	 * @return string
530 530
 	 */
531 531
 	public function getPublicShareKey() {
532
-		return $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.' . $this->publicKeyId, Encryption::ID);
532
+		return $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.'.$this->publicKeyId, Encryption::ID);
533 533
 	}
534 534
 
535 535
 	/**
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	 * @return string returns openssl key
603 603
 	 */
604 604
 	public function getSystemPrivateKey($keyId) {
605
-		return $this->keyStorage->getSystemUserKey($keyId . '.' . $this->privateKeyId, Encryption::ID);
605
+		return $this->keyStorage->getSystemUserKey($keyId.'.'.$this->privateKeyId, Encryption::ID);
606 606
 	}
607 607
 
608 608
 	/**
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	 */
613 613
 	public function setSystemPrivateKey($keyId, $key) {
614 614
 		return $this->keyStorage->setSystemUserKey(
615
-			$keyId . '.' . $this->privateKeyId,
615
+			$keyId.'.'.$this->privateKeyId,
616 616
 			$key,
617 617
 			Encryption::ID);
618 618
 	}
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 	 * @return string
674 674
 	 */
675 675
 	public function getPublicMasterKey() {
676
-		return $this->keyStorage->getSystemUserKey($this->masterKeyId . '.' . $this->publicKeyId, Encryption::ID);
676
+		return $this->keyStorage->getSystemUserKey($this->masterKeyId.'.'.$this->publicKeyId, Encryption::ID);
677 677
 	}
678 678
 
679 679
 	/**
@@ -682,6 +682,6 @@  discard block
 block discarded – undo
682 682
 	 * @return string
683 683
 	 */
684 684
 	public function getPrivateMasterKey() {
685
-		return $this->keyStorage->getSystemUserKey($this->masterKeyId . '.' . $this->privateKeyId, Encryption::ID);
685
+		return $this->keyStorage->getSystemUserKey($this->masterKeyId.'.'.$this->privateKeyId, Encryption::ID);
686 686
 	}
687 687
 }
Please login to merge, or discard this patch.
apps/encryption/lib/Crypto/DecryptAll.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 				if ($useLoginPassword) {
55 55
 					$question = new Question('Please enter the user\'s login password: ');
56 56
 				} elseif ($this->util->isRecoveryEnabledForUser($user) === false) {
57
-					$output->writeln('No recovery key available for user ' . $user);
57
+					$output->writeln('No recovery key available for user '.$user);
58 58
 					return false;
59 59
 				} else {
60 60
 					$user = $recoveryKeyId;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @throws PrivateKeyMissingException
90 90
 	 */
91
-	protected function getPrivateKey(string $user, string $password): string|false {
91
+	protected function getPrivateKey(string $user, string $password): string | false {
92 92
 		$recoveryKeyId = $this->keyManager->getRecoveryKeyId();
93 93
 		$masterKeyId = $this->keyManager->getMasterKeyId();
94 94
 		if ($user === $recoveryKeyId) {
Please login to merge, or discard this patch.
apps/encryption/lib/Crypto/EncryptAll.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$this->input = $input;
69 69
 		$this->output = $output;
70 70
 
71
-		$headline = 'Encrypt all files with the ' . Encryption::DISPLAY_NAME;
71
+		$headline = 'Encrypt all files with the '.Encryption::DISPLAY_NAME;
72 72
 		$this->output->writeln("\n");
73 73
 		$this->output->writeln($headline);
74 74
 		$this->output->writeln(str_pad('', strlen($headline), '='));
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 				$users = $backend->getUsers('', $limit, $offset);
125 125
 				foreach ($users as $user) {
126 126
 					if ($this->keyManager->userHasKeys($user) === false) {
127
-						$progress->setMessage('Create key-pair for ' . $user);
127
+						$progress->setMessage('Create key-pair for '.$user);
128 128
 						$progress->advance();
129 129
 						$this->setupUserFS($user);
130 130
 						$password = $this->generateOneTimePassword($user);
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
 	protected function encryptUsersFiles(string $uid, ProgressBar $progress, string $userCount): void {
193 193
 		$this->setupUserFS($uid);
194 194
 		$directories = [];
195
-		$directories[] = '/' . $uid . '/files';
195
+		$directories[] = '/'.$uid.'/files';
196 196
 
197 197
 		while ($root = array_pop($directories)) {
198 198
 			$content = $this->rootView->getDirectoryContent($root);
199 199
 			foreach ($content as $file) {
200
-				$path = $root . '/' . $file->getName();
200
+				$path = $root.'/'.$file->getName();
201 201
 				if ($file->isShared()) {
202 202
 					$progress->setMessage("Skip shared file/folder $path");
203 203
 					$progress->advance();
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 							$progress->advance();
215 215
 						}
216 216
 					} catch (\Exception $e) {
217
-						$progress->setMessage("Failed to encrypt path $path: " . $e->getMessage());
217
+						$progress->setMessage("Failed to encrypt path $path: ".$e->getMessage());
218 218
 						$progress->advance();
219 219
 						$this->logger->error(
220 220
 							'Failed to encrypt path {path}',
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		}
238 238
 
239 239
 		$source = $path;
240
-		$target = $path . '.encrypted.' . time();
240
+		$target = $path.'.encrypted.'.time();
241 241
 
242 242
 		try {
243 243
 			$copySuccess = $this->rootView->copy($source, $target);
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 				if ($this->rootView->file_exists($target)) {
247 247
 					$this->rootView->unlink($target);
248 248
 				}
249
-				throw new \Exception('Copy failed for ' . $source);
249
+				throw new \Exception('Copy failed for '.$source);
250 250
 			}
251 251
 			$this->rootView->rename($target, $source);
252 252
 		} catch (DecryptionFailedException $e) {
Please login to merge, or discard this patch.
apps/encryption/lib/Crypto/Crypt.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 				['app' => 'encryption']);
94 94
 
95 95
 			if (openssl_error_string()) {
96
-				$this->logger->error('Encryption library openssl_pkey_new() fails: ' . openssl_error_string(),
96
+				$this->logger->error('Encryption library openssl_pkey_new() fails: '.openssl_error_string(),
97 97
 					['app' => 'encryption']);
98 98
 			}
99 99
 		} elseif (openssl_pkey_export($res,
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 				'privateKey' => $privateKey
109 109
 			];
110 110
 		}
111
-		$this->logger->error('Encryption library couldn\'t export users private key, please check your servers OpenSSL configuration.' . $this->user,
111
+		$this->logger->error('Encryption library couldn\'t export users private key, please check your servers OpenSSL configuration.'.$this->user,
112 112
 			['app' => 'encryption']);
113 113
 		if (openssl_error_string()) {
114
-			$this->logger->error('Encryption Library:' . openssl_error_string(),
114
+			$this->logger->error('Encryption Library:'.openssl_error_string(),
115 115
 				['app' => 'encryption']);
116 116
 		}
117 117
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	/**
141 141
 	 * @throws EncryptionFailedException
142 142
 	 */
143
-	public function symmetricEncryptFileContent(string $plainContent, string $passPhrase, int $version, string $position): string|false {
143
+	public function symmetricEncryptFileContent(string $plainContent, string $passPhrase, int $version, string $position): string | false {
144 144
 		if (!$plainContent) {
145 145
 			$this->logger->error('Encryption Library, symmetrical encryption failed no content given',
146 146
 				['app' => 'encryption']);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$this->getCipher());
156 156
 
157 157
 		// Create a signature based on the key as well as the current version
158
-		$sig = $this->createSignature($encryptedContent, $passPhrase . '_' . $version . '_' . $position);
158
+		$sig = $this->createSignature($encryptedContent, $passPhrase.'_'.$version.'_'.$position);
159 159
 
160 160
 		// combine content to encrypt the IV identifier and actual IV
161 161
 		$catFile = $this->concatIV($encryptedContent, $iv);
@@ -172,18 +172,18 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public function generateHeader($keyFormat = self::DEFAULT_KEY_FORMAT) {
174 174
 		if (in_array($keyFormat, self::SUPPORTED_KEY_FORMATS, true) === false) {
175
-			throw new \InvalidArgumentException('key format "' . $keyFormat . '" is not supported');
175
+			throw new \InvalidArgumentException('key format "'.$keyFormat.'" is not supported');
176 176
 		}
177 177
 
178 178
 		$header = self::HEADER_START
179
-			. ':cipher:' . $this->getCipher()
180
-			. ':keyFormat:' . $keyFormat;
179
+			. ':cipher:'.$this->getCipher()
180
+			. ':keyFormat:'.$keyFormat;
181 181
 
182 182
 		if ($this->useLegacyBase64Encoding !== true) {
183
-			$header .= ':encoding:' . self::BINARY_ENCODING_FORMAT;
183
+			$header .= ':encoding:'.self::BINARY_ENCODING_FORMAT;
184 184
 		}
185 185
 
186
-		$header .= ':' . self::HEADER_END;
186
+		$header .= ':'.self::HEADER_END;
187 187
 
188 188
 		return $header;
189 189
 	}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
 		if (!$encryptedContent) {
203 203
 			$error = 'Encryption (symmetric) of content failed';
204
-			$this->logger->error($error . openssl_error_string(),
204
+			$this->logger->error($error.openssl_error_string(),
205 205
 				['app' => 'encryption']);
206 206
 			throw new EncryptionFailedException($error);
207 207
 		}
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
 	}
281 281
 
282 282
 	private function concatIV(string $encryptedContent, string $iv): string {
283
-		return $encryptedContent . '00iv00' . $iv;
283
+		return $encryptedContent.'00iv00'.$iv;
284 284
 	}
285 285
 
286 286
 	private function concatSig(string $encryptedContent, string $signature): string {
287
-		return $encryptedContent . '00sig00' . $signature;
287
+		return $encryptedContent.'00sig00'.$signature;
288 288
 	}
289 289
 
290 290
 	/**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * encrypted content and is not used in any crypto primitive.
294 294
 	 */
295 295
 	private function addPadding(string $data): string {
296
-		return $data . 'xxx';
296
+		return $data.'xxx';
297 297
 	}
298 298
 
299 299
 	/**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	protected function generatePasswordHash(string $password, string $cipher, string $uid = '', int $iterations = 600000): string {
305 305
 		$instanceId = $this->config->getSystemValue('instanceid');
306 306
 		$instanceSecret = $this->config->getSystemValue('secret');
307
-		$salt = hash('sha256', $uid . $instanceId . $instanceSecret, true);
307
+		$salt = hash('sha256', $uid.$instanceId.$instanceSecret, true);
308 308
 		$keySize = $this->getKeySize($cipher);
309 309
 
310 310
 		return hash_pbkdf2(
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 * @param string $password
344 344
 	 * @param string $uid for regular users, empty for system keys
345 345
 	 */
346
-	public function decryptPrivateKey($privateKey, $password = '', $uid = '') : string|false {
346
+	public function decryptPrivateKey($privateKey, $password = '', $uid = '') : string | false {
347 347
 		$header = $this->parseHeader($privateKey);
348 348
 
349 349
 		if (isset($header['cipher'])) {
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 		if ($catFile['signature'] !== false) {
428 428
 			try {
429 429
 				// First try the new format
430
-				$this->checkSignature($catFile['encrypted'], $passPhrase . '_' . $version . '_' . $position, $catFile['signature']);
430
+				$this->checkSignature($catFile['encrypted'], $passPhrase.'_'.$version.'_'.$position, $catFile['signature']);
431 431
 			} catch (GenericEncryptionException $e) {
432 432
 				// For compatibility with old files check the version without _
433
-				$this->checkSignature($catFile['encrypted'], $passPhrase . $version . $position, $catFile['signature']);
433
+				$this->checkSignature($catFile['encrypted'], $passPhrase.$version.$position, $catFile['signature']);
434 434
 			}
435 435
 		}
436 436
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	 * create signature
466 466
 	 */
467 467
 	private function createSignature(string $data, string $passPhrase): string {
468
-		$passPhrase = hash('sha512', $passPhrase . 'a', true);
468
+		$passPhrase = hash('sha512', $passPhrase.'a', true);
469 469
 		return hash_hmac('sha256', $data, $passPhrase);
470 470
 	}
471 471
 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	/**
474 474
 	 * @param bool $hasSignature did the block contain a signature, in this case we use a different padding
475 475
 	 */
476
-	private function removePadding(string $padded, bool $hasSignature = false): string|false {
476
+	private function removePadding(string $padded, bool $hasSignature = false): string | false {
477 477
 		if ($hasSignature === false && substr($padded, -2) === 'xx') {
478 478
 			return substr($padded, 0, -2);
479 479
 		} elseif ($hasSignature === true && substr($padded, -3) === 'xxx') {
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		if ($plainContent) {
549 549
 			return $plainContent;
550 550
 		} else {
551
-			throw new DecryptionFailedException('Encryption library: Decryption (symmetric) of content failed: ' . openssl_error_string());
551
+			throw new DecryptionFailedException('Encryption library: Decryption (symmetric) of content failed: '.openssl_error_string());
552 552
 		}
553 553
 	}
554 554
 
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 		if (openssl_private_decrypt($shareKey, $intermediate, $privateKey, OPENSSL_PKCS1_OAEP_PADDING)) {
610 610
 			return $intermediate;
611 611
 		} else {
612
-			throw new MultiKeyDecryptException('multikeydecrypt with share key failed:' . openssl_error_string());
612
+			throw new MultiKeyDecryptException('multikeydecrypt with share key failed:'.openssl_error_string());
613 613
 		}
614 614
 	}
615 615
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 		if ($this->opensslOpen($encKeyFile, $plainContent, $shareKey, $privateKey, 'RC4')) {
627 627
 			return $plainContent;
628 628
 		} else {
629
-			throw new MultiKeyDecryptException('multikeydecrypt with share key failed:' . openssl_error_string());
629
+			throw new MultiKeyDecryptException('multikeydecrypt with share key failed:'.openssl_error_string());
630 630
 		}
631 631
 	}
632 632
 
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 				return $mappedShareKeys;
670 670
 			}
671 671
 		}
672
-		throw new MultiKeyEncryptException('multikeyencryption failed ' . openssl_error_string());
672
+		throw new MultiKeyEncryptException('multikeyencryption failed '.openssl_error_string());
673 673
 	}
674 674
 
675 675
 	/**
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 				'data' => $sealed
706 706
 			];
707 707
 		} else {
708
-			throw new MultiKeyEncryptException('multikeyencryption failed ' . openssl_error_string());
708
+			throw new MultiKeyEncryptException('multikeyencryption failed '.openssl_error_string());
709 709
 		}
710 710
 	}
711 711
 
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 				$result = (strlen($output) === strlen($data));
760 760
 			}
761 761
 		} else {
762
-			throw new DecryptionFailedException('Unsupported cipher ' . $cipher_algo);
762
+			throw new DecryptionFailedException('Unsupported cipher '.$cipher_algo);
763 763
 		}
764 764
 
765 765
 		return $result;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	 * @deprecated 27.0.0 use multiKeyEncrypt
772 772
 	 * @throws EncryptionFailedException
773 773
 	 */
774
-	private function opensslSeal(string $data, string &$sealed_data, array &$encrypted_keys, array $public_key, string $cipher_algo): int|false {
774
+	private function opensslSeal(string $data, string &$sealed_data, array &$encrypted_keys, array $public_key, string $cipher_algo): int | false {
775 775
 		$result = false;
776 776
 
777 777
 		// check if RC4 is used
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 				}
807 807
 			}
808 808
 		} else {
809
-			throw new EncryptionFailedException('Unsupported cipher ' . $cipher_algo);
809
+			throw new EncryptionFailedException('Unsupported cipher '.$cipher_algo);
810 810
 		}
811 811
 
812 812
 		return $result;
Please login to merge, or discard this patch.
apps/encryption/lib/Command/DropLegacyFileKey.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 			do {
49 49
 				$users = $backend->getUsers('', $limit, $offset);
50 50
 				foreach ($users as $user) {
51
-					$output->writeln('Scanning all files for ' . $user);
51
+					$output->writeln('Scanning all files for '.$user);
52 52
 					$this->setupUserFS($user);
53
-					$result = $result && $this->scanFolder($output, '/' . $user);
53
+					$result = $result && $this->scanFolder($output, '/'.$user);
54 54
 				}
55 55
 				$offset += $limit;
56 56
 			} while (count($users) >= $limit);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$clean = true;
69 69
 
70 70
 		foreach ($this->rootView->getDirectoryContent($folder) as $item) {
71
-			$path = $folder . '/' . $item['name'];
71
+			$path = $folder.'/'.$item['name'];
72 72
 			if ($this->rootView->is_dir($path)) {
73 73
 				if ($this->scanFolder($output, $path) === false) {
74 74
 					$clean = false;
@@ -82,21 +82,21 @@  discard block
 block discarded – undo
82 82
 				$stats = $this->rootView->stat($path);
83 83
 				if (!isset($stats['hasHeader']) || $stats['hasHeader'] === false) {
84 84
 					$clean = false;
85
-					$output->writeln('<error>' . $path . ' does not have a proper header</error>');
85
+					$output->writeln('<error>'.$path.' does not have a proper header</error>');
86 86
 				} else {
87 87
 					try {
88 88
 						$legacyFileKey = $this->keyManager->getFileKey($path, true);
89 89
 						if ($legacyFileKey === '') {
90
-							$output->writeln('Got an empty legacy filekey for ' . $path . ', continuing', OutputInterface::VERBOSITY_VERBOSE);
90
+							$output->writeln('Got an empty legacy filekey for '.$path.', continuing', OutputInterface::VERBOSITY_VERBOSE);
91 91
 							continue;
92 92
 						}
93 93
 					} catch (GenericEncryptionException $e) {
94
-						$output->writeln('Got a decryption error for legacy filekey for ' . $path . ', continuing', OutputInterface::VERBOSITY_VERBOSE);
94
+						$output->writeln('Got a decryption error for legacy filekey for '.$path.', continuing', OutputInterface::VERBOSITY_VERBOSE);
95 95
 						continue;
96 96
 					}
97 97
 					/* If that did not throw and filekey is not empty, a legacy filekey is used */
98 98
 					$clean = false;
99
-					$output->writeln($path . ' is using a legacy filekey, migrating');
99
+					$output->writeln($path.' is using a legacy filekey, migrating');
100 100
 					$this->migrateSinglefile($path, $item, $output);
101 101
 				}
102 102
 			}
@@ -107,29 +107,29 @@  discard block
 block discarded – undo
107 107
 
108 108
 	private function migrateSinglefile(string $path, FileInfo $fileInfo, OutputInterface $output): void {
109 109
 		$source = $path;
110
-		$target = $path . '.reencrypted.' . time();
110
+		$target = $path.'.reencrypted.'.time();
111 111
 
112 112
 		try {
113 113
 			$this->rootView->copy($source, $target);
114 114
 			$copyResource = $this->rootView->fopen($target, 'r');
115 115
 			$sourceResource = $this->rootView->fopen($source, 'w');
116 116
 			if ($copyResource === false || $sourceResource === false) {
117
-				throw new DecryptionFailedException('Failed to open ' . $source . ' or ' . $target);
117
+				throw new DecryptionFailedException('Failed to open '.$source.' or '.$target);
118 118
 			}
119 119
 			if (stream_copy_to_stream($copyResource, $sourceResource) === false) {
120
-				$output->writeln('<error>Failed to copy ' . $target . ' data into ' . $source . '</error>');
120
+				$output->writeln('<error>Failed to copy '.$target.' data into '.$source.'</error>');
121 121
 				$output->writeln('<error>Leaving both files in there to avoid data loss</error>');
122 122
 				return;
123 123
 			}
124 124
 			$this->rootView->touch($source, $fileInfo->getMTime());
125 125
 			$this->rootView->unlink($target);
126
-			$output->writeln('<info>Migrated ' . $source . '</info>', OutputInterface::VERBOSITY_VERBOSE);
126
+			$output->writeln('<info>Migrated '.$source.'</info>', OutputInterface::VERBOSITY_VERBOSE);
127 127
 		} catch (DecryptionFailedException $e) {
128 128
 			if ($this->rootView->file_exists($target)) {
129 129
 				$this->rootView->unlink($target);
130 130
 			}
131
-			$output->writeln('<error>Failed to migrate ' . $path . '</error>');
132
-			$output->writeln('<error>' . $e . '</error>', OutputInterface::VERBOSITY_VERBOSE);
131
+			$output->writeln('<error>Failed to migrate '.$path.'</error>');
132
+			$output->writeln('<error>'.$e.'</error>', OutputInterface::VERBOSITY_VERBOSE);
133 133
 		} finally {
134 134
 			if (is_resource($copyResource)) {
135 135
 				fclose($copyResource);
Please login to merge, or discard this patch.
apps/encryption/lib/Recovery.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		$encryptedRecoveryKey = $this->crypt->encryptPrivateKey($decryptedRecoveryKey, $newPassword);
78 78
 		$header = $this->crypt->generateHeader();
79 79
 		if ($encryptedRecoveryKey !== false) {
80
-			$this->keyManager->setSystemPrivateKey($this->keyManager->getRecoveryKeyId(), $header . $encryptedRecoveryKey);
80
+			$this->keyManager->setSystemPrivateKey($this->keyManager->getRecoveryKeyId(), $header.$encryptedRecoveryKey);
81 81
 			return true;
82 82
 		}
83 83
 		return false;
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 				$value);
139 139
 
140 140
 			if ($value === '1') {
141
-				$this->addRecoveryKeys('/' . $this->user->getUID() . '/files/');
141
+				$this->addRecoveryKeys('/'.$this->user->getUID().'/files/');
142 142
 			} else {
143
-				$this->removeRecoveryKeys('/' . $this->user->getUID() . '/files/');
143
+				$this->removeRecoveryKeys('/'.$this->user->getUID().'/files/');
144 144
 			}
145 145
 
146 146
 			return true;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		foreach ($dirContent as $item) {
158 158
 			$filePath = $item->getPath();
159 159
 			if ($item['type'] === 'dir') {
160
-				$this->addRecoveryKeys($filePath . '/');
160
+				$this->addRecoveryKeys($filePath.'/');
161 161
 			} else {
162 162
 				$fileKey = $this->keyManager->getFileKey($filePath, null);
163 163
 				if (!empty($fileKey)) {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		foreach ($dirContent as $item) {
188 188
 			$filePath = $item->getPath();
189 189
 			if ($item['type'] === 'dir') {
190
-				$this->removeRecoveryKeys($filePath . '/');
190
+				$this->removeRecoveryKeys($filePath.'/');
191 191
 			} else {
192 192
 				$this->keyManager->deleteShareKey($filePath, $this->keyManager->getRecoveryKeyId());
193 193
 			}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
 		$privateKey = $this->crypt->decryptPrivateKey($encryptedKey, $recoveryPassword);
204 204
 		if ($privateKey !== false) {
205
-			$this->recoverAllFiles('/' . $user . '/files/', $privateKey, $user);
205
+			$this->recoverAllFiles('/'.$user.'/files/', $privateKey, $user);
206 206
 		}
207 207
 	}
208 208
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			// Get relative path from encryption/keyfiles
217 217
 			$filePath = $item->getPath();
218 218
 			if ($this->view->is_dir($filePath)) {
219
-				$this->recoverAllFiles($filePath . '/', $privateKey, $uid);
219
+				$this->recoverAllFiles($filePath.'/', $privateKey, $uid);
220 220
 			} else {
221 221
 				$this->recoverFile($filePath, $privateKey, $uid);
222 222
 			}
Please login to merge, or discard this patch.
tests/lib/Encryption/DecryptAllTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			->with($this->inputInterface, $this->outputInterface, $user)
155 155
 			->willReturn($success);
156 156
 
157
-		$callback = function () use ($dummyEncryptionModule) {
157
+		$callback = function() use ($dummyEncryptionModule) {
158 158
 			return $dummyEncryptionModule;
159 159
 		};
160 160
 		$moduleDescription = [
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			];
200 200
 			$instance->expects($this->exactly(2))
201 201
 				->method('decryptUsersFiles')
202
-				->willReturnCallback(function ($user) use (&$calls): void {
202
+				->willReturnCallback(function($user) use (&$calls): void {
203 203
 					$expected = array_shift($calls);
204 204
 					$this->assertEquals($expected, $user);
205 205
 				});
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$this->view->expects($this->any())->method('is_dir')
267 267
 			->willReturnCallback(
268
-				function ($path) {
268
+				function($path) {
269 269
 					if ($path === '/user1/files/foo') {
270 270
 						return true;
271 271
 					}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		];
280 280
 		$instance->expects($this->exactly(2))
281 281
 			->method('decryptFile')
282
-			->willReturnCallback(function ($path) use (&$calls): bool {
282
+			->willReturnCallback(function($path) use (&$calls): bool {
283 283
 				$expected = array_shift($calls);
284 284
 				$this->assertEquals($expected, $path);
285 285
 				return true;
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 
328 328
 			$this->view->expects($this->once())
329 329
 				->method('copy')
330
-				->with($path, $path . '.decrypted.42');
330
+				->with($path, $path.'.decrypted.42');
331 331
 			$this->view->expects($this->once())
332 332
 				->method('rename')
333
-				->with($path . '.decrypted.42', $path);
333
+				->with($path.'.decrypted.42', $path);
334 334
 		} else {
335 335
 			$instance->expects($this->never())->method('getTimestamp');
336 336
 			$this->view->expects($this->never())->method('copy');
@@ -367,19 +367,19 @@  discard block
 block discarded – undo
367 367
 
368 368
 		$this->view->expects($this->once())
369 369
 			->method('copy')
370
-			->with($path, $path . '.decrypted.42')
371
-			->willReturnCallback(function (): void {
370
+			->with($path, $path.'.decrypted.42')
371
+			->willReturnCallback(function(): void {
372 372
 				throw new DecryptionFailedException();
373 373
 			});
374 374
 
375 375
 		$this->view->expects($this->never())->method('rename');
376 376
 		$this->view->expects($this->once())
377 377
 			->method('file_exists')
378
-			->with($path . '.decrypted.42')
378
+			->with($path.'.decrypted.42')
379 379
 			->willReturn(true);
380 380
 		$this->view->expects($this->once())
381 381
 			->method('unlink')
382
-			->with($path . '.decrypted.42');
382
+			->with($path.'.decrypted.42');
383 383
 
384 384
 		$this->assertFalse(
385 385
 			$this->invokePrivate($instance, 'decryptFile', [$path])
Please login to merge, or discard this patch.