aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public_key/src
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2017-03-31 15:38:53 +0200
committerIngela Anderton Andin <[email protected]>2017-04-12 11:01:09 +0200
commitf606520095236e8dabb85564d3e91361e0b57b6e (patch)
treece97305c1bb185596d2e018ede24bdeb5e1d254b /lib/public_key/src
parent4da32ec432dd2dee0b19403bed21a836f1638549 (diff)
downloadotp-f606520095236e8dabb85564d3e91361e0b57b6e.tar.gz
otp-f606520095236e8dabb85564d3e91361e0b57b6e.tar.bz2
otp-f606520095236e8dabb85564d3e91361e0b57b6e.zip
public_key: Public RSA key is present in private key
Change the return value from {#'RSAPublicKey'{}, #'RSAPrivateKey'{}} to #'RSAPrivateKey'{} This conforms to the #'ECPrivateKey'{} return value. Note that DH key will be returned as {Public::integer(), Private::integer()} as there is no key structure (record) only two integers. Maybe we would like to add extraction functions for the public key from the private ones later.
Diffstat (limited to 'lib/public_key/src')
-rw-r--r--lib/public_key/src/public_key.erl32
1 files changed, 13 insertions, 19 deletions
diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl
index 965606045d..7b5819fa84 100644
--- a/lib/public_key/src/public_key.erl
+++ b/lib/public_key/src/public_key.erl
@@ -402,7 +402,7 @@ dh_gex_group(Min, N, Max, Groups) ->
(#'ECParameters'{}) ->
#'ECPrivateKey'{};
({rsa, Size::pos_integer(), PubExp::pos_integer()}) ->
- {#'RSAPublicKey'{}, #'RSAPrivateKey'{}}.
+ #'RSAPrivateKey'{}.
%% Description: Generates a new keypair
%%--------------------------------------------------------------------
@@ -417,18 +417,15 @@ generate_key({rsa, ModulusSize, PublicExponent}) ->
{[E, N], [E, N, D, P, Q, D_mod_P_1, D_mod_Q_1, InvQ_mod_P]} ->
Nint = crypto:bytes_to_integer(N),
Eint = crypto:bytes_to_integer(E),
- {#'RSAPublicKey'{modulus = Nint,
- publicExponent = Eint},
- #'RSAPrivateKey'{version = 0, % Two-factor (I guess since otherPrimeInfos is not given)
- modulus = Nint,
- publicExponent = Eint,
- privateExponent = crypto:bytes_to_integer(D),
- prime1 = crypto:bytes_to_integer(P),
- prime2 = crypto:bytes_to_integer(Q),
- exponent1 = crypto:bytes_to_integer(D_mod_P_1),
- exponent2 = crypto:bytes_to_integer(D_mod_Q_1),
- coefficient = crypto:bytes_to_integer(InvQ_mod_P)}
- };
+ #'RSAPrivateKey'{version = 0, % Two-factor (I guess since otherPrimeInfos is not given)
+ modulus = Nint,
+ publicExponent = Eint,
+ privateExponent = crypto:bytes_to_integer(D),
+ prime1 = crypto:bytes_to_integer(P),
+ prime2 = crypto:bytes_to_integer(Q),
+ exponent1 = crypto:bytes_to_integer(D_mod_P_1),
+ exponent2 = crypto:bytes_to_integer(D_mod_Q_1),
+ coefficient = crypto:bytes_to_integer(InvQ_mod_P)};
{[E, N], [E, N, D]} -> % FIXME: what to set the other fields in #'RSAPrivateKey'?
% Answer: Miller [Mil76]
@@ -438,9 +435,7 @@ generate_key({rsa, ModulusSize, PublicExponent}) ->
% 1976.
Nint = crypto:bytes_to_integer(N),
Eint = crypto:bytes_to_integer(E),
- {#'RSAPublicKey'{modulus = Nint,
- publicExponent = Eint},
- #'RSAPrivateKey'{version = 0, % Two-factor (I guess since otherPrimeInfos is not given)
+ #'RSAPrivateKey'{version = 0, % Two-factor (I guess since otherPrimeInfos is not given)
modulus = Nint,
publicExponent = Eint,
privateExponent = crypto:bytes_to_integer(D),
@@ -448,9 +443,8 @@ generate_key({rsa, ModulusSize, PublicExponent}) ->
prime2 = '?',
exponent1 = '?',
exponent2 = '?',
- coefficient = '?'}
- };
-
+ coefficient = '?'};
+
Other ->
Other
end.