Lines Matching full:self
204 def __init__(self, alg): argument
205 self.alg = alg
207 def __str__(self): argument
212 def __init__(self, name): argument
213 self.name = name
215 def __str__(self): argument
220 def __init__(self, alg): argument
221 self.alg = alg
223 def __str__(self): argument
228 def __init__(self, cc, rc): argument
229 self.cc = cc
230 self.rc = rc
233 self.name = TPM2_FMT1_ERRORS.get(rc & 0x3f, "TPM_RC_UNKNOWN")
235 self.name = TPM2_WARN_ERRORS.get(rc & 0x7f, "TPM_RC_UNKNOWN")
237 self.name = TPM2_VER1_ERRORS.get(rc & 0x7f, "TPM_RC_UNKNOWN")
239 self.name = TPM2_VER0_ERRORS.get(rc & 0x7f, "TPM_RC_UNKNOWN")
241 def __str__(self): argument
242 if self.cc:
243 return '%s: cc=0x%08x, rc=0x%08x' % (self.name, self.cc, self.rc)
245 return '%s: rc=0x%08x' % (self.name, self.rc)
251 def __init__(self, session_handle=TPM2_RS_PW, nonce=bytes(), argument
253 self.session_handle = session_handle
254 self.nonce = nonce
255 self.session_attributes = session_attributes
256 self.hmac = hmac
258 def __bytes__(self): argument
259 fmt = '>I H%us B H%us' % (len(self.nonce), len(self.hmac))
260 return struct.pack(fmt, self.session_handle, len(self.nonce),
261 self.nonce, self.session_attributes, len(self.hmac),
262 self.hmac)
264 def __len__(self): argument
265 fmt = '>I H%us B H%us' % (len(self.nonce), len(self.hmac))
272 def __init__(self, user_auth=bytes(), data=bytes()): argument
273 self.user_auth = user_auth
274 self.data = data
276 def __bytes__(self): argument
277 fmt = '>H%us H%us' % (len(self.user_auth), len(self.data))
278 return struct.pack(fmt, len(self.user_auth), self.user_auth,
279 len(self.data), self.data)
281 def __len__(self): argument
282 fmt = '>H%us H%us' % (len(self.user_auth), len(self.data))
296 def __fmt(self): argument
298 (len(self.auth_policy), len(self.parameters), len(self.unique))
300 def __init__(self, object_type, name_alg, object_attributes, argument
303 self.object_type = object_type
304 self.name_alg = name_alg
305 self.object_attributes = object_attributes
306 self.auth_policy = auth_policy
307 self.parameters = parameters
308 self.unique = unique
310 def __bytes__(self): argument
311 return struct.pack(self.__fmt(),
312 self.object_type,
313 self.name_alg,
314 self.object_attributes,
315 len(self.auth_policy),
316 self.auth_policy,
317 self.parameters,
318 len(self.unique),
319 self.unique)
321 def __len__(self): argument
322 return struct.calcsize(self.__fmt())
360 def __init__(self, flags = 0): argument
361 self.flags = flags
363 if (self.flags & Client.FLAG_SPACE) == 0:
364 self.tpm = open('/dev/tpm0', 'r+b', buffering=0)
366 self.tpm = open('/dev/tpmrm0', 'r+b', buffering=0)
368 if (self.flags & Client.FLAG_NONBLOCK):
369 flags = fcntl.fcntl(self.tpm, fcntl.F_GETFL)
371 fcntl.fcntl(self.tpm, fcntl.F_SETFL, flags)
372 self.tpm_poll = select.poll()
374 def __del__(self): argument
375 if self.tpm:
376 self.tpm.close()
378 def close(self): argument
379 self.tpm.close()
381 def send_cmd(self, cmd): argument
382 self.tpm.write(cmd)
384 if (self.flags & Client.FLAG_NONBLOCK):
385 self.tpm_poll.register(self.tpm, select.POLLIN)
386 self.tpm_poll.poll(10000)
388 rsp = self.tpm.read()
390 if (self.flags & Client.FLAG_NONBLOCK):
391 self.tpm_poll.unregister(self.tpm)
393 if (self.flags & Client.FLAG_DEBUG) != 0:
406 def read_pcr(self, i, bank_alg = TPM2_ALG_SHA1): argument
421 rsp = self.send_cmd(cmd)
438 def extend_pcr(self, i, dig, bank_alg = TPM2_ALG_SHA1): argument
455 self.send_cmd(cmd)
457 def start_auth_session(self, session_type, name_alg = TPM2_ALG_SHA1): argument
472 return struct.unpack('>I', self.send_cmd(cmd)[10:14])[0]
474 def __calc_pcr_digest(self, pcrs, bank_alg = TPM2_ALG_SHA1, argument
480 pcr = self.read_pcr(i, bank_alg)
487 def policy_pcr(self, handle, pcrs, bank_alg = TPM2_ALG_SHA1, argument
490 dig = self.__calc_pcr_digest(pcrs, bank_alg, name_alg)
512 self.send_cmd(cmd)
514 def policy_password(self, handle): argument
522 self.send_cmd(cmd)
524 def get_policy_digest(self, handle): argument
532 return self.send_cmd(cmd)[12:]
534 def flush_context(self, handle): argument
542 self.send_cmd(cmd)
544 def create_root_key(self, auth_value = bytes()): argument
587 return struct.unpack('>I', self.send_cmd(cmd)[10:14])[0]
589 def seal(self, parent_key, data, auth_value, policy_dig, argument
625 rsp = self.send_cmd(cmd)
629 def unseal(self, parent_key, blob, auth_value, policy_handle): argument
648 data_handle = struct.unpack('>I', self.send_cmd(cmd)[10:14])[0]
666 rsp = self.send_cmd(cmd)
668 self.flush_context(data_handle)
674 def reset_da_lock(self): argument
687 self.send_cmd(cmd)
689 def __get_cap_cnt(self, cap, pt, cnt): argument
699 rsp = self.send_cmd(cmd)[10:]
710 def get_cap(self, cap, pt): argument
715 next_handles, more_data = self.__get_cap_cnt(cap, pt, 1)
721 def get_cap_pcrs(self): argument
731 rsp = self.send_cmd(cmd)[10:]