Lines Matching refs:res

578 	TEE_Result res;  in op_attr_secret_value_to_user()  local
583 res = copy_from_user(&s, size, sizeof(s)); in op_attr_secret_value_to_user()
584 if (res != TEE_SUCCESS) in op_attr_secret_value_to_user()
585 return res; in op_attr_secret_value_to_user()
588 res = copy_to_user(size, &key_size, sizeof(key_size)); in op_attr_secret_value_to_user()
589 if (res != TEE_SUCCESS) in op_attr_secret_value_to_user()
590 return res; in op_attr_secret_value_to_user()
601 TEE_Result res; in op_attr_secret_value_to_binary() local
605 res = op_u32_to_binary_helper(key->key_size, data, data_len, offs); in op_attr_secret_value_to_binary()
606 if (res != TEE_SUCCESS) in op_attr_secret_value_to_binary()
607 return res; in op_attr_secret_value_to_binary()
673 TEE_Result res = TEE_SUCCESS; in op_attr_bignum_to_user() local
678 res = copy_from_user(&s, size, sizeof(s)); in op_attr_bignum_to_user()
679 if (res != TEE_SUCCESS) in op_attr_bignum_to_user()
680 return res; in op_attr_bignum_to_user()
683 res = copy_to_user(size, &req_size, sizeof(req_size)); in op_attr_bignum_to_user()
684 if (res != TEE_SUCCESS) in op_attr_bignum_to_user()
685 return res; in op_attr_bignum_to_user()
692 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in op_attr_bignum_to_user()
697 if (res != TEE_SUCCESS) in op_attr_bignum_to_user()
698 return res; in op_attr_bignum_to_user()
710 TEE_Result res; in op_attr_bignum_to_binary() local
715 res = op_u32_to_binary_helper(n, data, data_len, offs); in op_attr_bignum_to_binary()
716 if (res != TEE_SUCCESS) in op_attr_bignum_to_binary()
717 return res; in op_attr_bignum_to_binary()
787 TEE_Result res; in op_attr_value_to_user() local
793 res = copy_from_user(&s, size, sizeof(s)); in op_attr_value_to_user()
794 if (res != TEE_SUCCESS) in op_attr_value_to_user()
795 return res; in op_attr_value_to_user()
868 TEE_Result res = copy_from_user(&d, src, sizeof(d)); in get_user_u64_as_size_t() local
874 if (!res && ADD_OVERFLOW(0, d, dst)) in get_user_u64_as_size_t()
877 return res; in get_user_u64_as_size_t()
890 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_get_info() local
893 res = tee_obj_get(to_user_ta_ctx(sess->ctx), in syscall_cryp_obj_get_info()
895 if (res != TEE_SUCCESS) in syscall_cryp_obj_get_info()
898 res = copy_to_user_private(info, &o->info, sizeof(o->info)); in syscall_cryp_obj_get_info()
901 return res; in syscall_cryp_obj_get_info()
908 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_restrict_usage() local
911 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_restrict_usage()
912 if (res != TEE_SUCCESS) in syscall_cryp_obj_restrict_usage()
918 return res; in syscall_cryp_obj_restrict_usage()
975 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_get_attr() local
982 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_get_attr()
983 if (res != TEE_SUCCESS) in syscall_cryp_obj_get_attr()
1054 TEE_Result res; in tee_obj_attr_to_binary() local
1070 res = attr_ops[ta->ops_index].to_binary(attr, data, len, &offs); in tee_obj_attr_to_binary()
1071 if (res != TEE_SUCCESS) in tee_obj_attr_to_binary()
1072 return res; in tee_obj_attr_to_binary()
1109 TEE_Result res; in tee_obj_attr_copy_from() local
1131 res = attr_ops[ta->ops_index].from_obj(attr, src_attr); in tee_obj_attr_copy_from()
1132 if (res != TEE_SUCCESS) in tee_obj_attr_copy_from()
1133 return res; in tee_obj_attr_copy_from()
1180 res = attr_ops[ta->ops_index].from_obj(attr, src_attr); in tee_obj_attr_copy_from()
1181 if (res != TEE_SUCCESS) in tee_obj_attr_copy_from()
1182 return res; in tee_obj_attr_copy_from()
1223 TEE_Result res = TEE_SUCCESS; in tee_obj_set_type() local
1245 res = check_key_size(type_props, max_key_size); in tee_obj_set_type()
1246 if (res) in tee_obj_set_type()
1247 return res; in tee_obj_set_type()
1257 res = crypto_acipher_alloc_rsa_public_key(o->attr, in tee_obj_set_type()
1261 res = crypto_acipher_alloc_rsa_keypair(o->attr, max_key_size); in tee_obj_set_type()
1264 res = crypto_acipher_alloc_dsa_public_key(o->attr, in tee_obj_set_type()
1268 res = crypto_acipher_alloc_dsa_keypair(o->attr, max_key_size); in tee_obj_set_type()
1271 res = crypto_acipher_alloc_dh_keypair(o->attr, max_key_size); in tee_obj_set_type()
1278 res = crypto_acipher_alloc_ecc_public_key(o->attr, obj_type, in tee_obj_set_type()
1286 res = crypto_acipher_alloc_ecc_keypair(o->attr, obj_type, in tee_obj_set_type()
1299 if (res != TEE_SUCCESS) in tee_obj_set_type()
1300 return res; in tee_obj_set_type()
1313 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_alloc() local
1321 res = tee_obj_set_type(o, obj_type, max_key_size); in syscall_cryp_obj_alloc()
1322 if (res != TEE_SUCCESS) { in syscall_cryp_obj_alloc()
1324 return res; in syscall_cryp_obj_alloc()
1329 res = copy_kaddr_to_uref(obj, o); in syscall_cryp_obj_alloc()
1330 if (res != TEE_SUCCESS) in syscall_cryp_obj_alloc()
1332 return res; in syscall_cryp_obj_alloc()
1338 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_close() local
1341 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_close()
1342 if (res != TEE_SUCCESS) in syscall_cryp_obj_close()
1343 return res; in syscall_cryp_obj_close()
1359 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_reset() local
1362 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_reset()
1363 if (res != TEE_SUCCESS) in syscall_cryp_obj_reset()
1364 return res; in syscall_cryp_obj_reset()
1384 TEE_Result res = TEE_SUCCESS; in copy_in_attrs() local
1391 res = vm_check_access_rights(&utc->uctx, in copy_in_attrs()
1395 if (res != TEE_SUCCESS) in copy_in_attrs()
1396 return res; in copy_in_attrs()
1409 res = vm_check_access_rights(&utc->uctx, flags, buf, in copy_in_attrs()
1411 if (res != TEE_SUCCESS) in copy_in_attrs()
1412 return res; in copy_in_attrs()
1553 TEE_Result res = TEE_SUCCESS; in tee_svc_cryp_obj_populate_type() local
1574 res = ops->from_user(attr, &attrs[n].content.value, in tee_svc_cryp_obj_populate_type()
1577 res = ops->from_user(attr, attrs[n].content.ref.buffer, in tee_svc_cryp_obj_populate_type()
1579 if (res != TEE_SUCCESS) in tee_svc_cryp_obj_populate_type()
1580 return res; in tee_svc_cryp_obj_populate_type()
1597 res = get_ec_key_size(attrs[n].content.value.a, in tee_svc_cryp_obj_populate_type()
1599 if (res != TEE_SUCCESS) in tee_svc_cryp_obj_populate_type()
1600 return res; in tee_svc_cryp_obj_populate_type()
1612 res = check_key_size(type_props, obj_size); in tee_svc_cryp_obj_populate_type()
1613 if (res != TEE_SUCCESS) in tee_svc_cryp_obj_populate_type()
1647 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_populate() local
1653 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_populate()
1654 if (res != TEE_SUCCESS) in syscall_cryp_obj_populate()
1655 return res; in syscall_cryp_obj_populate()
1676 res = copy_in_attrs(to_user_ta_ctx(sess->ctx), usr_attrs, attr_count, in syscall_cryp_obj_populate()
1678 if (res != TEE_SUCCESS) in syscall_cryp_obj_populate()
1681 res = tee_svc_cryp_check_attr(ATTR_USAGE_POPULATE, type_props, in syscall_cryp_obj_populate()
1683 if (res != TEE_SUCCESS) in syscall_cryp_obj_populate()
1686 res = tee_svc_cryp_obj_populate_type(o, type_props, attrs, attr_count); in syscall_cryp_obj_populate()
1687 if (res == TEE_SUCCESS) in syscall_cryp_obj_populate()
1692 return res; in syscall_cryp_obj_populate()
1698 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_copy() local
1702 res = tee_obj_get(to_user_ta_ctx(sess->ctx), in syscall_cryp_obj_copy()
1704 if (res != TEE_SUCCESS) in syscall_cryp_obj_copy()
1705 return res; in syscall_cryp_obj_copy()
1707 res = tee_obj_get(to_user_ta_ctx(sess->ctx), in syscall_cryp_obj_copy()
1709 if (res != TEE_SUCCESS) in syscall_cryp_obj_copy()
1710 return res; in syscall_cryp_obj_copy()
1719 res = tee_obj_attr_copy_from(dst_o, src_o); in syscall_cryp_obj_copy()
1720 if (res != TEE_SUCCESS) in syscall_cryp_obj_copy()
1721 return res; in syscall_cryp_obj_copy()
1768 TEE_Result res = TEE_SUCCESS; in tee_svc_obj_generate_key_rsa() local
1773 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_rsa()
1775 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_rsa()
1776 return res; in tee_svc_obj_generate_key_rsa()
1778 res = check_pub_rsa_key(key->e); in tee_svc_obj_generate_key_rsa()
1779 if (res) in tee_svc_obj_generate_key_rsa()
1780 return res; in tee_svc_obj_generate_key_rsa()
1784 res = crypto_acipher_gen_rsa_key(key, key_size); in tee_svc_obj_generate_key_rsa()
1785 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_rsa()
1786 return res; in tee_svc_obj_generate_key_rsa()
1798 TEE_Result res; in tee_svc_obj_generate_key_dsa() local
1801 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_dsa()
1803 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_dsa()
1804 return res; in tee_svc_obj_generate_key_dsa()
1806 res = crypto_acipher_gen_dsa_key(o->attr, key_size); in tee_svc_obj_generate_key_dsa()
1807 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_dsa()
1808 return res; in tee_svc_obj_generate_key_dsa()
1820 TEE_Result res; in tee_svc_obj_generate_key_dh() local
1826 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_dh()
1828 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_dh()
1829 return res; in tee_svc_obj_generate_key_dh()
1837 res = crypto_acipher_gen_dh_key(tee_dh_key, dh_q, dh_xbits, key_size); in tee_svc_obj_generate_key_dh()
1838 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_dh()
1839 return res; in tee_svc_obj_generate_key_dh()
1852 TEE_Result res; in tee_svc_obj_generate_key_ecc() local
1856 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_ecc()
1858 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_ecc()
1859 return res; in tee_svc_obj_generate_key_ecc()
1863 res = crypto_acipher_gen_ecc_key(tee_ecc_key, key_size); in tee_svc_obj_generate_key_ecc()
1864 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_ecc()
1865 return res; in tee_svc_obj_generate_key_ecc()
1880 TEE_Result res = TEE_SUCCESS; in syscall_obj_generate_key() local
1888 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_obj_generate_key()
1889 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
1890 return res; in syscall_obj_generate_key()
1906 res = check_key_size(type_props, key_size); in syscall_obj_generate_key()
1907 if (res) in syscall_obj_generate_key()
1908 return res; in syscall_obj_generate_key()
1916 res = copy_in_attrs(to_user_ta_ctx(sess->ctx), usr_params, param_count, in syscall_obj_generate_key()
1918 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
1921 res = tee_svc_cryp_check_attr(ATTR_USAGE_GENERATE_KEY, type_props, in syscall_obj_generate_key()
1923 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
1950 res = TEE_ERROR_EXCESS_DATA; in syscall_obj_generate_key()
1954 res = crypto_rng_read((void *)(key + 1), byte_size); in syscall_obj_generate_key()
1955 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
1966 res = tee_svc_obj_generate_key_rsa(o, type_props, key_size, in syscall_obj_generate_key()
1968 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
1973 res = tee_svc_obj_generate_key_dsa(o, type_props, key_size, in syscall_obj_generate_key()
1975 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
1980 res = tee_svc_obj_generate_key_dh(o, type_props, key_size, in syscall_obj_generate_key()
1982 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
1989 res = tee_svc_obj_generate_key_ecc(o, type_props, key_size, in syscall_obj_generate_key()
1991 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
1996 res = TEE_ERROR_BAD_FORMAT; in syscall_obj_generate_key()
2001 if (res == TEE_SUCCESS) { in syscall_obj_generate_key()
2005 return res; in syscall_obj_generate_key()
2168 TEE_Result res = TEE_SUCCESS; in syscall_cryp_state_alloc() local
2174 res = tee_obj_get(utc, uref_to_vaddr(key1), &o1); in syscall_cryp_state_alloc()
2175 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2176 return res; in syscall_cryp_state_alloc()
2179 res = tee_svc_cryp_check_key_type(o1, algo, mode); in syscall_cryp_state_alloc()
2180 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2181 return res; in syscall_cryp_state_alloc()
2184 res = tee_obj_get(utc, uref_to_vaddr(key2), &o2); in syscall_cryp_state_alloc()
2185 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2186 return res; in syscall_cryp_state_alloc()
2189 res = tee_svc_cryp_check_key_type(o2, algo, mode); in syscall_cryp_state_alloc()
2190 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2191 return res; in syscall_cryp_state_alloc()
2206 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2208 res = crypto_cipher_alloc_ctx(&cs->ctx, algo); in syscall_cryp_state_alloc()
2209 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2215 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2217 res = crypto_authenc_alloc_ctx(&cs->ctx, algo); in syscall_cryp_state_alloc()
2218 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2224 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2226 res = crypto_mac_alloc_ctx(&cs->ctx, algo); in syscall_cryp_state_alloc()
2227 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2233 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2235 res = crypto_hash_alloc_ctx(&cs->ctx, algo); in syscall_cryp_state_alloc()
2236 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2244 res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_state_alloc()
2248 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2253 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2256 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2260 res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_state_alloc()
2263 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2266 res = copy_kaddr_to_uref(state, cs); in syscall_cryp_state_alloc()
2267 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2281 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2283 return res; in syscall_cryp_state_alloc()
2289 TEE_Result res = TEE_SUCCESS; in syscall_cryp_state_copy() local
2293 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(dst), &cs_dst); in syscall_cryp_state_copy()
2294 if (res != TEE_SUCCESS) in syscall_cryp_state_copy()
2295 return res; in syscall_cryp_state_copy()
2297 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(src), &cs_src); in syscall_cryp_state_copy()
2298 if (res != TEE_SUCCESS) in syscall_cryp_state_copy()
2299 return res; in syscall_cryp_state_copy()
2337 TEE_Result res = TEE_SUCCESS; in syscall_cryp_state_free() local
2340 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_cryp_state_free()
2341 if (res != TEE_SUCCESS) in syscall_cryp_state_free()
2342 return res; in syscall_cryp_state_free()
2352 TEE_Result res = TEE_SUCCESS; in syscall_hash_init() local
2355 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_hash_init()
2356 if (res != TEE_SUCCESS) in syscall_hash_init()
2357 return res; in syscall_hash_init()
2361 res = crypto_hash_init(cs->ctx); in syscall_hash_init()
2362 if (res != TEE_SUCCESS) in syscall_hash_init()
2363 return res; in syscall_hash_init()
2370 res = tee_obj_get(to_user_ta_ctx(sess->ctx), in syscall_hash_init()
2372 if (res != TEE_SUCCESS) in syscall_hash_init()
2373 return res; in syscall_hash_init()
2379 res = crypto_mac_init(cs->ctx, (void *)(key + 1), in syscall_hash_init()
2381 if (res != TEE_SUCCESS) in syscall_hash_init()
2382 return res; in syscall_hash_init()
2399 TEE_Result res = TEE_SUCCESS; in syscall_hash_update() local
2409 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_hash_update()
2413 if (res != TEE_SUCCESS) in syscall_hash_update()
2414 return res; in syscall_hash_update()
2416 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_hash_update()
2417 if (res != TEE_SUCCESS) in syscall_hash_update()
2418 return res; in syscall_hash_update()
2425 res = crypto_hash_update(cs->ctx, chunk, chunk_size); in syscall_hash_update()
2426 if (res != TEE_SUCCESS) in syscall_hash_update()
2427 return res; in syscall_hash_update()
2430 res = crypto_mac_update(cs->ctx, chunk, chunk_size); in syscall_hash_update()
2431 if (res != TEE_SUCCESS) in syscall_hash_update()
2432 return res; in syscall_hash_update()
2447 TEE_Result res = TEE_SUCCESS; in syscall_hash_final() local
2455 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_hash_final()
2459 if (res != TEE_SUCCESS) in syscall_hash_final()
2460 return res; in syscall_hash_final()
2462 res = get_user_u64_as_size_t(&hlen, hash_len); in syscall_hash_final()
2463 if (res != TEE_SUCCESS) in syscall_hash_final()
2464 return res; in syscall_hash_final()
2466 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_hash_final()
2471 if (res != TEE_SUCCESS) in syscall_hash_final()
2472 return res; in syscall_hash_final()
2474 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_hash_final()
2475 if (res != TEE_SUCCESS) in syscall_hash_final()
2476 return res; in syscall_hash_final()
2483 res = tee_alg_get_digest_size(cs->algo, &hash_size); in syscall_hash_final()
2484 if (res != TEE_SUCCESS) in syscall_hash_final()
2485 return res; in syscall_hash_final()
2487 res = TEE_ERROR_SHORT_BUFFER; in syscall_hash_final()
2492 res = crypto_hash_update(cs->ctx, chunk, chunk_size); in syscall_hash_final()
2493 if (res != TEE_SUCCESS) in syscall_hash_final()
2494 return res; in syscall_hash_final()
2497 res = crypto_hash_final(cs->ctx, hash, hash_size); in syscall_hash_final()
2498 if (res != TEE_SUCCESS) in syscall_hash_final()
2499 return res; in syscall_hash_final()
2503 res = tee_alg_get_digest_size(cs->algo, &hash_size); in syscall_hash_final()
2504 if (res != TEE_SUCCESS) in syscall_hash_final()
2505 return res; in syscall_hash_final()
2507 res = TEE_ERROR_SHORT_BUFFER; in syscall_hash_final()
2512 res = crypto_mac_update(cs->ctx, chunk, chunk_size); in syscall_hash_final()
2513 if (res != TEE_SUCCESS) in syscall_hash_final()
2514 return res; in syscall_hash_final()
2517 res = crypto_mac_final(cs->ctx, hash, hash_size); in syscall_hash_final()
2518 if (res != TEE_SUCCESS) in syscall_hash_final()
2519 return res; in syscall_hash_final()
2529 return res; in syscall_hash_final()
2539 TEE_Result res = TEE_SUCCESS; in syscall_cipher_init() local
2542 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_cipher_init()
2543 if (res != TEE_SUCCESS) in syscall_cipher_init()
2544 return res; in syscall_cipher_init()
2549 res = vm_check_access_rights(&utc->uctx, in syscall_cipher_init()
2553 if (res != TEE_SUCCESS) in syscall_cipher_init()
2554 return res; in syscall_cipher_init()
2556 res = tee_obj_get(utc, cs->key1, &o); in syscall_cipher_init()
2557 if (res != TEE_SUCCESS) in syscall_cipher_init()
2558 return res; in syscall_cipher_init()
2570 res = crypto_cipher_init(cs->ctx, cs->mode, in syscall_cipher_init()
2575 res = crypto_cipher_init(cs->ctx, cs->mode, in syscall_cipher_init()
2579 if (res != TEE_SUCCESS) in syscall_cipher_init()
2580 return res; in syscall_cipher_init()
2594 TEE_Result res = TEE_SUCCESS; in tee_svc_cipher_update_helper() local
2597 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in tee_svc_cipher_update_helper()
2598 if (res != TEE_SUCCESS) in tee_svc_cipher_update_helper()
2599 return res; in tee_svc_cipher_update_helper()
2604 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in tee_svc_cipher_update_helper()
2608 if (res != TEE_SUCCESS) in tee_svc_cipher_update_helper()
2609 return res; in tee_svc_cipher_update_helper()
2619 res = get_user_u64_as_size_t(&dlen, dst_len); in tee_svc_cipher_update_helper()
2620 if (res != TEE_SUCCESS) in tee_svc_cipher_update_helper()
2621 return res; in tee_svc_cipher_update_helper()
2623 res = vm_check_access_rights(uctx, flags, (uaddr_t)dst, dlen); in tee_svc_cipher_update_helper()
2624 if (res != TEE_SUCCESS) in tee_svc_cipher_update_helper()
2625 return res; in tee_svc_cipher_update_helper()
2629 res = TEE_ERROR_SHORT_BUFFER; in tee_svc_cipher_update_helper()
2635 res = tee_do_cipher_update(cs->ctx, cs->algo, cs->mode, in tee_svc_cipher_update_helper()
2645 if ((res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) && in tee_svc_cipher_update_helper()
2651 res = res2; in tee_svc_cipher_update_helper()
2654 return res; in tee_svc_cipher_update_helper()
2816 TEE_Result res = TEE_ERROR_GENERIC; in get_sm2_kep_params() local
2832 res = crypto_acipher_alloc_ecc_public_key(peer_key, in get_sm2_kep_params()
2835 if (res) in get_sm2_kep_params()
2836 return res; in get_sm2_kep_params()
2838 res = crypto_acipher_alloc_ecc_public_key(peer_eph_key, in get_sm2_kep_params()
2841 if (res) in get_sm2_kep_params()
2899 res = TEE_ERROR_BAD_PARAMETERS; in get_sm2_kep_params()
2905 res = TEE_ERROR_BAD_PARAMETERS; in get_sm2_kep_params()
2914 return res; in get_sm2_kep_params()
2924 TEE_Result res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_derive_key() local
2933 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_cryp_derive_key()
2934 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
2935 return res; in syscall_cryp_derive_key()
2943 res = copy_in_attrs(utc, usr_params, param_count, params); in syscall_cryp_derive_key()
2944 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
2948 res = tee_obj_get(utc, cs->key1, &ko); in syscall_cryp_derive_key()
2949 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
2952 res = tee_obj_get(utc, uref_to_vaddr(derived_key), &so); in syscall_cryp_derive_key()
2953 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
2962 res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_derive_key()
2973 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
2980 res = TEE_ERROR_OVERFLOW; in syscall_cryp_derive_key()
2989 res = crypto_acipher_dh_shared_secret(ko->attr, in syscall_cryp_derive_key()
2991 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3000 res = TEE_ERROR_OUT_OF_MEMORY; in syscall_cryp_derive_key()
3013 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3034 res = TEE_ERROR_NOT_IMPLEMENTED; in syscall_cryp_derive_key()
3039 res = crypto_acipher_alloc_ecc_public_key(&key_public, key_type, in syscall_cryp_derive_key()
3041 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3053 res = crypto_acipher_ecc_shared_secret(ko->attr, &key_public, in syscall_cryp_derive_key()
3057 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3074 res = get_hkdf_params(params, param_count, &salt, &salt_len, in syscall_cryp_derive_key()
3076 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3081 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3085 res = tee_cryp_hkdf(hash_id, ikm, ik->key_size, salt, salt_len, in syscall_cryp_derive_key()
3088 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3103 res = get_concat_kdf_params(params, param_count, &info, in syscall_cryp_derive_key()
3105 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3110 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3114 res = tee_cryp_concat_kdf(hash_id, shared_secret, ss->key_size, in syscall_cryp_derive_key()
3117 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3132 res = get_pbkdf2_params(params, param_count, &salt, &salt_len, in syscall_cryp_derive_key()
3134 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3139 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3143 res = tee_cryp_pbkdf2(hash_id, password, ss->key_size, salt, in syscall_cryp_derive_key()
3146 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3163 res = tee_obj_get(utc, cs->key2, &ko2); in syscall_cryp_derive_key()
3164 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3167 res = get_sm2_kep_params(params, param_count, &peer_key, in syscall_cryp_derive_key()
3169 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3175 res = crypto_acipher_sm2_kep_derive(ko->attr, /* key1 */ in syscall_cryp_derive_key()
3180 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3190 res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_derive_key()
3194 return res; in syscall_cryp_derive_key()
3200 TEE_Result res = TEE_SUCCESS; in syscall_cryp_random_number_generate() local
3202 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_cryp_random_number_generate()
3205 if (res != TEE_SUCCESS) in syscall_cryp_random_number_generate()
3206 return res; in syscall_cryp_random_number_generate()
3208 res = crypto_rng_read(buf, blen); in syscall_cryp_random_number_generate()
3209 if (res != TEE_SUCCESS) in syscall_cryp_random_number_generate()
3210 return res; in syscall_cryp_random_number_generate()
3212 return res; in syscall_cryp_random_number_generate()
3222 TEE_Result res = TEE_SUCCESS; in syscall_authenc_init() local
3225 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_authenc_init()
3229 if (res != TEE_SUCCESS) in syscall_authenc_init()
3230 return res; in syscall_authenc_init()
3232 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_init()
3233 if (res != TEE_SUCCESS) in syscall_authenc_init()
3234 return res; in syscall_authenc_init()
3236 res = tee_obj_get(to_user_ta_ctx(sess->ctx), cs->key1, &o); in syscall_authenc_init()
3237 if (res != TEE_SUCCESS) in syscall_authenc_init()
3238 return res; in syscall_authenc_init()
3243 res = crypto_authenc_init(cs->ctx, cs->mode, (uint8_t *)(key + 1), in syscall_authenc_init()
3246 if (res != TEE_SUCCESS) in syscall_authenc_init()
3247 return res; in syscall_authenc_init()
3259 TEE_Result res = TEE_SUCCESS; in syscall_authenc_update_aad() local
3262 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_authenc_update_aad()
3266 if (res != TEE_SUCCESS) in syscall_authenc_update_aad()
3267 return res; in syscall_authenc_update_aad()
3269 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_update_aad()
3270 if (res != TEE_SUCCESS) in syscall_authenc_update_aad()
3271 return res; in syscall_authenc_update_aad()
3279 res = crypto_authenc_update_aad(cs->ctx, cs->mode, aad_data, in syscall_authenc_update_aad()
3281 if (res != TEE_SUCCESS) in syscall_authenc_update_aad()
3282 return res; in syscall_authenc_update_aad()
3294 TEE_Result res = TEE_SUCCESS; in syscall_authenc_update_payload() local
3297 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_update_payload()
3298 if (res != TEE_SUCCESS) in syscall_authenc_update_payload()
3299 return res; in syscall_authenc_update_payload()
3307 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_authenc_update_payload()
3311 if (res != TEE_SUCCESS) in syscall_authenc_update_payload()
3312 return res; in syscall_authenc_update_payload()
3314 res = get_user_u64_as_size_t(&dlen, dst_len); in syscall_authenc_update_payload()
3315 if (res != TEE_SUCCESS) in syscall_authenc_update_payload()
3316 return res; in syscall_authenc_update_payload()
3318 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_authenc_update_payload()
3323 if (res != TEE_SUCCESS) in syscall_authenc_update_payload()
3324 return res; in syscall_authenc_update_payload()
3327 res = TEE_ERROR_SHORT_BUFFER; in syscall_authenc_update_payload()
3331 res = crypto_authenc_update_payload(cs->ctx, cs->mode, src_data, in syscall_authenc_update_payload()
3334 if (res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) { in syscall_authenc_update_payload()
3338 res = res2; in syscall_authenc_update_payload()
3341 return res; in syscall_authenc_update_payload()
3352 TEE_Result res = TEE_SUCCESS; in syscall_authenc_enc_final() local
3356 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_enc_final()
3357 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
3358 return res; in syscall_authenc_enc_final()
3369 res = vm_check_access_rights(uctx, in syscall_authenc_enc_final()
3373 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
3374 return res; in syscall_authenc_enc_final()
3379 res = get_user_u64_as_size_t(&dlen, dst_len); in syscall_authenc_enc_final()
3380 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
3381 return res; in syscall_authenc_enc_final()
3383 res = vm_check_access_rights(uctx, in syscall_authenc_enc_final()
3388 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
3389 return res; in syscall_authenc_enc_final()
3393 res = TEE_ERROR_SHORT_BUFFER; in syscall_authenc_enc_final()
3397 res = get_user_u64_as_size_t(&tlen, tag_len); in syscall_authenc_enc_final()
3398 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
3399 return res; in syscall_authenc_enc_final()
3401 res = vm_check_access_rights(uctx, in syscall_authenc_enc_final()
3406 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
3407 return res; in syscall_authenc_enc_final()
3409 res = crypto_authenc_enc_final(cs->ctx, src_data, src_len, dst_data, in syscall_authenc_enc_final()
3413 if (res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) { in syscall_authenc_enc_final()
3427 return res; in syscall_authenc_enc_final()
3437 TEE_Result res = TEE_SUCCESS; in syscall_authenc_dec_final() local
3440 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_dec_final()
3441 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
3442 return res; in syscall_authenc_dec_final()
3453 res = vm_check_access_rights(uctx, in syscall_authenc_dec_final()
3457 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
3458 return res; in syscall_authenc_dec_final()
3463 res = get_user_u64_as_size_t(&dlen, dst_len); in syscall_authenc_dec_final()
3464 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
3465 return res; in syscall_authenc_dec_final()
3467 res = vm_check_access_rights(uctx, in syscall_authenc_dec_final()
3472 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
3473 return res; in syscall_authenc_dec_final()
3477 res = TEE_ERROR_SHORT_BUFFER; in syscall_authenc_dec_final()
3481 res = vm_check_access_rights(uctx, TEE_MEMORY_ACCESS_READ, in syscall_authenc_dec_final()
3483 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
3484 return res; in syscall_authenc_dec_final()
3486 res = crypto_authenc_dec_final(cs->ctx, src_data, src_len, dst_data, in syscall_authenc_dec_final()
3490 if ((res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) && in syscall_authenc_dec_final()
3498 return res; in syscall_authenc_dec_final()
3529 TEE_Result res = TEE_SUCCESS; in syscall_asymm_operate() local
3540 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_asymm_operate()
3541 if (res != TEE_SUCCESS) in syscall_asymm_operate()
3542 return res; in syscall_asymm_operate()
3544 res = vm_check_access_rights(&utc->uctx, in syscall_asymm_operate()
3548 if (res != TEE_SUCCESS) in syscall_asymm_operate()
3549 return res; in syscall_asymm_operate()
3551 res = get_user_u64_as_size_t(&dlen, dst_len); in syscall_asymm_operate()
3552 if (res != TEE_SUCCESS) in syscall_asymm_operate()
3553 return res; in syscall_asymm_operate()
3555 res = vm_check_access_rights(&utc->uctx, in syscall_asymm_operate()
3560 if (res != TEE_SUCCESS) in syscall_asymm_operate()
3561 return res; in syscall_asymm_operate()
3569 res = copy_in_attrs(utc, usr_params, num_params, params); in syscall_asymm_operate()
3570 if (res != TEE_SUCCESS) in syscall_asymm_operate()
3573 res = tee_obj_get(utc, cs->key1, &o); in syscall_asymm_operate()
3574 if (res != TEE_SUCCESS) in syscall_asymm_operate()
3577 res = TEE_ERROR_GENERIC; in syscall_asymm_operate()
3584 res = crypto_acipher_rsanopad_encrypt(o->attr, src_data, in syscall_asymm_operate()
3588 res = crypto_acipher_rsanopad_decrypt(o->attr, src_data, in syscall_asymm_operate()
3596 res = TEE_ERROR_GENERIC; in syscall_asymm_operate()
3602 res = crypto_acipher_sm2_pke_encrypt(o->attr, src_data, in syscall_asymm_operate()
3606 res = crypto_acipher_sm2_pke_decrypt(o->attr, src_data, in syscall_asymm_operate()
3610 res = TEE_ERROR_GENERIC; in syscall_asymm_operate()
3629 res = crypto_acipher_rsaes_encrypt(cs->algo, o->attr, in syscall_asymm_operate()
3634 res = crypto_acipher_rsaes_decrypt( in syscall_asymm_operate()
3638 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_operate()
3657 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_operate()
3661 res = crypto_acipher_rsassa_sign(cs->algo, o->attr, salt_len, in syscall_asymm_operate()
3669 res = crypto_acipher_dsa_sign(cs->algo, o->attr, src_data, in syscall_asymm_operate()
3678 res = crypto_acipher_ecc_sign(cs->algo, o->attr, src_data, in syscall_asymm_operate()
3682 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_operate()
3689 if (res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) { in syscall_asymm_operate()
3696 return res; in syscall_asymm_operate()
3707 TEE_Result res = TEE_SUCCESS; in syscall_asymm_verify() local
3715 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_asymm_verify()
3716 if (res != TEE_SUCCESS) in syscall_asymm_verify()
3717 return res; in syscall_asymm_verify()
3722 res = vm_check_access_rights(&utc->uctx, in syscall_asymm_verify()
3726 if (res != TEE_SUCCESS) in syscall_asymm_verify()
3727 return res; in syscall_asymm_verify()
3729 res = vm_check_access_rights(&utc->uctx, in syscall_asymm_verify()
3733 if (res != TEE_SUCCESS) in syscall_asymm_verify()
3734 return res; in syscall_asymm_verify()
3742 res = copy_in_attrs(utc, usr_params, num_params, params); in syscall_asymm_verify()
3743 if (res != TEE_SUCCESS) in syscall_asymm_verify()
3746 res = tee_obj_get(utc, cs->key1, &o); in syscall_asymm_verify()
3747 if (res != TEE_SUCCESS) in syscall_asymm_verify()
3750 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_verify()
3758 res = tee_alg_get_digest_size(hash_algo, &hash_size); in syscall_asymm_verify()
3759 if (res != TEE_SUCCESS) in syscall_asymm_verify()
3762 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_verify()
3768 res = crypto_acipher_rsassa_verify(cs->algo, o->attr, salt_len, in syscall_asymm_verify()
3775 res = tee_alg_get_digest_size(hash_algo, &hash_size); in syscall_asymm_verify()
3776 if (res != TEE_SUCCESS) in syscall_asymm_verify()
3807 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_verify()
3811 res = crypto_acipher_dsa_verify(cs->algo, o->attr, data, in syscall_asymm_verify()
3817 res = crypto_acipher_ecc_verify(cs->algo, o->attr, data, in syscall_asymm_verify()
3822 res = TEE_ERROR_NOT_SUPPORTED; in syscall_asymm_verify()
3827 return res; in syscall_asymm_verify()