Lines Matching refs:res

55 	TEE_Result res = TEE_ERROR_GENERIC;  in generate_key()  local
57 res = allocate_key(); in generate_key()
58 if (res) in generate_key()
61 res = crypto_bignum_bin2bn((uint8_t *)&e, sizeof(e), key->e); in generate_key()
62 if (res) in generate_key()
72 res = crypto_acipher_gen_rsa_key(key, CFG_ATTESTATION_PTA_KEY_SIZE); in generate_key()
73 if (!res) in generate_key()
79 return res; in generate_key()
116 TEE_Result res = TEE_ERROR_GENERIC; in serialize_key() local
154 return res; in serialize_key()
159 TEE_Result res = TEE_ERROR_GENERIC; in deserialize_bignum() local
174 res = crypto_bignum_bin2bn(p, sz, bn); in deserialize_bignum()
175 if (res) in deserialize_bignum()
183 TEE_Result res = TEE_ERROR_GENERIC; in deserialize_key() local
187 res = allocate_key(); in deserialize_key()
188 if (res) in deserialize_key()
189 return res; in deserialize_key()
218 TEE_Result res = TEE_ERROR_BAD_STATE; in sec_storage_obj_read() local
231 res = tee_pobj_get(uuid, (void *)obj_id, obj_id_len, flags, in sec_storage_obj_read()
233 if (res) in sec_storage_obj_read()
234 return res; in sec_storage_obj_read()
236 res = po->fops->open(po, &file_size, &fh); in sec_storage_obj_read()
237 if (res) in sec_storage_obj_read()
241 res = po->fops->read(fh, offset, data, NULL, &read_len); in sec_storage_obj_read()
242 if (res == TEE_ERROR_CORRUPT_OBJECT) { in sec_storage_obj_read()
245 } else if (!res) { in sec_storage_obj_read()
253 return res; in sec_storage_obj_read()
265 TEE_Result res = TEE_SUCCESS; in sec_storage_obj_write() local
275 res = tee_pobj_get(uuid, (void *)obj_id, obj_id_len, flags, in sec_storage_obj_write()
277 if (res) in sec_storage_obj_write()
278 return res; in sec_storage_obj_write()
280 res = po->fops->open(po, NULL, &fh); in sec_storage_obj_write()
281 if (res == TEE_ERROR_ITEM_NOT_FOUND) in sec_storage_obj_write()
282 res = po->fops->create(po, false, NULL, 0, NULL, 0, in sec_storage_obj_write()
284 if (!res) { in sec_storage_obj_write()
285 res = po->fops->write(fh, offset, data, NULL, len); in sec_storage_obj_write()
291 return res; in sec_storage_obj_write()
296 TEE_Result res = TEE_ERROR_GENERIC; in load_key() local
299 res = sec_storage_obj_read(&pta_uuid, TEE_STORAGE_PRIVATE, in load_key()
302 if (res) in load_key()
303 return res; in load_key()
305 res = deserialize_key(buf, size); in load_key()
306 if (!res) in load_key()
309 return res; in load_key()
314 TEE_Result res = TEE_ERROR_GENERIC; in write_key() local
317 res = serialize_key(buf, size); in write_key()
318 if (res) in write_key()
319 return res; in write_key()
321 res = sec_storage_obj_write(&pta_uuid, TEE_STORAGE_PRIVATE, in write_key()
324 if (!res) in write_key()
326 return res; in write_key()
331 TEE_Result res = TEE_SUCCESS; in init_key() local
343 res = TEE_ERROR_OUT_OF_MEMORY; in init_key()
346 res = load_key(buf, size); in init_key()
347 if (res == TEE_ERROR_ITEM_NOT_FOUND) { in init_key()
348 res = generate_key(); in init_key()
349 if (res) in init_key()
351 res = write_key(buf, size); in init_key()
356 return res; in init_key()
362 TEE_Result res = TEE_ERROR_GENERIC; in cmd_get_pubkey() local
375 res = init_key(); in cmd_get_pubkey()
376 if (res) in cmd_get_pubkey()
377 return res; in cmd_get_pubkey()
383 res = TEE_ERROR_SHORT_BUFFER; in cmd_get_pubkey()
390 res = TEE_ERROR_SHORT_BUFFER; in cmd_get_pubkey()
395 return res; in cmd_get_pubkey()
400 TEE_Result res = TEE_ERROR_ITEM_NOT_FOUND; in hash_binary() local
406 res = ops->open(uuid, &h); in hash_binary()
407 if (!res) in hash_binary()
410 if (res) in hash_binary()
411 return res; in hash_binary()
420 res = ops->get_tag(h, hash, &tag_len); in hash_binary()
421 if (res) in hash_binary()
428 return res; in hash_binary()
435 TEE_Result res = TEE_SUCCESS; in digest_nonce_and_hash() local
438 res = crypto_hash_alloc_ctx(&ctx, TEE_ALG_SHA256); in digest_nonce_and_hash()
439 if (res) in digest_nonce_and_hash()
440 return res; in digest_nonce_and_hash()
441 res = crypto_hash_init(ctx); in digest_nonce_and_hash()
442 if (res) in digest_nonce_and_hash()
444 res = crypto_hash_update(ctx, nonce, nonce_sz); in digest_nonce_and_hash()
445 if (res) in digest_nonce_and_hash()
447 res = crypto_hash_update(ctx, hash, TEE_SHA256_HASH_SIZE); in digest_nonce_and_hash()
448 if (res) in digest_nonce_and_hash()
450 res = crypto_hash_final(ctx, digest, TEE_SHA256_HASH_SIZE); in digest_nonce_and_hash()
453 return res; in digest_nonce_and_hash()
476 TEE_Result res = TEE_SUCCESS; in sign_buffer() local
478 res = digest_nonce_and_hash(digest, nonce, nonce_sz, buf); in sign_buffer()
479 if (res) in sign_buffer()
480 return res; in sign_buffer()
521 TEE_Result res = TEE_SUCCESS; in hash_regions() local
528 res = crypto_hash_alloc_ctx(&ctx, TEE_ALG_SHA256); in hash_regions()
529 if (res) in hash_regions()
530 return res; in hash_regions()
532 res = crypto_hash_init(ctx); in hash_regions()
533 if (res) in hash_regions()
546 res = TEE_ERROR_OUT_OF_MEMORY; in hash_regions()
566 res = crypto_hash_update(ctx, (uint8_t *)r->va, r->size); in hash_regions()
567 if (res) in hash_regions()
573 if (res) in hash_regions()
576 res = crypto_hash_final(ctx, hash, TEE_SHA256_HASH_SIZE); in hash_regions()
580 return res; in hash_regions()
593 TEE_Result res = TEE_SUCCESS; in cmd_get_ta_shdr_digest() local
610 res = init_key(); in cmd_get_ta_shdr_digest()
611 if (res) in cmd_get_ta_shdr_digest()
612 return res; in cmd_get_ta_shdr_digest()
620 res = hash_binary(uuid, out); in cmd_get_ta_shdr_digest()
621 if (res) in cmd_get_ta_shdr_digest()
622 return res; in cmd_get_ta_shdr_digest()
634 TEE_Result res = TEE_SUCCESS; in cmd_hash_ta_memory() local
658 res = init_key(); in cmd_hash_ta_memory()
659 if (res) in cmd_hash_ta_memory()
660 return res; in cmd_hash_ta_memory()
669 res = hash_regions(&uctx->vm_info, out); in cmd_hash_ta_memory()
671 if (res) in cmd_hash_ta_memory()
672 return res; in cmd_hash_ta_memory()
684 TEE_Result res = TEE_SUCCESS; in cmd_hash_tee_memory() local
700 res = init_key(); in cmd_hash_tee_memory()
701 if (res) in cmd_hash_tee_memory()
702 return res; in cmd_hash_tee_memory()
710 res = crypto_hash_alloc_ctx(&ctx, TEE_ALG_SHA256); in cmd_hash_tee_memory()
711 if (res) in cmd_hash_tee_memory()
712 return res; in cmd_hash_tee_memory()
713 res = crypto_hash_init(ctx); in cmd_hash_tee_memory()
714 if (res) in cmd_hash_tee_memory()
716 res = crypto_hash_update(ctx, __text_start, in cmd_hash_tee_memory()
718 if (res) in cmd_hash_tee_memory()
720 res = crypto_hash_update(ctx, __text_data_end, in cmd_hash_tee_memory()
723 res = crypto_hash_update(ctx, __text_init_start, in cmd_hash_tee_memory()
725 if (res) in cmd_hash_tee_memory()
727 res = crypto_hash_update(ctx, __text_pageable_start, in cmd_hash_tee_memory()
730 if (res) in cmd_hash_tee_memory()
733 if (res) in cmd_hash_tee_memory()
735 res = crypto_hash_update(ctx, __rodata_start, in cmd_hash_tee_memory()
737 if (res) in cmd_hash_tee_memory()
740 res = crypto_hash_update(ctx, __rodata_init_start, in cmd_hash_tee_memory()
743 if (res) in cmd_hash_tee_memory()
745 res = crypto_hash_update(ctx, __rodata_pageable_start, in cmd_hash_tee_memory()
748 if (res) in cmd_hash_tee_memory()
751 res = crypto_hash_final(ctx, out, TEE_SHA256_HASH_SIZE); in cmd_hash_tee_memory()
752 if (res) in cmd_hash_tee_memory()
757 res = sign_buffer(out, out_sz, nonce, nonce_sz); in cmd_hash_tee_memory()
760 return res; in cmd_hash_tee_memory()
767 TEE_Result res = TEE_ERROR_BAD_PARAMETERS; in invoke_command() local
772 res = to_bounce_params(param_types, params, bparams, &eparams); in invoke_command()
773 if (res) in invoke_command()
774 return res; in invoke_command()
778 res = cmd_get_pubkey(param_types, eparams); in invoke_command()
781 res = cmd_get_ta_shdr_digest(param_types, eparams); in invoke_command()
784 res = cmd_hash_ta_memory(param_types, eparams); in invoke_command()
787 res = cmd_hash_tee_memory(param_types, eparams); in invoke_command()
794 if (!res && res2) in invoke_command()
795 res = res2; in invoke_command()
797 return res; in invoke_command()