tpm_initialize.py 文件源码

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

项目:python-keylime 作者: mit-ll 项目源码 文件源码
def test_ownerpw(owner_pw,reentry=False):
    tmppath = None
    try:
        #make a temp file for the output 
        _,tmppath = tempfile.mkstemp()
        (output,code) = tpm_exec.run("getpubek -pwdo %s -ok %s"%(owner_pw,tmppath),raiseOnError=False) 
        if code!=tpm_exec.EXIT_SUCESS:
            if len(output)>0 and output[0].startswith("Error Authentication failed (Incorrect Password) from TPM_OwnerReadPubek"):
                return False
            elif len(output)>0 and output[0].startswith("Error Defend lock running from TPM_OwnerReadPubek"):
                if reentry:
                    logger.error("Unable to unlock TPM")
                    return False
                # tpm got locked. lets try to unlock it
                logger.error("TPM is locked from too many invalid owner password attempts, attempting to unlock with password: %s"%owner_pw)
                # i have no idea why, but runnig this twice seems to actually work
                tpm_exec.run("resetlockvalue -pwdo %s"%owner_pw,raiseOnError=False) 
                tpm_exec.run("resetlockvalue -pwdo %s"%owner_pw,raiseOnError=False) 
                return test_ownerpw(owner_pw,True)
            else:
                raise Exception("test ownerpw, getpubek failed with code "+str(code)+": "+str(output))
    finally:
        if tmppath is not None:
            os.remove(tmppath)
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号