parallaxsecond / rust-tss-esapi

TSS 2.0 Enhanced System API (ESAPI) Rust wrapper
https://docs.rs/tss-esapi/
Apache License 2.0
85 stars 51 forks source link

Fixes max size issue with SensitiveData. #482

Closed Superhepper closed 7 months ago

Superhepper commented 8 months ago

This fixes #481

Superhepper commented 8 months ago

Yes you understand it correctly.

Calculating the size for versions >= 4.0.0 is just using the way that the specification says it should be done.

11.1.14 TPM2B_SENSITIVE_DATA

This buffer wraps the TPMU_SENSITIVE_CREATE structure.

Parameter Type Description
size UINT16
buffer[size]{: sizeof(TPMU_SENSITIVE_CREATE)} BYTE symmetric data for a created object or the label and context for a derived object

But in earlier versions that structure is not available so it will be manually calculated by removing the size of the size variable.

Actually using the buffer macro for TPM2B types that are not sized buffers is not great. Because for other types the size is fixed and any other size then the specified one should be an error while for sized buffers the size just needs to be lower or equal to the max size.

wiktor-k commented 8 months ago

Thanks for the explainer. I think it's worth having your knowledge captured in some persistent media (like a comment here). 🙇‍♂️

Superhepper commented 8 months ago

Thanks for the explainer. I think it's worth having your knowledge captured in some persistent media (like a comment here). 🙇‍♂️

Fixed it. Added a comment that summarize what I wrote above.

Superhepper commented 7 months ago

@ionut-arm Could you please have a look at this as well.