feat: add marshal/unmarshall to command/response#415
feat: add marshal/unmarshall to command/response#415chrisfenner merged 6 commits intogoogle:mainfrom
Conversation
96c4d1c to
22ad7f5
Compare
22ad7f5 to
2bd232d
Compare
21becf4 to
59f5c5a
Compare
|
@chrisfenner once this PR will be approved it will be required to squash because latest commit messages won't be useful. |
chrisfenner
left a comment
There was a problem hiding this comment.
This is looking really awesome! I have a few more comments to try to drive down the complexity of this solution and maximize the usability, but I think we're really close. Thanks for incorporating my feedback!
Note: this allow to reuse some logic in unmarshalParameter
8f3ee81 to
9b4e0b3
Compare
|
Hi @chrisfenner sorry for the delay, I've added 3 atomic commits to address your latest feedbacks. |
chrisfenner
left a comment
There was a problem hiding this comment.
Thanks for your patience on my review, @loicsikidi -- your reply came in while I was at a conference, and then I have been out sick the past week. I think we are very close here, just a couple more things to make sure that this satisfies your original use case of making it as easy as possible for users to compute cpHash/rpHash for audit- and audit-adjacent TPM activities.
|
As agreed I've refactored Marshal/Unmarshal. Command cmdData, err := MarshalCommand(myCmd)
// handle err
cpHash := sha256.Sum256(cmdData)
// do something interesting with cpHashResponse I'm waiting for your feedbacks. PS: I see the light at the end of the tunnel 😄 |
26b1b05 to
07b2132
Compare
07b2132 to
aa80b13
Compare
| // rpHash := sha256.Sum256(rspData) | ||
| // | ||
| // Note: Encrypted response parameters (via sessions) are not currently supported. | ||
| func MarshalResponse[C Command[R, *R], R any](cmd C, rsp *R) ([]byte, error) { |
There was a problem hiding this comment.
I need to get the Command Code as an input.
I think that it's more natural to pass the command but maybe that TPMCC is better.
WDYT?
There was a problem hiding this comment.
I think what you've written is perfect. Very natural. Thanks!
chrisfenner
left a comment
There was a problem hiding this comment.
Thanks so much for this change and for incorporating the feedback!
| // rpHash := sha256.Sum256(rspData) | ||
| // | ||
| // Note: Encrypted response parameters (via sessions) are not currently supported. | ||
| func MarshalResponse[C Command[R, *R], R any](cmd C, rsp *R) ([]byte, error) { |
There was a problem hiding this comment.
I think what you've written is perfect. Very natural. Thanks!
|
Thank you @loicsikidi for this change! I'm very happy with how the feature turned out. I appreciate your willingness to entertain my many comments :) |
a naive implementation of Command/Response marshalling in order to address #414
I'm open to feedback if there a better way to provide this feature.