@@ -349,7 +349,7 @@ is_higher(_, _) ->
349349
350350
351351% %--------------------------------------------------------------------
352- -spec supported_protocol_versions () -> [tls_version ()].
352+ -spec supported_protocol_versions () -> [tls_version ()].
353353% %
354354% % Description: Protocol versions supported
355355% %--------------------------------------------------------------------
@@ -378,32 +378,31 @@ supported_protocol_versions([]) ->
378378supported_protocol_versions ([_ |_ ] = Vsns ) ->
379379 sufficient_support (Vsns ).
380380
381- sufficient_crypto_support (Version ) ->
382- sufficient_crypto_support (crypto :supports (), Version ).
383-
384- sufficient_crypto_support (CryptoSupport , Version ) when Version == 'tlsv1' ;
385- Version == 'tlsv1.1' ->
386- Hashes = proplists :get_value (hashs , CryptoSupport ),
387- PKeys = proplists :get_value (public_keys , CryptoSupport ),
388- proplists :get_bool (sha , Hashes )
381+ sufficient_crypto_support (Version ) when Version == 'tlsv1' ;
382+ Version == 'tlsv1.1' ->
383+ Hashes = crypto :supports (hashs ),
384+ PKeys = crypto :supports (public_keys ),
385+ proplists :get_bool (sha , Hashes )
386+ andalso
387+ proplists :get_bool (md5 , Hashes )
389388 andalso
390- proplists :get_bool (md5 , Hashes )
391- andalso
392- proplists :get_bool (aes_cbc , proplists :get_value (ciphers , CryptoSupport ))
389+ proplists :get_bool (aes_cbc , crypto :supports (ciphers ))
393390 andalso
394- (proplists :get_bool (ecdsa , PKeys ) orelse proplists :get_bool (rsa , PKeys ) orelse proplists :get_bool (dss , PKeys ))
391+ (proplists :get_bool (ecdsa , PKeys ) orelse proplists :get_bool (rsa , PKeys ) orelse
392+ proplists :get_bool (dss , PKeys ))
395393 andalso
396394 (proplists :get_bool (ecdh , PKeys ) orelse proplists :get_bool (dh , PKeys ));
397395
398- sufficient_crypto_support (CryptoSupport , 'tlsv1.2' ) ->
399- PKeys = proplists :get_value (public_keys , CryptoSupport ),
400- (proplists :get_bool (sha256 , proplists :get_value (hashs , CryptoSupport )))
401- andalso
402- (proplists :get_bool (aes_cbc , proplists :get_value (ciphers , CryptoSupport )))
396+ sufficient_crypto_support ('tlsv1.2' ) ->
397+ PKeys = crypto :supports (public_keys ),
398+ (proplists :get_bool (sha256 , crypto :supports (hashs )))
403399 andalso
404- (proplists :get_bool (ecdsa , PKeys ) orelse proplists : get_bool ( rsa , PKeys ) orelse proplists : get_bool ( dss , PKeys ))
400+ (proplists :get_bool (aes_cbc , crypto : supports ( ciphers ))
405401 andalso
406- (proplists :get_bool (ecdh , PKeys ) orelse proplists :get_bool (dh , PKeys ));
402+ (proplists :get_bool (ecdsa , PKeys ) orelse proplists :get_bool (rsa , PKeys ) orelse
403+ proplists :get_bool (dss , PKeys ))
404+ andalso
405+ (proplists :get_bool (ecdh , PKeys ) orelse proplists :get_bool (dh , PKeys )));
407406
408407% % A TLS-compliant application MUST implement the TLS_AES_128_GCM_SHA256
409408% % [GCM] cipher suite and SHOULD implement the TLS_AES_256_GCM_SHA384
@@ -415,9 +414,9 @@ sufficient_crypto_support(CryptoSupport, 'tlsv1.2') ->
415414% % CertificateVerify and certificates), and ecdsa_secp256r1_sha256. A
416415% % TLS-compliant application MUST support key exchange with secp256r1
417416% % (NIST P-256) and SHOULD support key exchange with X25519 [RFC7748].
418- sufficient_crypto_support (CryptoSupport , 'tlsv1.3' ) ->
417+ sufficient_crypto_support ('tlsv1.3' ) ->
419418 Fun = fun ({Group , Algorithm }) ->
420- is_algorithm_supported (CryptoSupport , Group , Algorithm )
419+ is_algorithm_supported (crypto : supports ( Group ) , Algorithm )
421420 end ,
422421 % % Minimum requirement check
423422 L = [{ciphers , aes_gcm }, % % TLS_AES_*_GCM_*
@@ -430,12 +429,12 @@ sufficient_crypto_support(CryptoSupport, 'tlsv1.3') ->
430429 {curves , secp256r1 } % % key exchange with secp256r1
431430 ],
432431 lists :all (Fun , L );
433- sufficient_crypto_support (CryptoSupport , Version ) ->
434- sufficient_crypto_support (CryptoSupport , protocol_version (Version )).
432+ sufficient_crypto_support (Version ) ->
433+ sufficient_crypto_support (protocol_version (Version )).
435434
436435
437- is_algorithm_supported (CryptoSupport , Group , Algorithm ) ->
438- proplists :get_bool (Algorithm , proplists : get_value ( Group , CryptoSupport ) ).
436+ is_algorithm_supported (CryptoSupport , Algorithm ) ->
437+ proplists :get_bool (Algorithm , CryptoSupport ).
439438
440439-spec is_acceptable_version (tls_version ()) -> boolean ().
441440is_acceptable_version (Version )
@@ -726,6 +725,5 @@ max_len(_) ->
726725 ? MAX_CIPHER_TEXT_LENGTH .
727726
728727sufficient_support (Versions ) ->
729- CryptoSupport = crypto :supports (),
730- [Ver || Ver <- Versions , sufficient_crypto_support (CryptoSupport , Ver )].
728+ [Ver || Ver <- Versions , sufficient_crypto_support (Ver )].
731729
0 commit comments