Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using HSM for signing #12

Open
maxpain opened this issue Nov 28, 2021 · 11 comments
Open

Using HSM for signing #12

maxpain opened this issue Nov 28, 2021 · 11 comments

Comments

@maxpain
Copy link

maxpain commented Nov 28, 2021

Hello. Is it possible use HSM (for example Google Cloud KMS/HSM) for signing Windows executables?

@jet2jet
Copy link
Owner

jet2jet commented Nov 29, 2021

No, currently resedit-js does not support any HSMs. I think it is good to support, but it may take some time to implement (also it may not be fully tested).

@maxpain
Copy link
Author

maxpain commented Nov 29, 2021

I am looking for signing my electron application in GitLab CI with our EV certificate on Google Cloud KMS.
I could use jsign, but it requires to build our own docker image with gcloud-sdk, jsign itself and electron-builder rather than using pure electron-builder image.

So it will be cool to use this npm module to do that right in the electron-builder config.

Can I implement HSM signing utilizing current API of this package?

@jet2jet
Copy link
Owner

jet2jet commented Nov 29, 2021

Sounds good. If you use @google-cloud/kms, please set it as optional dependency because this feature would be an optional feature.

@maxpain
Copy link
Author

maxpain commented Nov 29, 2021

So, can I implement HSM signing utilizing current API of this package?
Honestly, I'm not very familiar with crypto stuff

@jet2jet
Copy link
Owner

jet2jet commented Nov 30, 2021

It's OK. I think it's not so easy, but I think all we need is implement ResEdit.SignerObject, especially three methods: getEncryptionAlgorithm, getCertificateData, and encryptData (other methods would be the same implementations as MySignerObject: https://github.com/jet2jet/resedit-js-cli/blob/main/src/main/signing/index.ts#L20).

The asymmetric-sign sample may help you to understand and implement this: https://github.com/googleapis/nodejs-kms/blob/HEAD/samples/signAsymmetric.js
(More information about signature creation: https://cloud.google.com/kms/docs/create-validate-signatures )

@maxpain
Copy link
Author

maxpain commented Dec 1, 2021

encryptData implementation would be to call asymmetric sign process as followings:

  • @google-cloud/kms package: client.asymmetricSign()

asymmetricSign just returns digital signature of provided payload, but encryptData method of ResEdit.SignerObject class must return whole encrypted payload, right? If so, ResEdit.SignerObject must let me provide some signData method.

@jet2jet
Copy link
Owner

jet2jet commented Dec 2, 2021

Yes, you are right (I missed it). I'll work to add signData-like method to SignerObject.

@jet2jet
Copy link
Owner

jet2jet commented Dec 2, 2021

I updated resedit package and resedit-js-cli repository.
Now signData method is to be used during signing process, so please implement signData method in SignerObject.

@maxpain
Copy link
Author

maxpain commented Dec 2, 2021

Thank you! Will try it today.

@maxpain
Copy link
Author

maxpain commented Dec 2, 2021

@jet2jet Is it possible to use returned value of digestData and pass it as an argument in signData?

@jet2jet
Copy link
Owner

jet2jet commented Dec 3, 2021

Is it possible to use returned value of digestData and pass it as an argument in signData?

No. But for asymmetricSign, digest parameter should be the digest data calculated from the parameter dataIterator of signData.
Pseudo code would be:

  d = createDigest(algorithm);
  d.update(...dataIterator);
  digest = d.digest();
  asymmetricSign(digest := digest, ...<other parameters>);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants