Lines Matching refs:self
14 def setUp(self): argument
15 self.client = tpm2.Client()
16 self.root_key = self.client.create_root_key()
18 def tearDown(self): argument
19 self.client.flush_context(self.root_key)
20 self.client.close()
22 def test_seal_with_auth(self): argument
26 blob = self.client.seal(self.root_key, data, auth, None)
27 result = self.client.unseal(self.root_key, blob, auth, None)
28 self.assertEqual(data, result)
30 def test_seal_with_policy(self): argument
31 handle = self.client.start_auth_session(tpm2.TPM2_SE_TRIAL)
38 self.client.policy_pcr(handle, pcrs)
39 self.client.policy_password(handle)
41 policy_dig = self.client.get_policy_digest(handle)
43 self.client.flush_context(handle)
45 blob = self.client.seal(self.root_key, data, auth, policy_dig)
47 handle = self.client.start_auth_session(tpm2.TPM2_SE_POLICY)
50 self.client.policy_pcr(handle, pcrs)
51 self.client.policy_password(handle)
53 result = self.client.unseal(self.root_key, blob, auth, handle)
55 self.client.flush_context(handle)
58 self.assertEqual(data, result)
60 def test_unseal_with_wrong_auth(self): argument
65 blob = self.client.seal(self.root_key, data, auth, None)
67 result = self.client.unseal(self.root_key, blob,
72 self.assertEqual(rc, tpm2.TPM2_RC_AUTH_FAIL)
74 def test_unseal_with_wrong_policy(self): argument
75 handle = self.client.start_auth_session(tpm2.TPM2_SE_TRIAL)
82 self.client.policy_pcr(handle, pcrs)
83 self.client.policy_password(handle)
85 policy_dig = self.client.get_policy_digest(handle)
87 self.client.flush_context(handle)
89 blob = self.client.seal(self.root_key, data, auth, policy_dig)
95 self.client.extend_pcr(1, ('X' * ds).encode())
97 handle = self.client.start_auth_session(tpm2.TPM2_SE_POLICY)
100 self.client.policy_pcr(handle, pcrs)
101 self.client.policy_password(handle)
103 result = self.client.unseal(self.root_key, blob, auth, handle)
105 self.client.flush_context(handle)
108 self.assertEqual(data, result)
112 self.client.extend_pcr(16, ('X' * ds).encode())
114 handle = self.client.start_auth_session(tpm2.TPM2_SE_POLICY)
119 self.client.policy_pcr(handle, pcrs)
120 self.client.policy_password(handle)
122 result = self.client.unseal(self.root_key, blob, auth, handle)
125 self.client.flush_context(handle)
127 self.client.flush_context(handle)
130 self.assertEqual(rc, tpm2.TPM2_RC_POLICY_FAIL)
132 def test_seal_with_too_long_auth(self): argument
139 blob = self.client.seal(self.root_key, data, auth, None)
143 self.assertEqual(rc, tpm2.TPM2_RC_SIZE)
145 def test_too_short_cmd(self): argument
155 self.client.send_cmd(cmd)
160 self.assertEqual(rejected, True)
162 def test_read_partial_resp(self): argument
170 self.client.tpm.write(cmd)
171 hdr = self.client.tpm.read(10)
173 rsp = self.client.tpm.read()
176 self.assertEqual(sz, 10 + 2 + 32)
177 self.assertEqual(len(rsp), 2 + 32)
179 def test_read_partial_overwrite(self): argument
187 self.client.tpm.write(cmd)
189 rsp1 = self.client.tpm.read(15)
192 self.client.tpm.write(cmd)
195 rsp2 = self.client.tpm.read()
198 self.assertEqual(len(rsp1), 15)
199 self.assertEqual(len(rsp2), 10 + 2 + 32)
201 def test_send_two_cmds(self): argument
210 self.client.tpm.write(cmd)
213 self.client.tpm.write(cmd)
214 rsp = self.client.tpm.read()
218 rsp = self.client.tpm.read()
223 self.assertEqual(rejected, True)
226 def setUp(self): argument
229 def test_make_two_spaces(self): argument
243 def test_flush_context(self): argument
253 def test_get_handles(self): argument
265 self.assertEqual(len(handles), 2)
270 def test_invalid_cc(self): argument
290 self.assertEqual(rc, tpm2.TPM2_RC_COMMAND_CODE |
294 def setUp(self): argument
297 def test_async(self): argument