forked from QPQ-AG/enoise
WIP
This commit is contained in:
+16
-17
@@ -7,7 +7,6 @@
|
||||
%%% For convenience there is also an API to use Noise over TCP (i.e. `gen_tcp')
|
||||
%%% and after "upgrading" a `gen_tcp'-socket into a `enoise'-socket it has a
|
||||
%%% similar API as `gen_tcp'.
|
||||
%%%
|
||||
%%% @end
|
||||
|
||||
-module(enoise).
|
||||
@@ -55,7 +54,7 @@
|
||||
-type timeout() :: pos_integer() | infinity.
|
||||
-type recv_return() :: {ok, binary(), com_state_state()}
|
||||
| {error, term()}).
|
||||
-type recv_msg_fun() :: fun((com_state_state(), timeout()) -> recv_return().
|
||||
-type recv_msg_fun() :: fun((com_state_state(), timeout()) -> recv_return()).
|
||||
|
||||
-type send_msg_fun() :: fun((com_state_state(), binary()) -> ok).
|
||||
|
||||
@@ -92,21 +91,6 @@ handshake(Options, Role) ->
|
||||
create_hstate(Options, Role).
|
||||
|
||||
|
||||
-spec step_handshake(HState, Data) -> Next
|
||||
when HState :: enoise_hs_state:state(),
|
||||
Data :: {rcvd, binary()}
|
||||
| {send, binary()},
|
||||
Next :: {ok, send, binary(), enoise_hs_state:state()}
|
||||
| {ok, rcvd, binary(), enoise_hs_state:state()}
|
||||
| {ok, done, split_state()}
|
||||
| {error, term()}.
|
||||
%% @doc
|
||||
%% Do a step (one of `{send, Payload}', `{rcvd, EncryptedData}', or `done')
|
||||
|
||||
step_handshake(HState, Data) ->
|
||||
do_step_handshake(HState, Data).
|
||||
|
||||
|
||||
-spec handshake(Options, Role, ComState) -> Outcome
|
||||
when Options :: options(),
|
||||
Role :: enoise_hs_state:noise_role(),
|
||||
@@ -126,6 +110,21 @@ handshake(Options, Role, ComState) ->
|
||||
end.
|
||||
|
||||
|
||||
-spec step_handshake(HState, Data) -> Next
|
||||
when HState :: enoise_hs_state:state(),
|
||||
Data :: {rcvd, binary()}
|
||||
| {send, binary()},
|
||||
Next :: {ok, send, binary(), enoise_hs_state:state()}
|
||||
| {ok, rcvd, binary(), enoise_hs_state:state()}
|
||||
| {ok, done, split_state()}
|
||||
| {error, term()}.
|
||||
%% @doc
|
||||
%% Do a step (one of `{send, Payload}', `{rcvd, EncryptedData}', or `done')
|
||||
|
||||
step_handshake(HState, Data) ->
|
||||
do_step_handshake(HState, Data).
|
||||
|
||||
|
||||
-spec connect(TcpSock, Options) -> Outcome
|
||||
when TcpSock :: gen_tcp:socket(),
|
||||
Options :: options(),
|
||||
|
||||
Reference in New Issue
Block a user