def get_mod_from_tpm(keyhandle):
(retout,code) = tpm_exec.run("getpubkey -ha %s -pwdk %s"%(keyhandle,get_tpm_metadata('aik_pw')),raiseOnError=False)
if code!=tpm_exec.EXIT_SUCESS and len(retout)>0 and retout[0].startswith("Error Authentication failed (Incorrect Password) from TPM_GetPubKey"):
return None
# now to parse things!
inMod = False
public_modulus = []
for line in retout:
if line.startswith("Modulus"):
inMod = True
continue
if inMod:
tokens = line.split()
for token in tokens:
public_modulus.append(string.atol(token,base=16))
return base64.b64encode(bytearray(public_modulus))
评论列表
文章目录