Lines Matching refs:res
723 TEE_Result res = TEE_SUCCESS; in op_attr_secret_value_from_user() local
729 res = copy_from_user(key + 1, buffer, size); in op_attr_secret_value_from_user()
730 if (!res) in op_attr_secret_value_from_user()
733 return res; in op_attr_secret_value_from_user()
740 TEE_Result res; in op_attr_secret_value_to_user() local
745 res = copy_from_user(&s, size, sizeof(s)); in op_attr_secret_value_to_user()
746 if (res != TEE_SUCCESS) in op_attr_secret_value_to_user()
747 return res; in op_attr_secret_value_to_user()
750 res = copy_to_user(size, &key_size, sizeof(key_size)); in op_attr_secret_value_to_user()
751 if (res != TEE_SUCCESS) in op_attr_secret_value_to_user()
752 return res; in op_attr_secret_value_to_user()
763 TEE_Result res; in op_attr_secret_value_to_binary() local
767 res = op_u32_to_binary_helper(key->key_size, data, data_len, offs); in op_attr_secret_value_to_binary()
768 if (res != TEE_SUCCESS) in op_attr_secret_value_to_binary()
769 return res; in op_attr_secret_value_to_binary()
826 TEE_Result res = TEE_SUCCESS; in op_attr_bignum_from_user() local
830 res = bb_memdup_user(buffer, size, &bbuf); in op_attr_bignum_from_user()
831 if (res) in op_attr_bignum_from_user()
832 return res; in op_attr_bignum_from_user()
834 res = crypto_bignum_bin2bn(bbuf, size, *bn); in op_attr_bignum_from_user()
838 return res; in op_attr_bignum_from_user()
845 TEE_Result res = TEE_SUCCESS; in op_attr_bignum_to_user() local
851 res = copy_from_user(&s, size, sizeof(s)); in op_attr_bignum_to_user()
852 if (res != TEE_SUCCESS) in op_attr_bignum_to_user()
853 return res; in op_attr_bignum_to_user()
856 res = copy_to_user(size, &req_size, sizeof(req_size)); in op_attr_bignum_to_user()
857 if (res != TEE_SUCCESS) in op_attr_bignum_to_user()
858 return res; in op_attr_bignum_to_user()
873 res = copy_to_user(buffer, bbuf, req_size); in op_attr_bignum_to_user()
876 return res; in op_attr_bignum_to_user()
882 TEE_Result res; in op_attr_bignum_to_binary() local
887 res = op_u32_to_binary_helper(n, data, data_len, offs); in op_attr_bignum_to_binary()
888 if (res != TEE_SUCCESS) in op_attr_bignum_to_binary()
889 return res; in op_attr_bignum_to_binary()
958 TEE_Result res; in op_attr_value_to_user() local
964 res = copy_from_user(&s, size, sizeof(s)); in op_attr_value_to_user()
965 if (res != TEE_SUCCESS) in op_attr_value_to_user()
966 return res; in op_attr_value_to_user()
1021 TEE_Result res = TEE_ERROR_GENERIC; in op_attr_25519_to_user() local
1026 res = copy_from_user(&s, size, sizeof(s)); in op_attr_25519_to_user()
1027 if (res != TEE_SUCCESS) in op_attr_25519_to_user()
1028 return res; in op_attr_25519_to_user()
1030 res = copy_to_user(size, &key_size, sizeof(key_size)); in op_attr_25519_to_user()
1031 if (res != TEE_SUCCESS) in op_attr_25519_to_user()
1032 return res; in op_attr_25519_to_user()
1043 TEE_Result res = TEE_ERROR_GENERIC; in op_attr_25519_to_binary() local
1048 res = op_u32_to_binary_helper(key_size, data, data_len, offs); in op_attr_25519_to_binary()
1049 if (res != TEE_SUCCESS) in op_attr_25519_to_binary()
1050 return res; in op_attr_25519_to_binary()
1154 TEE_Result res = copy_from_user(&d, src, sizeof(d)); in get_user_u64_as_size_t() local
1160 if (!res && ADD_OVERFLOW(0, d, dst)) in get_user_u64_as_size_t()
1163 return res; in get_user_u64_as_size_t()
1178 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_get_info() local
1181 res = tee_obj_get(to_user_ta_ctx(sess->ctx), in syscall_cryp_obj_get_info()
1183 if (res != TEE_SUCCESS) in syscall_cryp_obj_get_info()
1199 res = copy_to_user_private(info, &o_info, sizeof(o_info)); in syscall_cryp_obj_get_info()
1202 return res; in syscall_cryp_obj_get_info()
1209 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_restrict_usage() local
1212 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_restrict_usage()
1213 if (res) in syscall_cryp_obj_restrict_usage()
1214 return res; in syscall_cryp_obj_restrict_usage()
1221 res = tee_svc_storage_write_usage(o, new_usage); in syscall_cryp_obj_restrict_usage()
1222 if (!res) in syscall_cryp_obj_restrict_usage()
1229 return res; in syscall_cryp_obj_restrict_usage()
1286 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_get_attr() local
1294 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_get_attr()
1295 if (res != TEE_SUCCESS) in syscall_cryp_obj_get_attr()
1374 TEE_Result res; in tee_obj_attr_to_binary() local
1390 res = attr_ops[ta->ops_index].to_binary(attr, data, len, &offs); in tee_obj_attr_to_binary()
1391 if (res != TEE_SUCCESS) in tee_obj_attr_to_binary()
1392 return res; in tee_obj_attr_to_binary()
1429 TEE_Result res; in tee_obj_attr_copy_from() local
1451 res = attr_ops[ta->ops_index].from_obj(attr, src_attr); in tee_obj_attr_copy_from()
1452 if (res != TEE_SUCCESS) in tee_obj_attr_copy_from()
1453 return res; in tee_obj_attr_copy_from()
1509 res = attr_ops[ta->ops_index].from_obj(attr, src_attr); in tee_obj_attr_copy_from()
1510 if (res != TEE_SUCCESS) in tee_obj_attr_copy_from()
1511 return res; in tee_obj_attr_copy_from()
1552 TEE_Result res = TEE_SUCCESS; in tee_obj_set_type() local
1574 res = check_key_size(type_props, max_key_size); in tee_obj_set_type()
1575 if (res) in tee_obj_set_type()
1576 return res; in tee_obj_set_type()
1586 res = crypto_acipher_alloc_rsa_public_key(o->attr, in tee_obj_set_type()
1590 res = crypto_acipher_alloc_rsa_keypair(o->attr, max_key_size); in tee_obj_set_type()
1593 res = crypto_acipher_alloc_dsa_public_key(o->attr, in tee_obj_set_type()
1597 res = crypto_acipher_alloc_dsa_keypair(o->attr, max_key_size); in tee_obj_set_type()
1600 res = crypto_acipher_alloc_dh_keypair(o->attr, max_key_size); in tee_obj_set_type()
1607 res = crypto_acipher_alloc_ecc_public_key(o->attr, obj_type, in tee_obj_set_type()
1615 res = crypto_acipher_alloc_ecc_keypair(o->attr, obj_type, in tee_obj_set_type()
1619 res = crypto_acipher_alloc_x25519_keypair(o->attr, in tee_obj_set_type()
1623 res = crypto_acipher_alloc_x448_keypair(o->attr, in tee_obj_set_type()
1627 res = crypto_acipher_alloc_ed25519_keypair(o->attr, in tee_obj_set_type()
1631 res = crypto_acipher_alloc_ed25519_public_key(o->attr, in tee_obj_set_type()
1644 if (res != TEE_SUCCESS) in tee_obj_set_type()
1645 return res; in tee_obj_set_type()
1661 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_alloc() local
1669 res = tee_obj_set_type(o, obj_type, max_key_size); in syscall_cryp_obj_alloc()
1670 if (res != TEE_SUCCESS) { in syscall_cryp_obj_alloc()
1672 return res; in syscall_cryp_obj_alloc()
1677 res = copy_kaddr_to_uref(obj, o); in syscall_cryp_obj_alloc()
1678 if (res != TEE_SUCCESS) in syscall_cryp_obj_alloc()
1680 return res; in syscall_cryp_obj_alloc()
1686 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_close() local
1689 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_close()
1690 if (res != TEE_SUCCESS) in syscall_cryp_obj_close()
1691 return res; in syscall_cryp_obj_close()
1707 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_reset() local
1710 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_reset()
1711 if (res != TEE_SUCCESS) in syscall_cryp_obj_reset()
1712 return res; in syscall_cryp_obj_reset()
1732 TEE_Result res = TEE_SUCCESS; in copy_in_attrs() local
1744 res = copy_from_user(usr_attrs_bbuf, usr_attrs, size); in copy_in_attrs()
1745 if (res) in copy_in_attrs()
1761 res = vm_check_access_rights(&utc->uctx, flags, buf, in copy_in_attrs()
1763 if (res != TEE_SUCCESS) in copy_in_attrs()
1772 return res; in copy_in_attrs()
1899 TEE_Result res = TEE_SUCCESS; in tee_svc_cryp_obj_populate_type() local
1920 res = ops->from_user(attr, &attrs[n].content.value, in tee_svc_cryp_obj_populate_type()
1923 res = ops->from_user(attr, attrs[n].content.ref.buffer, in tee_svc_cryp_obj_populate_type()
1925 if (res != TEE_SUCCESS) in tee_svc_cryp_obj_populate_type()
1926 return res; in tee_svc_cryp_obj_populate_type()
1943 res = get_ec_key_size(attrs[n].content.value.a, in tee_svc_cryp_obj_populate_type()
1945 if (res != TEE_SUCCESS) in tee_svc_cryp_obj_populate_type()
1946 return res; in tee_svc_cryp_obj_populate_type()
1958 res = check_key_size(type_props, obj_size); in tee_svc_cryp_obj_populate_type()
1959 if (res != TEE_SUCCESS) in tee_svc_cryp_obj_populate_type()
1995 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_populate() local
2001 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_cryp_obj_populate()
2002 if (res != TEE_SUCCESS) in syscall_cryp_obj_populate()
2003 return res; in syscall_cryp_obj_populate()
2024 res = copy_in_attrs(to_user_ta_ctx(sess->ctx), usr_attrs, attr_count, in syscall_cryp_obj_populate()
2026 if (res != TEE_SUCCESS) in syscall_cryp_obj_populate()
2029 res = tee_svc_cryp_check_attr(ATTR_USAGE_POPULATE, type_props, in syscall_cryp_obj_populate()
2031 if (res != TEE_SUCCESS) in syscall_cryp_obj_populate()
2034 res = tee_svc_cryp_obj_populate_type(o, type_props, attrs, attr_count); in syscall_cryp_obj_populate()
2035 if (res == TEE_SUCCESS) in syscall_cryp_obj_populate()
2040 return res; in syscall_cryp_obj_populate()
2046 TEE_Result res = TEE_SUCCESS; in syscall_cryp_obj_copy() local
2050 res = tee_obj_get(to_user_ta_ctx(sess->ctx), in syscall_cryp_obj_copy()
2052 if (res != TEE_SUCCESS) in syscall_cryp_obj_copy()
2053 return res; in syscall_cryp_obj_copy()
2055 res = tee_obj_get(to_user_ta_ctx(sess->ctx), in syscall_cryp_obj_copy()
2057 if (res != TEE_SUCCESS) in syscall_cryp_obj_copy()
2058 return res; in syscall_cryp_obj_copy()
2067 res = tee_obj_attr_copy_from(dst_o, src_o); in syscall_cryp_obj_copy()
2068 if (res != TEE_SUCCESS) in syscall_cryp_obj_copy()
2069 return res; in syscall_cryp_obj_copy()
2128 TEE_Result res = TEE_SUCCESS; in tee_svc_obj_generate_key_rsa() local
2133 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_rsa()
2135 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_rsa()
2136 return res; in tee_svc_obj_generate_key_rsa()
2138 res = check_pub_rsa_key(key->e); in tee_svc_obj_generate_key_rsa()
2139 if (res) in tee_svc_obj_generate_key_rsa()
2140 return res; in tee_svc_obj_generate_key_rsa()
2142 res = crypto_bignum_bin2bn((const uint8_t *)&e, sizeof(e), in tee_svc_obj_generate_key_rsa()
2144 if (res) in tee_svc_obj_generate_key_rsa()
2145 return res; in tee_svc_obj_generate_key_rsa()
2147 res = crypto_acipher_gen_rsa_key(key, key_size); in tee_svc_obj_generate_key_rsa()
2148 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_rsa()
2149 return res; in tee_svc_obj_generate_key_rsa()
2161 TEE_Result res; in tee_svc_obj_generate_key_dsa() local
2164 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_dsa()
2166 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_dsa()
2167 return res; in tee_svc_obj_generate_key_dsa()
2169 res = crypto_acipher_gen_dsa_key(o->attr, key_size); in tee_svc_obj_generate_key_dsa()
2170 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_dsa()
2171 return res; in tee_svc_obj_generate_key_dsa()
2183 TEE_Result res; in tee_svc_obj_generate_key_dh() local
2189 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_dh()
2191 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_dh()
2192 return res; in tee_svc_obj_generate_key_dh()
2200 res = crypto_acipher_gen_dh_key(tee_dh_key, dh_q, dh_xbits, key_size); in tee_svc_obj_generate_key_dh()
2201 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_dh()
2202 return res; in tee_svc_obj_generate_key_dh()
2215 TEE_Result res; in tee_svc_obj_generate_key_ecc() local
2219 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_ecc()
2221 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_ecc()
2222 return res; in tee_svc_obj_generate_key_ecc()
2226 res = crypto_acipher_gen_ecc_key(tee_ecc_key, key_size); in tee_svc_obj_generate_key_ecc()
2227 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_ecc()
2228 return res; in tee_svc_obj_generate_key_ecc()
2246 TEE_Result res = TEE_ERROR_GENERIC; in tee_svc_obj_generate_key_x25519() local
2250 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_x25519()
2252 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_x25519()
2253 return res; in tee_svc_obj_generate_key_x25519()
2257 res = crypto_acipher_gen_x25519_key(tee_x25519_key, key_size); in tee_svc_obj_generate_key_x25519()
2258 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_x25519()
2259 return res; in tee_svc_obj_generate_key_x25519()
2273 TEE_Result res = TEE_ERROR_GENERIC; in tee_svc_obj_generate_key_x448() local
2277 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_x448()
2279 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_x448()
2280 return res; in tee_svc_obj_generate_key_x448()
2283 res = crypto_acipher_gen_x448_key(tee_x448_key, key_size); in tee_svc_obj_generate_key_x448()
2284 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_x448()
2285 return res; in tee_svc_obj_generate_key_x448()
2301 TEE_Result res = TEE_ERROR_GENERIC; in tee_svc_obj_generate_key_ed25519() local
2305 res = tee_svc_cryp_obj_populate_type(o, type_props, params, in tee_svc_obj_generate_key_ed25519()
2307 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_ed25519()
2308 return res; in tee_svc_obj_generate_key_ed25519()
2312 res = crypto_acipher_gen_ed25519_key(key, key_size); in tee_svc_obj_generate_key_ed25519()
2313 if (res != TEE_SUCCESS) in tee_svc_obj_generate_key_ed25519()
2314 return res; in tee_svc_obj_generate_key_ed25519()
2424 TEE_Result res = TEE_SUCCESS; in syscall_obj_generate_key() local
2432 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_obj_generate_key()
2433 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2434 return res; in syscall_obj_generate_key()
2450 res = check_key_size(type_props, key_size); in syscall_obj_generate_key()
2451 if (res) in syscall_obj_generate_key()
2452 return res; in syscall_obj_generate_key()
2460 res = copy_in_attrs(to_user_ta_ctx(sess->ctx), usr_params, param_count, in syscall_obj_generate_key()
2462 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2465 res = tee_svc_cryp_check_attr(ATTR_USAGE_GENERATE_KEY, type_props, in syscall_obj_generate_key()
2467 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2498 res = TEE_ERROR_EXCESS_DATA; in syscall_obj_generate_key()
2502 res = crypto_rng_read((void *)(key + 1), byte_size); in syscall_obj_generate_key()
2503 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2514 res = tee_svc_obj_generate_key_rsa(o, type_props, key_size, in syscall_obj_generate_key()
2516 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2521 res = tee_svc_obj_generate_key_dsa(o, type_props, key_size, in syscall_obj_generate_key()
2523 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2528 res = tee_svc_obj_generate_key_dh(o, type_props, key_size, in syscall_obj_generate_key()
2530 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2539 res = tee_svc_obj_generate_key_ecc(o, type_props, key_size, in syscall_obj_generate_key()
2541 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2546 res = tee_svc_obj_generate_key_x25519(o, type_props, key_size, in syscall_obj_generate_key()
2548 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2552 res = tee_svc_obj_generate_key_x448(o, type_props, key_size, in syscall_obj_generate_key()
2554 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2559 res = tee_svc_obj_generate_key_ed25519(o, type_props, key_size, in syscall_obj_generate_key()
2561 if (res != TEE_SUCCESS) in syscall_obj_generate_key()
2566 res = TEE_ERROR_BAD_FORMAT; in syscall_obj_generate_key()
2571 if (res == TEE_SUCCESS) { in syscall_obj_generate_key()
2575 return res; in syscall_obj_generate_key()
2785 TEE_Result res = TEE_SUCCESS; in syscall_cryp_state_alloc() local
2793 res = tee_obj_get(utc, uref_to_vaddr(key1), &o1); in syscall_cryp_state_alloc()
2794 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2795 return res; in syscall_cryp_state_alloc()
2798 res = tee_svc_cryp_check_key_type(o1, algo, mode); in syscall_cryp_state_alloc()
2799 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2800 return res; in syscall_cryp_state_alloc()
2803 res = tee_obj_get(utc, uref_to_vaddr(key2), &o2); in syscall_cryp_state_alloc()
2804 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2805 return res; in syscall_cryp_state_alloc()
2808 res = tee_svc_cryp_check_key_type(o2, algo, mode); in syscall_cryp_state_alloc()
2809 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2810 return res; in syscall_cryp_state_alloc()
2827 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2829 res = crypto_cipher_alloc_ctx(&cs->ctx, algo); in syscall_cryp_state_alloc()
2830 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2836 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2838 res = crypto_authenc_alloc_ctx(&cs->ctx, algo); in syscall_cryp_state_alloc()
2839 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2845 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2847 res = crypto_mac_alloc_ctx(&cs->ctx, algo); in syscall_cryp_state_alloc()
2848 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2854 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2856 res = crypto_hash_alloc_ctx(&cs->ctx, algo); in syscall_cryp_state_alloc()
2857 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2865 res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_state_alloc()
2869 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2874 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2877 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_state_alloc()
2881 res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_state_alloc()
2884 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2887 res = copy_kaddr_to_uref(state, cs); in syscall_cryp_state_alloc()
2888 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2902 if (res != TEE_SUCCESS) in syscall_cryp_state_alloc()
2904 return res; in syscall_cryp_state_alloc()
2910 TEE_Result res = TEE_SUCCESS; in syscall_cryp_state_copy() local
2914 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(dst), &cs_dst); in syscall_cryp_state_copy()
2915 if (res != TEE_SUCCESS) in syscall_cryp_state_copy()
2916 return res; in syscall_cryp_state_copy()
2918 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(src), &cs_src); in syscall_cryp_state_copy()
2919 if (res != TEE_SUCCESS) in syscall_cryp_state_copy()
2920 return res; in syscall_cryp_state_copy()
2958 TEE_Result res = TEE_SUCCESS; in syscall_cryp_state_free() local
2961 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_cryp_state_free()
2962 if (res != TEE_SUCCESS) in syscall_cryp_state_free()
2963 return res; in syscall_cryp_state_free()
2973 TEE_Result res = TEE_SUCCESS; in syscall_hash_init() local
2976 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_hash_init()
2977 if (res != TEE_SUCCESS) in syscall_hash_init()
2978 return res; in syscall_hash_init()
2982 res = crypto_hash_init(cs->ctx); in syscall_hash_init()
2983 if (res != TEE_SUCCESS) in syscall_hash_init()
2984 return res; in syscall_hash_init()
2991 res = tee_obj_get(to_user_ta_ctx(sess->ctx), in syscall_hash_init()
2993 if (res != TEE_SUCCESS) in syscall_hash_init()
2994 return res; in syscall_hash_init()
3000 res = crypto_mac_init(cs->ctx, (void *)(key + 1), in syscall_hash_init()
3002 if (res != TEE_SUCCESS) in syscall_hash_init()
3003 return res; in syscall_hash_init()
3020 TEE_Result res = TEE_SUCCESS; in syscall_hash_update() local
3032 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_hash_update()
3036 if (res != TEE_SUCCESS) in syscall_hash_update()
3037 return res; in syscall_hash_update()
3039 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_hash_update()
3040 if (res != TEE_SUCCESS) in syscall_hash_update()
3041 return res; in syscall_hash_update()
3049 res = crypto_hash_update(cs->ctx, chunk, chunk_size); in syscall_hash_update()
3051 if (res != TEE_SUCCESS) in syscall_hash_update()
3052 return res; in syscall_hash_update()
3056 res = crypto_mac_update(cs->ctx, chunk, chunk_size); in syscall_hash_update()
3058 if (res != TEE_SUCCESS) in syscall_hash_update()
3059 return res; in syscall_hash_update()
3079 TEE_Result res = TEE_SUCCESS; in syscall_hash_final() local
3090 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_hash_final()
3094 if (res != TEE_SUCCESS) in syscall_hash_final()
3095 return res; in syscall_hash_final()
3097 res = get_user_u64_as_size_t(&hlen, hash_len); in syscall_hash_final()
3098 if (res != TEE_SUCCESS) in syscall_hash_final()
3099 return res; in syscall_hash_final()
3101 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_hash_final()
3106 if (res != TEE_SUCCESS) in syscall_hash_final()
3107 return res; in syscall_hash_final()
3109 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_hash_final()
3110 if (res != TEE_SUCCESS) in syscall_hash_final()
3111 return res; in syscall_hash_final()
3121 res = crypto_hash_update(cs->ctx, chunk, in syscall_hash_final()
3124 if (res) in syscall_hash_final()
3125 return res; in syscall_hash_final()
3133 res = crypto_hash_final(cs->ctx, hash, hlen); in syscall_hash_final()
3135 return res; in syscall_hash_final()
3138 res = tee_alg_get_digest_size(cs->algo, &hash_size); in syscall_hash_final()
3139 if (res != TEE_SUCCESS) in syscall_hash_final()
3140 return res; in syscall_hash_final()
3142 res = TEE_ERROR_SHORT_BUFFER; in syscall_hash_final()
3148 res = crypto_hash_update(cs->ctx, chunk, chunk_size); in syscall_hash_final()
3150 if (res != TEE_SUCCESS) in syscall_hash_final()
3151 return res; in syscall_hash_final()
3155 res = crypto_hash_final(cs->ctx, hash, hash_size); in syscall_hash_final()
3157 if (res != TEE_SUCCESS) in syscall_hash_final()
3158 return res; in syscall_hash_final()
3162 res = tee_alg_get_digest_size(cs->algo, &hash_size); in syscall_hash_final()
3163 if (res != TEE_SUCCESS) in syscall_hash_final()
3164 return res; in syscall_hash_final()
3166 res = TEE_ERROR_SHORT_BUFFER; in syscall_hash_final()
3172 res = crypto_mac_update(cs->ctx, chunk, chunk_size); in syscall_hash_final()
3174 if (res != TEE_SUCCESS) in syscall_hash_final()
3175 return res; in syscall_hash_final()
3179 res = crypto_mac_final(cs->ctx, hash, hash_size); in syscall_hash_final()
3181 if (res != TEE_SUCCESS) in syscall_hash_final()
3182 return res; in syscall_hash_final()
3192 return res; in syscall_hash_final()
3202 TEE_Result res = TEE_SUCCESS; in syscall_cipher_init() local
3206 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_cipher_init()
3207 if (res != TEE_SUCCESS) in syscall_cipher_init()
3208 return res; in syscall_cipher_init()
3213 res = tee_obj_get(utc, cs->key1, &o); in syscall_cipher_init()
3214 if (res != TEE_SUCCESS) in syscall_cipher_init()
3215 return res; in syscall_cipher_init()
3221 res = bb_memdup_user(iv, iv_len, &iv_bbuf); in syscall_cipher_init()
3222 if (res) in syscall_cipher_init()
3223 return res; in syscall_cipher_init()
3231 res = crypto_cipher_init(cs->ctx, cs->mode, in syscall_cipher_init()
3236 res = crypto_cipher_init(cs->ctx, cs->mode, in syscall_cipher_init()
3240 if (res != TEE_SUCCESS) in syscall_cipher_init()
3241 return res; in syscall_cipher_init()
3255 TEE_Result res = TEE_SUCCESS; in tee_svc_cipher_update_helper() local
3258 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in tee_svc_cipher_update_helper()
3259 if (res != TEE_SUCCESS) in tee_svc_cipher_update_helper()
3260 return res; in tee_svc_cipher_update_helper()
3268 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in tee_svc_cipher_update_helper()
3272 if (res != TEE_SUCCESS) in tee_svc_cipher_update_helper()
3273 return res; in tee_svc_cipher_update_helper()
3283 res = get_user_u64_as_size_t(&dlen, dst_len); in tee_svc_cipher_update_helper()
3284 if (res != TEE_SUCCESS) in tee_svc_cipher_update_helper()
3285 return res; in tee_svc_cipher_update_helper()
3287 res = vm_check_access_rights(uctx, flags, (uaddr_t)dst, dlen); in tee_svc_cipher_update_helper()
3288 if (res != TEE_SUCCESS) in tee_svc_cipher_update_helper()
3289 return res; in tee_svc_cipher_update_helper()
3293 res = TEE_ERROR_SHORT_BUFFER; in tee_svc_cipher_update_helper()
3300 res = tee_do_cipher_update(cs->ctx, cs->algo, cs->mode, in tee_svc_cipher_update_helper()
3311 if ((res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) && in tee_svc_cipher_update_helper()
3317 res = res2; in tee_svc_cipher_update_helper()
3320 return res; in tee_svc_cipher_update_helper()
3344 TEE_Result res = TEE_SUCCESS; in get_hkdf_params() local
3367 res = bb_memdup_user(p->content.ref.buffer, in get_hkdf_params()
3369 if (res) in get_hkdf_params()
3370 return res; in get_hkdf_params()
3386 res = bb_memdup_user(p->content.ref.buffer, in get_hkdf_params()
3388 if (res) in get_hkdf_params()
3389 return res; in get_hkdf_params()
3434 TEE_Result res = TEE_SUCCESS; in get_concat_kdf_params() local
3437 res = bb_memdup_user(p->content.ref.buffer, in get_concat_kdf_params()
3440 if (res) in get_concat_kdf_params()
3441 return res; in get_concat_kdf_params()
3484 TEE_Result res = TEE_SUCCESS; in get_pbkdf2_params() local
3487 res = bb_memdup_user(p->content.ref.buffer, in get_pbkdf2_params()
3489 if (res) in get_pbkdf2_params()
3490 return res; in get_pbkdf2_params()
3527 TEE_Result res = TEE_ERROR_GENERIC; in get_sm2_kep_params() local
3543 res = crypto_acipher_alloc_ecc_public_key(peer_key, in get_sm2_kep_params()
3546 if (res) in get_sm2_kep_params()
3547 return res; in get_sm2_kep_params()
3549 res = crypto_acipher_alloc_ecc_public_key(peer_eph_key, in get_sm2_kep_params()
3552 if (res) in get_sm2_kep_params()
3568 res = bb_memdup_user(p->content.ref.buffer, in get_sm2_kep_params()
3571 if (res) in get_sm2_kep_params()
3572 return res; in get_sm2_kep_params()
3581 res = bb_memdup_user(p->content.ref.buffer, in get_sm2_kep_params()
3584 if (res) in get_sm2_kep_params()
3585 return res; in get_sm2_kep_params()
3595 res = bb_memdup_user(p->content.ref.buffer, in get_sm2_kep_params()
3598 if (res) in get_sm2_kep_params()
3599 return res; in get_sm2_kep_params()
3609 res = bb_memdup_user(p->content.ref.buffer, in get_sm2_kep_params()
3612 if (res) in get_sm2_kep_params()
3613 return res; in get_sm2_kep_params()
3622 res = bb_memdup_user(p->content.ref.buffer, in get_sm2_kep_params()
3625 if (res) in get_sm2_kep_params()
3626 return res; in get_sm2_kep_params()
3633 res = bb_memdup_user(p->content.ref.buffer, in get_sm2_kep_params()
3636 if (res) in get_sm2_kep_params()
3637 return res; in get_sm2_kep_params()
3644 res = bb_memdup_user(p->content.ref.buffer, in get_sm2_kep_params()
3647 if (res) in get_sm2_kep_params()
3648 return res; in get_sm2_kep_params()
3654 res = bb_memdup_user(p->content.ref.buffer, in get_sm2_kep_params()
3657 if (res) in get_sm2_kep_params()
3658 return res; in get_sm2_kep_params()
3665 res = TEE_ERROR_BAD_PARAMETERS; in get_sm2_kep_params()
3671 res = TEE_ERROR_BAD_PARAMETERS; in get_sm2_kep_params()
3680 return res; in get_sm2_kep_params()
3690 TEE_Result res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_derive_key() local
3699 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_cryp_derive_key()
3700 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3701 return res; in syscall_cryp_derive_key()
3709 res = copy_in_attrs(utc, usr_params, param_count, params); in syscall_cryp_derive_key()
3710 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3714 res = tee_obj_get(utc, cs->key1, &ko); in syscall_cryp_derive_key()
3715 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3718 res = tee_obj_get(utc, uref_to_vaddr(derived_key), &so); in syscall_cryp_derive_key()
3719 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3728 res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_derive_key()
3740 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3747 res = TEE_ERROR_OVERFLOW; in syscall_cryp_derive_key()
3751 res = bb_memdup_user(params[0].content.ref.buffer, bin_size, in syscall_cryp_derive_key()
3753 if (res) in syscall_cryp_derive_key()
3760 res = crypto_acipher_dh_shared_secret(ko->attr, in syscall_cryp_derive_key()
3762 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3771 res = TEE_ERROR_OUT_OF_MEMORY; in syscall_cryp_derive_key()
3787 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3808 res = TEE_ERROR_NOT_IMPLEMENTED; in syscall_cryp_derive_key()
3812 res = bb_memdup_user(params[0].content.ref.buffer, in syscall_cryp_derive_key()
3815 if (res) in syscall_cryp_derive_key()
3818 res = bb_memdup_user(params[1].content.ref.buffer, in syscall_cryp_derive_key()
3821 if (res) in syscall_cryp_derive_key()
3825 res = crypto_acipher_alloc_ecc_public_key(&key_public, key_type, in syscall_cryp_derive_key()
3827 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3837 res = crypto_acipher_ecc_shared_secret(ko->attr, &key_public, in syscall_cryp_derive_key()
3841 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3858 res = get_hkdf_params(cs->algo, params, param_count, &salt, in syscall_cryp_derive_key()
3861 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3866 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3870 res = tee_cryp_hkdf(hash_id, ikm, ik->key_size, salt, salt_len, in syscall_cryp_derive_key()
3873 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3888 res = get_concat_kdf_params(params, param_count, &info, in syscall_cryp_derive_key()
3890 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3895 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3899 res = tee_cryp_concat_kdf(hash_id, shared_secret, ss->key_size, in syscall_cryp_derive_key()
3902 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3917 res = get_pbkdf2_params(params, param_count, &salt, &salt_len, in syscall_cryp_derive_key()
3919 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3924 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3928 res = tee_cryp_pbkdf2(hash_id, password, ss->key_size, salt, in syscall_cryp_derive_key()
3931 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3948 res = tee_obj_get(utc, cs->key2, &ko2); in syscall_cryp_derive_key()
3949 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3952 res = get_sm2_kep_params(params, param_count, &peer_key, in syscall_cryp_derive_key()
3954 if (res != TEE_SUCCESS) in syscall_cryp_derive_key()
3960 res = crypto_acipher_sm2_kep_derive(ko->attr, /* key1 */ in syscall_cryp_derive_key()
3965 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
3983 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3989 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
3993 res = bb_memdup_user(params[0].content.ref.buffer, in syscall_cryp_derive_key()
3996 if (res) in syscall_cryp_derive_key()
4004 res = crypto_acipher_x25519_shared_secret(ko->attr, in syscall_cryp_derive_key()
4009 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
4025 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
4031 res = TEE_ERROR_BAD_PARAMETERS; in syscall_cryp_derive_key()
4035 res = bb_memdup_user(params[0].content.ref.buffer, in syscall_cryp_derive_key()
4038 if (res) in syscall_cryp_derive_key()
4046 res = crypto_acipher_x448_shared_secret(ko->attr, in syscall_cryp_derive_key()
4051 if (res == TEE_SUCCESS) { in syscall_cryp_derive_key()
4059 res = TEE_ERROR_NOT_SUPPORTED; in syscall_cryp_derive_key()
4063 return res; in syscall_cryp_derive_key()
4068 TEE_Result res = TEE_SUCCESS; in syscall_cryp_random_number_generate() local
4075 res = crypto_rng_read(bbuf, blen); in syscall_cryp_random_number_generate()
4076 if (res != TEE_SUCCESS) in syscall_cryp_random_number_generate()
4077 return res; in syscall_cryp_random_number_generate()
4079 res = copy_to_user(buf, bbuf, blen); in syscall_cryp_random_number_generate()
4080 return res; in syscall_cryp_random_number_generate()
4090 TEE_Result res = TEE_SUCCESS; in syscall_authenc_init() local
4094 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_init()
4095 if (res != TEE_SUCCESS) in syscall_authenc_init()
4096 return res; in syscall_authenc_init()
4098 res = tee_obj_get(to_user_ta_ctx(sess->ctx), cs->key1, &o); in syscall_authenc_init()
4099 if (res != TEE_SUCCESS) in syscall_authenc_init()
4100 return res; in syscall_authenc_init()
4106 res = bb_memdup_user(nonce, nonce_len, &nonce_bbuf); in syscall_authenc_init()
4107 if (res) in syscall_authenc_init()
4108 return res; in syscall_authenc_init()
4110 res = crypto_authenc_init(cs->ctx, cs->mode, (uint8_t *)(key + 1), in syscall_authenc_init()
4113 if (res != TEE_SUCCESS) in syscall_authenc_init()
4114 return res; in syscall_authenc_init()
4126 TEE_Result res = TEE_SUCCESS; in syscall_authenc_update_aad() local
4131 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_authenc_update_aad()
4135 if (res != TEE_SUCCESS) in syscall_authenc_update_aad()
4136 return res; in syscall_authenc_update_aad()
4138 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_update_aad()
4139 if (res != TEE_SUCCESS) in syscall_authenc_update_aad()
4140 return res; in syscall_authenc_update_aad()
4149 res = crypto_authenc_update_aad(cs->ctx, cs->mode, aad_data, in syscall_authenc_update_aad()
4152 if (res != TEE_SUCCESS) in syscall_authenc_update_aad()
4153 return res; in syscall_authenc_update_aad()
4165 TEE_Result res = TEE_SUCCESS; in syscall_authenc_update_payload() local
4168 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_update_payload()
4169 if (res != TEE_SUCCESS) in syscall_authenc_update_payload()
4170 return res; in syscall_authenc_update_payload()
4181 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_authenc_update_payload()
4185 if (res != TEE_SUCCESS) in syscall_authenc_update_payload()
4186 return res; in syscall_authenc_update_payload()
4188 res = get_user_u64_as_size_t(&dlen, dst_len); in syscall_authenc_update_payload()
4189 if (res != TEE_SUCCESS) in syscall_authenc_update_payload()
4190 return res; in syscall_authenc_update_payload()
4192 res = vm_check_access_rights(&to_user_ta_ctx(sess->ctx)->uctx, in syscall_authenc_update_payload()
4197 if (res != TEE_SUCCESS) in syscall_authenc_update_payload()
4198 return res; in syscall_authenc_update_payload()
4201 res = TEE_ERROR_SHORT_BUFFER; in syscall_authenc_update_payload()
4206 res = crypto_authenc_update_payload(cs->ctx, cs->mode, src_data, in syscall_authenc_update_payload()
4210 if (res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) { in syscall_authenc_update_payload()
4214 res = res2; in syscall_authenc_update_payload()
4217 return res; in syscall_authenc_update_payload()
4228 TEE_Result res = TEE_SUCCESS; in syscall_authenc_enc_final() local
4232 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_enc_final()
4233 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
4234 return res; in syscall_authenc_enc_final()
4249 res = vm_check_access_rights(uctx, in syscall_authenc_enc_final()
4253 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
4254 return res; in syscall_authenc_enc_final()
4259 res = get_user_u64_as_size_t(&dlen, dst_len); in syscall_authenc_enc_final()
4260 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
4261 return res; in syscall_authenc_enc_final()
4263 res = vm_check_access_rights(uctx, in syscall_authenc_enc_final()
4268 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
4269 return res; in syscall_authenc_enc_final()
4273 res = TEE_ERROR_SHORT_BUFFER; in syscall_authenc_enc_final()
4277 res = get_user_u64_as_size_t(&tlen, tag_len); in syscall_authenc_enc_final()
4278 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
4279 return res; in syscall_authenc_enc_final()
4281 res = vm_check_access_rights(uctx, in syscall_authenc_enc_final()
4286 if (res != TEE_SUCCESS) in syscall_authenc_enc_final()
4287 return res; in syscall_authenc_enc_final()
4290 res = crypto_authenc_enc_final(cs->ctx, src_data, src_len, dst_data, in syscall_authenc_enc_final()
4295 if (res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) { in syscall_authenc_enc_final()
4309 return res; in syscall_authenc_enc_final()
4319 TEE_Result res = TEE_SUCCESS; in syscall_authenc_dec_final() local
4322 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_authenc_dec_final()
4323 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
4324 return res; in syscall_authenc_dec_final()
4339 res = vm_check_access_rights(uctx, in syscall_authenc_dec_final()
4343 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
4344 return res; in syscall_authenc_dec_final()
4349 res = get_user_u64_as_size_t(&dlen, dst_len); in syscall_authenc_dec_final()
4350 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
4351 return res; in syscall_authenc_dec_final()
4353 res = vm_check_access_rights(uctx, in syscall_authenc_dec_final()
4358 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
4359 return res; in syscall_authenc_dec_final()
4363 res = TEE_ERROR_SHORT_BUFFER; in syscall_authenc_dec_final()
4368 res = vm_check_access_rights(uctx, in syscall_authenc_dec_final()
4372 if (res != TEE_SUCCESS) in syscall_authenc_dec_final()
4373 return res; in syscall_authenc_dec_final()
4376 res = crypto_authenc_dec_final(cs->ctx, src_data, src_len, dst_data, in syscall_authenc_dec_final()
4381 if ((res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) && in syscall_authenc_dec_final()
4389 return res; in syscall_authenc_dec_final()
4420 TEE_Result res = TEE_SUCCESS; in syscall_asymm_operate() local
4432 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_asymm_operate()
4433 if (res != TEE_SUCCESS) in syscall_asymm_operate()
4434 return res; in syscall_asymm_operate()
4439 res = vm_check_access_rights(&utc->uctx, in syscall_asymm_operate()
4443 if (res != TEE_SUCCESS) in syscall_asymm_operate()
4444 return res; in syscall_asymm_operate()
4446 res = get_user_u64_as_size_t(&dlen, dst_len); in syscall_asymm_operate()
4447 if (res != TEE_SUCCESS) in syscall_asymm_operate()
4448 return res; in syscall_asymm_operate()
4450 res = vm_check_access_rights(&utc->uctx, in syscall_asymm_operate()
4455 if (res != TEE_SUCCESS) in syscall_asymm_operate()
4456 return res; in syscall_asymm_operate()
4464 res = copy_in_attrs(utc, usr_params, num_params, params); in syscall_asymm_operate()
4465 if (res != TEE_SUCCESS) in syscall_asymm_operate()
4468 res = tee_obj_get(utc, cs->key1, &o); in syscall_asymm_operate()
4469 if (res != TEE_SUCCESS) in syscall_asymm_operate()
4472 res = TEE_ERROR_GENERIC; in syscall_asymm_operate()
4480 res = crypto_acipher_rsanopad_encrypt(o->attr, src_data, in syscall_asymm_operate()
4486 res = crypto_acipher_rsanopad_decrypt(o->attr, src_data, in syscall_asymm_operate()
4495 res = TEE_ERROR_GENERIC; in syscall_asymm_operate()
4502 res = crypto_acipher_sm2_pke_encrypt(o->attr, src_data, in syscall_asymm_operate()
4508 res = crypto_acipher_sm2_pke_decrypt(o->attr, src_data, in syscall_asymm_operate()
4513 res = TEE_ERROR_GENERIC; in syscall_asymm_operate()
4538 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_operate()
4542 res = copy_from_user(&mgf_algo, buf, in syscall_asymm_operate()
4544 if (res) in syscall_asymm_operate()
4554 res = crypto_acipher_rsaes_encrypt(cs->algo, o->attr, in syscall_asymm_operate()
4562 res = crypto_acipher_rsaes_decrypt( in syscall_asymm_operate()
4568 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_operate()
4588 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_operate()
4593 res = crypto_acipher_rsassa_sign(cs->algo, o->attr, salt_len, in syscall_asymm_operate()
4603 res = crypto_acipher_dsa_sign(cs->algo, o->attr, src_data, in syscall_asymm_operate()
4610 res = tee_svc_obj_ed25519_sign(o->attr, src_data, src_len, in syscall_asymm_operate()
4623 res = crypto_acipher_ecc_sign(cs->algo, o->attr, src_data, in syscall_asymm_operate()
4628 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_operate()
4635 if (res == TEE_SUCCESS || res == TEE_ERROR_SHORT_BUFFER) { in syscall_asymm_operate()
4642 return res; in syscall_asymm_operate()
4653 TEE_Result res = TEE_SUCCESS; in syscall_asymm_verify() local
4661 res = tee_svc_cryp_get_state(sess, uref_to_vaddr(state), &cs); in syscall_asymm_verify()
4662 if (res != TEE_SUCCESS) in syscall_asymm_verify()
4663 return res; in syscall_asymm_verify()
4671 res = vm_check_access_rights(&utc->uctx, in syscall_asymm_verify()
4675 if (res != TEE_SUCCESS) in syscall_asymm_verify()
4676 return res; in syscall_asymm_verify()
4678 res = vm_check_access_rights(&utc->uctx, in syscall_asymm_verify()
4682 if (res != TEE_SUCCESS) in syscall_asymm_verify()
4683 return res; in syscall_asymm_verify()
4691 res = copy_in_attrs(utc, usr_params, num_params, params); in syscall_asymm_verify()
4692 if (res != TEE_SUCCESS) in syscall_asymm_verify()
4695 res = tee_obj_get(utc, cs->key1, &o); in syscall_asymm_verify()
4696 if (res != TEE_SUCCESS) in syscall_asymm_verify()
4699 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_verify()
4707 res = tee_alg_get_digest_size(hash_algo, &hash_size); in syscall_asymm_verify()
4708 if (res != TEE_SUCCESS) in syscall_asymm_verify()
4711 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_verify()
4718 res = crypto_acipher_rsassa_verify(cs->algo, o->attr, salt_len, in syscall_asymm_verify()
4726 res = tee_alg_get_digest_size(hash_algo, &hash_size); in syscall_asymm_verify()
4727 if (res != TEE_SUCCESS) in syscall_asymm_verify()
4758 res = TEE_ERROR_BAD_PARAMETERS; in syscall_asymm_verify()
4763 res = crypto_acipher_dsa_verify(cs->algo, o->attr, data, in syscall_asymm_verify()
4770 res = tee_svc_obj_ed25519_verify(o->attr, data, in syscall_asymm_verify()
4779 res = crypto_acipher_ecc_verify(cs->algo, o->attr, data, in syscall_asymm_verify()
4785 res = TEE_ERROR_NOT_SUPPORTED; in syscall_asymm_verify()
4790 return res; in syscall_asymm_verify()