diff options
author | Ingela Anderton Andin <[email protected]> | 2013-04-25 14:51:19 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2013-05-08 10:39:21 +0200 |
commit | badb8f14e9829ce0a797b56702997aa355cdd9ba (patch) | |
tree | e0e83ebf28a70a67a4bb710b7f3ef03301facf03 /lib/ssl | |
parent | dad86c51e920d015da390ec6bef3da24924fa063 (diff) | |
download | otp-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/ssl')
-rw-r--r-- | lib/ssl/src/ssl_handshake.erl | 16 | ||||
-rw-r--r-- | lib/ssl/test/erl_make_certs.erl | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl index 0744ef4180..338319ab9e 100644 --- a/lib/ssl/src/ssl_handshake.erl +++ b/lib/ssl/src/ssl_handshake.erl @@ -429,10 +429,8 @@ key_exchange(client, _Version, {srp, PublicKey}) -> key_exchange(server, Version, {dh, {PublicKey, _}, #'DHParameter'{prime = P, base = G}, HashSign, ClientRandom, ServerRandom, PrivateKey}) -> - <<?UINT32(_), PBin/binary>> = crypto:mpint(P), - <<?UINT32(_), GBin/binary>> = crypto:mpint(G), - ServerDHParams = #server_dh_params{dh_p = PBin, - dh_g = GBin, dh_y = PublicKey}, + ServerDHParams = #server_dh_params{dh_p = int_to_bin(P), + dh_g = int_to_bin(G), dh_y = PublicKey}, enc_server_key_exchange(Version, ServerDHParams, HashSign, ClientRandom, ServerRandom, PrivateKey); @@ -452,12 +450,10 @@ key_exchange(server, Version, {psk, PskIdentityHint, key_exchange(server, Version, {dhe_psk, PskIdentityHint, {PublicKey, _}, #'DHParameter'{prime = P, base = G}, HashSign, ClientRandom, ServerRandom, PrivateKey}) -> - <<?UINT32(_), PBin/binary>> = crypto:mpint(P), - <<?UINT32(_), GBin/binary>> = crypto:mpint(G), ServerEDHPSKParams = #server_dhe_psk_params{ hint = PskIdentityHint, - dh_params = #server_dh_params{dh_p = PBin, - dh_g = GBin, dh_y = PublicKey} + dh_params = #server_dh_params{dh_p = int_to_bin(P), + dh_g = int_to_bin(G), dh_y = PublicKey} }, enc_server_key_exchange(Version, ServerEDHPSKParams, HashSign, ClientRandom, ServerRandom, PrivateKey); @@ -1791,3 +1787,7 @@ handle_srp_extension(undefined, Session) -> Session; handle_srp_extension(#srp{username = Username}, Session) -> Session#session{srp_username = Username}. + +int_to_bin(I) -> + L = (length(integer_to_list(I, 16)) + 1) div 2, + <<I:(L*8)>>. diff --git a/lib/ssl/test/erl_make_certs.erl b/lib/ssl/test/erl_make_certs.erl index c32ca6dd1f..723ccf4496 100644 --- a/lib/ssl/test/erl_make_certs.erl +++ b/lib/ssl/test/erl_make_certs.erl @@ -409,7 +409,7 @@ int2list(I) -> binary_to_list(<<I:(L*8)>>). gen_ec2(CurveId) -> - {PrivKey, PubKey} = crypto:generate_key(ecdh,CurveId), + {PrivKey, PubKey} = crypto:generate_key(ecdh, CurveId), #'ECPrivateKey'{version = 1, privateKey = int2list(PrivKey), |