Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/models
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2022-12-01 20:27:13 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2022-12-01 20:27:13 +0100
commit26f2ccf943675505b003c12dd308dff347303362 (patch)
tree1ee556558efd3565d45c6666faa152c24e3c4d47 /archinstall/lib/models
parentb855d44b65a63e457e4d9d91fec98c092169b706 (diff)
parent126f56169d6faacd492b0b0f10c18762cf42a2ba (diff)
Merge branch 'upstreamMaster'
Diffstat (limited to 'archinstall/lib/models')
-rw-r--r--archinstall/lib/models/disk_encryption.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/archinstall/lib/models/disk_encryption.py b/archinstall/lib/models/disk_encryption.py
new file mode 100644
index 00000000..3edab93e
--- /dev/null
+++ b/archinstall/lib/models/disk_encryption.py
@@ -0,0 +1,43 @@
+from dataclasses import dataclass, field
+from enum import Enum, auto
+from typing import Optional, List, Dict, TYPE_CHECKING, Any
+
+from ..hsm.fido import Fido2Device
+
+if TYPE_CHECKING:
+ _: Any
+
+
+class EncryptionType(Enum):
+ Partition = auto()
+ # FullDiskEncryption = auto()
+
+ @classmethod
+ def _encryption_type_mapper(cls) -> Dict[str, 'EncryptionType']:
+ return {
+ # str(_('Full disk encryption')): EncryptionType.FullDiskEncryption,
+ str(_('Partition encryption')): EncryptionType.Partition
+ }
+
+ @classmethod
+ def text_to_type(cls, text: str) -> 'EncryptionType':
+ mapping = cls._encryption_type_mapper()
+ return mapping[text]
+
+ @classmethod
+ def type_to_text(cls, type_: 'EncryptionType') -> str:
+ mapping = cls._encryption_type_mapper()
+ type_to_text = {type_: text for text, type_ in mapping.items()}
+ return type_to_text[type_]
+
+
+@dataclass
+class DiskEncryption:
+ encryption_type: EncryptionType = EncryptionType.Partition
+ encryption_password: str = ''
+ partitions: List[str] = field(default_factory=list)
+ hsm_device: Optional[Fido2Device] = None
+
+ def generate_encryption_file(self, partition) -> bool:
+ return partition in self.partitions and partition['mountpoint'] != '/'
+