LUKS2 'keyslots_size' config attribute calculation doesn't work as expected when --offset parameter is used with luksFormat
This can be hit only with 2.1 pre-release currently: I've created LUKS2 device with data offset set explicitly to 8MiB with following:
cryptsetup luksFormat --type luks2 --offset 16384 /dev/sdx
Following:
cryptsetup luksDump --debug-json /dev/sdx
shows following:
...
"segments":{
"0":{
"type":"crypt",
"offset":"8388608", <<--- correct
"size":"dynamic",
"iv_tweak":"0",
"encryption":"aes-xts-plain64",
"sector_size":512
}
},
(...)
"config":{
"json_size":"12288",
"keyslots_size":"4161536" <<--- I'd expect value "8355840" (8M - 2*16K)
}
It's not necessarily a bug, but I'd expect cryptsetup to extend keyslots area (capped by internal max value) up to first segment offset.
What do you think?