Skip to content

Commit 577b5fd

Browse files
committed
encryption based on cpu arch
1 parent 1e83929 commit 577b5fd

12 files changed

+465
-151
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
build/
66
.settings/
77
vendor/
8+
9+
.php_cs.cache

.php_cs.cache

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/Command/SetupExport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
109109
$setup = [
110110
'signatory' => $this->configService->getAppValue('key_pairs'),
111111
'remote' => $this->remoteService->getAll(true),
112-
'encryption' => $this->encryptService->getEncryptionKey()
112+
'encryption' => $this->encryptService->getEncryptionKeys(true)
113113
];
114114

115115
$data = json_encode($setup);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
6+
/**
7+
* Nextcloud - Backup now. Restore later.
8+
*
9+
* This file is licensed under the Affero General Public License version 3 or
10+
* later. See the COPYING file.
11+
*
12+
* @author Maxence Lange <maxence@artificial-owl.com>
13+
* @copyright 2021, Maxence Lange <maxence@artificial-owl.com>
14+
* @license GNU AGPL version 3 or any later version
15+
*
16+
* This program is free software: you can redistribute it and/or modify
17+
* it under the terms of the GNU Affero General Public License as
18+
* published by the Free Software Foundation, either version 3 of the
19+
* License, or (at your option) any later version.
20+
*
21+
* This program is distributed in the hope that it will be useful,
22+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+
* GNU Affero General Public License for more details.
25+
*
26+
* You should have received a copy of the GNU Affero General Public License
27+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
28+
*
29+
*/
30+
31+
32+
namespace OCA\Backup\Exceptions;
33+
34+
use Exception;
35+
36+
/**
37+
* Class PackDecryptException
38+
*
39+
* @package OCA\Backup\Exceptions
40+
*/
41+
class PackDecryptException extends Exception {
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
6+
/**
7+
* Nextcloud - Backup now. Restore later.
8+
*
9+
* This file is licensed under the Affero General Public License version 3 or
10+
* later. See the COPYING file.
11+
*
12+
* @author Maxence Lange <maxence@artificial-owl.com>
13+
* @copyright 2021, Maxence Lange <maxence@artificial-owl.com>
14+
* @license GNU AGPL version 3 or any later version
15+
*
16+
* This program is free software: you can redistribute it and/or modify
17+
* it under the terms of the GNU Affero General Public License as
18+
* published by the Free Software Foundation, either version 3 of the
19+
* License, or (at your option) any later version.
20+
*
21+
* This program is distributed in the hope that it will be useful,
22+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+
* GNU Affero General Public License for more details.
25+
*
26+
* You should have received a copy of the GNU Affero General Public License
27+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
28+
*
29+
*/
30+
31+
32+
namespace OCA\Backup\Exceptions;
33+
34+
use Exception;
35+
36+
/**
37+
* Class PackEncryptException
38+
*
39+
* @package OCA\Backup\Exceptions
40+
*/
41+
class PackEncryptException extends Exception {
42+
}

lib/Model/RestoringChunkPart.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class RestoringChunkPart implements JsonSerializable, IDeserializable {
6161
/** @var bool */
6262
private $encrypted = false;
6363

64+
/** @var string */
65+
private $algorithm = '';
66+
6467
/** @var string */
6568
private $encryptedChecksum = '';
6669

@@ -126,8 +129,9 @@ public function getOrder(): int {
126129
*
127130
* @return RestoringChunkPart
128131
*/
129-
public function setEncrypted(bool $encrypted): self {
132+
public function setEncrypted(bool $encrypted, string $algorithm = ''): self {
130133
$this->encrypted = $encrypted;
134+
$this->algorithm = $algorithm;
131135

132136
return $this;
133137
}
@@ -140,6 +144,25 @@ public function isEncrypted(): bool {
140144
}
141145

142146

147+
/**
148+
* @param string $algorithm
149+
*
150+
* @return RestoringChunkPart
151+
*/
152+
public function setAlgorithm(string $algorithm): self {
153+
$this->algorithm = $algorithm;
154+
155+
return $this;
156+
}
157+
158+
/**
159+
* @return string
160+
*/
161+
public function getAlgorithm(): string {
162+
return $this->algorithm;
163+
}
164+
165+
143166
/**
144167
* @return string
145168
*/
@@ -219,6 +242,7 @@ public function import(array $data): IDeserializable {
219242
->setOrder($this->getInt('order', $data))
220243
->setContent($this->get('content', $data))
221244
->setEncrypted($this->getBool('encrypted', $data))
245+
->setAlgorithm($this->get('algorithm', $data))
222246
->setChecksum($this->get('checksum', $data))
223247
->setEncryptedChecksum($this->get('encryptedChecksum', $data));
224248

@@ -234,6 +258,7 @@ public function jsonSerialize(): array {
234258
'name' => $this->getName(),
235259
'order' => $this->getOrder(),
236260
'encrypted' => $this->isEncrypted(),
261+
'algorithm' => $this->getAlgorithm(),
237262
'checksum' => $this->getChecksum(),
238263
'encryptedChecksum' => $this->getEncryptedChecksum()
239264
];

lib/Model/RestoringPoint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class RestoringPoint implements IDeserializable, INC23QueryRow, ISignedModel, Js
6060
public const STATUS_COMPRESSED = 2;
6161
public const STATUS_ENCRYPTED = 4;
6262

63-
const LOCK_TIMEOUT = 3600 * 3;
63+
public const LOCK_TIMEOUT = 3600 * 3;
6464

6565
public static $DEF_STATUS =
6666
[

lib/Service/ConfigService.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class ConfigService {
6666
public const PACK_INDEX = 'pack_index';
6767
public const PACK_REMOTE_INDEX = 'pack_remote_index';
6868

69-
public const ENCRYPTION_KEY = 'encryption_key';
69+
public const ENCRYPTION_KEYS = 'encryption_keys';
70+
public const FORCE_CBC = 'force_cbc';
7071
public const TIME_SLOTS = 'time_slots';
7172
public const MOCKUP_DATE = 'mockup_date';
7273

@@ -88,7 +89,8 @@ class ConfigService {
8889
self::DELAY_UNIT => 'd',
8990
self::ALLOW_WEEKDAY => 0,
9091
self::PACK_BACKUP => '1',
91-
self::ENCRYPTION_KEY => '',
92+
self::ENCRYPTION_KEYS => '{}',
93+
self::FORCE_CBC => 0,
9294
self::TIME_SLOTS => '23-5',
9395
self::MOCKUP_DATE => 0,
9496
self::BACKUP_DAYS => 60,
@@ -365,5 +367,4 @@ public function setSettings(array $settings): array {
365367

366368
return $this->getSettings();
367369
}
368-
369370
}

0 commit comments

Comments
 (0)