diff options
author | Andreas Schultz <[email protected]> | 2013-10-30 19:58:09 +0100 |
---|---|---|
committer | Andreas Schultz <[email protected]> | 2014-01-13 13:00:24 +0100 |
commit | 23b298c13344f75ae1d9a17580dc53d0d50ef86b (patch) | |
tree | 05a16b64b5f2ba8e6accba26e341de43d24779f4 /lib/crypto/src/crypto.erl | |
parent | ac9b565b6c3c8ccaef5964a4aa9336e81abf6c55 (diff) | |
download | otp-23b298c13344f75ae1d9a17580dc53d0d50ef86b.tar.gz otp-23b298c13344f75ae1d9a17580dc53d0d50ef86b.tar.bz2 otp-23b298c13344f75ae1d9a17580dc53d0d50ef86b.zip |
crypto: move elitic curve definitions from OpenSSL built-ins to Erlang
Decouple eliptic curve definition from OpenSSL and define them in
Erlang.
Diffstat (limited to 'lib/crypto/src/crypto.erl')
-rw-r--r-- | lib/crypto/src/crypto.erl | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl index 12ff060bf9..d953bd3bca 100644 --- a/lib/crypto/src/crypto.erl +++ b/lib/crypto/src/crypto.erl @@ -34,6 +34,7 @@ -export([public_encrypt/4, private_decrypt/4]). -export([private_encrypt/4, public_decrypt/4]). -export([dh_generate_parameters/2, dh_check/1]). %% Testing see +-export([ec_curve/1, ec_curves/0]). %% DEPRECATED %% Replaced by hash_* @@ -557,7 +558,7 @@ generate_key(srp, {user, [Generator, Prime, Version]}, PrivateArg) user_srp_gen_key(Private, Generator, Prime); generate_key(ecdh, Curve, undefined) -> - ec_key_generate(Curve). + ec_key_generate(nif_curve_params(Curve)). compute_key(dh, OthersPublicKey, MyPrivateKey, DHParameters) -> @@ -1502,21 +1503,27 @@ ec_key_generate(_Key) -> ?nif_stub. ecdh_compute_key_nif(_Others, _Curve, _My) -> ?nif_stub. +ec_curves() -> + crypto_ec_curves:curves(). + +ec_curve(X) -> + crypto_ec_curves:curve(X). + %% %% EC %% term_to_nif_prime({prime_field, Prime}) -> - {prime_field, int_to_bin(Prime)}; + {prime_field, ensure_int_as_bin(Prime)}; term_to_nif_prime(PrimeField) -> PrimeField. term_to_nif_curve({A, B, Seed}) -> {ensure_int_as_bin(A), ensure_int_as_bin(B), Seed}. nif_curve_params({PrimeField, Curve, BasePoint, Order, CoFactor}) -> - {term_to_nif_prime(PrimeField), term_to_nif_curve(Curve), ensure_int_as_bin(BasePoint), int_to_bin(Order), int_to_bin(CoFactor)}; + {term_to_nif_prime(PrimeField), term_to_nif_curve(Curve), ensure_int_as_bin(BasePoint), ensure_int_as_bin(Order), ensure_int_as_bin(CoFactor)}; nif_curve_params(Curve) when is_atom(Curve) -> %% named curve - Curve. + crypto_ec_curves:curve(Curve). %% MISC -------------------------------------------------------------------- |