def get_pub_ek(): # assumes that owner_pw is correct at this point
owner_pw = get_tpm_metadata('owner_pw')
tmppath = None
try:
#make a temp file for the output
tmpfd,tmppath = tempfile.mkstemp()
(output,code) = tpm_exec.run("getpubek -pwdo %s -ok %s"%(owner_pw,tmppath),raiseOnError=False) # generates pubek.pem
if code!=tpm_exec.EXIT_SUCESS:
raise Exception("getpubek failed with code "+str(code)+": "+str(output))
# read in the output
f = open(tmppath,"rb")
ek = f.read()
f.close()
os.close(tmpfd)
finally:
if tmppath is not None:
os.remove(tmppath)
set_tpm_metadata('ek',ek)
评论列表
文章目录