On Thu, Aug 15, 2019 at 08:15:29AM +0300, Ard Biesheuvel wrote: > > So what about checking that the cipher key size matches the shash > digest size, or that the cipher block size matches the skcipher IV > size? This all moves to the TFM init function? I don't think you need to check those things. If the shash produces an incorrect key size the setkey will just fail naturally. As to the block size matching the IV size, in the kernel it's not actually possible to get an underlying cipher with different block size than the cbc mode that you used to derive it. The size checks that we have in general are to stop people from making crazy combinations such as lrw(des3_ede), it's not there to test the correctness of a given implementation. That is, we assume that whoever provides "aes" will give it the correct geometry for it. Sure we haven't made it explicit (which we should at some point) but as it stands, it can only occur if we have a bug or someone loads a malicious kernel module in which case none of this matters. > Are there any existing templates that use this approach? I'm not sure of templates doing this but this is similar to fallbacks. In fact we don't check any gemoetry on the fallbacks at all. Cheers, -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt