tpm_initialize.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:python-keylime 作者: mit-ll 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号