Lines Matching refs:mgr
22 …isk_write_crypt_sector(sector_t *dst, const void *data, size_t size, const struct mem_tpm_mgr *mgr) in disk_write_crypt_sector() argument
25 *dst = disk_find_free(mgr); in disk_write_crypt_sector()
26 aes_encrypt_ctr(sector->iv_data, sizeof(sector->iv_data), data, size, &mgr->tm_key_e); in disk_write_crypt_sector()
27 aes_cmac(§or->mac, sector->data, sizeof(sector->data), &mgr->tm_key_e); in disk_write_crypt_sector()
34 static void disk_populate_used_vtpm(const struct mem_vtpm_page *src, const struct mem_tpm_mgr *mgr) in disk_populate_used_vtpm() argument
37 disk_set_used(src->disk_loc, mgr); in disk_populate_used_vtpm()
44 const struct mem_tpm_mgr *mgr) in disk_write_vtpm_page() argument
61 disk_write_crypt_sector(&dst->disk_loc, &pt, sizeof(pt), mgr); in disk_write_vtpm_page()
106 static void disk_populate_used_group(const struct mem_group_hdr *src, const struct mem_tpm_mgr *mgr) in disk_populate_used_group() argument
113 disk_set_used(src->disk_loc, mgr); in disk_populate_used_group()
115 disk_set_used(src->disk_inuse[i], mgr); in disk_populate_used_group()
124 disk_populate_used_vtpm(&group->data[i], mgr); in disk_populate_used_group()
129 const aes_context *group_key, const struct mem_tpm_mgr *mgr);
133 const aes_context *group_key, const struct mem_tpm_mgr *mgr) in disk_write_vtpm_itree() argument
144 disk_write_vtpm_page(page, group_key, mgr); in disk_write_vtpm_itree()
158 NR_ENTRIES_PER_ITREE, group_key, mgr); in disk_write_vtpm_itree()
161 disk_write_crypt_sector(&loc[i], &pt, sizeof(pt), mgr); in disk_write_vtpm_itree()
179 const struct mem_tpm_mgr *mgr) in disk_write_group_sector() argument
205 NR_ENTRIES_PER_GROUP_BASE, &key_e, mgr); in disk_write_group_sector()
207 generate_group_seals(group, mgr); in disk_write_group_sector()
212 disk_write_crypt_sector(&src->disk_loc, &disk, sizeof(disk), mgr); in disk_write_group_sector()
219 static void disk_write_seal_list(struct mem_tpm_mgr *mgr, struct mem_group *group) in disk_write_seal_list() argument
225 if (mgr->root_seals_valid & (1 + mgr->active_root)) in disk_write_seal_list()
229 memcpy(sblob.tpm_manager_uuid, mgr->uuid, 16); in disk_write_seal_list()
230 memcpy(&sblob.nvram_slot, &mgr->nvram_slot, 4); in disk_write_seal_list()
231 memcpy(&sblob.nvram_auth, &mgr->nvram_auth, 20); in disk_write_seal_list()
232 memcpy(&sblob.counter_index, &mgr->counter_index, 4); in disk_write_seal_list()
233 memcpy(&sblob.counter_auth, &mgr->counter_auth, 20); in disk_write_seal_list()
239 aes_encrypt_one(&sblob.tm_key, &mgr->tm_key, &mgr->nv_key); in disk_write_seal_list()
241 memcpy(&sblob.tm_key, &mgr->tm_key, 16); in disk_write_seal_list()
268 disk_write_sector(seal_loc(mgr), seal, sizeof(*seal)); in disk_write_seal_list()
269 mgr->root_seals_valid |= 1 + mgr->active_root; in disk_write_seal_list()
275 static void disk_populate_used_mgr(const struct mem_tpm_mgr *mgr) in disk_populate_used_mgr() argument
281 for(i=0; i < mgr->nr_groups; i++) in disk_populate_used_mgr()
282 disk_populate_used_group(&mgr->groups[i], mgr); in disk_populate_used_mgr()
285 static void disk_write_group_itree(struct mem_tpm_mgr *mgr, int base, int nr_entries,
288 static void disk_write_group_itree(struct mem_tpm_mgr *mgr, int base, int nr_entries, in disk_write_group_itree() argument
294 for(i=0; i < mgr->nr_groups; i++) { in disk_write_group_itree()
295 struct mem_group_hdr *group = mgr->groups + base + i; in disk_write_group_itree()
296 disk_write_group_sector(group, mgr); in disk_write_group_itree()
314 disk_write_group_itree(mgr, base, child_entries, pt.hash, pt.location, NR_ENTRIES_PER_ITREE); in disk_write_group_itree()
317 disk_write_crypt_sector(&loc[i], &pt, sizeof(pt), mgr); in disk_write_group_itree()
326 static void disk_write_root_sector(struct mem_tpm_mgr *mgr) in disk_write_root_sector() argument
331 root.v.sequence = native_be64(mgr->sequence); in disk_write_root_sector()
332 root.v.tpm_counter_value = mgr->counter_value; in disk_write_root_sector()
334 root.v.nr_groups = native_be32(mgr->nr_groups); in disk_write_root_sector()
336 …disk_write_group_itree(mgr, 0, mgr->nr_groups, root.v.group_hash, root.group_loc, NR_ENTRIES_PER_R… in disk_write_root_sector()
340 while (i < mgr->nr_groups) { in disk_write_root_sector()
342 struct mem_group_hdr *group = &mgr->groups[i]; in disk_write_root_sector()
364 …aes_encrypt_ctr(root_sect->iv_data, sizeof(root_sect->iv_data), &root, sizeof(root), &mgr->tm_key_… in disk_write_root_sector()
365 aes_cmac(&root_sect->mac, &root_sect->data, sizeof(root_sect->data), &mgr->tm_key_e); in disk_write_root_sector()
366 disk_write_sector(root_loc(mgr), root_sect, sizeof(*root_sect)); in disk_write_root_sector()
372 void disk_write_all(struct mem_tpm_mgr *mgr) in disk_write_all() argument
374 disk_flush_slot(mgr); in disk_write_all()
375 disk_populate_used_mgr(mgr); in disk_write_all()
376 disk_write_root_sector(mgr); in disk_write_all()
378 disk_write_seal_list(mgr, mgr->groups[0].v); in disk_write_all()
391 struct mem_tpm_mgr *mgr = calloc(1, sizeof(*mgr)); in vtpm_new_disk() local
393 do_random(mgr->uuid, 16); in vtpm_new_disk()
394 do_random(&mgr->tm_key, 16); in vtpm_new_disk()
395 do_random(&mgr->nvram_auth, 20); in vtpm_new_disk()
396 do_random(&mgr->counter_auth, 20); in vtpm_new_disk()
397 do_random(&mgr->nv_key, 16); in vtpm_new_disk()
399 aes_setup(&mgr->tm_key_e, &mgr->tm_key); in vtpm_new_disk()
402 rc = TPM_disk_nvalloc(&mgr->nvram_slot, mgr->nvram_auth); in vtpm_new_disk()
406 rc = TPM_disk_alloc_counter(&mgr->counter_index, mgr->counter_auth, &mgr->counter_value); in vtpm_new_disk()
410 mgr->nr_groups = 1; in vtpm_new_disk()
411 mgr->groups = calloc(1, sizeof(mgr->groups[0])); in vtpm_new_disk()
412 mgr->groups[0].v = vtpm_new_group(NULL); in vtpm_new_disk()
414 TPM_disk_nvwrite(&mgr->nv_key, 16, mgr->nvram_slot, mgr->nvram_auth); in vtpm_new_disk()
416 g_mgr = mgr; in vtpm_new_disk()