Usually in Python, default values use None instead. Moreover here, zero could have a special meaning: the enum ESYS_TR contains an entry for 0, which is ESYS_TR.PCR0:
For basic NV configurations work. Also, modify the arguments to NV_Read
and NV_Write so we can just default the authHandle to the nvIndex handle
if the authHandle is not specified. This makes calls simpler in the more
common auth to the handle role.
In the end, my questions are: why was zero used, instead of None? Can this be modified (this will help checking the type annotations of ESAPI.py)?
Now is a great time to modify that before we actually fully roll 1.0. I have no objections to using None over 0. I chose 0 since it's unused in NV index space, but I think None is a better choice.
Hello, In tpm2-pytss 1.0.0-rc0, some functions in ESAPI take a parameter
auth_handle: ESYS_TR = 0
(mostly the ones related to NV index). For example https://github.com/tpm2-software/tpm2-pytss/blob/7cd4cc0632f87b51483dc59630e7fb2d6abd2630/tpm2_pytss/ESAPI.py#L6170-L6179This zero means "use the handle from
nv_index
", and this is implemented for example in https://github.com/tpm2-software/tpm2-pytss/blob/7cd4cc0632f87b51483dc59630e7fb2d6abd2630/tpm2_pytss/ESAPI.py#L6205-L6206Usually in Python, default values use
None
instead. Moreover here, zero could have a special meaning: the enumESYS_TR
contains an entry for0
, which isESYS_TR.PCR0
:It seems that these
auth_handle=0
were introduced in commit https://github.com/tpm2-software/tpm2-pytss/commit/40ec6dc1093ed3cb16bcc42f1e9e5c88829aef48 and documented by:In the end, my questions are: why was zero used, instead of
None
? Can this be modified (this will help checking the type annotations ofESAPI.py
)?