138138
139139
140140#if !defined(NO_WOLFSSH_SERVER ) && !defined(NO_WOLFSSH_CLIENT ) && \
141- !defined(SINGLE_THREADED ) && !defined(WOLFSSH_TEST_BLOCK ) && \
142- !defined(WOLFSSH_NO_DH_GROUP16_SHA512 ) && !defined(WOLFSSH_NO_HMAC_SHA2_512 )
141+ !defined(SINGLE_THREADED ) && !defined(WOLFSSH_TEST_BLOCK )
143142
143+ #define KEXTEST_AVAILABLE
144+ #endif
145+
146+ #ifdef KEXTEST_AVAILABLE
144147static int tsClientUserAuth (byte authType , WS_UserAuthData * authData , void * ctx )
145148{
146149 static char password [] = "upthehill" ;
@@ -163,7 +166,7 @@ static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
163166#define NUMARGS 12
164167#define ARGLEN 32
165168
166- /*
169+ /*
167170 * Macro: ADD_ARG
168171 * Purpose: Adds a string argument to the argument list.
169172 * Parameters:
@@ -185,7 +188,7 @@ static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
185188 WSTRNCPY((argList)[(argListCount)++], (arg), ARGLEN); \
186189} while (0)
187190
188- /*
191+ /*
189192 * Macro: ADD_ARG_INT
190193 * Purpose: Adds an integer argument to the argument list as a string.
191194 * Parameters:
@@ -209,7 +212,7 @@ static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
209212} while (0)
210213
211214
212- static int wolfSSH_wolfSSH_Group16_512 ( void )
215+ static int wolfSSH_KexTest_Connect ( const char * kex )
213216{
214217 tcp_ready ready ;
215218 THREAD_TYPE serverThread ;
@@ -226,27 +229,6 @@ static int wolfSSH_wolfSSH_Group16_512(void)
226229 int serverArgc = 0 ;
227230 int clientArgc = 0 ;
228231
229- WSTARTTCP ();
230-
231- #if defined(DEBUG_WOLFSSH )
232- wolfSSH_Debugging_ON ();
233- #endif
234-
235- wolfSSH_Init ();
236-
237- #if defined(FIPS_VERSION_GE ) && FIPS_VERSION_GE (5 ,2 )
238- {
239- int i ;
240- for (i = 0 ; i < FIPS_CAST_COUNT ; i ++ ) {
241- wc_RunCast_fips (i );
242- }
243- }
244- #endif /* HAVE_FIPS */
245-
246- #if !defined(WOLFSSL_TIRTOS )
247- ChangeToWolfSshRoot ();
248- #endif
249-
250232 InitTcpReady (& ready );
251233
252234 ADD_ARG (serverArgv , serverArgc , "echoserver" );
@@ -257,7 +239,7 @@ static int wolfSSH_wolfSSH_Group16_512(void)
257239 ADD_ARG (serverArgv , serverArgc , "-0" );
258240 #endif
259241 ADD_ARG (serverArgv , serverArgc , "-x" );
260- ADD_ARG (serverArgv , serverArgc , "diffie-hellman-group16-sha512" );
242+ ADD_ARG (serverArgv , serverArgc , kex );
261243 ADD_ARG (serverArgv , serverArgc , "-m" );
262244 ADD_ARG (serverArgv , serverArgc , "hmac-sha2-512" );
263245 ADD_ARG (serverArgv , serverArgc , "-c" );
@@ -318,18 +300,27 @@ static int wolfSSH_wolfSSH_Group16_512(void)
318300 return EXIT_SUCCESS ;
319301}
320302
321- #endif
303+ #endif /* KEXTEST_AVAILABLE */
322304
323305int wolfSSH_KexTest (int argc , char * * argv )
324306{
325307 (void )argc ;
326308 (void )argv ;
327309
328310
329- #if defined(NO_WOLFSSH_SERVER ) || defined(NO_WOLFSSH_CLIENT ) || \
330- defined(SINGLE_THREADED ) || defined(WOLFSSH_TEST_BLOCK )
311+ #if !defined(KEXTEST_AVAILABLE )
331312 return 77 ;
332313#else
314+ WSTARTTCP ();
315+
316+ #if defined(DEBUG_WOLFSSH )
317+ wolfSSH_Debugging_ON ();
318+ #endif
319+
320+ #if !defined(WOLFSSL_TIRTOS )
321+ ChangeToWolfSshRoot ();
322+ #endif
323+
333324 AssertIntEQ (wolfSSH_Init (), WS_SUCCESS );
334325
335326 #if defined(FIPS_VERSION_GE ) && FIPS_VERSION_GE (5 ,2 )
@@ -341,14 +332,23 @@ int wolfSSH_KexTest(int argc, char** argv)
341332 }
342333 #endif /* HAVE_FIPS */
343334
344- #if !defined(WOLFSSH_NO_DH_GROUP16_SHA512 ) && !defined(WOLFSSH_NO_HMAC_SHA2_512 )
345- wolfSSH_wolfSSH_Group16_512 ();
335+ #if !defined(WOLFSSH_NO_DH_GROUP16_SHA512 )
336+ AssertIntEQ (wolfSSH_KexTest_Connect ("diffie-hellman-group16-sha512" ),
337+ EXIT_SUCCESS );
338+ #endif
339+ #if !defined(WOLFSSH_NO_CURVE25519_MLKEM768_SHA256 )
340+ AssertIntEQ (wolfSSH_KexTest_Connect ("mlkem768x25519-sha256" ),
341+ EXIT_SUCCESS );
342+ #endif
343+ #if !defined(WOLFSSH_NO_NISTP384_MLKEM1024_SHA384 )
344+ AssertIntEQ (wolfSSH_KexTest_Connect ("mlkem1024nistp384-sha384" ),
345+ EXIT_SUCCESS );
346346#endif
347347
348348 AssertIntEQ (wolfSSH_Cleanup (), WS_SUCCESS );
349349
350350 return 0 ;
351- #endif
351+ #endif /* KEXTEST_AVAILABLE */
352352}
353353
354354
0 commit comments