aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/src
diff options
context:
space:
mode:
authorWim Lewis <[email protected]>2017-01-08 18:40:32 -0800
committerWim Lewis <[email protected]>2017-01-08 18:40:32 -0800
commit24af5238589a2b0c4a153ead9e2f37506870f94c (patch)
treef6b707aed127166e12eceb78a6c694b76578031f /lib/crypto/src
parentaf0ae0c83aa33ff437de346552b52709649622ef (diff)
downloadotp-24af5238589a2b0c4a153ead9e2f37506870f94c.tar.gz
otp-24af5238589a2b0c4a153ead9e2f37506870f94c.tar.bz2
otp-24af5238589a2b0c4a153ead9e2f37506870f94c.zip
Add RSA key generation
Support RSA key generation using generate_key(rsa, {bits, e}). This depends on the currently-experimental "dirty scheduler" support because key generation is a potentially lengthy process.
Diffstat (limited to 'lib/crypto/src')
-rw-r--r--lib/crypto/src/crypto.erl9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 0b62964efa..d4a2a51697 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -445,6 +445,10 @@ generate_key(srp, {user, [Generator, Prime, Version]}, PrivateArg)
end,
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 };
+
generate_key(ecdh, Curve, PrivKey) ->
ec_key_generate(nif_curve_params(Curve), ensure_int_as_bin(PrivKey)).
@@ -780,6 +784,11 @@ rsa_verify_nif(_Type, _Digest, _Signature, _Key) -> ?nif_stub.
ecdsa_verify_nif(_Type, _Digest, _Signature, _Curve, _Key) -> ?nif_stub.
%% Public Keys --------------------------------------------------------------------
+%% RSA Rivest-Shamir-Adleman functions
+%%
+
+rsa_generate_key_nif(_Bits, _Exp) -> ?nif_stub.
+
%% DH Diffie-Hellman functions
%%