Handle failed decrypts in handshake
This commit is contained in:
parent
a484d14c41
commit
a024fc4dc9
@ -181,8 +181,12 @@ do_handshake(HState, ComState, Timeout) ->
|
|||||||
in ->
|
in ->
|
||||||
case hs_recv_msg(ComState, Timeout) of
|
case hs_recv_msg(ComState, Timeout) of
|
||||||
{ok, Data, ComState1} ->
|
{ok, Data, ComState1} ->
|
||||||
{ok, HState1, _Msg} = enoise_hs_state:read_message(HState, Data),
|
case enoise_hs_state:read_message(HState, Data) of
|
||||||
do_handshake(HState1, ComState1, Timeout);
|
{ok, HState1, _Msg} ->
|
||||||
|
do_handshake(HState1, ComState1, Timeout);
|
||||||
|
Err = {error, _} ->
|
||||||
|
Err
|
||||||
|
end;
|
||||||
Err = {error, _} ->
|
Err = {error, _} ->
|
||||||
Err
|
Err
|
||||||
end;
|
end;
|
||||||
|
@ -160,8 +160,11 @@ encrypt_and_hash(HS = #noise_hs{ ss = SS0 }, PlainText) ->
|
|||||||
{ok, HS#noise_hs{ ss = SS1 }, CipherText}.
|
{ok, HS#noise_hs{ ss = SS1 }, CipherText}.
|
||||||
|
|
||||||
decrypt_and_hash(HS = #noise_hs{ ss = SS0 }, CipherText) ->
|
decrypt_and_hash(HS = #noise_hs{ ss = SS0 }, CipherText) ->
|
||||||
{ok, SS1, PlainText} = enoise_sym_state:decrypt_and_hash(SS0, CipherText),
|
case enoise_sym_state:decrypt_and_hash(SS0, CipherText) of
|
||||||
{ok, HS#noise_hs{ ss = SS1 }, PlainText}.
|
{ok, SS1, PlainText} ->
|
||||||
|
{ok, HS#noise_hs{ ss = SS1 }, PlainText};
|
||||||
|
|
||||||
|
{error, Reason} ->
|
||||||
|
{error, Reason}
|
||||||
|
end.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user