From ef2fdf16a76e8c5aab0a7fe2a7bdc3c7f026bd6d Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Mon, 7 Feb 2022 20:07:28 +0100 Subject: [PATCH] disk: new type LUKSContainer Representation for the encrypted storage container of the same name. Implements the following disk interfaces: - Entity - Container Co-Authored-By: Christian Kellner --- internal/disk/luks.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 internal/disk/luks.go diff --git a/internal/disk/luks.go b/internal/disk/luks.go new file mode 100644 index 000000000..37e6b54e0 --- /dev/null +++ b/internal/disk/luks.go @@ -0,0 +1,40 @@ +package disk + +import "fmt" + +type Argon2id struct { + Iterations uint + Memory uint + Parallelism uint +} +type LUKSContainer struct { + Passphrase string + UUID string + Cipher string + Label string + Subsystem string + SectorSize uint64 + + // password-based key derivation function + PBKDF Argon2id + + Payload Entity +} + +func (lc *LUKSContainer) IsContainer() bool { + return true +} + +func (lc *LUKSContainer) GetItemCount() uint { + if lc.Payload == nil { + return 0 + } + return 1 +} + +func (lc *LUKSContainer) GetChild(n uint) Entity { + if n != 0 { + panic(fmt.Sprintf("invalid child index for LUKSContainer: %d != 0", n)) + } + return lc.Payload +}