stream cipher behaviour inconsistently failing
I have been trying without success to use cryptsetup - in both modi plain or LUKS - to create a device with a stream cipher [Chacha20*, ARC4] instead of one of the default block ciphers.
Behaviour is the same for different distributions/kernels (Fedora, Ubuntu), where the kernel in principle supports the ciphers [checked via /proc/crypto, /lib/modules/*/kernel/crypto/, modprobe]
For Chacha20 [chacha20poly1305] cryptsetup fails during creation since no cbc-plain is support as mode - I suppose it is reasonable for a stream cipher not to care about block modi.
For RC4, I can create a a device and access it. But after closing any attempt to reopen it fails with the device not being redable.
My approach for RC4:
> dd if=/dev/zero of=/dev/shm/container bs=1M count=200
> dd if=/dev/urandom of=/tmp/keyfile bs=1k count=8
> cryptsetup --cipher arc4 --key-file=/tmp/keyfile open --type plain /dev/shm/container ramdisk
> mkfs.ext4 /dev/mapper/ramdisk
> echo "test" > /dev/mapper/ramdisk/test.foo
> cryptsetup close ramdisk
> cryptsetup --cipher arc4 --key-file=/tmp/keyfile open --type plain /dev/shm/container ramdisk
-- fails
Using LUKS instead of plain, the header information looks like
> cryptsetup luksDump /dev/shm/container
LUKS header information for /dev/shm/container
Version: 1
Cipher name: arc4
Cipher mode: cbc-plain
Hash spec: sha256
Payload offset: 4096
Actually, I can format the device with different arc-modi-IV combinations as well - I suppose that plain also uses as default mode cbc-plain(??).
My current assumption is, that cryptsetup/dm-crypt does not support stream ciphers and that a fail as for chacha20 should be the default behaviour and arc4 is not catched gracefully?
Question is, if this assumption is correct or how it would be possible to use stream ciphers with dm-crypt?
Tested on Fedora 4.3.5-300.fc23.x86_64 [+Ubuntu, Raspbian/AMD]
cryptsetup 1.7.2