diff options
author | Ingela Anderton Andin <[email protected]> | 2017-04-12 11:07:03 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2017-04-12 11:07:03 +0200 |
commit | e19e06d91eff086b4649c5524b3756e9c8e79fbe (patch) | |
tree | 3024a6e68eba1dc399941d3817570535dd688f9d /lib/public_key | |
parent | 4da32ec432dd2dee0b19403bed21a836f1638549 (diff) | |
parent | 1d019afd9d69eaa566d652117b607c83bfb93b31 (diff) | |
download | otp-e19e06d91eff086b4649c5524b3756e9c8e79fbe.tar.gz otp-e19e06d91eff086b4649c5524b3756e9c8e79fbe.tar.bz2 otp-e19e06d91eff086b4649c5524b3756e9c8e79fbe.zip |
Merge branch 'ingela/ssl/ECC-combos/OTP-14334'
* ingela/ssl/ECC-combos/OTP-14334:
ssl: Generate correct certificate chains for the ECC tests
public_key: Public RSA key is present in private key
Diffstat (limited to 'lib/public_key')
-rw-r--r-- | lib/public_key/doc/src/public_key.xml | 5 | ||||
-rw-r--r-- | lib/public_key/src/public_key.erl | 32 | ||||
-rw-r--r-- | lib/public_key/test/erl_make_certs.erl | 2 |
3 files changed, 16 insertions, 23 deletions
diff --git a/lib/public_key/doc/src/public_key.xml b/lib/public_key/doc/src/public_key.xml index 2300ce3937..940585575c 100644 --- a/lib/public_key/doc/src/public_key.xml +++ b/lib/public_key/doc/src/public_key.xml @@ -331,14 +331,15 @@ </func> <func> - <name>generate_key(Params) -> {Public::binary(), Private::binary()} | #'ECPrivateKey'{} | {#'RSAPublicKey'{}, #'RSAPrivateKey'{}}</name> + <name>generate_key(Params) -> {Public::binary(), Private::binary()} | #'ECPrivateKey'{} | #'RSAPrivateKey'{}</name> <fsummary>Generates a new keypair.</fsummary> <type> <v>Params = #'DHParameter'{} | {namedCurve, oid()} | #'ECParameters'{} | {rsa, Size::integer(), PubExp::integer} </v> </type> <desc> - <p>Generates a new keypair. See also + <p>Generates a new keypair. Note that except for Diffie-Hellman + the public key is included in the private key structure. See also <seealso marker="crypto:crypto#generate_key/2">crypto:generate_key/2</seealso> </p> </desc> 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. diff --git a/lib/public_key/test/erl_make_certs.erl b/lib/public_key/test/erl_make_certs.erl index 00be7dd5b3..95d0dec920 100644 --- a/lib/public_key/test/erl_make_certs.erl +++ b/lib/public_key/test/erl_make_certs.erl @@ -351,8 +351,6 @@ gen_rsa2(Size) -> %% The numbers 2048,17 is choosen to not cause the cryptolib on %% FIPS-enabled test machines be mad at us. public_key:generate_key({rsa, 2048, 17}) - of - {_Public, Private} -> Private catch error:notsup -> %% Disabled dirty_schedulers => crypto:generate_key not working |