Re: [PATCH v5 7/9] fscrypt: add inline encryption support
From: Eric Biggers <ebiggers@kernel.org>
Date: 2019-11-05 03:12:26
Also in:
linux-f2fs-devel, linux-fscrypt, linux-fsdevel, linux-scsi
On Thu, Oct 31, 2019 at 02:21:03PM -0700, Christoph Hellwig wrote:
quoted
quoted
Btw, I'm not happy about the 8-byte IV assumptions everywhere here. That really should be a parameter, not hardcoded.To be clear, the 8-byte IV assumption doesn't really come from fs/crypto/, but rather in what the blk-crypto API provides. If blk-crypto were to provide longer IV support, fs/crypto/ would pretty easily be able to make use of it.That's what I meant - we hardcode the value in fscrypt. Instead we need to expose the size from blk-crypt and check for it.quoted
(And if IVs >= 24 bytes were supported and we added AES-128-CBC-ESSIV and Adiantum support to blk-crypto.c, then inline encryption would be able to do everything that the existing filesystem-layer contents encryption can do.) Do you have anything in mind for how to make the API support longer IVs in a clean way? Are you thinking of something like: #define BLK_CRYPTO_MAX_DUN_SIZE 24 u8 dun[BLK_CRYPTO_MAX_DUN_SIZE]; int dun_size; We do have to perform arithmetic operations on it, so a byte array would make it ugly and slower, but it should be possible...Well, we could make it an array of u64s, which means we can do all the useful arithmetics on components on one of them. But I see the point, this adds significant complexity for no real short term gain, and we should probably postponed it until needed. Maybe just document the assumptions a little better.
Just in case it's not obvious to anyone, I should also mention that being limited to specifying a 64-bit DUN doesn't prevent hardware that accepts a longer IV (e.g. 128 bits) from being used. It would just be a matter of zero-padding the IV in the driver rather than in hardware. The actual limitation we're talking about here is in the range of IVs that can be specified. A 64-bit DUN only allows the first 64 bits of the IV to be nonzero. That works for fscrypt in all cases except DIRECT_KEY policies, and it would work for dm-crypt using the usual dm-crypt IV generator (plain64). But for inline encryption to be compatible with DIRECT_KEY fscrypt policies or with certain other dm-crypt IV generators, we'd need the ability to specify more IV bits. - Eric