LUKS (Linux Unified Key Setup)

LUKS is the standard Linux disk encryption format, managed by cryptsetup on top of dm-crypt. It is offered by most Linux installers and is actively maintained, with LUKS1 and LUKS2 headers. Several passphrases can unlock one volume key.

Overview

A LUKS volume starts with a header containing the magic LUKS 0xBA 0xBE, version, cipher name and mode, hash, payload offset, master key digest and up to 8 key slots. LUKS1 key slots use PBKDF2 and anti-forensic splitting. LUKS2 stores JSON metadata, supports Argon2 and additional segments.

History

  • Designed by Clemens Fruhwirth in 2004 for cryptsetup.
  • LUKS2 was introduced with cryptsetup 2.0 (2018).

Structures

Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.

Parse Luks1

OffsetSizeTypeFieldNotes
0x832bytesCipher Name
0x2832bytesCipher Mode
0x4832bytesHash
0x684u32 BEPayload Offset
0x6C4u32 BEKey Bytes
0x7020bytesValue
0x8432bytesSalt
0xA44u32 BEIterations
0xA840bytesUuid
o4u32 BE–
o + 44u32 BEIterations
o + 832bytesSalt
o + 404u32 BEAterial Sector
o + 444u32 BEStripes

Try Luks2

OffsetSizeTypeFieldNotes
0x62u16 BE–
0x88u64 BEHeader Size
0x108u64 BEParsed
0x1848bytesLabel
0xA840bytesUuid
0xD048bytesSubsystem

Try Luks2

OffsetSizeTypeFieldNotes
0x4832bytesChecksum Algorithm
0x1C064bytesStored
0x1C064bytes–

Other fields read

Read inOffsetSizeTypeFieldNotes
Hashi * 88u64 LE–
Variable Hash0x032bytes–
Compressi * 88u64 LE–
Resolve Volume Start0x1008u64 BEHeader Offset

Constants

Argon2

NameValueTypeNotes
TypeD0int
TypeI1int
TypeId2int
BlockWords128int
SyncPoints4int
Version0x13uint
RowsEnumerable.Range(0, 8).Select(i => Enumerable.Range(0, 16).Select(j => 16 * i + j).ToAr…int[][]

Luks Header

NameValueTypeNotes
PrimaryMagic[(byte)’L’, (byte)’U’, (byte)’K’, (byte)’S’, 0xBA, 0xBE]byte[]
SecondaryMagic[(byte)’S’, (byte)’K’, (byte)’U’, (byte)’L’, 0xBA, 0xBE]byte[]
SecondaryOffsets[16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304]long[]
Luks1Active0x00AC71F3uint

Implementation limits

ClassNameValueNotes
Luks Decrypted DeviceMaxChunkBytes1024 * 1024
Luks ModuleMaxArgon2MemoryKiB4L * 1024 * 1024
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.