Fixed loading of parent handles in TPM TSS2 keys #153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We need to make sure to be able to load TPM2 TSS2 keys which have been created with earlier versions of the tpm2-openssl provider or with earlier versions of the tpm2-tss-engine.
The parent handle of TPM2_TSS keys created with provider version < 1.2 or engine version < 1.2.0-rc0 have been written using ASN1_INTEGER_set ASN1_INTEGER_set takes a (signed) long (which on 32-bit systems is 32-bit and on 64-bit systems is 64bit) As parent handles are in the range of 0x81000000 - 0x81FFFFFF the MSB on a 32-bit system is always set, and therefore is treated as negative. This won't be the case on 64 bit systems or in case the handle had been written using BN_set_word().
The parent handle of TPM2_TSS keys create with provider verision 1.2 - 1.3 have been written using ASN1_INTEGER_set_uint64. These values can safely be read using BN_get_word, as the values written always were of type TPM2_HANDLE (uint32_t).
Resolves: #152
See also: #74,
tpm2-software/tpm2-tss-engine#222, tpm2-software/tpm2-tools#3113