uint32_t tcg_hash_extend(uint32_t addr, uint32_t len, uint32_t pcr) { struct TCG_HashAll tcg_hash_all; struct TCG_PassTroughtToTPM tcg_passtrough_to_tpm; char _unused[0x22]; tcg_hash_all.ipb_length = 0x0010; tcg_hash_all._reserved = 0x0000; tcg_hash_all.hash_data_ptr = addr; tcg_hash_all.hash_data_len = len; tcg_hash_all.algorithm_id = TPM_ALGO_SHA1; tcg_passtrough_to_tpm.ipb_length = 0x002a; tcg_passtrough_to_tpm._reserved1 = 0x0000; tcg_passtrough_to_tpm.opb_length = 0x0022; tcg_passtrough_to_tpm._reserved2 = 0x0000; tcg_passtrough_to_tpm.tpm_tag = __htons(TPM_TAG_RQU_COMMAND); tcg_passtrough_to_tpm.input_size = __htonl(0x00000022); tcg_passtrough_to_tpm.cmd_ordinal = __htonl(TPM_ORD_Extend); tcg_passtrough_to_tpm.pcr = __htonl(pcr); v86.addr = 0x1a; v86.eax = 0xbb05; v86.ebx = TCG_MAGIC; v86.ecx = 0x00000000; v86.edx = 0x00000000; v86.es = VTOPSEG(&tcg_hash_all); v86.edi = VTOPOFF(&tcg_hash_all); v86.ds = VTOPSEG(&tcg_passtrough_to_tpm.hash); v86.esi = VTOPOFF(&tcg_passtrough_to_tpm.hash); v86int(); if (v86.eax != TCG_PC_OK) return (v86.eax); v86.addr = 0x1a; v86.eax = 0xbb02; v86.ebx = TCG_MAGIC; v86.ecx = 0x00000000; v86.edx = 0x00000000; v86.es = VTOPSEG(&tcg_passtrough_to_tpm); v86.edi = VTOPOFF(&tcg_passtrough_to_tpm); v86.ds = VTOPSEG(&_unused); v86.esi = VTOPOFF(&_unused); v86int(); return (v86.eax); }
uint32_t htonl(uint32_t hl) { return (__htonl(hl)); }