Hi Jason, On Fri, Oct 14, 2022 at 04:19:41PM -0300, Jason Gunthorpe wrote: > On Wed, Oct 12, 2022 at 05:06:16PM +0800, Herbert Xu wrote: > > > > Rather, drivers that do AES should be called "aes". For this hardware > > > key situation, I guess that means keys have a type (in-memory vs > > > hardware-resident). Then, a crypto operation takes an "algorithm" and a > > > "key", and the abstraction then picks the best implementation that's > > > compatible with both the "algorithm" and the "key". > > > > No the key is already in a specific hardware bound to some driver. > > The user already knows where the key is and therefore they know > > which driver it is. > > Do they? > > We have HW that can do HW resident keys as as well, in our case it is > plugged into the storage system with fscrypt and all the crypto > operations are being done "inline" as the data is DMA'd into/out of > the storage. So, no crypto API here. > > I would say the user knows about the key and its binding in the sense > they loaded a key into the storage device and mounted a fscrypt > filesystem from that storage device - but the kernel may not know this > explicitly. Are you referring to the support for hardware-wrapped inline crypto keys? It isn't upstream yet, but my latest patchset is at https://lore.kernel.org/linux-fscrypt/20220927014718.125308-2-ebiggers@xxxxxxxxxx/T/#u. There's also a version of it used by some Android devices already. Out of curiosity, are you using it in an Android device, or have you adopted it in some other downstream? Anyway, that feature does indeed use a boolean flag to indicate whether the key is hardware-wrapped or not. And yes, it doesn't use the crypto API. Nor does it use the keyrings subsystem, for that matter. However, the design of hardware-wrapped inline crypto keys is that keys are scoped to a particular block device (or a set of block devices), which are assumed to have only one version of wrapped keys. That makes the boolean flag work, as it's always unambiguous what the keys mean. I don't think that would work as well for the crypto API, which is a bit more general. In the crypto API, there can be an arbitrary number of crypto drivers, each of which has its own version of hardware-wrapped (bound) keys. So maybe the existing design that is based on algorithm names is fine. > > > If you don't want a proliferation of different ways of doing the same > > > thing, maybe the requirement should be that the author of this series > > > also converts the existing "paes" kludge to use the new thing he's > > > proposing? > > > > Yes that would definitely be a good idea. We should also talk to the > > people who added paes in the first place, i.e., s390. > > Yes, it would be nice to see a comprehensive understand on how HW > resident keys can be modeled in the keyring. Note that the keyrings subsystem is not as useful as it might seem. It sounds like something you want (you have keys, and there is a subsystem called "keyrings", so it should be used, right?), but often it isn't. fscrypt has mostly moved away from using it, as it caused lots of problems. I would caution against assuming that it needs to be part of any solution. - Eric