-
Notifications
You must be signed in to change notification settings - Fork 568
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
Feature: ECC Support in TPM2 #4357
Conversation
4c963f6
to
d86ffe9
Compare
6286c1f
to
9e1439e
Compare
9e1439e
to
8c882c5
Compare
To add ECDH support, different TPM2-TSS methods need to be incorporated into Key Agreement PK operations. The class hierarchy of Botan's EC keys currently makes this hard since a TPM2 EC key may not be restricted to just ECDH or ECDSA.
This includes disentangling the TPM2 Crypto Backend from the availability of the TPM2 RSA Adapter module. Instead, it now only depends on the software RSA/EC implementation of Botan.
Co-Authored-By: Amos Treiber <[email protected]>
8c882c5
to
485d1f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was closely involved with the implementation, so this is really more of a self-review. The CI failures seem to be inherited from master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. If possible I'd like to avoid introducing new public APIs that use EC_Point
since ideally that type goes away in Botan4, and using EC_AffinePoint
from the outset avoids API breakage.
} else if(signature->sigAlg == TPM2_ALG_RSAPSS) { | ||
return signature->signature.rsapss; | ||
std::vector<uint8_t> marshal_signature(const TPMT_SIGNATURE& signature) const override { | ||
const auto& sig = [&] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if
/else if
formulation originally used seems cleaner to me tbh
src/lib/prov/tpm2/tpm2_key.cpp
Outdated
} | ||
|
||
auto curve = Botan::EC_Group::from_name(curve_name.value()); | ||
auto point = curve.point(BigInt(as_span(public_blob->publicArea.unique.ecc.x)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to move the EC interfaces away from BigInt
in general I'd suggest instead concatenating x and y as bytestrings with 04
prefix and deserializing.
friend class TPM2::PublicKey; | ||
|
||
EC_PublicKey(Object handle, SessionBundle sessions, const TPM2B_PUBLIC* public_blob); | ||
EC_PublicKey(Object handle, SessionBundle sessions, std::pair<EC_Group, EC_Point> public_key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason to use EC_Point
here vs EC_AffinePoint
? (Likewise elsewhere in this module.) I'd like to transition the entire library eventually to EC_AffinePoint
only, where EC_Point
basically becomes an implementation detail that isn't exposed. So if we can avoid introducing new uses that would be a plus from my view.
- sigAlg cases via if/else in tpm2_rsa.cpp - Avoid BigInt and EC_Point
Thanks for the review! I transitioned the public interface The Crypto Backend still uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks
This PR extends #4337 to include ECC*, which checks another box of the ToDos in #3877.
Changes and Additions
TPM2::Signature_Operation
andTPM2::Verification_Operation
intpm2_pkops.h
.* Fine Print: Limitations
tpm2-tss
.