aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/src
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2013-04-25 14:51:19 +0200
committerIngela Anderton Andin <[email protected]>2013-05-08 10:39:21 +0200
commitbadb8f14e9829ce0a797b56702997aa355cdd9ba (patch)
treee0e83ebf28a70a67a4bb710b7f3ef03301facf03 /lib/crypto/src
parentdad86c51e920d015da390ec6bef3da24924fa063 (diff)
downloadotp-badb8f14e9829ce0a797b56702997aa355cdd9ba.tar.gz
otp-badb8f14e9829ce0a797b56702997aa355cdd9ba.tar.bz2
otp-badb8f14e9829ce0a797b56702997aa355cdd9ba.zip
ssl, crypto: Eliminate remaining mpint and EC resource key from API
Diffstat (limited to 'lib/crypto/src')
-rw-r--r--lib/crypto/src/crypto.erl17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 43ea1d48fd..f87644b3fe 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -855,8 +855,8 @@ verify(rsa, Type, DataOrDigest, Signature, Key) ->
notsup -> erlang:error(notsup);
Bool -> Bool
end;
-verify(ecdsa, Type, DataOrDigest, Signature, Key) ->
- case ecdsa_verify_nif(Type, DataOrDigest, Signature, term_to_ec_key(Key)) of
+verify(ecdsa, Type, DataOrDigest, Signature, [Key, Curve]) ->
+ case ecdsa_verify_nif(Type, DataOrDigest, Signature, term_to_ec_key({Curve, undefined, Key})) of
notsup -> erlang:error(notsup);
Bool -> Bool
end.
@@ -901,6 +901,11 @@ map_ensure_int_as_bin([H|_]=List) when is_integer(H) ->
map_ensure_int_as_bin(List) ->
List.
+ensure_int_as_bin(Int) when is_integer(Int) ->
+ int_to_bin(Int);
+ensure_int_as_bin(Bin) ->
+ Bin.
+
map_to_norm_bin([H|_]=List) when is_integer(H) ->
lists:map(fun(E) -> int_to_bin(E) end, List);
map_to_norm_bin(List) ->
@@ -917,8 +922,8 @@ sign(dss, Type, DataOrDigest, Key) ->
error -> erlang:error(badkey, [DataOrDigest, Key]);
Sign -> Sign
end;
-sign(ecdsa, Type, DataOrDigest, Key) ->
- case ecdsa_sign_nif(Type, DataOrDigest, term_to_ec_key(Key)) of
+sign(ecdsa, Type, DataOrDigest, [Key, Curve]) ->
+ case ecdsa_sign_nif(Type, DataOrDigest, term_to_ec_key({Curve, Key, undefined})) of
error -> erlang:error(badkey, [Type,DataOrDigest,Key]);
Sign -> Sign
end.
@@ -1228,9 +1233,9 @@ term_to_nif_prime({prime_field, Prime}) ->
term_to_nif_prime(PrimeField) ->
PrimeField.
term_to_nif_curve({A, B, Seed}) ->
- {int_to_bin(A), int_to_bin(B), Seed}.
+ {ensure_int_as_bin(A), ensure_int_as_bin(B), Seed}.
term_to_nif_curve_parameters({PrimeField, Curve, BasePoint, Order, CoFactor}) ->
- {term_to_nif_prime(PrimeField), term_to_nif_curve(Curve), BasePoint, int_to_bin(Order), int_to_bin(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_curve_parameters(Curve) when is_atom(Curve) ->
%% named curve
Curve.