Lines Matching refs:res

101 	TEE_Result res = TEE_SUCCESS;  in ta_operation_open()  local
116 res = thread_rpc_cmd(OPTEE_RPC_CMD_FS, ARRAY_SIZE(params), params); in ta_operation_open()
117 if (!res) in ta_operation_open()
120 return res; in ta_operation_open()
163 TEE_Result res = maybe_grow_files(db, idx); in set_file() local
165 if (!res) in set_file()
168 return res; in set_file()
197 TEE_Result res = db->ops->read(db->fh, idx * l, entry, NULL, &l); in read_ent() local
199 if (!res && l != sizeof(*entry)) in read_ent()
202 return res; in read_ent()
215 TEE_Result res; in tadb_open() local
227 res = db->ops->open(&po, NULL, &db->fh); in tadb_open()
228 if (res == TEE_ERROR_ITEM_NOT_FOUND) in tadb_open()
229 res = db->ops->create(&po, false, NULL, 0, NULL, 0, in tadb_open()
232 if (res) in tadb_open()
237 return res; in tadb_open()
242 TEE_Result res = TEE_SUCCESS; in tee_tadb_open() local
247 res = tadb_open(&tadb_db); in tee_tadb_open()
248 if (res) in tee_tadb_open()
255 return res; in tee_tadb_open()
282 TEE_Result res; in tadb_authenc_init() local
286 res = crypto_authenc_alloc_ctx(&ctx, TADB_AUTH_ENC_ALG); in tadb_authenc_init()
287 if (res) in tadb_authenc_init()
288 return res; in tadb_authenc_init()
290 res = crypto_authenc_init(ctx, mode, entry->key, sizeof(entry->key), in tadb_authenc_init()
293 if (res) in tadb_authenc_init()
298 return res; in tadb_authenc_init()
304 TEE_Result res; in tadb_update_payload() local
307 res = crypto_authenc_update_payload(ctx, mode, (const uint8_t *)src, in tadb_update_payload()
309 assert(res || sz == len); in tadb_update_payload()
310 return res; in tadb_update_payload()
315 TEE_Result res; in populate_files() local
339 res = read_ent(db, idx, &entry); in populate_files()
340 if (res) { in populate_files()
341 if (res == TEE_ERROR_ITEM_NOT_FOUND) in populate_files()
353 res = write_ent(db, idx, &entry); in populate_files()
354 if (res) in populate_files()
359 res = set_file(db, entry.file_number); in populate_files()
360 if (res) in populate_files()
369 return res; in populate_files()
375 TEE_Result res; in tee_tadb_ta_create() local
386 res = tee_tadb_open(&ta->db); in tee_tadb_ta_create()
387 if (res) in tee_tadb_ta_create()
396 res = populate_files(ta->db); in tee_tadb_ta_create()
397 if (res) in tee_tadb_ta_create()
406 res = set_file(ta->db, i); in tee_tadb_ta_create()
407 if (res) in tee_tadb_ta_create()
415 res = crypto_rng_read(ta->entry.iv, sizeof(ta->entry.iv)); in tee_tadb_ta_create()
416 if (res) in tee_tadb_ta_create()
419 res = crypto_rng_read(ta->entry.key, sizeof(ta->entry.key)); in tee_tadb_ta_create()
420 if (res) in tee_tadb_ta_create()
423 res = ta_operation_open(OPTEE_RPC_FS_CREATE, ta->entry.file_number, in tee_tadb_ta_create()
425 if (res) in tee_tadb_ta_create()
428 res = tadb_authenc_init(TEE_MODE_ENCRYPT, &ta->entry, &ta->ctx); in tee_tadb_ta_create()
429 if (res) in tee_tadb_ta_create()
443 return res; in tee_tadb_ta_create()
449 TEE_Result res; in tee_tadb_ta_write() local
458 res = tee_fs_rpc_write_init(&op, OPTEE_RPC_CMD_FS, ta->fd, in tee_tadb_ta_write()
460 if (res) in tee_tadb_ta_write()
461 return res; in tee_tadb_ta_write()
463 res = tadb_update_payload(ta->ctx, TEE_MODE_ENCRYPT, in tee_tadb_ta_write()
465 if (res) in tee_tadb_ta_write()
466 return res; in tee_tadb_ta_write()
468 res = tee_fs_rpc_write_final(&op); in tee_tadb_ta_write()
469 if (res) in tee_tadb_ta_write()
470 return res; in tee_tadb_ta_write()
498 TEE_Result res; in find_ent() local
511 res = read_ent(db, idx, &entry); in find_ent()
512 if (res) { in find_ent()
513 if (res == TEE_ERROR_ITEM_NOT_FOUND) in find_ent()
515 return res; in find_ent()
526 return res; in find_ent()
532 TEE_Result res = find_ent(db, &null_uuid, idx, NULL); in find_free_ent_idx() local
538 if (res == TEE_ERROR_ITEM_NOT_FOUND) in find_free_ent_idx()
540 return res; in find_free_ent_idx()
545 TEE_Result res; in tee_tadb_ta_close_and_commit() local
552 res = crypto_authenc_enc_final(ta->ctx, NULL, 0, NULL, &dsz, in tee_tadb_ta_close_and_commit()
554 if (res) in tee_tadb_ta_close_and_commit()
567 res = find_ent(ta->db, &ta->entry.prop.uuid, &idx, &old_ent); in tee_tadb_ta_close_and_commit()
568 if (!res) { in tee_tadb_ta_close_and_commit()
571 res = find_free_ent_idx(ta->db, &idx); in tee_tadb_ta_close_and_commit()
572 if (res) in tee_tadb_ta_close_and_commit()
575 res = write_ent(ta->db, idx, &ta->entry); in tee_tadb_ta_close_and_commit()
576 if (res) in tee_tadb_ta_close_and_commit()
594 return res; in tee_tadb_ta_close_and_commit()
603 TEE_Result res; in tee_tadb_ta_delete() local
608 res = tee_tadb_open(&db); in tee_tadb_ta_delete()
609 if (res) in tee_tadb_ta_delete()
610 return res; in tee_tadb_ta_delete()
613 res = find_ent(db, uuid, &idx, &entry); in tee_tadb_ta_delete()
614 if (res) { in tee_tadb_ta_delete()
617 return res; in tee_tadb_ta_delete()
621 res = write_ent(db, idx, &null_entry); in tee_tadb_ta_delete()
625 if (res) in tee_tadb_ta_delete()
626 return res; in tee_tadb_ta_delete()
635 TEE_Result res = TEE_SUCCESS; in tee_tadb_ta_open() local
646 res = tee_tadb_open(&ta->db); in tee_tadb_ta_open()
647 if (res) in tee_tadb_ta_open()
651 res = find_ent(ta->db, uuid, &idx, &ta->entry); in tee_tadb_ta_open()
653 if (res) in tee_tadb_ta_open()
656 res = ta_operation_open(OPTEE_RPC_FS_OPEN, ta->entry.file_number, in tee_tadb_ta_open()
658 if (res) in tee_tadb_ta_open()
661 res = tadb_authenc_init(TEE_MODE_DECRYPT, &ta->entry, &ta->ctx); in tee_tadb_ta_open()
662 if (res) in tee_tadb_ta_open()
672 return res; in tee_tadb_ta_open()
698 TEE_Result res; in ta_load() local
714 res = thread_rpc_cmd(OPTEE_RPC_CMD_FS, ARRAY_SIZE(params), params); in ta_load()
715 if (res) { in ta_load()
719 return res; in ta_load()
725 TEE_Result res = TEE_SUCCESS; in tee_tadb_ta_read() local
734 res = ta_load(ta); in tee_tadb_ta_read()
735 if (res) in tee_tadb_ta_read()
736 return res; in tee_tadb_ta_read()
757 res = tadb_update_payload(ta->ctx, TEE_MODE_DECRYPT, in tee_tadb_ta_read()
760 if (res) in tee_tadb_ta_read()
764 res = copy_to_user((uint8_t *)buf_user + num_bytes, in tee_tadb_ta_read()
766 if (res) in tee_tadb_ta_read()
776 res = crypto_authenc_dec_final(ta->ctx, NULL, 0, NULL, &dl, in tee_tadb_ta_read()
778 if (res) in tee_tadb_ta_read()
779 return res; in tee_tadb_ta_read()
784 return res; in tee_tadb_ta_read()