Lines Matching refs:handle

130 	struct ree_fs_ta_handle *handle;  in ree_fs_ta_open()  local
142 handle = calloc(1, sizeof(*handle)); in ree_fs_ta_open()
143 if (!handle) in ree_fs_ta_open()
224 handle->bs_hdr = bs_hdr; in ree_fs_ta_open()
261 res = tee_ta_decrypt_init(&handle->enc_ctx, ehdr, in ree_fs_ta_open()
267 handle->ehdr = ehdr; in ree_fs_ta_open()
275 handle->nw_ta = ta; in ree_fs_ta_open()
276 handle->nw_ta_size = ta_size; in ree_fs_ta_open()
277 handle->offs = offs; in ree_fs_ta_open()
278 handle->hash_ctx = hash_ctx; in ree_fs_ta_open()
279 handle->shdr = shdr; in ree_fs_ta_open()
280 handle->mobj = mobj; in ree_fs_ta_open()
281 *h = (struct ts_store_handle *)handle; in ree_fs_ta_open()
292 free(handle); in ree_fs_ta_open()
299 struct ree_fs_ta_handle *handle = (struct ree_fs_ta_handle *)h; in ree_fs_ta_get_size() local
301 *size = handle->shdr->img_size; in ree_fs_ta_get_size()
308 struct ree_fs_ta_handle *handle = (struct ree_fs_ta_handle *)h; in ree_fs_ta_get_tag() local
310 if (!tag || *tag_len < handle->shdr->hash_size) { in ree_fs_ta_get_tag()
311 *tag_len = handle->shdr->hash_size; in ree_fs_ta_get_tag()
314 *tag_len = handle->shdr->hash_size; in ree_fs_ta_get_tag()
316 memcpy(tag, SHDR_GET_HASH(handle->shdr), handle->shdr->hash_size); in ree_fs_ta_get_tag()
437 struct ree_fs_ta_handle *handle = (struct ree_fs_ta_handle *)h; in ree_fs_ta_read() local
439 uint8_t *src = (uint8_t *)handle->nw_ta + handle->offs; in ree_fs_ta_read()
444 if (ADD_OVERFLOW(handle->offs, len, &next_offs) || in ree_fs_ta_read()
445 next_offs > handle->nw_ta_size) in ree_fs_ta_read()
448 if (handle->shdr->img_type == SHDR_ENCRYPTED_TA) { in ree_fs_ta_read()
451 res = tee_ta_decrypt_update(handle->enc_ctx, dst, src, in ree_fs_ta_read()
467 res = tee_ta_decrypt_update(handle->enc_ctx, b, in ree_fs_ta_read()
473 res = crypto_hash_update(handle->hash_ctx, b, in ree_fs_ta_read()
489 res = crypto_hash_update(handle->hash_ctx, dst, len); in ree_fs_ta_read()
494 handle->offs = next_offs; in ree_fs_ta_read()
495 if (handle->offs == handle->nw_ta_size) { in ree_fs_ta_read()
496 if (handle->shdr->img_type == SHDR_ENCRYPTED_TA) { in ree_fs_ta_read()
501 res = tee_ta_decrypt_final(handle->enc_ctx, in ree_fs_ta_read()
502 handle->ehdr, NULL, NULL, 0); in ree_fs_ta_read()
510 res = check_digest(handle); in ree_fs_ta_read()
514 if (handle->bs_hdr) in ree_fs_ta_read()
515 res = check_update_version(handle->bs_hdr); in ree_fs_ta_read()
522 struct ree_fs_ta_handle *handle = (struct ree_fs_ta_handle *)h; in ree_fs_ta_close() local
524 if (!handle) in ree_fs_ta_close()
526 thread_rpc_free_payload(handle->mobj); in ree_fs_ta_close()
527 crypto_hash_free_ctx(handle->hash_ctx); in ree_fs_ta_close()
528 free(handle->shdr); in ree_fs_ta_close()
529 free(handle->ehdr); in ree_fs_ta_close()
530 free(handle->bs_hdr); in ree_fs_ta_close()
531 free(handle); in ree_fs_ta_close()
567 struct buf_ree_fs_ta_handle *handle = NULL; in buf_ta_open() local
570 handle = calloc(1, sizeof(*handle)); in buf_ta_open()
571 if (!handle) in buf_ta_open()
573 res = ree_fs_ta_open(uuid, &handle->h); in buf_ta_open()
576 res = ree_fs_ta_get_size(handle->h, &handle->ta_size); in buf_ta_open()
580 res = ree_fs_ta_get_tag(handle->h, NULL, &handle->tag_len); in buf_ta_open()
585 handle->tag = malloc(handle->tag_len); in buf_ta_open()
586 if (!handle->tag) { in buf_ta_open()
590 res = ree_fs_ta_get_tag(handle->h, handle->tag, &handle->tag_len); in buf_ta_open()
594 handle->mm = tee_mm_alloc(&tee_mm_sec_ddr, handle->ta_size); in buf_ta_open()
595 if (!handle->mm) { in buf_ta_open()
599 handle->buf = phys_to_virt(tee_mm_get_smem(handle->mm), in buf_ta_open()
600 MEM_AREA_TA_RAM, handle->ta_size); in buf_ta_open()
601 if (!handle->buf) { in buf_ta_open()
605 res = ree_fs_ta_read(handle->h, handle->buf, handle->ta_size); in buf_ta_open()
608 *h = (struct ts_store_handle *)handle; in buf_ta_open()
610 ree_fs_ta_close(handle->h); in buf_ta_open()
613 tee_mm_free(handle->mm); in buf_ta_open()
614 free(handle->tag); in buf_ta_open()
615 free(handle); in buf_ta_open()
623 struct buf_ree_fs_ta_handle *handle = (struct buf_ree_fs_ta_handle *)h; in buf_ta_get_size() local
625 *size = handle->ta_size; in buf_ta_get_size()
632 struct buf_ree_fs_ta_handle *handle = (struct buf_ree_fs_ta_handle *)h; in buf_ta_read() local
633 uint8_t *src = handle->buf + handle->offs; in buf_ta_read()
636 if (ADD_OVERFLOW(handle->offs, len, &next_offs) || in buf_ta_read()
637 next_offs > handle->ta_size) in buf_ta_read()
642 handle->offs = next_offs; in buf_ta_read()
649 struct buf_ree_fs_ta_handle *handle = (struct buf_ree_fs_ta_handle *)h; in buf_ta_get_tag() local
651 *tag_len = handle->tag_len; in buf_ta_get_tag()
652 if (!tag || *tag_len < handle->tag_len) in buf_ta_get_tag()
655 memcpy(tag, handle->tag, handle->tag_len); in buf_ta_get_tag()
662 struct buf_ree_fs_ta_handle *handle = (struct buf_ree_fs_ta_handle *)h; in buf_ta_close() local
664 if (!handle) in buf_ta_close()
666 tee_mm_free(handle->mm); in buf_ta_close()
667 free(handle->tag); in buf_ta_close()
668 free(handle); in buf_ta_close()