grub2/grub-core/disk
Glenn Washburn cf3a3acff0 cryptodisk: Properly handle non-512 byte sized sectors
By default, dm-crypt internally uses an IV that corresponds to 512-byte
sectors, even when a larger sector size is specified. What this means is
that when using a larger sector size, the IV is incremented every sector.
However, the amount the IV is incremented is the number of 512 byte blocks
in a sector (i.e. 8 for 4K sectors). Confusingly the IV does not correspond
to the number of, for example, 4K sectors. So each 512 byte cipher block in
a sector will be encrypted with the same IV and the IV will be incremented
afterwards by the number of 512 byte cipher blocks in the sector.

There are some encryption utilities which do it the intuitive way and have
the IV equal to the sector number regardless of sector size (ie. the fifth
sector would have an IV of 4 for each cipher block). And this is supported
by dm-crypt with the iv_large_sectors option and also cryptsetup as of 2.3.3
with the --iv-large-sectors, though not with LUKS headers (only with --type
plain). However, support for this has not been included as grub does not
support plain devices right now.

One gotcha here is that the encrypted split keys are encrypted with a hard-
coded 512-byte sector size. So even if your data is encrypted with 4K sector
sizes, the split key encrypted area must be decrypted with a block size of
512 (ie the IV increments every 512 bytes). This made these changes less
aesthetically pleasing than desired.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-12-12 01:19:05 +01:00
..
arc Rename grub_disk members 2019-03-25 15:14:52 +01:00
efi disk: Rename grub_disk_get_size() to grub_disk_native_sectors() 2020-12-12 01:19:03 +01:00
i386/pc Rename grub_disk members 2019-03-25 15:14:52 +01:00
ieee1275 calloc: Use calloc() at most places 2020-07-29 16:55:47 +02:00
uboot Rename grub_disk members 2019-03-25 15:14:52 +01:00
xen calloc: Use calloc() at most places 2020-07-29 16:55:47 +02:00
AFSplitter.c afsplitter: Move into its own module 2020-01-10 14:27:49 +01:00
ahci.c ahci: Increase time-out from 10 s to 32 s 2018-09-13 10:54:54 +02:00
ata.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
cryptodisk.c cryptodisk: Properly handle non-512 byte sized sectors 2020-12-12 01:19:05 +01:00
diskfilter.c disk: Rename grub_disk_get_size() to grub_disk_native_sectors() 2020-12-12 01:19:03 +01:00
dmraid_nvidia.c disk: Rename grub_disk_get_size() to grub_disk_native_sectors() 2020-12-12 01:19:03 +01:00
geli.c disk: Rename grub_disk_get_size() to grub_disk_native_sectors() 2020-12-12 01:19:03 +01:00
host.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
ldm.c disk: Rename grub_disk_get_size() to grub_disk_native_sectors() 2020-12-12 01:19:03 +01:00
loopback.c loopback: Do not automaticaly replace existing loopback dev, error instead 2020-12-12 01:19:03 +01:00
luks2.c cryptodisk: Properly handle non-512 byte sized sectors 2020-12-12 01:19:05 +01:00
luks.c cryptodisk: Properly handle non-512 byte sized sectors 2020-12-12 01:19:05 +01:00
lvm.c lvm: Fix two more potential data-dependent alloc overflows 2020-07-29 16:55:48 +02:00
mdraid1x_linux.c disk: Rename grub_disk_get_size() to grub_disk_native_sectors() 2020-12-12 01:19:03 +01:00
mdraid_linux_be.c Handle big-endian mdraid. 2012-03-26 16:10:40 +02:00
mdraid_linux.c disk: Rename grub_disk_get_size() to grub_disk_native_sectors() 2020-12-12 01:19:03 +01:00
memdisk.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
pata.c Add PCI command activation to all PCI drivers as required for coreboot 2013-11-26 14:21:11 +01:00
raid5_recover.c * include/grub/diskfilter.h (grub_raid5_recover_func_t): Use proper 2012-06-25 17:36:50 +02:00
raid6_recover.c btrfs: Make more generic the code for RAID 6 rebuilding 2018-10-31 12:07:29 +01:00
scsi.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
usbms.c cleanup: grub_cpu_to_XXX_compile_time for constants 2014-09-22 20:47:10 +04:00