I suspect PKCS11 module would be pretty easy to work, but I'm not sure if it would work out of the box. I don't have a lot of experience with PKCS11 and Java. It'll require some config at least.
The relevant Keywhiz config looks like this for an nCipher module.
derivationProviderClass: com.ncipher.provider.km.nCipherKM
contentKeyStore:
path: /.../derivation.sworld
type: ncipher.sworld
password: external:/.../derivation.password
alias: basekey
Those options configure the "Derivation Provider", ie the Java crypto provider which does the key derivation per-item. That's the bit you want in your HSM.
There's a sun.security.pkcs11.SunPKCS11 which looks like it's probably usable here.
The only thing is it seems to need a configuration file passed to it, which isn't supported right now in Keywhiz.
It's not entirely clear to me but you might be able to configure the PKCS11 module entirely using JVM options or the
If not, we'd need some changes, at least to pass in the argument in
And we'd need to add it to the configuration in