@@ -753,9 +753,9 @@ encode_extensions([#sni{hostname = ""} | Rest], Acc) ->
753753encode_extensions ([# sni {hostname = Hostname } | Rest ], Acc ) ->
754754 HostLen = length (Hostname ),
755755 HostnameBin = list_to_binary (Hostname ),
756- % Hostname type (1 byte) + Hostname length (2 bytes) + Hostname (HostLen bytes)
756+ % % Hostname type (1 byte) + Hostname length (2 bytes) + Hostname (HostLen bytes)
757757 ServerNameLength = 1 + 2 + HostLen ,
758- % ServerNameListSize (2 bytes) + ServerNameLength
758+ % % ServerNameListSize (2 bytes) + ServerNameLength
759759 ExtLength = 2 + ServerNameLength ,
760760 encode_extensions (Rest , <<? UINT16 (? SNI_EXT ), ? UINT16 (ExtLength ),
761761 ? UINT16 (ServerNameLength ),
@@ -1561,7 +1561,7 @@ handle_client_hello_extensions(RecordCB, Random, ClientCipherSuites,
15611561 Random , NegotiatedCipherSuite ,
15621562 ClientCipherSuites ,
15631563 ConnectionStates0 ,
1564- Renegotiation , SecureRenegotation ),
1564+ Renegotiation ),
15651565
15661566 Empty = empty_extensions (Version , server_hello ),
15671567 {ServerMaxFragEnum , ConnectionStates , Session } =
@@ -1595,7 +1595,7 @@ handle_client_hello_extensions(RecordCB, Random, ClientCipherSuites,
15951595
15961596handle_server_hello_extensions (RecordCB , Random , CipherSuite ,
15971597 Exts , Version ,
1598- SslOpts ,
1598+ SslOpts ,
15991599 ConnectionStates0 , Renegotiation , IsNew ) ->
16001600 ConnectionStates = handle_renegotiation_extension (client , RecordCB , Version ,
16011601 maps :get (renegotiation_info , Exts , undefined ),
@@ -1618,7 +1618,8 @@ handle_server_hello_extensions(RecordCB, Random, CipherSuite,
16181618 undefined ->
16191619 NextProtocolNegotiation = maps :get (next_protocol_negotiation , Exts , undefined ),
16201620 NextProtocolSelector = maps :get (next_protocol_selector , SslOpts , undefined ),
1621- Protocol = handle_next_protocol (NextProtocolNegotiation , NextProtocolSelector , Renegotiation ),
1621+ Protocol =
1622+ handle_next_protocol (NextProtocolNegotiation , NextProtocolSelector , Renegotiation ),
16221623 {ConnectionStates , npn , Protocol , StaplingState };
16231624 {error , Reason } ->
16241625 throw (? ALERT_REC (? FATAL , ? HANDSHAKE_FAILURE , Reason ));
@@ -3918,12 +3919,12 @@ handle_renegotiation_info(_, _RecordCB, server, undefined, ConnectionStates, _,
39183919 {ok , ssl_record :set_renegotiation_flag (false , ConnectionStates )}
39193920 end ;
39203921
3921- handle_renegotiation_info (_ , _RecordCB , _ , undefined , ConnectionStates , false , _ , _ ) ->
3922+ handle_renegotiation_info (_ , _RecordCB , _ , undefined , ConnectionStates , false ,_ ) ->
39223923 {ok , ssl_record :set_renegotiation_flag (false , ConnectionStates )};
39233924
39243925handle_renegotiation_info (_ , _RecordCB , client ,
39253926 # renegotiation_info {renegotiated_connection = ClientServerVerify },
3926- ConnectionStates , true , _ , _ ) ->
3927+ ConnectionStates , true , _ ) ->
39273928 #{reneg := ReNeg } = ssl_record :current_connection_state (ConnectionStates , read ),
39283929 #{client_verify_data := CData , server_verify_data := SData } = ReNeg ,
39293930 case <<CData /binary , SData /binary >> == ClientServerVerify of
@@ -3934,10 +3935,11 @@ handle_renegotiation_info(_, _RecordCB, client,
39343935 end ;
39353936handle_renegotiation_info (_ , _RecordCB , server ,
39363937 # renegotiation_info {renegotiated_connection = ClientVerify },
3937- ConnectionStates , true , _ , CipherSuites ) ->
3938+ ConnectionStates , true , CipherSuites ) ->
39383939 case is_member (? TLS_EMPTY_RENEGOTIATION_INFO_SCSV , CipherSuites ) of
39393940 true ->
3940- throw (? ALERT_REC (? FATAL , ? HANDSHAKE_FAILURE , {server_renegotiation , empty_renegotiation_info_scsv }));
3941+ throw (? ALERT_REC (? FATAL , ? HANDSHAKE_FAILURE ,
3942+ {server_renegotiation , empty_renegotiation_info_scsv }));
39413943 false ->
39423944 case ssl_record :current_connection_state (ConnectionStates , read ) of
39433945 #{reneg := #{client_verify_data := ClientVerify }} ->
@@ -3946,28 +3948,17 @@ handle_renegotiation_info(_, _RecordCB, server,
39463948 throw (? ALERT_REC (? FATAL , ? HANDSHAKE_FAILURE , server_renegotiation ))
39473949 end
39483950 end ;
3949- handle_renegotiation_info (_ , RecordCB , client , undefined , ConnectionStates , true , SecureRenegotation , _ ) ->
3950- handle_renegotiation_info (RecordCB , ConnectionStates , SecureRenegotation );
3951-
3952- handle_renegotiation_info (_ , RecordCB , server , undefined , ConnectionStates , true , SecureRenegotation , CipherSuites ) ->
3951+ handle_renegotiation_info (_ , _ , client , undefined , _ , true , _ ) ->
3952+ throw (? ALERT_REC (? FATAL , ? NO_RENEGOTIATION , only_allow_secure_renegotiation ));
3953+ handle_renegotiation_info (_ , _ , server , undefined , _ , true , CipherSuites ) ->
39533954 case is_member (? TLS_EMPTY_RENEGOTIATION_INFO_SCSV , CipherSuites ) of
39543955 true ->
3955- throw (? ALERT_REC (? FATAL , ? HANDSHAKE_FAILURE , {server_renegotiation , empty_renegotiation_info_scsv }));
3956+ throw (? ALERT_REC (? FATAL , ? HANDSHAKE_FAILURE ,
3957+ {server_renegotiation , empty_renegotiation_info_scsv }));
39563958 false ->
3957- handle_renegotiation_info ( RecordCB , ConnectionStates , SecureRenegotation )
3959+ throw ( ? ALERT_REC ( ? FATAL , ? NO_RENEGOTIATION , only_allow_secure_renegotiation ) )
39583960 end .
39593961
3960- handle_renegotiation_info (_RecordCB , ConnectionStates , SecureRenegotation ) ->
3961- #{reneg := #{secure_renegotiation := SR }} = ssl_record :current_connection_state (ConnectionStates , read ),
3962- case {SecureRenegotation , SR } of
3963- {_ , true } ->
3964- throw (? ALERT_REC (? FATAL , ? HANDSHAKE_FAILURE , already_secure ));
3965- {true , false } ->
3966- throw (? ALERT_REC (? FATAL , ? NO_RENEGOTIATION ));
3967- {false , false } ->
3968- {ok , ConnectionStates }
3969- end .
3970-
39713962cert_curve (_ , _ , no_suite ) ->
39723963 {no_curve , no_suite };
39733964cert_curve (Cert , ECCCurve0 , CipherSuite ) ->
0 commit comments