def test_make_two_spaces(self): log = logging.getLogger(__name__) log.debug("test_make_two_spaces") space1 = tpm2.Client(tpm2.Client.FLAG_SPACE) root1 = space1.create_root_key() space2 = tpm2.Client(tpm2.Client.FLAG_SPACE) root2 = space2.create_root_key() root3 = space2.create_root_key() log.debug("%08x" % (root1)) log.debug("%08x" % (root2)) log.debug("%08x" % (root3))
def test_get_handles(self): log = logging.getLogger(__name__) log.debug("test_get_handles") space1 = tpm2.Client(tpm2.Client.FLAG_SPACE) space1.create_root_key() space2 = tpm2.Client(tpm2.Client.FLAG_SPACE) space2.create_root_key() space2.create_root_key() handles = space2.get_cap(tpm2.TPM2_CAP_HANDLES, tpm2.HR_TRANSIENT) self.assertEqual(len(handles), 2) log.debug("%08x" % (handles[0])) log.debug("%08x" % (handles[1]))
def test_async(self): log = logging.getLogger(__name__) log.debug(sys._getframe().f_code.co_name) async_client = tpm2.Client(tpm2.Client.FLAG_NONBLOCK) log.debug("Calling get_cap in a NON_BLOCKING mode") async_client.get_cap(tpm2.TPM2_CAP_HANDLES, tpm2.HR_LOADED_SESSION) async_client.close()
def test_flush_context(self): log = logging.getLogger(__name__) log.debug("test_flush_context") space1 = tpm2.Client(tpm2.Client.FLAG_SPACE) root1 = space1.create_root_key() log.debug("%08x" % (root1)) space1.flush_context(root1)
def test_flush_invalid_context(self): log = logging.getLogger(__name__) log.debug(sys._getframe().f_code.co_name) async_client = tpm2.Client(tpm2.Client.FLAG_SPACE | tpm2.Client.FLAG_NONBLOCK) log.debug("Calling flush_context passing in an invalid handle ") handle = 0x80123456 rc = 0 try: async_client.flush_context(handle) except OSError as e: rc = e.errno self.assertEqual(rc, 22) async_client.close()
def test_invalid_cc(self): log = logging.getLogger(__name__) log.debug(sys._getframe().f_code.co_name) TPM2_CC_INVALID = tpm2.TPM2_CC_FIRST - 1 space1 = tpm2.Client(tpm2.Client.FLAG_SPACE) root1 = space1.create_root_key() log.debug("%08x" % (root1)) fmt = '>HII' cmd = struct.pack(fmt, tpm2.TPM2_ST_NO_SESSIONS, struct.calcsize(fmt), TPM2_CC_INVALID) rc = 0 try: space1.send_cmd(cmd) except ProtocolError, e: rc = e.rc
def setUp(self): self.client = tpm2.Client() self.root_key = self.client.create_root_key()