// IsTpmProvisioningRequired checks if the Storage Root Key (SRK) is persisted
// at 0x810000001 and the encrypted AK blob is present, which is used as an
// indicator that the TPM is provisioned and the AK can directly be loaded.
// This function uses the low-level go-tpm library directly as go-attestation
// does not provide such a functionality.
IsTpmProvisioningRequired checks if the Storage Root Key (SRK) is persisted
at 0x810000001 and the encrypted AK blob is present, which is used as an
indicator that the TPM is provisioned and the AK can directly be loaded.
This function uses the low-level go-tpm library directly as go-attestation
does not provide such a functionality.
// IsTpmProvisioningRequired checks if the Storage Root Key ( SRK ) is persisted // at 0x810000001 and the encrypted AK blob is present which is used as an // indicator that the TPM is provisioned and the AK can directly be loaded . // This function uses the low - level go - tpm library directly as go - attestation // does not provide such a functionality .
func IsTpmProvisioningRequired(ak string) (bool, error) {
	if _, err := os.Stat(ak); err != nil {
		log.Info("TPM Provisioning (Credential Activation) REQUIRED")
		return true, nil
	}
	rwc, err := tpm2.OpenTPM("/dev/tpm0")
	if err != nil {
		return true, fmt.Errorf("Failed to Open TPM. Check access rights to /dev/tpm0")
	}
	defer rwc.Close()
	srkHandle := tpmutil.Handle(0x81000001)
	_, _, _, err = tpm2.ReadPublic(rwc, srkHandle)
	if err == nil {
		log.Info("TPM Provisioning (Credential Activation) NOT REQUIRED")
		return false, nil
	}
	log.Info("TPM Provisioning (Credential Activation) REQUIRED")
	return true, nil
}
func IsTpmProvisioningRequired ( ak string ) ( bool , error ) { if _ , err := os . Stat ( ak ) ; err != nil { log . Info ( " " ) return true , nil } rwc , err := tpm2 . OpenTPM ( " " ) if err != nil { return true , fmt . Errorf ( " " ) } defer rwc . Close ( ) srkHandle := tpmutil . Handle ( 0x81000001 ) _ , _ , _ , err = tpm2 . ReadPublic ( rwc , srkHandle ) if err == nil { log . Info ( " " ) return false , nil } log . Info ( " " ) return true , nil }
IsTpmProvisioningRequired checks if the Storage Root Key (SRK) is persisted
at 0x810000001 and the encrypted AK blob is present, which is used as an
indicator that the TPM is provisioned and the AK can directly be loaded.
IsTpmProvisioningRequired checks if the Storage Root Key ( SRK ) is persisted at 0x810000001 and the encrypted AK blob is present which is used as an indicator that the TPM is provisioned and the AK can directly be loaded .