summaryrefslogtreecommitdiffstats
path: root/apps/encryption
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-26 09:30:18 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-26 16:34:56 +0100
commitb80ebc96748b45fd2e0ba9323308657c4b00b7ec (patch)
treeec20e0ffa2f86b9b54939a83a785407319f94559 /apps/encryption
parent62403d0932be7d620c7bdadc6b4e13eb496fcd6f (diff)
downloadnextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.tar.gz
nextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.zip
Use the short array syntax, everywhere
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/encryption')
-rw-r--r--apps/encryption/lib/AppInfo/Application.php2
-rw-r--r--apps/encryption/lib/Crypto/EncryptAll.php12
-rw-r--r--apps/encryption/lib/Crypto/Encryption.php8
-rw-r--r--apps/encryption/lib/Recovery.php4
-rw-r--r--apps/encryption/templates/altmail.php4
-rw-r--r--apps/encryption/templates/mail.php2
-rw-r--r--apps/encryption/tests/Crypto/CryptTest.php48
-rw-r--r--apps/encryption/tests/Crypto/EncryptionTest.php62
-rw-r--r--apps/encryption/tests/KeyManagerTest.php14
9 files changed, 78 insertions, 78 deletions
diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php
index 6d7c00687e3..745dfe59aa7 100644
--- a/apps/encryption/lib/AppInfo/Application.php
+++ b/apps/encryption/lib/AppInfo/Application.php
@@ -58,7 +58,7 @@ class Application extends \OCP\AppFramework\App {
/**
* @param array $urlParams
*/
- public function __construct($urlParams = array()) {
+ public function __construct($urlParams = []) {
parent::__construct('encryption', $urlParams);
$this->encryptionManager = \OC::$server->getEncryptionManager();
$this->config = \OC::$server->getConfig();
diff --git a/apps/encryption/lib/Crypto/EncryptAll.php b/apps/encryption/lib/Crypto/EncryptAll.php
index 4865f06277e..1820140337c 100644
--- a/apps/encryption/lib/Crypto/EncryptAll.php
+++ b/apps/encryption/lib/Crypto/EncryptAll.php
@@ -120,7 +120,7 @@ class EncryptAll {
$this->questionHelper = $questionHelper;
$this->secureRandom = $secureRandom;
// store one time passwords for the users
- $this->userPasswords = array();
+ $this->userPasswords = [];
}
/**
@@ -265,7 +265,7 @@ class EncryptAll {
protected function encryptUsersFiles($uid, ProgressBar $progress, $userCount) {
$this->setupUserFS($uid);
- $directories = array();
+ $directories = [];
$directories[] = '/' . $uid . '/files';
while($root = array_pop($directories)) {
@@ -322,11 +322,11 @@ class EncryptAll {
*/
protected function outputPasswords() {
$table = new Table($this->output);
- $table->setHeaders(array('Username', 'Private key password'));
+ $table->setHeaders(['Username', 'Private key password']);
//create rows
- $newPasswords = array();
- $unchangedPasswords = array();
+ $newPasswords = [];
+ $unchangedPasswords = [];
foreach ($this->userPasswords as $uid => $password) {
if (empty($password)) {
$unchangedPasswords[] = $uid;
@@ -451,7 +451,7 @@ class EncryptAll {
$this->output->writeln("\n\nPassword successfully send to all users");
} else {
$table = new Table($this->output);
- $table->setHeaders(array('Username', 'Private key password'));
+ $table->setHeaders(['Username', 'Private key password']);
$this->output->writeln("\n\nCould not send password to following users:\n");
$rows = [];
foreach ($noMail as $uid) {
diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php
index 8b5ec5e1e05..edeb04ce857 100644
--- a/apps/encryption/lib/Crypto/Encryption.php
+++ b/apps/encryption/lib/Crypto/Encryption.php
@@ -236,7 +236,7 @@ class Encryption implements IEncryptionModule {
$this->cipher = $this->crypt->getLegacyCipher();
}
- return array('cipher' => $this->cipher, 'signed' => 'true');
+ return ['cipher' => $this->cipher, 'signed' => 'true'];
}
/**
@@ -266,7 +266,7 @@ class Encryption implements IEncryptionModule {
$result = $this->crypt->symmetricEncryptFileContent($this->writeCache, $this->fileKey, $this->version + 1, $position);
$this->writeCache = '';
}
- $publicKeys = array();
+ $publicKeys = [];
if ($this->useMasterPassword === true) {
$publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey();
} else {
@@ -402,7 +402,7 @@ class Encryption implements IEncryptionModule {
if (!empty($fileKey)) {
- $publicKeys = array();
+ $publicKeys = [];
if ($this->useMasterPassword === true) {
$publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey();
} else {
@@ -425,7 +425,7 @@ class Encryption implements IEncryptionModule {
} else {
$this->logger->debug('no file key found, we assume that the file "{file}" is not encrypted',
- array('file' => $path, 'app' => 'encryption'));
+ ['file' => $path, 'app' => 'encryption']);
return false;
}
diff --git a/apps/encryption/lib/Recovery.php b/apps/encryption/lib/Recovery.php
index d586d330237..335e6c13d73 100644
--- a/apps/encryption/lib/Recovery.php
+++ b/apps/encryption/lib/Recovery.php
@@ -213,7 +213,7 @@ class Recovery {
$fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID());
if (!empty($fileKey)) {
$accessList = $this->file->getAccessList($filePath);
- $publicKeys = array();
+ $publicKeys = [];
foreach ($accessList['users'] as $uid) {
$publicKeys[$uid] = $this->keyManager->getPublicKey($uid);
}
@@ -299,7 +299,7 @@ class Recovery {
if (!empty($fileKey)) {
$accessList = $this->file->getAccessList($path);
- $publicKeys = array();
+ $publicKeys = [];
foreach ($accessList['users'] as $user) {
$publicKeys[$user] = $this->keyManager->getPublicKey($user);
}
diff --git a/apps/encryption/templates/altmail.php b/apps/encryption/templates/altmail.php
index a5b1512aada..dde85e0af14 100644
--- a/apps/encryption/templates/altmail.php
+++ b/apps/encryption/templates/altmail.php
@@ -2,9 +2,9 @@
/** @var OC_Theme $theme */
/** @var array $_ */
-print_unescaped($l->t("Hey there,\n\nthe admin enabled server-side-encryption. Your files were encrypted using the password '%s'.\n\nPlease login to the web interface, go to the section 'basic encryption module' of your personal settings and update your encryption password by entering this password into the 'old log-in password' field and your current login-password.\n\n", array($_['password'])));
+print_unescaped($l->t("Hey there,\n\nthe admin enabled server-side-encryption. Your files were encrypted using the password '%s'.\n\nPlease login to the web interface, go to the section 'basic encryption module' of your personal settings and update your encryption password by entering this password into the 'old log-in password' field and your current login-password.\n\n", [$_['password']]));
if ( isset($_['expiration']) ) {
- print_unescaped($l->t("The share will expire on %s.", array($_['expiration'])));
+ print_unescaped($l->t("The share will expire on %s.", [$_['expiration']]));
print_unescaped("\n\n");
}
// TRANSLATORS term at the end of a mail
diff --git a/apps/encryption/templates/mail.php b/apps/encryption/templates/mail.php
index 6e9f9885d33..1241cfd9f62 100644
--- a/apps/encryption/templates/mail.php
+++ b/apps/encryption/templates/mail.php
@@ -15,7 +15,7 @@
<td width="20px">&nbsp;</td>
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php
- print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', array($_['password'])));
+ print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']]));
// TRANSLATORS term at the end of a mail
p($l->t('Cheers!'));
?>
diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php
index 7428b3fe1af..31b61ee0664 100644
--- a/apps/encryption/tests/Crypto/CryptTest.php
+++ b/apps/encryption/tests/Crypto/CryptTest.php
@@ -80,7 +80,7 @@ class CryptTest extends TestCase {
$this->config->expects($this->once())
->method('getSystemValue')
->with($this->equalTo('openssl'), $this->equalTo([]))
- ->willReturn(array());
+ ->willReturn([]);
$result = self::invokePrivate($this->crypt, 'getOpenSSLConfig');
$this->assertSame(1, count($result));
@@ -96,7 +96,7 @@ class CryptTest extends TestCase {
$this->config->expects($this->once())
->method('getSystemValue')
->with($this->equalTo('openssl'), $this->equalTo([]))
- ->willReturn(array('foo' => 'bar', 'private_key_bits' => 1028));
+ ->willReturn(['foo' => 'bar', 'private_key_bits' => 1028]);
$result = self::invokePrivate($this->crypt, 'getOpenSSLConfig');
$this->assertSame(2, count($result));
@@ -185,14 +185,14 @@ class CryptTest extends TestCase {
* @return array
*/
public function dataProviderGetCipher() {
- return array(
- array('AES-128-CFB', 'AES-128-CFB'),
- array('AES-256-CFB', 'AES-256-CFB'),
- array('AES-128-CTR', 'AES-128-CTR'),
- array('AES-256-CTR', 'AES-256-CTR'),
+ return [
+ ['AES-128-CFB', 'AES-128-CFB'],
+ ['AES-256-CFB', 'AES-256-CFB'],
+ ['AES-128-CTR', 'AES-128-CTR'],
+ ['AES-256-CTR', 'AES-256-CTR'],
- array('unknown', 'AES-256-CTR')
- );
+ ['unknown', 'AES-256-CTR']
+ ];
}
/**
@@ -203,7 +203,7 @@ class CryptTest extends TestCase {
$result = self::invokePrivate(
$this->crypt,
'concatIV',
- array('content', 'my_iv'));
+ ['content', 'my_iv']);
$this->assertSame('content00iv00my_iv',
$result
@@ -214,7 +214,7 @@ class CryptTest extends TestCase {
* @dataProvider dataTestSplitMetaData
*/
public function testSplitMetaData($data, $expected) {
- $result = self::invokePrivate($this->crypt, 'splitMetaData', array($data, 'AES-256-CFB'));
+ $result = self::invokePrivate($this->crypt, 'splitMetaData', [$data, 'AES-256-CFB']);
$this->assertTrue(is_array($result));
$this->assertSame(3, count($result));
$this->assertArrayHasKey('encrypted', $result);
@@ -239,7 +239,7 @@ class CryptTest extends TestCase {
*/
public function testHasSignature($data, $expected) {
$this->assertSame($expected,
- $this->invokePrivate($this->crypt, 'hasSignature', array($data, 'AES-256-CFB'))
+ $this->invokePrivate($this->crypt, 'hasSignature', [$data, 'AES-256-CFB'])
);
}
@@ -257,7 +257,7 @@ class CryptTest extends TestCase {
$this->expectException(\OCP\Encryption\Exceptions\GenericEncryptionException::class);
$data = 'encryptedContent00iv001234567890123456xx';
- $this->invokePrivate($this->crypt, 'hasSignature', array($data, $cipher));
+ $this->invokePrivate($this->crypt, 'hasSignature', [$data, $cipher]);
}
public function dataTestHasSignatureFail() {
@@ -273,7 +273,7 @@ class CryptTest extends TestCase {
* test addPadding()
*/
public function testAddPadding() {
- $result = self::invokePrivate($this->crypt, 'addPadding', array('data'));
+ $result = self::invokePrivate($this->crypt, 'addPadding', ['data']);
$this->assertSame('dataxxx', $result);
}
@@ -285,7 +285,7 @@ class CryptTest extends TestCase {
* @param $expected
*/
public function testRemovePadding($data, $expected) {
- $result = self::invokePrivate($this->crypt, 'removePadding', array($data));
+ $result = self::invokePrivate($this->crypt, 'removePadding', [$data]);
$this->assertSame($expected, $result);
}
@@ -295,10 +295,10 @@ class CryptTest extends TestCase {
* @return array
*/
public function dataProviderRemovePadding() {
- return array(
- array('dataxx', 'data'),
- array('data', false)
- );
+ return [
+ ['dataxx', 'data'],
+ ['data', false]
+ ];
}
/**
@@ -307,7 +307,7 @@ class CryptTest extends TestCase {
public function testParseHeader() {
$header= 'HBEGIN:foo:bar:cipher:AES-256-CFB:HEND';
- $result = self::invokePrivate($this->crypt, 'parseHeader', array($header));
+ $result = self::invokePrivate($this->crypt, 'parseHeader', [$header]);
$this->assertTrue(is_array($result));
$this->assertSame(2, count($result));
@@ -331,15 +331,15 @@ class CryptTest extends TestCase {
$this->assertTrue(is_string($iv));
$this->assertSame(16, strlen($iv));
- $result = self::invokePrivate($this->crypt, 'encrypt', array($decrypted, $iv, $password));
+ $result = self::invokePrivate($this->crypt, 'encrypt', [$decrypted, $iv, $password]);
$this->assertTrue(is_string($result));
- return array(
+ return [
'password' => $password,
'iv' => $iv,
'encrypted' => $result,
- 'decrypted' => $decrypted);
+ 'decrypted' => $decrypted];
}
@@ -353,7 +353,7 @@ class CryptTest extends TestCase {
$result = self::invokePrivate(
$this->crypt,
'decrypt',
- array($data['encrypted'], $data['iv'], $data['password']));
+ [$data['encrypted'], $data['iv'], $data['password']]);
$this->assertSame($data['decrypted'], $result);
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php
index 9a541880e79..cebb27580e2 100644
--- a/apps/encryption/tests/Crypto/EncryptionTest.php
+++ b/apps/encryption/tests/Crypto/EncryptionTest.php
@@ -124,7 +124,7 @@ class EncryptionTest extends TestCase {
* test if public key from one of the recipients is missing
*/
public function testEndUser1() {
- $this->instance->begin('/foo/bar', 'user1', 'r', array(), array('users' => array('user1', 'user2', 'user3')));
+ $this->instance->begin('/foo/bar', 'user1', 'r', [], ['users' => ['user1', 'user2', 'user3']]);
$this->endTest();
}
@@ -135,7 +135,7 @@ class EncryptionTest extends TestCase {
public function testEndUser2() {
$this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class);
- $this->instance->begin('/foo/bar', 'user2', 'r', array(), array('users' => array('user1', 'user2', 'user3')));
+ $this->instance->begin('/foo/bar', 'user2', 'r', [], ['users' => ['user1', 'user2', 'user3']]);
$this->endTest();
}
@@ -182,17 +182,17 @@ class EncryptionTest extends TestCase {
*/
public function testGetPathToRealFile($path, $expected) {
$this->assertSame($expected,
- self::invokePrivate($this->instance, 'getPathToRealFile', array($path))
+ self::invokePrivate($this->instance, 'getPathToRealFile', [$path])
);
}
public function dataProviderForTestGetPathToRealFile() {
- return array(
- array('/user/files/foo/bar.txt', '/user/files/foo/bar.txt'),
- array('/user/files/foo.txt', '/user/files/foo.txt'),
- array('/user/files_versions/foo.txt.v543534', '/user/files/foo.txt'),
- array('/user/files_versions/foo/bar.txt.v5454', '/user/files/foo/bar.txt'),
- );
+ return [
+ ['/user/files/foo/bar.txt', '/user/files/foo/bar.txt'],
+ ['/user/files/foo.txt', '/user/files/foo.txt'],
+ ['/user/files_versions/foo.txt.v543534', '/user/files/foo.txt'],
+ ['/user/files_versions/foo/bar.txt.v5454', '/user/files/foo/bar.txt'],
+ ];
}
/**
@@ -241,12 +241,12 @@ class EncryptionTest extends TestCase {
}
public function dataTestBegin() {
- return array(
- array('w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'),
- array('r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'),
- array('w', [], 'legacyCipher', 'defaultCipher', '', 'defaultCipher'),
- array('r', [], 'legacyCipher', 'defaultCipher', 'file_key', 'legacyCipher'),
- );
+ return [
+ ['w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'],
+ ['r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'],
+ ['w', [], 'legacyCipher', 'defaultCipher', '', 'defaultCipher'],
+ ['r', [], 'legacyCipher', 'defaultCipher', 'file_key', 'legacyCipher'],
+ ];
}
@@ -335,10 +335,10 @@ class EncryptionTest extends TestCase {
}
public function dataTestUpdate() {
- return array(
- array('', false),
- array('fileKey', true)
- );
+ return [
+ ['', false],
+ ['fileKey', true]
+ ];
}
public function testUpdateNoUsers() {
@@ -417,19 +417,19 @@ class EncryptionTest extends TestCase {
}
public function dataTestShouldEncrypt() {
- return array(
- array('/user1/files/foo.txt', true, true, true),
- array('/user1/files_versions/foo.txt', true, true, true),
- array('/user1/files_trashbin/foo.txt', true, true, true),
- array('/user1/some_folder/foo.txt', true, true, false),
- array('/user1/foo.txt', true, true, false),
- array('/user1/files', true, true, false),
- array('/user1/files_trashbin', true, true, false),
- array('/user1/files_versions', true, true, false),
+ return [
+ ['/user1/files/foo.txt', true, true, true],
+ ['/user1/files_versions/foo.txt', true, true, true],
+ ['/user1/files_trashbin/foo.txt', true, true, true],
+ ['/user1/some_folder/foo.txt', true, true, false],
+ ['/user1/foo.txt', true, true, false],
+ ['/user1/files', true, true, false],
+ ['/user1/files_trashbin', true, true, false],
+ ['/user1/files_versions', true, true, false],
// test if shouldEncryptHomeStorage is set to false
- array('/user1/files/foo.txt', false, true, false),
- array('/user1/files_versions/foo.txt', false, false, true),
- );
+ ['/user1/files/foo.txt', false, true, false],
+ ['/user1/files_versions/foo.txt', false, false, true],
+ ];
}
diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php
index a9886a0b9ec..c7b9d62690e 100644
--- a/apps/encryption/tests/KeyManagerTest.php
+++ b/apps/encryption/tests/KeyManagerTest.php
@@ -322,7 +322,7 @@ class KeyManagerTest extends TestCase {
$this->assertTrue(
$this->instance->setRecoveryKey('pass',
- array('publicKey' => 'publicKey', 'privateKey' => 'privateKey'))
+ ['publicKey' => 'publicKey', 'privateKey' => 'privateKey'])
);
}
@@ -505,12 +505,12 @@ class KeyManagerTest extends TestCase {
* @return array
*/
public function dataTestAddSystemKeys() {
- return array(
- array(['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']),
- array(['public' => false], [], 'user1', ['recoveryKey']),
- array(['public' => true],[], 'user2', ['publicShareKey']),
- array(['public' => false], [], 'user2', []),
- );
+ return [
+ [['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']],
+ [['public' => false], [], 'user1', ['recoveryKey']],
+ [['public' => true],[], 'user2', ['publicShareKey']],
+ [['public' => false], [], 'user2', []],
+ ];
}
public function testGetMasterKeyId() {