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

reduce repetitive, nested structs by proving a defaults package #303

Open
chrisfenner opened this issue Sep 3, 2022 · 1 comment
Open
Labels
tpmdirect Issues specific to the tpmdirect development work

Comments

@chrisfenner
Copy link
Member

#300 had

Nested Structs make writing code confusing

#300 suggested a number of ideas here.

  • Using tags/sizing and reducing the number of nesting done
  • Add more default templates users can use. For more specific structs, such as tpmu.PublicParams adding all most commonly used would be nice to have for users. For broader structs like tpmt.Public, having examples to follow should suffice.
  • Add a way to pick common combinations of tpma.Object aside for manually setting true for each specific field.
@chrisfenner
Copy link
Member Author

I don't think we should reduce the nesting. The value of this library is its 1:1-ness with the actual TPM spec, which is deeply nested. The spec makes it clear when you pass a TPM2B_X vs a TPMS_X and I think those types should be very clearly delineated from each other to avoid making people debug "there shouldn't have been a size prefix to my serialization but I accidentally got one" (and vice-versa) type issues.

That said, I think we can make these issues better using the other suggestions:

  • Default templates.
  • Add a way to pick common combinations

We should provide "standard" TPMU_PUBLIC_PARMS for various obvious cases (RSA signing/decryption, ECC signing decryption, sealed blob), and this will cut a huge chunk of the nesting out:

image

becomes

image

WDYT @josephlr @alexmwu?

@chrisfenner chrisfenner added the tpmdirect Issues specific to the tpmdirect development work label Sep 3, 2022
@chrisfenner chrisfenner changed the title nested structs reduce repetitive, nested structs by proving a defaults package Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tpmdirect Issues specific to the tpmdirect development work
Projects
None yet
Development

No branches or pull requests

1 participant