From 6073fc94303ec517432fa02cbbaa6e70a0fd1659 Mon Sep 17 00:00:00 2001 From: Hans Nilsson Date: Fri, 15 Mar 2019 17:42:34 +0100 Subject: ssh: Use the exceptions as error return change --- lib/ssh/src/ssh_transport.erl | 36 ++++++++++-------------------------- 1 file 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}, {<>,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(<>) -> <>. -- cgit v1.2.3