Skip to content

Commit 28c1262

Browse files
committed
Soft Disable AES-CBC
1. By default, soft disable AES-CBC. It isn't offered as a default encrypt algorithm, but may be set at runtime. 2. Add guard where AES-CBC can be added back as a default. 3. Add option to example client to run it with a custom encrypt algorithm list.
1 parent ee9bc3b commit 28c1262

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

examples/client/client.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
651651
const char* cmd = NULL;
652652
const char* privKeyName = NULL;
653653
const char* keyList = NULL;
654+
const char* cipherList = NULL;
654655
byte imExit = 0;
655656
byte listAlgos = 0;
656657
byte nonBlock = 0;
@@ -669,7 +670,7 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
669670

670671
(void)keepOpen;
671672

672-
while ((ch = mygetopt(argc, argv, "?ac:h:i:j:p:tu:xzNP:RJ:A:XeEk:qK:")) != -1) {
673+
while ((ch = mygetopt(argc, argv, "?ac:C:h:i:j:p:tu:xzNP:RJ:A:XeEk:qK:")) != -1) {
673674
switch (ch) {
674675
case 'h':
675676
host = myoptarg;
@@ -750,6 +751,10 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
750751
keyList = myoptarg;
751752
break;
752753

754+
case 'C':
755+
cipherList = myoptarg;
756+
break;
757+
753758
#if !defined(SINGLE_THREADED) && !defined(WOLFSSL_NUCLEUS)
754759
case 'c':
755760
cmd = myoptarg;
@@ -841,6 +846,11 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
841846
err_sys("Error setting key list.\n");
842847
}
843848
}
849+
if (cipherList) {
850+
if (wolfSSH_CTX_SetAlgoListCipher(ctx, cipherList) != WS_SUCCESS) {
851+
err_sys("Error setting cipher list.\n");
852+
}
853+
}
844854

845855
if (((func_args*)args)->user_auth == NULL)
846856
wolfSSH_SetUserAuth(ctx, ClientUserAuth);

src/internal.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@
147147
WOLFSSH_NO_NISTP256_MLKEM768_SHA256
148148
Set when ML-KEM is disabled in wolfssl. Set to disable use of ECDHE with
149149
prime NISTP256 hybridized with post-quantum ML-KEM 768.
150+
WOLFSSH_NO_AES_CBC_SOFT_DISABLE
151+
AES-CBC is normally soft-disabled. The default configuration will not
152+
advertise the availability of AES-CBC algorithms during KEX. AES-CBC
153+
algorithms still work. Setting this flag will advertise AES-CBC
154+
algorithms during KEX by default.
150155
WOLFSSH_NO_AES_CBC
151156
Set when AES or AES-CBC are disabled. Set to disable use of AES-CBC
152157
encryption.
@@ -804,10 +809,12 @@ static const char cannedEncAlgoNames[] =
804809
"aes128-ctr,"
805810
#endif
806811
#if !defined(WOLFSSH_NO_AES_CBC)
807-
"aes256-cbc,"
808-
"aes192-cbc,"
809-
"aes128-cbc,"
810-
#endif
812+
#if defined(WOLFSSH_NO_AES_CBC_SOFT_DISABLE)
813+
"aes256-cbc,"
814+
"aes192-cbc,"
815+
"aes128-cbc,"
816+
#endif
817+
#endif /* WOLFSSH_NO_AES_CBC */
811818
"";
812819

813820
static const char cannedMacAlgoNames[] =

tests/kex.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ static int wolfSSH_wolfSSH_Group16_512(void)
175175
sA[10], sA[11] };
176176
char cA[NUMARGS][ARGLEN];
177177
char *clientArgv[NUMARGS] =
178-
{ cA[0], cA[1], cA[2], cA[3], cA[4] };
178+
{ cA[0], cA[1], cA[2], cA[3], cA[4], cA[5], cA[6], cA[7], cA[8], cA[9],
179+
cA[10], cA[11] };
179180
int serverArgc = 0;
180181
int clientArgc = 0;
181182

@@ -227,6 +228,8 @@ static int wolfSSH_wolfSSH_Group16_512(void)
227228
WSTRNCPY(cA[clientArgc++], "client", ARGLEN);
228229
WSTRNCPY(cA[clientArgc++], "-u", ARGLEN);
229230
WSTRNCPY(cA[clientArgc++], "jill", ARGLEN);
231+
WSTRNCPY(cA[clientArgc++], "-C", ARGLEN);
232+
WSTRNCPY(cA[clientArgc++], "aes256-cbc", ARGLEN);
230233
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSH_ZEPHYR)
231234
WSTRNCPY(cA[clientArgc++], "-p", ARGLEN);
232235
WSNPRINTF(cA[clientArgc++], ARGLEN, "%d", ready.port);

0 commit comments

Comments
 (0)