TPMLIB_ChooseTPMVersion(3)

๐Ÿ’… TPMLIB_ChooseTPMVersion(3) โ€” like, the whole manual page, bestie

okay so this is a page from the libtpms manual, and honestly? it's giving "small function, big responsibilities." let's get into it ๐ŸŽ€


โœจ NAME โœจ

TPMLIB_ChooseTPMVersion โ€” the function where you, the main character, pick which version of the TPM you want. that's it. that's the whole job. ๐Ÿ‘‘


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <libtpms/tpm_types.h>

#include <libtpms/tpm_library.h>

TPM_RESULT TPMLIB_ChooseTPMVersion(TPMLIB_TPMVersion ver);

 typedef enum TPMLIB_TPMVersion {
    TPMLIB_TPM_VERSION_1_2,
    TPMLIB_TPM_VERSION_2,
 } TPMLIB_TPMVersion;

like yes, you gotta include both headers, no shortcuts, we don't do that here ๐Ÿ’…


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so TPMLIB_ChooseTPMVersion() is literally the "pick your fighter" screen for the TPM โ€” you're choosing whether you want a TPM 1.2 or a TPM 2. that's the vibe check. ๐ŸŽฎ

timing matters, bestie. you must call this function before TPMLIB_MainInit() gets called โ€” do it after and it will return an error, no cap. ๐Ÿ˜ญ that's the rule and we respect it.

the good news? you can call it again later โ€” but only once TPMLIB_Terminate() has been called. so like... terminate first, then re-choose. order is everything fr fr ๐Ÿซถ

now for the โœจ default behaviour โœจ (iykyk, defaults are sneaky):

  • if you don't call this function at all, then whatever TPM version was chosen last is the one that gets started with TPMLIB_MainInit().
  • and if this function is not called... a TPM 1.2 will be used.

so yeah, silence = TPM 1.2. iconic of it, honestly. ๐Ÿ™ˆ


๐Ÿ’€ ERRORS ๐Ÿ’€

  • TPM_SUCCESS โ€” slay! โœจ the version of the TPM was chosen successfully. everything worked, we love to see it. ๐Ÿ’–
  • TPM_FAIL โ€” oop. ๐Ÿ’€ either the choice of the TPM was wrong, or TPMLIB_MainInit() has already been called (remember the timing rule? yeah, that one). ๐Ÿ˜ญ
wanna see the complete list of TPM error codes? go look at the include file libtpms/tpm_error.h โ€” it's all there, i promise. ๐Ÿ“–

๐ŸŒˆ SEE ALSO ๐ŸŒˆ


and that's the page!! ๐Ÿฆ‹ okay bye, go call your functions in the right order โ€” mwah ๐Ÿ’œ

โ€” brought to you by libtpms, dated 2026-01-02, and yeah that's the same TPMLIB_ChooseTPMVersion(3) you started with. full circle, periodt. ๐ŸŽ€

๐Ÿ“ฆ where this page comes from