Lines Matching refs:res

111 	TEE_Result res;  in rpc_read()  local
116 res = ht->stor->rpc_read_init(ht->stor_aux, &op, type, idx, vers, &p); in rpc_read()
117 if (res != TEE_SUCCESS) in rpc_read()
118 return res; in rpc_read()
120 res = ht->stor->rpc_read_final(&op, &bytes); in rpc_read()
121 if (res != TEE_SUCCESS) in rpc_read()
122 return res; in rpc_read()
150 TEE_Result res; in rpc_write() local
154 res = ht->stor->rpc_write_init(ht->stor_aux, &op, type, idx, vers, &p); in rpc_write()
155 if (res != TEE_SUCCESS) in rpc_write()
156 return res; in rpc_write()
180 TEE_Result res; in traverse_post_order() local
190 res = traverse_post_order(targ, node->child[0]); in traverse_post_order()
191 if (res != TEE_SUCCESS) in traverse_post_order()
192 return res; in traverse_post_order()
194 res = traverse_post_order(targ, node->child[1]); in traverse_post_order()
195 if (res != TEE_SUCCESS) in traverse_post_order()
196 return res; in traverse_post_order()
323 TEE_Result res; in init_head_from_data() local
328 res = rpc_read_node(ht, 1, idx, &ht->root.node); in init_head_from_data()
329 if (res != TEE_SUCCESS) in init_head_from_data()
330 return res; in init_head_from_data()
334 res = rpc_read_head(ht, idx, &ht->head); in init_head_from_data()
335 if (res != TEE_SUCCESS) in init_head_from_data()
336 return res; in init_head_from_data()
347 res = rpc_read_head(ht, idx, head + idx); in init_head_from_data()
348 if (res != TEE_SUCCESS) in init_head_from_data()
349 return res; in init_head_from_data()
356 res = rpc_read_node(ht, 1, idx, &ht->root.node); in init_head_from_data()
357 if (res != TEE_SUCCESS) in init_head_from_data()
358 return res; in init_head_from_data()
370 TEE_Result res; in init_tree_from_data() local
384 res = rpc_read_node(ht, node_id, committed_version, in init_tree_from_data()
386 if (res != TEE_SUCCESS) in init_tree_from_data()
387 return res; in init_tree_from_data()
389 res = get_node(ht, true, node_id, &nc); in init_tree_from_data()
390 if (res != TEE_SUCCESS) in init_tree_from_data()
391 return res; in init_tree_from_data()
403 TEE_Result res; in calc_node_hash() local
407 res = crypto_hash_init(ctx); in calc_node_hash()
408 if (res != TEE_SUCCESS) in calc_node_hash()
409 return res; in calc_node_hash()
411 res = crypto_hash_update(ctx, ndata, nsize); in calc_node_hash()
412 if (res != TEE_SUCCESS) in calc_node_hash()
413 return res; in calc_node_hash()
416 res = crypto_hash_update(ctx, (void *)meta, sizeof(*meta)); in calc_node_hash()
417 if (res != TEE_SUCCESS) in calc_node_hash()
418 return res; in calc_node_hash()
422 res = crypto_hash_update(ctx, node->child[0]->node.hash, in calc_node_hash()
424 if (res != TEE_SUCCESS) in calc_node_hash()
425 return res; in calc_node_hash()
429 res = crypto_hash_update(ctx, node->child[1]->node.hash, in calc_node_hash()
431 if (res != TEE_SUCCESS) in calc_node_hash()
432 return res; in calc_node_hash()
443 TEE_Result res = TEE_SUCCESS; in authenc_init() local
457 res = crypto_rng_read(iv, TEE_FS_HTREE_IV_SIZE); in authenc_init()
458 if (res != TEE_SUCCESS) in authenc_init()
459 return res; in authenc_init()
462 res = crypto_authenc_alloc_ctx(&ctx, alg); in authenc_init()
463 if (res != TEE_SUCCESS) in authenc_init()
464 return res; in authenc_init()
466 res = crypto_authenc_init(ctx, mode, ht->fek, TEE_FS_HTREE_FEK_SIZE, iv, in authenc_init()
469 if (res != TEE_SUCCESS) in authenc_init()
473 res = crypto_authenc_update_aad(ctx, mode, ht->root.node.hash, in authenc_init()
475 if (res != TEE_SUCCESS) in authenc_init()
478 res = crypto_authenc_update_aad(ctx, mode, in authenc_init()
481 if (res != TEE_SUCCESS) in authenc_init()
485 res = crypto_authenc_update_aad(ctx, mode, ht->head.enc_fek, in authenc_init()
487 if (res != TEE_SUCCESS) in authenc_init()
490 res = crypto_authenc_update_aad(ctx, mode, iv, TEE_FS_HTREE_IV_SIZE); in authenc_init()
491 if (res != TEE_SUCCESS) in authenc_init()
501 return res; in authenc_init()
508 TEE_Result res; in authenc_decrypt_final() local
511 res = crypto_authenc_dec_final(ctx, crypt, len, plain, &out_size, tag, in authenc_decrypt_final()
516 if (res == TEE_SUCCESS && out_size != len) in authenc_decrypt_final()
518 if (res == TEE_ERROR_MAC_INVALID) in authenc_decrypt_final()
521 return res; in authenc_decrypt_final()
528 TEE_Result res; in authenc_encrypt_final() local
532 res = crypto_authenc_enc_final(ctx, plain, len, crypt, &out_size, tag, in authenc_encrypt_final()
537 if (res == TEE_SUCCESS && in authenc_encrypt_final()
541 return res; in authenc_encrypt_final()
546 TEE_Result res; in verify_root() local
549 res = tee_fs_fek_crypt(ht->uuid, TEE_MODE_DECRYPT, ht->head.enc_fek, in verify_root()
551 if (res != TEE_SUCCESS) in verify_root()
552 return res; in verify_root()
554 res = authenc_init(&ctx, TEE_MODE_DECRYPT, ht, NULL, sizeof(ht->imeta)); in verify_root()
555 if (res != TEE_SUCCESS) in verify_root()
556 return res; in verify_root()
566 TEE_Result res; in verify_node() local
570 res = calc_node_hash(node, NULL, ctx, digest); in verify_node()
572 res = calc_node_hash(node, &targ->ht->imeta.meta, ctx, digest); in verify_node()
573 if (res == TEE_SUCCESS && in verify_node()
577 return res; in verify_node()
582 TEE_Result res; in verify_tree() local
585 res = crypto_hash_alloc_ctx(&ctx, TEE_FS_HTREE_HASH_ALG); in verify_tree()
586 if (res != TEE_SUCCESS) in verify_tree()
587 return res; in verify_tree()
589 res = htree_traverse_post_order(ht, verify_node, ctx); in verify_tree()
592 return res; in verify_tree()
597 TEE_Result res; in init_root_node() local
600 res = crypto_hash_alloc_ctx(&ctx, TEE_FS_HTREE_HASH_ALG); in init_root_node()
601 if (res != TEE_SUCCESS) in init_root_node()
602 return res; in init_root_node()
607 res = calc_node_hash(&ht->root, &ht->imeta.meta, ctx, in init_root_node()
611 return res; in init_root_node()
618 TEE_Result res; in tee_fs_htree_open() local
631 res = crypto_rng_read(ht->fek, sizeof(ht->fek)); in tee_fs_htree_open()
632 if (res != TEE_SUCCESS) in tee_fs_htree_open()
635 res = tee_fs_fek_crypt(ht->uuid, TEE_MODE_ENCRYPT, ht->fek, in tee_fs_htree_open()
637 if (res != TEE_SUCCESS) in tee_fs_htree_open()
640 res = init_root_node(ht); in tee_fs_htree_open()
641 if (res != TEE_SUCCESS) in tee_fs_htree_open()
645 res = tee_fs_htree_sync_to_storage(&ht, hash); in tee_fs_htree_open()
646 if (res != TEE_SUCCESS) in tee_fs_htree_open()
648 res = rpc_write_head(ht, 0, &dummy_head); in tee_fs_htree_open()
650 res = init_head_from_data(ht, hash); in tee_fs_htree_open()
651 if (res != TEE_SUCCESS) in tee_fs_htree_open()
654 res = verify_root(ht); in tee_fs_htree_open()
655 if (res != TEE_SUCCESS) in tee_fs_htree_open()
658 res = init_tree_from_data(ht); in tee_fs_htree_open()
659 if (res != TEE_SUCCESS) in tee_fs_htree_open()
662 res = verify_tree(ht); in tee_fs_htree_open()
665 if (res == TEE_SUCCESS) in tee_fs_htree_open()
669 return res; in tee_fs_htree_open()
703 TEE_Result res; in htree_sync_node_to_storage() local
732 res = calc_node_hash(node, meta, targ->arg, node->node.hash); in htree_sync_node_to_storage()
733 if (res != TEE_SUCCESS) in htree_sync_node_to_storage()
734 return res; in htree_sync_node_to_storage()
744 TEE_Result res; in update_root() local
749 res = authenc_init(&ctx, TEE_MODE_ENCRYPT, ht, NULL, sizeof(ht->imeta)); in update_root()
750 if (res != TEE_SUCCESS) in update_root()
751 return res; in update_root()
760 TEE_Result res; in tee_fs_htree_sync_to_storage() local
770 res = crypto_hash_alloc_ctx(&ctx, TEE_FS_HTREE_HASH_ALG); in tee_fs_htree_sync_to_storage()
771 if (res != TEE_SUCCESS) in tee_fs_htree_sync_to_storage()
772 return res; in tee_fs_htree_sync_to_storage()
774 res = htree_traverse_post_order(ht, htree_sync_node_to_storage, ctx); in tee_fs_htree_sync_to_storage()
775 if (res != TEE_SUCCESS) in tee_fs_htree_sync_to_storage()
779 res = update_root(ht); in tee_fs_htree_sync_to_storage()
780 if (res != TEE_SUCCESS) in tee_fs_htree_sync_to_storage()
783 res = rpc_write_head(ht, ht->head.counter & 1, &ht->head); in tee_fs_htree_sync_to_storage()
784 if (res != TEE_SUCCESS) in tee_fs_htree_sync_to_storage()
792 if (res != TEE_SUCCESS) in tee_fs_htree_sync_to_storage()
794 return res; in tee_fs_htree_sync_to_storage()
800 TEE_Result res; in get_block_node() local
803 res = get_node(ht, create, BLOCK_NUM_TO_NODE_ID(block_num), &nd); in get_block_node()
804 if (res == TEE_SUCCESS) in get_block_node()
807 return res; in get_block_node()
814 TEE_Result res; in tee_fs_htree_write_block() local
824 res = get_block_node(ht, true, block_num, &node); in tee_fs_htree_write_block()
825 if (res != TEE_SUCCESS) in tee_fs_htree_write_block()
832 res = ht->stor->rpc_write_init(ht->stor_aux, &op, in tee_fs_htree_write_block()
835 if (res != TEE_SUCCESS) in tee_fs_htree_write_block()
838 res = authenc_init(&ctx, TEE_MODE_ENCRYPT, ht, &node->node, in tee_fs_htree_write_block()
840 if (res != TEE_SUCCESS) in tee_fs_htree_write_block()
842 res = authenc_encrypt_final(ctx, node->node.tag, block, in tee_fs_htree_write_block()
844 if (res != TEE_SUCCESS) in tee_fs_htree_write_block()
847 res = ht->stor->rpc_write_final(&op); in tee_fs_htree_write_block()
848 if (res != TEE_SUCCESS) in tee_fs_htree_write_block()
855 if (res != TEE_SUCCESS) in tee_fs_htree_write_block()
857 return res; in tee_fs_htree_write_block()
864 TEE_Result res; in tee_fs_htree_read_block() local
875 res = get_block_node(ht, false, block_num, &node); in tee_fs_htree_read_block()
876 if (res != TEE_SUCCESS) in tee_fs_htree_read_block()
880 res = ht->stor->rpc_read_init(ht->stor_aux, &op, in tee_fs_htree_read_block()
883 if (res != TEE_SUCCESS) in tee_fs_htree_read_block()
886 res = ht->stor->rpc_read_final(&op, &len); in tee_fs_htree_read_block()
887 if (res != TEE_SUCCESS) in tee_fs_htree_read_block()
890 res = TEE_ERROR_CORRUPT_OBJECT; in tee_fs_htree_read_block()
894 res = authenc_init(&ctx, TEE_MODE_DECRYPT, ht, &node->node, in tee_fs_htree_read_block()
896 if (res != TEE_SUCCESS) in tee_fs_htree_read_block()
899 res = authenc_decrypt_final(ctx, node->node.tag, enc_block, in tee_fs_htree_read_block()
902 if (res != TEE_SUCCESS) in tee_fs_htree_read_block()
904 return res; in tee_fs_htree_read_block()