google/go-tpm

tpmDirect Design Feedback

matt-tsai opened this issue · 2 comments

Working with tpmDirect was much simpler than working with tpm2 on the developer side. The complexity for users is not quite easier with tpmDirect due to so much nesting involved.

Some pain points

  • Complicated to write due to all the structures being wrapped with internal
  • Hovering over tpm2b.Public will not show the struct’s fields
  • Nested Structs make writing code confusing
  • Too Flexible

Some solutions to address pain points:

  • Using tags/sizing and reducing the number of nesting done
  • Moving all the structs into one big file rather than being wrapped in "internal". This will also solve the "hovering for fields" problem.
  • Implementing interfaces for tpm2b structs and more; this will bring much more complexity for marginal improvements.
  • 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.

Broke this out into 2 bugs:

  • Complicated to write due to all the structures being wrapped with internal
  • Hovering over tpm2b.Public will not show the struct’s fields

Tracked in #302

  • Nested Structs make writing code confusing
  • Too Flexible

Tracked in #303

Special thanks to @matt-tsai for such concrete and actionable feedback. This will help make the library ready for prime time! Closing as duplicate of these two now.