mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 17:57:59 +00:00
crypto: key: reduce class inheritance depth
This commit is contained in:
parent
3a0e1a1cc2
commit
dd2a054ac4
2 changed files with 5 additions and 19 deletions
|
@ -383,7 +383,9 @@ def init_ciphers(self, manifest_data=None):
|
|||
self.nonce_manager = NonceManager(self.repository, nonce)
|
||||
|
||||
|
||||
class FlexiKeyBase:
|
||||
class FlexiKey:
|
||||
FILE_ID = 'BORG_KEY'
|
||||
|
||||
@classmethod
|
||||
def detect(cls, repository, manifest_data):
|
||||
key = cls(repository)
|
||||
|
@ -406,12 +408,6 @@ def detect(cls, repository, manifest_data):
|
|||
key._passphrase = passphrase
|
||||
return key
|
||||
|
||||
def find_key(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def load(self, target, passphrase):
|
||||
raise NotImplementedError
|
||||
|
||||
def _load(self, key_data, passphrase):
|
||||
cdata = a2b_base64(key_data)
|
||||
data = self.decrypt_key_file(cdata, passphrase)
|
||||
|
@ -489,16 +485,6 @@ def create(cls, repository, args):
|
|||
logger.info('Keep this key safe. Your data will be inaccessible without it.')
|
||||
return key
|
||||
|
||||
def save(self, target, passphrase, create=False):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_new_target(self, args):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class FlexiKey(FlexiKeyBase):
|
||||
FILE_ID = 'BORG_KEY'
|
||||
|
||||
def sanity_check(self, filename, id):
|
||||
file_id = self.FILE_ID.encode() + b' '
|
||||
repo_id = hexlify(id)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
from ..chunker import has_seek_hole
|
||||
from ..constants import * # NOQA
|
||||
from ..crypto.low_level import bytes_to_long, num_cipher_blocks
|
||||
from ..crypto.key import FlexiKeyBase, RepoKey, KeyfileKey, Passphrase, TAMRequiredError
|
||||
from ..crypto.key import FlexiKey, RepoKey, KeyfileKey, Passphrase, TAMRequiredError
|
||||
from ..crypto.keymanager import RepoIdMismatch, NotABorgKeyFile
|
||||
from ..crypto.file_integrity import FileIntegrityError
|
||||
from ..helpers import Location, get_security_dir
|
||||
|
@ -2882,7 +2882,7 @@ def test_init_interrupt(self):
|
|||
def raise_eof(*args):
|
||||
raise EOFError
|
||||
|
||||
with patch.object(FlexiKeyBase, 'create', raise_eof):
|
||||
with patch.object(FlexiKey, 'create', raise_eof):
|
||||
self.cmd('init', '--encryption=repokey', self.repository_location, exit_code=1)
|
||||
assert not os.path.exists(self.repository_location)
|
||||
|
||||
|
|
Loading…
Reference in a new issue