File 0118-ssl-Improve-interop-check.patch of Package erlang

From 6bb87d632c1d8187bb78a4707b3a5d3c58c32b38 Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin <ingela@erlang.org>
Date: Thu, 25 Mar 2021 16:09:01 +0100
Subject: [PATCH 2/2] ssl: Improve interop check

---
 lib/ssl/test/openssl_cipher_suite_SUITE.erl | 52 +++++++++------------
 1 file changed, 22 insertions(+), 30 deletions(-)

diff --git a/lib/ssl/test/openssl_cipher_suite_SUITE.erl b/lib/ssl/test/openssl_cipher_suite_SUITE.erl
index fb1f28aa4a..ad0ecec8b7 100644
--- a/lib/ssl/test/openssl_cipher_suite_SUITE.erl
+++ b/lib/ssl/test/openssl_cipher_suite_SUITE.erl
@@ -401,8 +401,7 @@ init_per_testcase(TestCase, Config) when TestCase == psk_rc4_128;
                                          TestCase == ecdhe_rsa_rc4_128;
                                          TestCase == ecdhe_ecdsa_rc4_128;
                                          TestCase == dh_anon_rc4_128 ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    case lists:member(rc4, SupCiphers) of
+    case supported_cipher(rc4, "RC4") of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -413,8 +412,7 @@ init_per_testcase(TestCase, Config) when  TestCase == psk_aes_128_ccm_8;
                                           TestCase == psk_aes_128_ccm_8;
                                           TestCase == dhe_psk_aes_128_ccm_8;
                                           TestCase == ecdhe_psk_aes_128_ccm_8 ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    case lists:member(aes_128_ccm, SupCiphers) of
+    case supported_cipher(aes_128_ccm, "AES128-CCM8") of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -425,8 +423,8 @@ init_per_testcase(TestCase, Config) when TestCase == psk_aes_256_ccm_8;
                                          TestCase == psk_aes_256_ccm_8;
                                          TestCase == dhe_psk_aes_256_ccm_8;
                                          TestCase == ecdhe_psk_aes_256_ccm_8 ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    case lists:member(aes_256_ccm, SupCiphers) of
+
+    case supported_cipher(aes_256_ccm, "AES128-CCM8")  of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -434,10 +432,7 @@ init_per_testcase(TestCase, Config) when TestCase == psk_aes_256_ccm_8;
             {skip, "Missing AES_256_CCM crypto support"}
     end;
 init_per_testcase(aes_256_gcm_sha384, Config) ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    SupHashs = proplists:get_value(hashs, crypto:supports()),
-    case (lists:member(aes_256_gcm, SupCiphers)) andalso
-        (lists:member(sha384, SupHashs)) of
+    case supported_cipher(aes_256_gcm, "AES256_GCM", sha384) of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -445,10 +440,7 @@ init_per_testcase(aes_256_gcm_sha384, Config) ->
             {skip, "Missing AES_256_GCM crypto support"}
     end;
 init_per_testcase(aes_128_gcm_sha256, Config) ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    SupHashs = proplists:get_value(hashs, crypto:supports()),
-    case lists:member(aes_128_gcm, SupCiphers) andalso
-        (lists:member(sha256, SupHashs)) of
+    case  supported_cipher(aes_128_gcm, "AES128_GCM", sha256) of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -457,10 +449,7 @@ init_per_testcase(aes_128_gcm_sha256, Config) ->
     end;
 
 init_per_testcase(chacha20_poly1305_sha256, Config) ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    SupHashs = proplists:get_value(hashs, crypto:supports()),
-    case (lists:member(chacha20_poly1305, SupCiphers)) andalso
-        (lists:member(sha256, SupHashs)) of
+    case supported_cipher(chacha20_poly1305_sha256, "CHACHA", sha256) of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -468,10 +457,7 @@ init_per_testcase(chacha20_poly1305_sha256, Config) ->
             {skip, "Missing CHACHA20_POLY1305 crypto support"}
     end;
 init_per_testcase(aes_128_ccm_sha256, Config) ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    SupHashs = proplists:get_value(hashs, crypto:supports()),
-    case (lists:member(aes_128_ccm, SupCiphers)) andalso
-        (lists:member(sha256, SupHashs)) of
+    case supported_cipher(aes_128_ccm, "AES128_CCM", sha256) of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -480,10 +466,7 @@ init_per_testcase(aes_128_ccm_sha256, Config) ->
     end;
 
 init_per_testcase(aes_128_ccm_8_sha256, Config) ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    SupHashs = proplists:get_value(hashs, crypto:supports()),
-    case (lists:member(aes_128_ccm, SupCiphers)) andalso
-        (lists:member(sha256, SupHashs)) of
+    case supported_cipher(aes_128_ccm, "AES128_CCM8", sha256) of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -493,8 +476,7 @@ init_per_testcase(aes_128_ccm_8_sha256, Config) ->
 
 init_per_testcase(TestCase, Config) when TestCase == ecdhe_ecdsa_with_aes_128_ccm;
                                          TestCase == ecdhe_ecdsa_with_aes_128_ccm_8->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    case lists:member(aes_128_ccm, SupCiphers) of
+    case supported_cipher(aes_128_ccm, "AES128_CCM") of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -504,8 +486,8 @@ init_per_testcase(TestCase, Config) when TestCase == ecdhe_ecdsa_with_aes_128_cc
 
 init_per_testcase(TestCase, Config) when TestCase == ecdhe_ecdsa_with_aes_256_ccm;
                                          TestCase == ecdhe_ecdsa_with_aes_256_ccm_8 ->
-    SupCiphers = proplists:get_value(ciphers, crypto:supports()),
-    case lists:member(aes_256_ccm, SupCiphers) of
+
+    case supported_cipher(aes_256_ccm, "AES256_CCM") of
         true ->
             ct:timetrap(?DEFAULT_TIMEOUT),
             Config;
@@ -983,3 +965,13 @@ test_ciphers(Kex, Cipher, Version) ->
 
 openssl_suitestr_to_map(OpenSSLSuiteStrs) ->
     [ssl_cipher_format:suite_openssl_str_to_map(SuiteStr) || SuiteStr <- OpenSSLSuiteStrs].
+
+
+supported_cipher(Cipher, CipherStr) ->
+    SupCrypto = proplists:get_value(ciphers, crypto:supports()),
+    SupOpenssl = [OCipher || OCipher <- ssl_test_lib:openssl_ciphers(),  string:find(OCipher, CipherStr) =/= nomatch],
+    lists:member(Cipher, SupCrypto) andalso SupOpenssl =/= [].
+
+supported_cipher(Cipher, CipherStr, Hash) ->
+    Hashes = proplists:get_value(hashs, crypto:supports()),
+    supported_cipher(Cipher, CipherStr) andalso lists:member(Hash, Hashes).
-- 
2.26.2

openSUSE Build Service is sponsored by