ima_emulator_adapter.py 文件源码

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

项目:python-keylime 作者: mit-ll 项目源码 文件源码
def main(argv=sys.argv):

    if tpm_initialize.get_tpm_manufacturer() != 'IBM':
        raise Exception("This stub should only be used with the IBM TPM emulator")

    # initialize position in ML
    pos=0

    # check if pcr is clean
    output = tpm_exec.run("pcrread -ix %s"%common.IMA_PCR)[0]
    pcrval = output[0].split()[5]

    if pcrval != ima.START_HASH.encode('hex'):
        print "Warning: IMA PCR is not empty, trying to find the last updated file in the measurement list..."
        pos = ml_extend(common.IMA_ML, 0, pcrval)

    print "Monitoring %s"%(common.IMA_ML)
    poll_object = select.poll()
    fd_object = file(common.IMA_ML, "r")
    number = fd_object.fileno()
    poll_object.register(fd_object,select.POLLIN|select.POLLPRI)

    while True:
        results = poll_object.poll()
        for result in results:
            if result[0] != number:
                continue
            pos = ml_extend(common.IMA_ML,pos)
            #print "new POS %d"%pos
            time.sleep(0.2)
    sys.exit(1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号