Skip to contentSkip to conversation

unit: Add runtime check for TLS suite cipher support

PATCH Applied Mat Martineau 2 participants 2 messages Feb 15, 2019 – Feb 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unit: Add runtime check for TLS suite cipher support

Skip TLS suite tests where the currently running kernel does not have support for the necessary cipher. Checksums types already have runtime validation.

---
 unit/test-tls.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
unit/test-tls.c +18 -3
index 01496d2..03c5370 100644
@@ -709,9 +709,24 @@ int main(int argc, char *argv[])
 	l_test_add("TLS connection version mismatch",
 			test_tls_version_mismatch_test, NULL);
 
-	for (i = 0; tls_cipher_suite_pref[i]; i++)
-		l_test_add(tls_cipher_suite_pref[i]->name, test_tls_suite_test,
-				tls_cipher_suite_pref[i]->name);
+	for (i = 0; tls_cipher_suite_pref[i]; i++) {
+		struct tls_cipher_suite *suite = tls_cipher_suite_pref[i];
+		struct tls_bulk_encryption_algorithm *alg = suite->encryption;
+		bool supported;
+
+		if (alg->cipher_type == TLS_CIPHER_AEAD)
+			supported = l_aead_cipher_is_supported(alg->l_aead_id);
+		else
+			supported = l_cipher_is_supported(alg->l_id);
+
+		if (supported) {
+			l_test_add(suite->name, test_tls_suite_test,
+					suite->name);
+		} else {
+			printf("Skipping %s due to missing cipher support\n",
+				suite->name);
+		}
+	}
 
 done:
 	return l_test_run();
Signature · 1 line
2.20.1
#1 lore raw

Hi Mat,

Quoted 6 lines · Mat Martineau

Skip TLS suite tests where the currently running kernel does not have support for the necessary cipher. Checksums types already have runtime validation.

---
  unit/test-tls.c | 21 ++++++++++++++++++---
  1 file changed, 18 insertions(+), 3 deletions(-)

Applied, thanks.

Regards,
-Denis