Lines Matching refs:res

85 	TEE_Result res;  in rpc_load()  local
96 res = thread_rpc_cmd(OPTEE_RPC_CMD_LOAD_TA, 2, params); in rpc_load()
97 if (res != TEE_SUCCESS) in rpc_load()
98 return res; in rpc_load()
106 res = TEE_ERROR_SHORT_BUFFER; in rpc_load()
119 res = thread_rpc_cmd(OPTEE_RPC_CMD_LOAD_TA, 2, params); in rpc_load()
121 if (res != TEE_SUCCESS) in rpc_load()
124 return res; in rpc_load()
136 TEE_Result res = TEE_SUCCESS; in ree_fs_ta_open() local
147 res = rpc_load(uuid, &ta, &ta_size, &mobj); in ree_fs_ta_open()
148 if (res != TEE_SUCCESS) in ree_fs_ta_open()
154 res = TEE_ERROR_SECURITY; in ree_fs_ta_open()
159 res = shdr_verify_signature(shdr); in ree_fs_ta_open()
160 if (res != TEE_SUCCESS) in ree_fs_ta_open()
164 res = TEE_ERROR_SECURITY; in ree_fs_ta_open()
172 res = crypto_hash_alloc_ctx(&hash_ctx, in ree_fs_ta_open()
174 if (res != TEE_SUCCESS) in ree_fs_ta_open()
176 res = crypto_hash_init(hash_ctx); in ree_fs_ta_open()
177 if (res != TEE_SUCCESS) in ree_fs_ta_open()
179 res = crypto_hash_update(hash_ctx, (uint8_t *)shdr, sizeof(*shdr)); in ree_fs_ta_open()
180 if (res != TEE_SUCCESS) in ree_fs_ta_open()
184 res = TEE_ERROR_SECURITY; in ree_fs_ta_open()
195 res = TEE_ERROR_SECURITY; in ree_fs_ta_open()
201 res = TEE_ERROR_OUT_OF_MEMORY; in ree_fs_ta_open()
215 res = TEE_ERROR_SECURITY; in ree_fs_ta_open()
219 res = crypto_hash_update(hash_ctx, (uint8_t *)bs_hdr, in ree_fs_ta_open()
221 if (res != TEE_SUCCESS) in ree_fs_ta_open()
235 res = TEE_ERROR_SECURITY; in ree_fs_ta_open()
244 res = TEE_ERROR_SECURITY; in ree_fs_ta_open()
251 res = TEE_ERROR_OUT_OF_MEMORY; in ree_fs_ta_open()
257 res = crypto_hash_update(hash_ctx, (uint8_t *)ehdr, ehdr_sz); in ree_fs_ta_open()
258 if (res != TEE_SUCCESS) in ree_fs_ta_open()
261 res = tee_ta_decrypt_init(&handle->enc_ctx, ehdr, in ree_fs_ta_open()
263 if (res != TEE_SUCCESS) in ree_fs_ta_open()
271 res = TEE_ERROR_SECURITY; in ree_fs_ta_open()
293 return res; in ree_fs_ta_open()
324 TEE_Result res; in check_digest() local
329 res = crypto_hash_final(h->hash_ctx, digest, h->shdr->hash_size); in check_digest()
330 if (res != TEE_SUCCESS) { in check_digest()
331 res = TEE_ERROR_SECURITY; in check_digest()
335 res = TEE_ERROR_SECURITY; in check_digest()
338 return res; in check_digest()
346 TEE_Result res = TEE_SUCCESS; in check_update_version() local
362 res = ops->open(&pobj, NULL, &fh); in check_update_version()
363 if (res != TEE_SUCCESS && res != TEE_ERROR_ITEM_NOT_FOUND) in check_update_version()
366 if (res == TEE_ERROR_ITEM_NOT_FOUND) { in check_update_version()
367 res = ops->create(&pobj, false, NULL, 0, NULL, 0, NULL, 0, &fh); in check_update_version()
368 if (res != TEE_SUCCESS) in check_update_version()
371 res = ops->write(fh, 0, &db_hdr, sizeof(db_hdr)); in check_update_version()
372 if (res != TEE_SUCCESS) in check_update_version()
377 res = ops->read(fh, 0, &db_hdr, &len); in check_update_version()
378 if (res != TEE_SUCCESS) { in check_update_version()
381 res = TEE_ERROR_BAD_STATE; in check_update_version()
389 res = ops->read(fh, sizeof(db_hdr) + (i * len), &hdr_entry, in check_update_version()
391 if (res != TEE_SUCCESS) { in check_update_version()
394 res = TEE_ERROR_BAD_STATE; in check_update_version()
406 res = TEE_ERROR_ACCESS_CONFLICT; in check_update_version()
410 res = ops->write(fh, sizeof(db_hdr) + (i * len), hdr, in check_update_version()
412 if (res != TEE_SUCCESS) in check_update_version()
417 res = ops->write(fh, sizeof(db_hdr) + (db_hdr.nb_entries * len), in check_update_version()
419 if (res != TEE_SUCCESS) in check_update_version()
423 res = ops->write(fh, 0, &db_hdr, sizeof(db_hdr)); in check_update_version()
424 if (res != TEE_SUCCESS) in check_update_version()
431 return res; in check_update_version()
442 TEE_Result res = TEE_SUCCESS; in ree_fs_ta_read() local
451 res = tee_ta_decrypt_update(handle->enc_ctx, dst, src, in ree_fs_ta_read()
453 if (res != TEE_SUCCESS) in ree_fs_ta_read()
467 res = tee_ta_decrypt_update(handle->enc_ctx, b, in ree_fs_ta_read()
469 if (res) in ree_fs_ta_read()
473 res = crypto_hash_update(handle->hash_ctx, b, in ree_fs_ta_read()
475 if (res) in ree_fs_ta_read()
480 if (res != TEE_SUCCESS) in ree_fs_ta_read()
489 res = crypto_hash_update(handle->hash_ctx, dst, len); in ree_fs_ta_read()
490 if (res != TEE_SUCCESS) in ree_fs_ta_read()
501 res = tee_ta_decrypt_final(handle->enc_ctx, in ree_fs_ta_read()
503 if (res != TEE_SUCCESS) in ree_fs_ta_read()
510 res = check_digest(handle); in ree_fs_ta_read()
511 if (res != TEE_SUCCESS) in ree_fs_ta_read()
512 return res; in ree_fs_ta_read()
515 res = check_update_version(handle->bs_hdr); in ree_fs_ta_read()
517 return res; in ree_fs_ta_read()
568 TEE_Result res = TEE_SUCCESS; in buf_ta_open() local
573 res = ree_fs_ta_open(uuid, &handle->h); in buf_ta_open()
574 if (res) in buf_ta_open()
576 res = ree_fs_ta_get_size(handle->h, &handle->ta_size); in buf_ta_open()
577 if (res) in buf_ta_open()
580 res = ree_fs_ta_get_tag(handle->h, NULL, &handle->tag_len); in buf_ta_open()
581 if (res != TEE_ERROR_SHORT_BUFFER) { in buf_ta_open()
582 res = TEE_ERROR_GENERIC; in buf_ta_open()
587 res = TEE_ERROR_OUT_OF_MEMORY; in buf_ta_open()
590 res = ree_fs_ta_get_tag(handle->h, handle->tag, &handle->tag_len); in buf_ta_open()
591 if (res) in buf_ta_open()
596 res = TEE_ERROR_OUT_OF_MEMORY; in buf_ta_open()
602 res = TEE_ERROR_OUT_OF_MEMORY; in buf_ta_open()
605 res = ree_fs_ta_read(handle->h, handle->buf, handle->ta_size); in buf_ta_open()
606 if (res) in buf_ta_open()
612 if (res) { in buf_ta_open()
617 return res; in buf_ta_open()