aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/c_src/crypto.c13
-rw-r--r--lib/crypto/src/crypto.erl4
2 files changed, 5 insertions, 12 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index e953eb960f..5781c1de78 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -3466,21 +3466,14 @@ static ERL_NIF_TERM ecdh_compute_key_nif(ErlNifEnv* env, int argc, const ERL_NIF
EC_POINT *my_ecpoint;
EC_KEY *other_ecdh = NULL;
- if (!enif_get_resource(env, argv[0], res_type_ec_key, (void **)&other_key))
+ if (!enif_get_resource(env, argv[1], res_type_ec_key, (void **)&other_key))
return enif_make_badarg(env);
group = EC_GROUP_dup(EC_KEY_get0_group(other_key->key));
priv_key = EC_KEY_get0_private_key(other_key->key);
- if (!term2point(env, argv[1], group, &my_ecpoint)) {
- struct nif_ec_key *my_key;
-
- if (!enif_get_resource(env, argv[1], res_type_ec_key, (void **)&my_key))
- goto out_err;
-
- if ((my_ecpoint = EC_POINT_new(group)) == NULL)
- goto out_err;
- EC_POINT_copy(my_ecpoint, EC_KEY_get0_public_key(my_key->key));
+ if (!term2point(env, argv[0], group, &my_ecpoint)) {
+ goto out_err;
}
if ((other_ecdh = EC_KEY_new()) == NULL
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 543d589d7e..6f4092ea74 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -1286,9 +1286,9 @@ term_to_ec_key({Curve, PrivKey, PubKey}) ->
term_to_ec_key_nif(_Curve, _PrivKey, _PubKey) -> ?nif_stub.
--spec ecdh_compute_key(ec_key_res(), ec_key_res() | ec_point()) -> binary().
+-spec ecdh_compute_key(ec_point(), ec_key_res()) -> binary().
ecdh_compute_key(Others, My) ->
- ecdh_compute_key_nif(term_to_ec_key(Others), My).
+ ecdh_compute_key_nif(Others, term_to_ec_key(My)).
ecdh_compute_key_nif(_Others, _My) -> ?nif_stub.