aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/src/crypto.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-03-07 16:31:30 +0100
committerHans Nilsson <[email protected]>2017-03-09 15:27:18 +0100
commitf7610977cb2370e2bf54531ad7d6bcd051e6b27c (patch)
tree6e6a9c99a907928d9ca6a5a65fa9b5a0a1cec395 /lib/crypto/src/crypto.erl
parentfcbcc330e733e62ae75c7748ae254e368ce97033 (diff)
downloadotp-f7610977cb2370e2bf54531ad7d6bcd051e6b27c.tar.gz
otp-f7610977cb2370e2bf54531ad7d6bcd051e6b27c.tar.bz2
otp-f7610977cb2370e2bf54531ad7d6bcd051e6b27c.zip
crypto: removed error function from PR and added error handling in crypto.erl
Diffstat (limited to 'lib/crypto/src/crypto.erl')
-rw-r--r--lib/crypto/src/crypto.erl9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index d4a2a51697..046fae674b 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -446,8 +446,13 @@ generate_key(srp, {user, [Generator, Prime, Version]}, PrivateArg)
user_srp_gen_key(Private, Generator, Prime);
generate_key(rsa, {ModulusSize, PublicExponent}, undefined) ->
- Private = rsa_generate_key_nif(ModulusSize, ensure_int_as_bin(PublicExponent)),
- { lists:sublist(Private, 2), Private };
+ case rsa_generate_key_nif(ModulusSize, ensure_int_as_bin(PublicExponent)) of
+ error ->
+ erlang:error(computation_failed,
+ [rsa,{ModulusSize,PublicExponent}]);
+ Private ->
+ {lists:sublist(Private, 2), Private}
+ end;
generate_key(ecdh, Curve, PrivKey) ->
ec_key_generate(nif_curve_params(Curve), ensure_int_as_bin(PrivKey)).