mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
add cipher suite check to suite tests to make adding test cases easier
This commit is contained in:
@@ -366,6 +366,9 @@ void c32to24(word32 in, word24 out);
|
|||||||
|
|
||||||
#ifdef NO_DES3
|
#ifdef NO_DES3
|
||||||
#define DES_BLOCK_SIZE 8
|
#define DES_BLOCK_SIZE 8
|
||||||
|
#else
|
||||||
|
#undef BUILD_DES3
|
||||||
|
#define BUILD_DES3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NO_AES
|
#ifdef NO_AES
|
||||||
@@ -375,6 +378,13 @@ void c32to24(word32 in, word24 out);
|
|||||||
#define BUILD_AES
|
#define BUILD_AES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_RC4
|
||||||
|
#undef BUILD_ARC4
|
||||||
|
#define BUILD_ARC4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(BUILD_AESGCM) || defined(HAVE_AESCCM)
|
#if defined(BUILD_AESGCM) || defined(HAVE_AESCCM)
|
||||||
#define HAVE_AEAD
|
#define HAVE_AEAD
|
||||||
#endif
|
#endif
|
||||||
|
@@ -32,10 +32,56 @@
|
|||||||
|
|
||||||
#define MAX_ARGS 40
|
#define MAX_ARGS 40
|
||||||
#define MAX_COMMAND_SZ 240
|
#define MAX_COMMAND_SZ 240
|
||||||
|
#define MAX_SUITE_SZ 80
|
||||||
|
|
||||||
#include "examples/client/client.h"
|
#include "examples/client/client.h"
|
||||||
#include "examples/server/server.h"
|
#include "examples/server/server.h"
|
||||||
|
|
||||||
|
|
||||||
|
CYASSL_CTX* cipherSuiteCtx = NULL;
|
||||||
|
|
||||||
|
/* if the cipher suite on line is valid store in suite and return 1, else 0 */
|
||||||
|
static int IsValidCipherSuite(const char* line, char* suite)
|
||||||
|
{
|
||||||
|
int found = 0;
|
||||||
|
int valid = 0;
|
||||||
|
|
||||||
|
const char* find = "-l ";
|
||||||
|
char* begin = strnstr(line, find, MAX_COMMAND_SZ);
|
||||||
|
char* end;
|
||||||
|
|
||||||
|
suite[0] = '\0';
|
||||||
|
|
||||||
|
if (begin) {
|
||||||
|
begin += 3;
|
||||||
|
|
||||||
|
end = strnstr(begin, " ", MAX_COMMAND_SZ);
|
||||||
|
|
||||||
|
if (end) {
|
||||||
|
long len = end - begin;
|
||||||
|
if (len > MAX_SUITE_SZ) {
|
||||||
|
printf("suite too long!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memcpy(suite, begin, len);
|
||||||
|
suite[len] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strncpy(suite, begin, MAX_SUITE_SZ);
|
||||||
|
|
||||||
|
suite[MAX_SUITE_SZ] = '\0';
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
if (CyaSSL_CTX_set_cipher_list(cipherSuiteCtx, suite) == SSL_SUCCESS)
|
||||||
|
valid = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void execute_test_case(int svr_argc, char** svr_argv,
|
static void execute_test_case(int svr_argc, char** svr_argv,
|
||||||
int cli_argc, char** cli_argv, int addNoVerify)
|
int cli_argc, char** cli_argv, int addNoVerify)
|
||||||
{
|
{
|
||||||
@@ -45,6 +91,7 @@ static void execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
tcp_ready ready;
|
tcp_ready ready;
|
||||||
THREAD_TYPE serverThread;
|
THREAD_TYPE serverThread;
|
||||||
char commandLine[MAX_COMMAND_SZ];
|
char commandLine[MAX_COMMAND_SZ];
|
||||||
|
char cipherSuite[MAX_SUITE_SZ+1];
|
||||||
int i;
|
int i;
|
||||||
size_t added = 0;
|
size_t added = 0;
|
||||||
static int tests = 1;
|
static int tests = 1;
|
||||||
@@ -69,6 +116,12 @@ static void execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
}
|
}
|
||||||
printf("trying server command line[%d]: %s\n", tests, commandLine);
|
printf("trying server command line[%d]: %s\n", tests, commandLine);
|
||||||
|
|
||||||
|
|
||||||
|
if (IsValidCipherSuite(commandLine, cipherSuite) == 0) {
|
||||||
|
printf("cipher suite %s not supported in build\n", cipherSuite);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
commandLine[0] = '\0';
|
commandLine[0] = '\0';
|
||||||
added = 0;
|
added = 0;
|
||||||
for (i = 0; i < cli_argc; i++) {
|
for (i = 0; i < cli_argc; i++) {
|
||||||
@@ -250,6 +303,12 @@ int SuiteTest(void)
|
|||||||
|
|
||||||
(void)test_harness;
|
(void)test_harness;
|
||||||
|
|
||||||
|
cipherSuiteCtx = CyaSSL_CTX_new(CyaTLSv1_2_client_method());
|
||||||
|
if (cipherSuiteCtx == NULL) {
|
||||||
|
printf("can't get cipher suite ctx\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(NO_RSA)
|
#if !defined(NO_RSA)
|
||||||
/* default case */
|
/* default case */
|
||||||
args.argc = 1;
|
args.argc = 1;
|
||||||
@@ -460,6 +519,8 @@ int SuiteTest(void)
|
|||||||
|
|
||||||
printf(" End Cipher Suite Tests\n");
|
printf(" End Cipher Suite Tests\n");
|
||||||
|
|
||||||
|
CyaSSL_CTX_free(cipherSuiteCtx);
|
||||||
|
|
||||||
return args.return_code;
|
return args.return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user