Skip to content

Commit

Permalink
Merge pull request erlang#6488 from belltoy/fix/quote-maybe-in-ssl
Browse files Browse the repository at this point in the history
Quote the atom `maybe` in the `ssl` application
OTP-18335
  • Loading branch information
u3s authored Dec 5, 2022
2 parents 4a693f2 + 3e55f1e commit b8a7d6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/ssl/src/ssl_gen_statem.erl
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ initial_hello({call, From}, {start, Timeout},
%% ServerHello is processed.
RequestedVersion = tls_record:hello_version(Versions),

{Ref,Maybe} = tls_handshake_1_3:maybe(),
{Ref,Maybe} = tls_handshake_1_3:maybe_do(),
try
%% Send Early Data
State4 = Maybe(tls_handshake_1_3:maybe_send_early_data(State3)),
Expand Down
32 changes: 16 additions & 16 deletions lib/ssl/src/tls_handshake_1_3.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

-export([get_max_early_data/1,
is_valid_binder/4,
maybe/0,
maybe_do/0,
path_validation/10]).

%% crypto:hash(sha256, "HelloRetryRequest").
Expand Down Expand Up @@ -632,7 +632,7 @@ do_start(#client_hello{cipher_suites = ClientCiphers,
early_data := EarlyDataEnabled}} = State0) ->
SNI = maps:get(sni, Extensions, undefined),
EarlyDataIndication = maps:get(early_data, Extensions, undefined),
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
ClientGroups0 = Maybe(supported_groups_from_extensions(Extensions)),
ClientGroups = Maybe(get_supported_groups(ClientGroups0)),
Expand Down Expand Up @@ -759,7 +759,7 @@ do_start(#server_hello{cipher_suite = SelectedCipherSuite,
session = Session0,
connection_states = ConnectionStates0
} = State0) ->
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
ClientGroups = Maybe(get_supported_groups(ClientGroups0)),
CookieExt = maps:get(cookie, Extensions, undefined),
Expand Down Expand Up @@ -848,7 +848,7 @@ do_negotiated({start_handshake, PSK0},
ssl_record:pending_connection_state(ConnectionStates0, read),
#security_parameters{prf_algorithm = HKDF} = SecParamsR,

{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
%% Create server_hello
ServerHello = server_hello(server_hello, SessionId, KeyShare, PSK0, ConnectionStates0),
Expand Down Expand Up @@ -914,7 +914,7 @@ do_negotiated({start_handshake, PSK0},


do_wait_cert(#certificate_1_3{} = Certificate, State0) ->
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
Maybe(process_certificate(Certificate, State0))
catch
Expand All @@ -926,7 +926,7 @@ do_wait_cert(#certificate_1_3{} = Certificate, State0) ->


do_wait_cv(#certificate_verify_1_3{} = CertificateVerify, #state{static_env = #static_env{role = Role}} = State0) ->
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
State1 = case Role of
server ->
Expand All @@ -943,7 +943,7 @@ do_wait_cv(#certificate_verify_1_3{} = CertificateVerify, #state{static_env = #s
%% TLS Server
do_wait_finished(#finished{verify_data = VerifyData},
#state{static_env = #static_env{role = server}} = State0) ->
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),

try
Maybe(validate_finished(State0, VerifyData)),
Expand All @@ -967,7 +967,7 @@ do_wait_finished(#finished{verify_data = VerifyData},
#state{static_env = #static_env{role = client,
protocol_cb = Connection}} = State0) ->

{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),

try
Maybe(validate_finished(State0, VerifyData)),
Expand Down Expand Up @@ -1002,7 +1002,7 @@ do_wait_sh(#server_hello{cipher_suite = SelectedCipherSuite,
session_tickets := SessionTickets,
use_ticket := UseTicket}} = State0) ->

{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
ClientGroups = Maybe(get_supported_groups(ClientGroups0)),
ServerKeyShare0 = maps:get(key_share, Extensions, undefined),
Expand Down Expand Up @@ -1059,7 +1059,7 @@ do_wait_ee(#encrypted_extensions{extensions = Extensions}, State0) ->
ALPNProtocol = get_alpn(ALPNProtocol0),
EarlyDataIndication = maps:get(early_data, Extensions, undefined),

{Ref, Maybe} = maybe(),
{Ref, Maybe} = maybe_do(),

try
%% RFC 6066: handle received/expected maximum fragment length
Expand All @@ -1085,7 +1085,7 @@ do_wait_ee(#encrypted_extensions{extensions = Extensions}, State0) ->


do_wait_cert_cr(#certificate_1_3{} = Certificate, State0) ->
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
Maybe(process_certificate(Certificate, State0))
catch
Expand All @@ -1095,7 +1095,7 @@ do_wait_cert_cr(#certificate_1_3{} = Certificate, State0) ->
{Alert, State}
end;
do_wait_cert_cr(#certificate_request_1_3{} = CertificateRequest, State0) ->
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
Maybe(process_certificate_request(CertificateRequest, State0))
catch
Expand All @@ -1105,7 +1105,7 @@ do_wait_cert_cr(#certificate_request_1_3{} = CertificateRequest, State0) ->


do_wait_eoed(#end_of_early_data{}, State0) ->
{Ref,_Maybe} = maybe(),
{Ref,_Maybe} = maybe_do(),
try
%% Step read state to enable reading handshake messages from the client.
%% Write state is already stepped in state 'negotiated'.
Expand Down Expand Up @@ -1228,7 +1228,7 @@ maybe_queue_cert_cert_cv(#state{connection_states = _ConnectionStates0,
socket = _Socket,
transport_cb = _Transport}
} = State0) ->
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
%% Create Certificate
Certificate = Maybe(certificate(OwnCerts, CertDbHandle, CertDbRef, <<>>, client)),
Expand All @@ -1255,7 +1255,7 @@ maybe_queue_cert_verify(_Certificate,
static_env = #static_env{role = client,
protocol_cb = Connection}
} = State) ->
{Ref,Maybe} = maybe(),
{Ref,Maybe} = maybe_do(),
try
CertificateVerify = Maybe(certificate_verify(CertPrivateKey, SignatureScheme, State, client)),
{ok, Connection:queue_handshake(CertificateVerify, State)}
Expand Down Expand Up @@ -2547,7 +2547,7 @@ get_alpn(ALPNProtocol0) ->
ALPNProtocol
end.

maybe() ->
maybe_do() ->
Ref = erlang:make_ref(),
Ok = fun(ok) -> ok;
({ok,R}) -> R;
Expand Down

0 comments on commit b8a7d6d

Please sign in to comment.