google / go-tpm

Apache License 2.0
553 stars 159 forks source link

Use `crypto/ecdh` for tpmdirect #327

Open Foxboron opened 1 year ago

Foxboron commented 1 year ago

It seems like tpmdirect is dealing with a bit of low-level stuff to accomplish ECDH which is mostly solved with the new crypto/ecdh package.

Would it be a good idea to consider using this package maybe?

Currently the only missing part is TPMECCNistP224 which crypot/ecdh doesn't implement.

chrisfenner commented 1 year ago

Thanks for this issue! Yes, we should use this.

Foxboron commented 1 year ago

I can write up a suggestion if we are fine with loosing support for a few curves.

chrisfenner commented 1 year ago

Hmm, more than P224? I think we'd have to discuss this in our team but if you sent a PR it would prompt such discussion, thanks!

Foxboron commented 1 year ago

We'll largely be limited to the supported curves in crypto/ecdh which would be P256, P384 and P521 which is a small subset of what TPMs intend to provide support for.

Alternatively one can implement the ecdh.Curve interface on the stuff that would need it in the future.

chrisfenner commented 1 year ago

Yeah, I will also take a look on my side to see if the Go crypto team would be receptive to adding those curves.