|
18 | 18 | from typing import Any, Self, cast |
19 | 19 |
|
20 | 20 | from awesomeversion import AwesomeVersion, AwesomeVersionCompareException |
21 | | -from cryptography.hazmat.backends import default_backend |
22 | | -from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes |
23 | 21 | from securetar import AddFileError, SecureTarFile, atomic_contents_add, secure_path |
24 | 22 | import voluptuous as vol |
25 | 23 | from voluptuous.humanize import humanize_error |
|
62 | 60 | from ..utils.json import json_bytes |
63 | 61 | from ..utils.sentinel import DEFAULT |
64 | 62 | from .const import BUF_SIZE, LOCATION_CLOUD_BACKUP, BackupType |
65 | | -from .utils import key_to_iv, password_to_key |
| 63 | +from .utils import password_to_key |
66 | 64 | from .validate import SCHEMA_BACKUP |
67 | 65 |
|
68 | 66 | _LOGGER: logging.Logger = logging.getLogger(__name__) |
@@ -102,7 +100,6 @@ def __init__( |
102 | 100 | self._tmp: TemporaryDirectory | None = None |
103 | 101 | self._outer_secure_tarfile: SecureTarFile | None = None |
104 | 102 | self._key: bytes | None = None |
105 | | - self._aes: Cipher | None = None |
106 | 103 | self._locations: dict[str | None, BackupLocation] = { |
107 | 104 | location: BackupLocation( |
108 | 105 | path=tar_file, |
@@ -348,16 +345,10 @@ def set_password(self, password: str | None) -> None: |
348 | 345 | self._init_password(password) |
349 | 346 | else: |
350 | 347 | self._key = None |
351 | | - self._aes = None |
352 | 348 |
|
353 | 349 | def _init_password(self, password: str) -> None: |
354 | | - """Set password + init aes cipher.""" |
| 350 | + """Create key from password.""" |
355 | 351 | self._key = password_to_key(password) |
356 | | - self._aes = Cipher( |
357 | | - algorithms.AES(self._key), |
358 | | - modes.CBC(key_to_iv(self._key)), |
359 | | - backend=default_backend(), |
360 | | - ) |
361 | 352 |
|
362 | 353 | async def validate_backup(self, location: str | None) -> None: |
363 | 354 | """Validate backup. |
|
0 commit comments