All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] sctp_big_chunk: Do not use md5 hmac algo if fips is enabled
@ 2023-06-20 17:03 Ashwin Dayanand Kamat via ltp
  2023-06-20 22:24 ` Petr Vorel
  2023-06-20 22:26 ` Petr Vorel
  0 siblings, 2 replies; 8+ messages in thread
From: Ashwin Dayanand Kamat via ltp @ 2023-06-20 17:03 UTC (permalink / raw)
  To: ltp, kashwindayan, akaher, tkundu, vsirnapalli

MD5 is not FIPS compliant. But still md5 is used as the default algorithm for sctp
even when fips is enabled. Due to this, sctp_big_chunk testcase is failing because listen()
system call in setup_server() is failing in fips environment.

Fix is to not use md5 algorithm while setting up server.
Instead use sha1 as algorithm if it's supported or else set it to none.

Signed-Off by: Ashwin Dayanand Kamat <kashwindayan@vmware.com>
---
 testcases/network/sctp/sctp_big_chunk.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/testcases/network/sctp/sctp_big_chunk.c b/testcases/network/sctp/sctp_big_chunk.c
index a6a326ea2..267f1cb45 100644
--- a/testcases/network/sctp/sctp_big_chunk.c
+++ b/testcases/network/sctp/sctp_big_chunk.c
@@ -133,11 +133,15 @@ static void setup_client(void)
 }
 
 static const char mtu_path[] = "/sys/class/net/lo/mtu";
+static const char hmac_algo_path[] = "/proc/sys/net/sctp/cookie_hmac_alg";
 static const unsigned int max_mtu = 65535;
 static unsigned int mtu;
 
 static void setup(void)
 {
+	char hmac_algo[CHAR_MAX];
+	int fips_enabled = tst_fips_enabled();
+
 	if (tst_parse_int(addr_param, &addr_num, 1, INT_MAX))
 		tst_brk(TBROK, "wrong address number '%s'", addr_param);
 
@@ -146,8 +150,18 @@ static void setup(void)
 	if (mtu < max_mtu)
 		tst_brk(TCONF, "Test needs that 'lo' MTU has %d", max_mtu);
 
+	SAFE_FILE_SCANF(hmac_algo_path, "%s", hmac_algo);
+
+	if (fips_enabled) {
+		if (!system("grep hmac\\(sha1\\) /proc/crypto"))
+			SAFE_FILE_PRINTF(hmac_algo_path, "%s", "sha1");
+		else
+			SAFE_FILE_PRINTF(hmac_algo_path, "%s", "none");
+	}
+
 	setup_server();
 	setup_client();
+	SAFE_FILE_PRINTF(hmac_algo_path, "%s", hmac_algo);
 }
 
 static void run(void)
-- 
2.39.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-06-21 14:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20 17:03 [LTP] [PATCH] sctp_big_chunk: Do not use md5 hmac algo if fips is enabled Ashwin Dayanand Kamat via ltp
2023-06-20 22:24 ` Petr Vorel
2023-06-20 22:26 ` Petr Vorel
2023-06-21  5:53   ` Ashwin Dayanand Kamat via ltp
2023-06-21  8:17     ` Petr Vorel
2023-06-21 12:48       ` Petr Vorel
2023-06-21 14:15         ` Ashwin Dayanand Kamat via ltp
     [not found]         ` <442F1FEF-AA44-4CC8-9809-6D99912CD063@vmware.com>
     [not found]           ` <B4BE4EDF-B94F-49F0-A624-CF2810A4E112@vmware.com>
2023-06-21 14:22             ` Ashwin Dayanand Kamat via ltp

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.