Closed gnarea closed 2 years ago
Thanks @rmhrisk!
I want to use GCP KMS, which offers a C library for PKCS#11, so it seems like I'd simply need to initialise the Crypto
class in node-webcrypto-p11
with the path to GCP KMS' shared object libkmsp11.so
.
However, the issues above with EnvelopedData
would still prevent me from using node-webcrypto-p11
, unless I'm missing something. I also use SignedData
and Certificate
, but I believe those are fine.
FYI, I ended up integrating the @google-cloud/kms
library in a new RSA-PSS provider. I may move it to a separate NPM package if other folks find it useful.
GCP KMS doesn't support (EC)DH, and our protocol only supports EnvelopedData
with ECDH, so that's as far as I can take the KMS integration today.
Sounds good
For security reasons, I'd like to move away from having private keys in the app's memory and use a KMS/HSM instead. This isn't currently supported, is it? The current implementation of PKI.js depends heavily on WebCrypto private keys, but I don't know if there's a way to make this work today.
I think one (ugly) way to make this work relatively easily is by having a webcrypto provider whose private
CryptoKey
s actually represent pointers to a key in a KMS/HSM. Of course, this would mean that methods likeexportKey()
would have to throw errors. This workaround would also require updating methods likeEnvelopedData.decrypt()
to take aCryptoKey
private key (instead of or in addition to anArrayBuffer
) andEnvelopedData.encrypt()
to take a private key when using DH (instead of generating one internally).The ideal solution IMHO would be to make this explicit by creating an abstraction for private keys, which would only support a subset of operations; e.g.:
... but that'd be a much more invasive change.
Thoughts?