Lines Matching refs:buf
34 static void tpm2_buf_append_auth(struct tpm_buf *buf, u32 session_handle, in tpm2_buf_append_auth() argument
39 tpm_buf_append_u32(buf, 9 + nonce_len + hmac_len); in tpm2_buf_append_auth()
40 tpm_buf_append_u32(buf, session_handle); in tpm2_buf_append_auth()
41 tpm_buf_append_u16(buf, nonce_len); in tpm2_buf_append_auth()
44 tpm_buf_append(buf, nonce, nonce_len); in tpm2_buf_append_auth()
46 tpm_buf_append_u8(buf, attributes); in tpm2_buf_append_auth()
47 tpm_buf_append_u16(buf, hmac_len); in tpm2_buf_append_auth()
50 tpm_buf_append(buf, hmac, hmac_len); in tpm2_buf_append_auth()
67 struct tpm_buf buf; in tpm2_seal_trusted() local
82 rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_CREATE); in tpm2_seal_trusted()
86 tpm_buf_append_u32(&buf, options->keyhandle); in tpm2_seal_trusted()
87 tpm2_buf_append_auth(&buf, TPM2_RS_PW, in tpm2_seal_trusted()
94 tpm_buf_append_u16(&buf, 4 + TPM_DIGEST_SIZE + payload->key_len + 1); in tpm2_seal_trusted()
96 tpm_buf_append_u16(&buf, TPM_DIGEST_SIZE); in tpm2_seal_trusted()
97 tpm_buf_append(&buf, options->blobauth, TPM_DIGEST_SIZE); in tpm2_seal_trusted()
98 tpm_buf_append_u16(&buf, payload->key_len + 1); in tpm2_seal_trusted()
99 tpm_buf_append(&buf, payload->key, payload->key_len); in tpm2_seal_trusted()
100 tpm_buf_append_u8(&buf, payload->migratable); in tpm2_seal_trusted()
103 tpm_buf_append_u16(&buf, 14 + options->policydigest_len); in tpm2_seal_trusted()
104 tpm_buf_append_u16(&buf, TPM_ALG_KEYEDHASH); in tpm2_seal_trusted()
105 tpm_buf_append_u16(&buf, hash); in tpm2_seal_trusted()
109 tpm_buf_append_u32(&buf, 0); in tpm2_seal_trusted()
110 tpm_buf_append_u16(&buf, options->policydigest_len); in tpm2_seal_trusted()
111 tpm_buf_append(&buf, options->policydigest, in tpm2_seal_trusted()
114 tpm_buf_append_u32(&buf, TPM2_OA_USER_WITH_AUTH); in tpm2_seal_trusted()
115 tpm_buf_append_u16(&buf, 0); in tpm2_seal_trusted()
119 tpm_buf_append_u16(&buf, TPM_ALG_NULL); in tpm2_seal_trusted()
120 tpm_buf_append_u16(&buf, 0); in tpm2_seal_trusted()
123 tpm_buf_append_u16(&buf, 0); in tpm2_seal_trusted()
126 tpm_buf_append_u32(&buf, 0); in tpm2_seal_trusted()
128 if (buf.flags & TPM_BUF_OVERFLOW) { in tpm2_seal_trusted()
133 rc = tpm_send(chip, buf.data, tpm_buf_length(&buf)); in tpm2_seal_trusted()
137 blob_len = be32_to_cpup((__be32 *) &buf.data[TPM_HEADER_SIZE]); in tpm2_seal_trusted()
142 if (tpm_buf_length(&buf) < TPM_HEADER_SIZE + 4 + blob_len) { in tpm2_seal_trusted()
147 memcpy(payload->blob, &buf.data[TPM_HEADER_SIZE + 4], blob_len); in tpm2_seal_trusted()
151 tpm_buf_destroy(&buf); in tpm2_seal_trusted()
181 struct tpm_buf buf; in tpm2_load_cmd() local
196 rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_LOAD); in tpm2_load_cmd()
200 tpm_buf_append_u32(&buf, options->keyhandle); in tpm2_load_cmd()
201 tpm2_buf_append_auth(&buf, TPM2_RS_PW, in tpm2_load_cmd()
207 tpm_buf_append(&buf, payload->blob, blob_len); in tpm2_load_cmd()
209 if (buf.flags & TPM_BUF_OVERFLOW) { in tpm2_load_cmd()
214 rc = tpm_send(chip, buf.data, tpm_buf_length(&buf)); in tpm2_load_cmd()
217 (__be32 *) &buf.data[TPM_HEADER_SIZE]); in tpm2_load_cmd()
220 tpm_buf_destroy(&buf); in tpm2_load_cmd()
245 struct tpm_buf buf; in tpm2_unseal_cmd() local
250 rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_UNSEAL); in tpm2_unseal_cmd()
254 tpm_buf_append_u32(&buf, blob_handle); in tpm2_unseal_cmd()
255 tpm2_buf_append_auth(&buf, in tpm2_unseal_cmd()
263 rc = tpm_send(chip, buf.data, tpm_buf_length(&buf)); in tpm2_unseal_cmd()
269 (__be16 *) &buf.data[TPM_HEADER_SIZE + 4]); in tpm2_unseal_cmd()
275 if (tpm_buf_length(&buf) < TPM_HEADER_SIZE + 6 + data_len) { in tpm2_unseal_cmd()
279 data = &buf.data[TPM_HEADER_SIZE + 6]; in tpm2_unseal_cmd()
287 tpm_buf_destroy(&buf); in tpm2_unseal_cmd()