aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-03-15 17:42:34 +0100
committerHans Nilsson <[email protected]>2019-03-19 14:51:20 +0100
commit6073fc94303ec517432fa02cbbaa6e70a0fd1659 (patch)
treeb80c4b0656a7ed08ef11fc3d5ca5dfd759406f95 /lib/ssh
parentd5bc39813f00cc969ec5c7cc2eecd0b4a81c5b95 (diff)
downloadotp-6073fc94303ec517432fa02cbbaa6e70a0fd1659.tar.gz
otp-6073fc94303ec517432fa02cbbaa6e70a0fd1659.tar.bz2
otp-6073fc94303ec517432fa02cbbaa6e70a0fd1659.zip
ssh: Use the exceptions as error return change
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/src/ssh_transport.erl36
1 files changed, 10 insertions, 26 deletions
diff --git a/lib/ssh/src/ssh_transport.erl b/lib/ssh/src/ssh_transport.erl
index 9f50772d75..1f4e281a30 100644
--- a/lib/ssh/src/ssh_transport.erl
+++ b/lib/ssh/src/ssh_transport.erl
@@ -1424,13 +1424,9 @@ encrypt_init(#ssh{encrypt = SshCipher, role = Role} = Ssh) ->
block_bytes = BlockBytes} = cipher(SshCipher),
IV = hash(Ssh, IvMagic, 8*IvBytes),
K = hash(Ssh, KeyMagic, 8*KeyBytes),
- case crypto:crypto_init(CryptoCipher, K, IV, true) of
- {ok,Ctx0} ->
- {ok, Ssh#ssh{encrypt_block_size = BlockBytes,
- encrypt_ctx = Ctx0}};
- {error,Error} ->
- error(Error)
- end.
+ Ctx0 = crypto:crypto_init(CryptoCipher, K, IV, true),
+ {ok, Ssh#ssh{encrypt_block_size = BlockBytes,
+ encrypt_ctx = Ctx0}}.
encrypt_final(Ssh) ->
{ok, Ssh#ssh{encrypt = none,
@@ -1470,12 +1466,8 @@ encrypt(#ssh{encrypt = SshCipher,
{Ssh#ssh{encrypt_ctx = IV}, {<<LenData/binary,Ctext/binary>>,Ctag}};
encrypt(#ssh{encrypt_ctx = Ctx0} = Ssh, Data) ->
- case crypto:crypto_update(Ctx0, Data) of
- Enc when is_binary(Enc) ->
- {Ssh, Enc};
- {error, Error} ->
- error(Error)
- end.
+ Enc = crypto:crypto_update(Ctx0, Data),
+ {Ssh, Enc}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Decryption
@@ -1510,13 +1502,9 @@ decrypt_init(#ssh{decrypt = SshCipher, role = Role} = Ssh) ->
block_bytes = BlockBytes} = cipher(SshCipher),
IV = hash(Ssh, IvMagic, 8*IvBytes),
K = hash(Ssh, KeyMagic, 8*KeyBytes),
- case crypto:crypto_init(CryptoCipher, K, IV, false) of
- {ok,Ctx0} ->
- {ok, Ssh#ssh{decrypt_block_size = BlockBytes,
- decrypt_ctx = Ctx0}};
- {error,Error} ->
- error(Error)
- end.
+ Ctx0 = crypto:crypto_init(CryptoCipher, K, IV, false),
+ {ok, Ssh#ssh{decrypt_block_size = BlockBytes,
+ decrypt_ctx = Ctx0}}.
decrypt_final(Ssh) ->
{ok, Ssh#ssh {decrypt = none,
@@ -1562,12 +1550,8 @@ decrypt(#ssh{decrypt = SshCipher,
{Ssh#ssh{decrypt_ctx = IV}, Dec};
decrypt(#ssh{decrypt_ctx = Ctx0} = Ssh, Data) ->
- case crypto:crypto_update(Ctx0, Data) of
- Dec when is_binary(Dec) ->
- {Ssh, Dec};
- {error, Error} ->
- error(Error)
- end.
+ Dec = crypto:crypto_update(Ctx0, Data),
+ {Ssh, Dec}.
next_gcm_iv(<<Fixed:32, InvCtr:64>>) -> <<Fixed:32, (InvCtr+1):64>>.