The trusted platform module(TPM),a system component implemented on physical resources,is designed to enable computers to achieve a higher level of security than the security level that it is possible to achieve by software alone.For this reason,the TPM provides a way to store cryptographic keys and other sensitive data in its memory,which is shielded from access by any entity other than the TPM.Users who want to use those keys and data to achieve some security goals are restricted to interact with the TPM through its APIs defined in the TPM specification.Therefore,whether the TPM can provide Protected Capabilities it claimed depends to a large extent on the security of its APIs.In this paper,we devise a formal model,which is accessible to a fully mechanized analysis,for the key management APIs in the TPM2.0 specification.We identify and formalize security properties of these APIs in our model and then successfully use the automated prover Tamarin to obtain the first mechanized analysis of them.The analysis shows that the key management subset of TPM APIs preserves the secrecy of non-duplicable keys for unbounded numbers of fresh keys and handles.The analysis also reports that the key duplication mechanism,used to duplicate a key between two hierarchies,is vulnerable to impersonation attacks,which enable an adversary to recover the duplicated key of the originating hierarchy or import his own key into the destination hierarchy.Aiming at avoiding these vulnerabilities,we proposean approach,which restricts the originating and destination TPMs to authenticate each other’s identity during duplication.Then we formally demonstrate that our approach maintains the secrecy of duplicable keys when they are duplicated.