Skip to content

+ dm-crypt plain mode: open, mount and create headerless volumes - #806

Merged
Hawkynt merged 4 commits into
mainfrom
feat/dmcrypt-plain
Nov 10, 2026
Merged

Hawkynt merged 4 commits into
mainfrom
feat/dmcrypt-plain

Conversation

@Hawkynt

@Hawkynt Hawkynt commented Nov 9, 2026

Copy link
Copy Markdown
Owner

dm-crypt plain mode (headerless) volumes can now be opened, mounted and created.

Changes

  • DmCryptPlainParameters / DmCryptPlainVolume / DmCryptPlainFormatDescriptor (DmCryptPlain): cipher spec, passphrase hash (incl. hash:bytes and plain), key size, offset and skip, defaulting to cryptsetup 2.8's plain defaults; never auto-detected.
  • Mounts the filesystem inside read-only/read-write through IEncryptedBlockDeviceProvider (parameters via the mount's volume parameters); extract uses the defaults; create via format options.
  • Spec: docs/DMCRYPT-PLAIN-ON-DISK.md (derived from cryptsetup's behaviour — its crypt_plain.c is GPL and was not converted). Support matrix row, API reference regenerated.

Verification

  • Unit tests: key derivation rules (digest rounds with 'A' prefixes, hash:n zero padding, plain), round trips for every parameter set, IV skip, mount + write through the resolver.
  • cryptsetup oracle (DmCryptPlainExternalConformanceTests, run in the CI "LUKS oracle" step), both directions, for XTS/sha256/sha512/ripemd160, CBC-plain/sha1 with offset+skip, sha256:20, CBC-ESSIV. All pass locally except CBC-ESSIV (this host's kernel lacks the essiv module), which CI covers.

Closes #800

Plain dm-crypt volumes store nothing but ciphertext; every parameter comes
from the user. They were not supported at all.

- DmCryptPlainParameters: cipher spec, passphrase hash (incl. hash:bytes and
  `plain`), key size, offset and skip, defaulting to cryptsetup 2.8's plain
  defaults (aes-xts-plain64, sha256, 256 bits). Read from the mount
  credentials' parameters or from the create options.
- DmCryptPlainVolume: key derivation (round r hashes r 'A's + passphrase,
  digests concatenated and cut to the key; hash:n zero-pads the rest), the
  block device (IV sector = skip + data sector) and the writer.
- DmCryptPlainFormatDescriptor ("DmCryptPlain"): never detected, chosen by
  id; lists/extracts volume.img with the defaults, mounts the filesystem
  inside read-only or read-write through IEncryptedBlockDeviceProvider,
  creates volumes. A wrong passphrase cannot be detected and simply finds no
  filesystem.

Sourcing: rung 2. cryptsetup's crypt_plain.c is GPL-2.0-or-later, so it was
read for orientation only; the key-derivation rules were written down in
docs/DMCRYPT-PLAIN-ON-DISK.md and are pinned by cryptsetup as the oracle.
Sector encryption reuses the LUKS AES XTS/CBC implementation.

Verified: cryptsetup open --type plain maps our volumes to our plaintext and
we decrypt what it writes through its mapping, both ways, for XTS with
sha256/sha512/ripemd160 and 256/512-bit keys, CBC-plain with sha1, offsets,
skips and sha256:20. The CBC-ESSIV case runs on CI (this host's kernel has
no essiv module).

Closes #800
The local regeneration cannot load Svr4BfsWriter and dropped its section and
index link; restore them (and count it) as main and CI have them.
Restoring the Svr4BfsWriter section by hand repeated the FileSystem.SysV
namespace heading; this is the file the README check itself regenerated
(artifact package-readmes of run 42720922485).
@Hawkynt
Hawkynt merged commit 0b32eb7 into main Nov 10, 2026
5 checks passed
@Hawkynt
Hawkynt deleted the feat/dmcrypt-plain branch November 10, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dm-crypt plain mode: open, mount and create headerless volumes

1 participant