suites.c 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. /* suites.c
  2. *
  3. * Copyright (C) 2006-2021 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <wolfssl/wolfcrypt/settings.h>
  25. #include <stdlib.h>
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include <wolfssl/ssl.h>
  29. #include <tests/unit.h>
  30. #if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) \
  31. && (defined(NO_MAIN_DRIVER) || defined(HAVE_STACK_SIZE))
  32. #include <wolfssl/wolfcrypt/ecc.h>
  33. #endif
  34. #define MAX_ARGS 40
  35. #define MAX_COMMAND_SZ 240
  36. #ifdef WOLFSSL_TLS13
  37. #define MAX_SUITE_SZ 200
  38. #else
  39. #define MAX_SUITE_SZ 80
  40. #endif
  41. #define NOT_BUILT_IN -123
  42. #if defined(NO_OLD_TLS) || !defined(WOLFSSL_ALLOW_SSLV3) || \
  43. !defined(WOLFSSL_ALLOW_TLSV10)
  44. #define VERSION_TOO_OLD -124
  45. #endif
  46. #include "examples/client/client.h"
  47. #include "examples/server/server.h"
  48. #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT)
  49. static WOLFSSL_CTX* cipherSuiteCtx = NULL;
  50. static char nonblockFlag[] = "-N";
  51. static char noVerifyFlag[] = "-d";
  52. static char disableEMSFlag[] = "-n";
  53. static char flagSep[] = " ";
  54. #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
  55. static char portFlag[] = "-p";
  56. static char svrPort[] = "0";
  57. #endif
  58. static char intTestFlag[] = "-H";
  59. static char forceDefCipherListFlag[] = "defCipherList";
  60. static char exitWithRetFlag[] = "exitWithRet";
  61. static char disableDHPrimeTest[] = "-2";
  62. #ifdef WOLFSSL_ASYNC_CRYPT
  63. static int devId = INVALID_DEVID;
  64. #endif
  65. #ifdef VERSION_TOO_OLD
  66. static int GetTlsVersion(const char* line)
  67. {
  68. int version = -1;
  69. const char* find = "-v ";
  70. const char* begin = strstr(line, find);
  71. if (begin) {
  72. begin += 3;
  73. version = atoi(begin);
  74. }
  75. return version;
  76. }
  77. #ifndef WOLFSSL_ALLOW_SSLV3
  78. /* if the protocol version is sslv3 return 1, else 0 */
  79. static int IsSslVersion(const char* line)
  80. {
  81. int version = GetTlsVersion(line);
  82. return (version == 0) ? 1 : 0;
  83. }
  84. #endif /* !WOLFSSL_ALLOW_SSLV3 */
  85. #ifndef WOLFSSL_ALLOW_TLSV10
  86. /* if the protocol version is TLSv1.0 return 1, else 0 */
  87. static int IsTls10Version(const char* line)
  88. {
  89. int version = GetTlsVersion(line);
  90. return (version == 1) ? 1 : 0;
  91. }
  92. #endif /* !WOLFSSL_ALLOW_TLSV10 */
  93. #ifdef NO_OLD_TLS
  94. /* if the protocol version is less than tls 1.2 return 1, else 0 */
  95. static int IsOldTlsVersion(const char* line)
  96. {
  97. int version = GetTlsVersion(line);
  98. return (version < 3) ? 1 : 0;
  99. }
  100. #endif /* NO_OLD_TLS */
  101. #endif /* VERSION_TOO_OLD */
  102. /* if the cipher suite on line is valid store in suite and return 1, else 0 */
  103. static int IsValidCipherSuite(const char* line, char *suite, size_t suite_spc)
  104. {
  105. int found = 0;
  106. int valid = 0;
  107. const char* find = "-l ";
  108. const char* begin = strstr(line, find);
  109. const char* end;
  110. if (suite_spc < MAX_SUITE_SZ+1)
  111. return 0;
  112. suite[0] = '\0';
  113. if (begin) {
  114. begin += 3;
  115. end = XSTRSTR(begin, " ");
  116. if (end) {
  117. long len = end - begin;
  118. if (len > MAX_SUITE_SZ) {
  119. printf("suite too long!\n");
  120. return 0;
  121. }
  122. XMEMCPY(suite, begin, len);
  123. suite[len] = '\0';
  124. }
  125. else
  126. XSTRNCPY(suite, begin, MAX_SUITE_SZ);
  127. suite[MAX_SUITE_SZ] = '\0';
  128. found = 1;
  129. }
  130. /* if QSH not enabled then do not use QSH suite */
  131. #ifdef HAVE_QSH
  132. if (suite[0] && (XSTRNCMP(suite, "QSH", 3) == 0)) {
  133. if (wolfSSL_CTX_set_cipher_list(cipherSuiteCtx, suite + 4)
  134. != WOLFSSL_SUCCESS)
  135. return 0;
  136. }
  137. #endif
  138. if (found) {
  139. if (wolfSSL_CTX_set_cipher_list(cipherSuiteCtx, suite) == WOLFSSL_SUCCESS)
  140. valid = 1;
  141. }
  142. return valid;
  143. }
  144. static int IsValidCert(const char* line)
  145. {
  146. int ret = 1;
  147. #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
  148. WOLFSSL_CTX* ctx;
  149. size_t i;
  150. const char* begin;
  151. char cert[80];
  152. #ifdef WOLFSSL_STATIC_MEMORY
  153. FILE* fStream = NULL;
  154. long chkSz = 0;
  155. #endif
  156. begin = XSTRSTR(line, "-c ");
  157. if (begin == NULL)
  158. return 1;
  159. begin += 3;
  160. for (i = 0; i < sizeof(cert) - 1 && *begin != ' ' && *begin != '\0'; i++)
  161. cert[i] = *(begin++);
  162. cert[i] = '\0';
  163. #ifdef WOLFSSL_STATIC_MEMORY
  164. fStream = XFOPEN(cert, "rb");
  165. if (fStream == NULL) {
  166. printf("Failed to open file %s\n", cert);
  167. printf("Invalid cert, skipping test\n");
  168. return 0;
  169. } else {
  170. printf("Successfully opened file\n");
  171. }
  172. XFSEEK(fStream, 0L, SEEK_END);
  173. chkSz = XFTELL(fStream);
  174. XFCLOSE(fStream);
  175. if (chkSz > LARGEST_MEM_BUCKET) {
  176. printf("File is larger than largest bucket, skipping this test\n");
  177. return 0;
  178. }
  179. #endif
  180. ctx = wolfSSL_CTX_new(wolfSSLv23_server_method_ex(NULL));
  181. if (ctx == NULL)
  182. return 0;
  183. ret = wolfSSL_CTX_use_certificate_chain_file(ctx, cert) == WOLFSSL_SUCCESS;
  184. wolfSSL_CTX_free(ctx);
  185. #endif /* !NO_FILESYSTEM && !NO_CERTS */
  186. (void)line;
  187. return ret;
  188. }
  189. static int IsValidCA(const char* line)
  190. {
  191. int ret = 1;
  192. #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
  193. WOLFSSL_CTX* ctx;
  194. size_t i;
  195. const char* begin;
  196. char cert[80];
  197. begin = XSTRSTR(line, "-A ");
  198. if (begin == NULL)
  199. return 1;
  200. begin += 3;
  201. for (i = 0; i < sizeof(cert) - 1 && *begin != ' ' && *begin != '\0'; i++)
  202. cert[i] = *(begin++);
  203. cert[i] = '\0';
  204. ctx = wolfSSL_CTX_new(wolfSSLv23_server_method_ex(NULL));
  205. if (ctx == NULL)
  206. return 0;
  207. ret = wolfSSL_CTX_use_certificate_chain_file(ctx, cert) == WOLFSSL_SUCCESS;
  208. wolfSSL_CTX_free(ctx);
  209. #endif /* !NO_FILESYSTEM && !NO_CERTS */
  210. (void)line;
  211. return ret;
  212. }
  213. #ifdef WOLFSSL_NO_CLIENT_AUTH
  214. static int IsClientAuth(const char* line, int* reqClientCert)
  215. {
  216. const char* begin;
  217. begin = XSTRSTR(line, "-H verifyFail");
  218. if (begin != NULL) {
  219. return 1;
  220. }
  221. begin = XSTRSTR(line, "-d");
  222. if (begin != NULL) {
  223. *reqClientCert = 0;
  224. }
  225. else {
  226. *reqClientCert = 1;
  227. }
  228. return 0;
  229. }
  230. #endif
  231. #ifdef NO_CERTS
  232. static int IsUsingCert(const char* line)
  233. {
  234. return XSTRSTR(line, "-c ") != NULL;
  235. }
  236. #endif
  237. #if defined(NO_CERTS) || defined(WOLFSSL_NO_CLIENT_AUTH)
  238. static int IsNoClientCert(const char* line)
  239. {
  240. const char* begin;
  241. begin = XSTRSTR(line, "-x");
  242. if (begin != NULL) {
  243. return 1;
  244. }
  245. return 0;
  246. }
  247. #endif
  248. static int execute_test_case(int svr_argc, char** svr_argv,
  249. int cli_argc, char** cli_argv,
  250. int addNoVerify, int addNonBlocking,
  251. int addDisableEMS, int forceSrvDefCipherList,
  252. int forceCliDefCipherList)
  253. {
  254. #ifdef WOLFSSL_TIRTOS
  255. func_args cliArgs = {0};
  256. func_args svrArgs = {0};
  257. cliArgs.argc = cli_argc;
  258. cliArgs.argv = cli_argv;
  259. svrArgs.argc = svr_argc;
  260. svrArgs.argv = svr_argv;
  261. #else
  262. func_args cliArgs = {cli_argc, cli_argv, 0, NULL, NULL};
  263. func_args svrArgs = {svr_argc, svr_argv, 0, NULL, NULL};
  264. #endif
  265. tcp_ready ready;
  266. THREAD_TYPE serverThread;
  267. char commandLine[MAX_COMMAND_SZ];
  268. char cipherSuite[MAX_SUITE_SZ+1];
  269. int i;
  270. size_t added;
  271. static int tests = 1;
  272. #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
  273. char portNumber[8];
  274. #endif
  275. int cliTestShouldFail = 0, svrTestShouldFail = 0;
  276. #ifdef WOLFSSL_NO_CLIENT_AUTH
  277. int reqClientCert;
  278. #endif
  279. /* Is Valid Cipher and Version Checks */
  280. /* build command list for the Is checks below */
  281. commandLine[0] = '\0';
  282. added = 0;
  283. for (i = 0; i < svrArgs.argc; i++) {
  284. added += XSTRLEN(svr_argv[i]) + 2;
  285. if (added >= MAX_COMMAND_SZ) {
  286. printf("server command line too long\n");
  287. break;
  288. }
  289. strcat(commandLine, svr_argv[i]);
  290. strcat(commandLine, flagSep);
  291. }
  292. if (IsValidCipherSuite(commandLine, cipherSuite, sizeof cipherSuite) == 0) {
  293. #ifdef DEBUG_SUITE_TESTS
  294. printf("cipher suite %s not supported in build\n", cipherSuite);
  295. #endif
  296. return NOT_BUILT_IN;
  297. }
  298. if (!IsValidCert(commandLine)) {
  299. #ifdef DEBUG_SUITE_TESTS
  300. printf("certificate %s not supported in build\n", commandLine);
  301. #endif
  302. return NOT_BUILT_IN;
  303. }
  304. #ifndef WOLFSSL_ALLOW_SSLV3
  305. if (IsSslVersion(commandLine) == 1) {
  306. #ifdef DEBUG_SUITE_TESTS
  307. printf("protocol version on line %s is too old\n", commandLine);
  308. #endif
  309. return VERSION_TOO_OLD;
  310. }
  311. #endif
  312. #ifndef WOLFSSL_ALLOW_TLSV10
  313. if (IsTls10Version(commandLine) == 1) {
  314. #ifdef DEBUG_SUITE_TESTS
  315. printf("protocol version on line %s is too old\n", commandLine);
  316. #endif
  317. return VERSION_TOO_OLD;
  318. }
  319. #endif
  320. #ifdef NO_OLD_TLS
  321. if (IsOldTlsVersion(commandLine) == 1) {
  322. #ifdef DEBUG_SUITE_TESTS
  323. printf("protocol version on line %s is too old\n", commandLine);
  324. #endif
  325. return VERSION_TOO_OLD;
  326. }
  327. #endif
  328. #ifdef WOLFSSL_NO_CLIENT_AUTH
  329. if (IsClientAuth(commandLine, &reqClientCert)) {
  330. #ifdef DEBUG_SUITE_TESTS
  331. printf("client auth on line %s not supported in build\n",
  332. commandLine);
  333. #endif
  334. return NOT_BUILT_IN;
  335. }
  336. #endif
  337. #ifdef NO_CERTS
  338. if (IsUsingCert(commandLine)) {
  339. #ifdef DEBUG_SUITE_TESTS
  340. printf("certificate %s not supported in build\n", commandLine);
  341. #endif
  342. return NOT_BUILT_IN;
  343. }
  344. #endif
  345. /* Build Server Command */
  346. if (addNoVerify) {
  347. printf("repeating test with client cert request off\n");
  348. if (svrArgs.argc >= MAX_ARGS)
  349. printf("server command line too long\n");
  350. else
  351. svr_argv[svrArgs.argc++] = noVerifyFlag;
  352. }
  353. if (addNonBlocking) {
  354. printf("repeating test with non blocking on\n");
  355. if (svrArgs.argc >= MAX_ARGS)
  356. printf("server command line too long\n");
  357. else
  358. svr_argv[svrArgs.argc++] = nonblockFlag;
  359. }
  360. #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
  361. /* add port */
  362. if (svrArgs.argc + 2 > MAX_ARGS)
  363. printf("cannot add the magic port number flag to server\n");
  364. else {
  365. svr_argv[svrArgs.argc++] = portFlag;
  366. svr_argv[svrArgs.argc++] = svrPort;
  367. }
  368. #endif
  369. if (forceSrvDefCipherList) {
  370. if (svrArgs.argc + 2 > MAX_ARGS)
  371. printf("cannot add the force def cipher list flag to server\n");
  372. else {
  373. svr_argv[svrArgs.argc++] = intTestFlag;
  374. svr_argv[svrArgs.argc++] = forceDefCipherListFlag;
  375. }
  376. }
  377. #ifdef TEST_PK_PRIVKEY
  378. svr_argv[svrArgs.argc++] = (char*)"-P";
  379. #endif
  380. /* update server flags list */
  381. commandLine[0] = '\0';
  382. added = 0;
  383. for (i = 0; i < svrArgs.argc; i++) {
  384. added += XSTRLEN(svr_argv[i]) + 2;
  385. if (added >= MAX_COMMAND_SZ) {
  386. printf("server command line too long\n");
  387. break;
  388. }
  389. strcat(commandLine, svr_argv[i]);
  390. strcat(commandLine, flagSep);
  391. }
  392. printf("trying server command line[%d]: %s\n", tests, commandLine);
  393. tests++; /* test count */
  394. /* determine based on args if this test is expected to fail */
  395. if (XSTRSTR(commandLine, exitWithRetFlag) != NULL) {
  396. svrTestShouldFail = 1;
  397. }
  398. InitTcpReady(&ready);
  399. #ifdef WOLFSSL_TIRTOS
  400. fdOpenSession(Task_self());
  401. #endif
  402. /* start server */
  403. svrArgs.signal = &ready;
  404. start_thread(server_test, &svrArgs, &serverThread);
  405. wait_tcp_ready(&svrArgs);
  406. /* Build Client Command */
  407. if (addNonBlocking) {
  408. if (cliArgs.argc >= MAX_ARGS)
  409. printf("cannot add the non block flag to client\n");
  410. else
  411. cli_argv[cliArgs.argc++] = nonblockFlag;
  412. }
  413. if (addDisableEMS) {
  414. printf("repeating test without extended master secret\n");
  415. if (cliArgs.argc >= MAX_ARGS)
  416. printf("cannot add the disable EMS flag to client\n");
  417. else
  418. cli_argv[cliArgs.argc++] = disableEMSFlag;
  419. }
  420. #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
  421. if (ready.port != 0) {
  422. if (cliArgs.argc + 2 > MAX_ARGS)
  423. printf("cannot add the magic port number flag to client\n");
  424. else {
  425. snprintf(portNumber, sizeof(portNumber), "%d", ready.port);
  426. cli_argv[cliArgs.argc++] = portFlag;
  427. cli_argv[cliArgs.argc++] = portNumber;
  428. }
  429. }
  430. #endif
  431. if (forceCliDefCipherList) {
  432. if (cliArgs.argc + 2 > MAX_ARGS)
  433. printf("cannot add the force def cipher list flag to client\n");
  434. else {
  435. cli_argv[cliArgs.argc++] = intTestFlag;
  436. cli_argv[cliArgs.argc++] = forceDefCipherListFlag;
  437. }
  438. }
  439. #ifdef TEST_PK_PRIVKEY
  440. cli_argv[cliArgs.argc++] = (char*)"-P";
  441. #endif
  442. commandLine[0] = '\0';
  443. added = 0;
  444. for (i = 0; i < cliArgs.argc; i++) {
  445. added += XSTRLEN(cli_argv[i]) + 2;
  446. if (added >= MAX_COMMAND_SZ) {
  447. printf("client command line too long\n");
  448. break;
  449. }
  450. strcat(commandLine, cli_argv[i]);
  451. strcat(commandLine, flagSep);
  452. }
  453. if (!IsValidCA(commandLine)) {
  454. #ifdef DEBUG_SUITE_TESTS
  455. printf("certificate %s not supported in build\n", commandLine);
  456. #endif
  457. return NOT_BUILT_IN;
  458. }
  459. #ifdef WOLFSSL_NO_CLIENT_AUTH
  460. if (reqClientCert && IsNoClientCert(commandLine)) {
  461. #ifdef DEBUG_SUITE_TESTS
  462. printf("client auth on line %s not supported in build\n",
  463. commandLine);
  464. #endif
  465. return NOT_BUILT_IN;
  466. }
  467. #endif
  468. #ifdef NO_CERTS
  469. if (IsNoClientCert(commandLine)) {
  470. #ifdef DEBUG_SUITE_TESTS
  471. printf("certificate %s not supported in build\n", commandLine);
  472. #endif
  473. return NOT_BUILT_IN;
  474. }
  475. #endif
  476. printf("trying client command line[%d]: %s\n", tests, commandLine);
  477. tests++;
  478. /* determine based on args if this test is expected to fail */
  479. if (XSTRSTR(commandLine, exitWithRetFlag) != NULL) {
  480. cliTestShouldFail = 1;
  481. }
  482. /* start client */
  483. client_test(&cliArgs);
  484. /* verify results */
  485. if ((cliArgs.return_code != 0 && cliTestShouldFail == 0) ||
  486. (cliArgs.return_code == 0 && cliTestShouldFail != 0)) {
  487. printf("client_test failed %d %s\n", cliArgs.return_code,
  488. cliTestShouldFail ? "(should fail)" : "");
  489. XEXIT(EXIT_FAILURE);
  490. }
  491. join_thread(serverThread);
  492. if ((svrArgs.return_code != 0 && svrTestShouldFail == 0) ||
  493. (svrArgs.return_code == 0 && svrTestShouldFail != 0)) {
  494. printf("server_test failed %d %s\n", svrArgs.return_code,
  495. svrTestShouldFail ? "(should fail)" : "");
  496. XEXIT(EXIT_FAILURE);
  497. }
  498. #ifdef WOLFSSL_TIRTOS
  499. fdCloseSession(Task_self());
  500. #endif
  501. FreeTcpReady(&ready);
  502. /* only run the first test for expected failure cases */
  503. /* the example server/client are not designed to handle expected failure in
  504. all cases, such as non-blocking, etc... */
  505. if (svrTestShouldFail || cliTestShouldFail) {
  506. return NOT_BUILT_IN;
  507. }
  508. return 0;
  509. }
  510. static void test_harness(void* vargs)
  511. {
  512. func_args* args = (func_args*)vargs;
  513. char* script;
  514. long sz, len;
  515. int cliMode = 0; /* server or client command flag, server first */
  516. int ret;
  517. FILE* file;
  518. char* svrArgs[MAX_ARGS];
  519. int svrArgsSz;
  520. char* cliArgs[MAX_ARGS];
  521. int cliArgsSz;
  522. char* cursor;
  523. char* comment;
  524. char lastChar = '\0';
  525. int do_it = 0;
  526. const char* fname = "tests/test.conf";
  527. const char* addArgs = NULL;
  528. if (args->argc == 1) {
  529. printf("notice: using default file %s\n", fname);
  530. }
  531. else if (args->argc == 3) {
  532. addArgs = args->argv[2];
  533. }
  534. else if (args->argc > 3) {
  535. printf("usage: harness [FILE] [ARG]\n");
  536. args->return_code = 1;
  537. return;
  538. }
  539. if (args->argc >= 2) {
  540. fname = args->argv[1];
  541. }
  542. file = fopen(fname, "rb");
  543. if (file == NULL) {
  544. fprintf(stderr, "unable to open %s\n", fname);
  545. args->return_code = 1;
  546. return;
  547. }
  548. fseek(file, 0, SEEK_END);
  549. sz = ftell(file);
  550. rewind(file);
  551. if (sz <= 0) {
  552. fprintf(stderr, "%s is empty\n", fname);
  553. fclose(file);
  554. args->return_code = 1;
  555. return;
  556. }
  557. script = (char*)malloc(sz+1);
  558. if (script == 0) {
  559. fprintf(stderr, "unable to allocate script buffer\n");
  560. fclose(file);
  561. args->return_code = 1;
  562. return;
  563. }
  564. len = fread(script, 1, sz, file);
  565. if (len != sz) {
  566. fprintf(stderr, "read error\n");
  567. fclose(file);
  568. free(script);
  569. args->return_code = 1;
  570. return;
  571. }
  572. fclose(file);
  573. script[sz] = 0;
  574. cursor = script;
  575. svrArgsSz = 1;
  576. svrArgs[0] = args->argv[0];
  577. cliArgsSz = 1;
  578. cliArgs[0] = args->argv[0];
  579. while (cursor && *cursor != 0) {
  580. switch (*cursor) {
  581. case '\n':
  582. /* A blank line triggers test case execution or switches
  583. to client mode if we don't have the client command yet */
  584. if (lastChar != '\n' && (cliArgsSz > 1 || svrArgsSz > 1)) {
  585. if (cliMode == 0)
  586. cliMode = 1; /* switch to client mode processing */
  587. else
  588. do_it = 1; /* Do It, we have server and client */
  589. }
  590. #ifdef DEBUG_SUITE_TESTS
  591. else {
  592. /* skip extra new-lines */
  593. printf("skipping extra new line\n");
  594. }
  595. #endif
  596. lastChar = *cursor;
  597. cursor++;
  598. break;
  599. case '#':
  600. lastChar = *cursor;
  601. /* Ignore lines that start with a # */
  602. comment = XSTRSEP(&cursor, "\n");
  603. #ifdef DEBUG_SUITE_TESTS
  604. printf("%s\n", comment);
  605. #else
  606. (void)comment;
  607. #endif
  608. break;
  609. case '-':
  610. default:
  611. /* Parameters start with a -. They end in either a newline
  612. * or a space. Capture until either, save in Args list. */
  613. lastChar = *cursor;
  614. if (cliMode)
  615. cliArgs[cliArgsSz++] = XSTRSEP(&cursor, " \n");
  616. else
  617. svrArgs[svrArgsSz++] = XSTRSEP(&cursor, " \n");
  618. if (cursor == NULL || *cursor == '\0') /* eof */
  619. do_it = 1;
  620. break;
  621. }
  622. if (svrArgsSz == MAX_ARGS || cliArgsSz == MAX_ARGS) {
  623. fprintf(stderr, "too many arguments, forcing test run\n");
  624. do_it = 1;
  625. }
  626. if (do_it) {
  627. /* additional arguments processing */
  628. if (cliArgsSz+2 < MAX_ARGS && svrArgsSz+2 < MAX_ARGS) {
  629. if (addArgs == NULL || XSTRSTR(addArgs, "doDH") == NULL) {
  630. /* The `-2` disable DH prime check is added to all tests by default */
  631. cliArgs[cliArgsSz++] = disableDHPrimeTest;
  632. svrArgs[svrArgsSz++] = disableDHPrimeTest;
  633. }
  634. if (addArgs && XSTRSTR(addArgs, "expFail")) {
  635. /* Tests should expect to fail */
  636. cliArgs[cliArgsSz++] = intTestFlag;
  637. cliArgs[cliArgsSz++] = exitWithRetFlag;
  638. svrArgs[svrArgsSz++] = intTestFlag;
  639. svrArgs[svrArgsSz++] = exitWithRetFlag;
  640. }
  641. }
  642. ret = execute_test_case(svrArgsSz, svrArgs,
  643. cliArgsSz, cliArgs, 0, 0, 0, 0, 0);
  644. /* don't repeat if not supported in build */
  645. if (ret == 0) {
  646. /* test with default cipher list on server side */
  647. execute_test_case(svrArgsSz, svrArgs,
  648. cliArgsSz, cliArgs, 0, 0, 0, 1, 0);
  649. /* test with default cipher list on client side */
  650. execute_test_case(svrArgsSz, svrArgs,
  651. cliArgsSz, cliArgs, 0, 0, 0, 0, 1);
  652. execute_test_case(svrArgsSz, svrArgs,
  653. cliArgsSz, cliArgs, 0, 1, 0, 0, 0);
  654. execute_test_case(svrArgsSz, svrArgs,
  655. cliArgsSz, cliArgs, 1, 0, 0, 0, 0);
  656. execute_test_case(svrArgsSz, svrArgs,
  657. cliArgsSz, cliArgs, 1, 1, 0, 0, 0);
  658. #ifdef HAVE_EXTENDED_MASTER
  659. execute_test_case(svrArgsSz, svrArgs,
  660. cliArgsSz, cliArgs, 0, 0, 1, 0, 0);
  661. execute_test_case(svrArgsSz, svrArgs,
  662. cliArgsSz, cliArgs, 0, 1, 1, 0, 0);
  663. execute_test_case(svrArgsSz, svrArgs,
  664. cliArgsSz, cliArgs, 1, 0, 1, 0, 0);
  665. execute_test_case(svrArgsSz, svrArgs,
  666. cliArgsSz, cliArgs, 1, 1, 1, 0, 0);
  667. #endif
  668. }
  669. svrArgsSz = 1;
  670. cliArgsSz = 1;
  671. cliMode = 0;
  672. do_it = 0;
  673. }
  674. }
  675. free(script);
  676. args->return_code = 0;
  677. }
  678. #endif /* !NO_WOLFSSL_SERVER && !NO_WOLFSSL_CLIENT */
  679. int SuiteTest(int argc, char** argv)
  680. {
  681. #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT)
  682. func_args args;
  683. char argv0[3][80];
  684. char* myArgv[3];
  685. printf(" Begin Cipher Suite Tests\n");
  686. /* setup */
  687. myArgv[0] = argv0[0];
  688. myArgv[1] = argv0[1];
  689. myArgv[2] = argv0[2];
  690. args.argv = myArgv;
  691. strcpy(argv0[0], "SuiteTest");
  692. #ifdef WOLFSSL_STATIC_MEMORY
  693. byte memory[200000];
  694. #endif
  695. cipherSuiteCtx = wolfSSL_CTX_new(wolfSSLv23_client_method());
  696. if (cipherSuiteCtx == NULL) {
  697. printf("can't get cipher suite ctx\n");
  698. args.return_code = EXIT_FAILURE;
  699. goto exit;
  700. }
  701. /* load in static memory buffer if enabled */
  702. #ifdef WOLFSSL_STATIC_MEMORY
  703. if (wolfSSL_CTX_load_static_memory(&cipherSuiteCtx, NULL,
  704. memory, sizeof(memory), 0, 1)
  705. != WOLFSSL_SUCCESS) {
  706. printf("unable to load static memory and create ctx");
  707. args.return_code = EXIT_FAILURE;
  708. goto exit;
  709. }
  710. #endif
  711. #ifdef WOLFSSL_ASYNC_CRYPT
  712. if (wolfAsync_DevOpen(&devId) < 0) {
  713. printf("Async device open failed");
  714. args.return_code = EXIT_FAILURE;
  715. goto exit;
  716. }
  717. wolfSSL_CTX_UseAsync(cipherSuiteCtx, devId);
  718. #endif /* WOLFSSL_ASYNC_CRYPT */
  719. /* support for custom command line tests */
  720. if (argc > 1) {
  721. /* Examples:
  722. ./tests/unit.test tests/test-altchains.conf
  723. ./tests/unit.test tests/test-fails.conf expFail
  724. ./tests/unit.test tests/test-dhprime.conf doDH
  725. */
  726. args.argc = argc;
  727. args.argv = argv;
  728. test_harness(&args);
  729. if (args.return_code != 0) {
  730. printf("error from script %d\n", args.return_code);
  731. args.return_code = EXIT_FAILURE;
  732. }
  733. goto exit;
  734. }
  735. /* default case */
  736. args.argc = 1;
  737. printf("starting default cipher suite tests\n");
  738. test_harness(&args);
  739. if (args.return_code != 0) {
  740. printf("error from script %d\n", args.return_code);
  741. args.return_code = EXIT_FAILURE;
  742. goto exit;
  743. }
  744. /* any extra cases will need another argument */
  745. args.argc = 2;
  746. #ifdef WOLFSSL_OLDTLS_SHA2_CIPHERSUITES
  747. /* SHA-2 cipher suites in old TLS versions */
  748. strcpy(argv0[1], "tests/test-sha2.conf");
  749. printf("starting SHA-2 cipher suite in old TLS versions tests\n");
  750. test_harness(&args);
  751. if (args.return_code != 0) {
  752. printf("error from script %d\n", args.return_code);
  753. args.return_code = EXIT_FAILURE;
  754. goto exit;
  755. }
  756. #endif
  757. #ifdef WOLFSSL_TLS13
  758. /* add TLSv13 extra suites */
  759. strcpy(argv0[1], "tests/test-tls13.conf");
  760. printf("starting TLSv13 extra cipher suite tests\n");
  761. test_harness(&args);
  762. if (args.return_code != 0) {
  763. printf("error from script %d\n", args.return_code);
  764. args.return_code = EXIT_FAILURE;
  765. goto exit;
  766. }
  767. #ifdef HAVE_ECC
  768. /* add TLSv13 ECC extra suites */
  769. strcpy(argv0[1], "tests/test-tls13-ecc.conf");
  770. printf("starting TLSv13 ECC extra cipher suite tests\n");
  771. test_harness(&args);
  772. if (args.return_code != 0) {
  773. printf("error from script %d\n", args.return_code);
  774. args.return_code = EXIT_FAILURE;
  775. goto exit;
  776. }
  777. #endif
  778. #ifndef WOLFSSL_NO_TLS12
  779. /* add TLSv13 downgrade tets */
  780. strcpy(argv0[1], "tests/test-tls13-down.conf");
  781. printf("starting TLSv13 Downgrade extra tests\n");
  782. test_harness(&args);
  783. if (args.return_code != 0) {
  784. printf("error from script %d\n", args.return_code);
  785. args.return_code = EXIT_FAILURE;
  786. goto exit;
  787. }
  788. #endif
  789. #endif
  790. #if defined(HAVE_CURVE25519) && defined(HAVE_ED25519)
  791. /* add ED25519 certificate cipher suite tests */
  792. strcpy(argv0[1], "tests/test-ed25519.conf");
  793. printf("starting ED25519 extra cipher suite tests\n");
  794. test_harness(&args);
  795. if (args.return_code != 0) {
  796. printf("error from script %d\n", args.return_code);
  797. args.return_code = EXIT_FAILURE;
  798. goto exit;
  799. }
  800. #endif
  801. #if defined(HAVE_CURVE448) && defined(HAVE_ED448)
  802. /* add ED448 certificate cipher suite tests */
  803. strcpy(argv0[1], "tests/test-ed448.conf");
  804. printf("starting ED448 extra cipher suite tests\n");
  805. test_harness(&args);
  806. if (args.return_code != 0) {
  807. printf("error from script %d\n", args.return_code);
  808. args.return_code = EXIT_FAILURE;
  809. goto exit;
  810. }
  811. #endif
  812. #if defined(HAVE_ECC) && defined(WOLFSSL_SHA512) && \
  813. (defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES))
  814. /* add P-521 certificate cipher suite tests */
  815. strcpy(argv0[1], "tests/test-p521.conf");
  816. printf("starting P-521 extra cipher suite tests\n");
  817. test_harness(&args);
  818. if (args.return_code != 0) {
  819. printf("error from script %d\n", args.return_code);
  820. args.return_code = EXIT_FAILURE;
  821. goto exit;
  822. }
  823. #endif
  824. #if defined(HAVE_ECC) && !defined(NO_SHA256) && defined(WOLFSSL_CUSTOM_CURVES) && \
  825. defined(HAVE_ECC_KOBLITZ) && defined(HAVE_ECC_BRAINPOOL)
  826. /* TLS non-NIST curves (Koblitz / Brainpool) */
  827. strcpy(argv0[1], "tests/test-ecc-cust-curves.conf");
  828. printf("starting TLS test of non-NIST curves (Koblitz / Brainpool)\n");
  829. test_harness(&args);
  830. if (args.return_code != 0) {
  831. printf("error from script %d\n", args.return_code);
  832. args.return_code = EXIT_FAILURE;
  833. goto exit;
  834. }
  835. #endif
  836. #ifdef WOLFSSL_DTLS
  837. /* add dtls extra suites */
  838. strcpy(argv0[1], "tests/test-dtls.conf");
  839. printf("starting dtls extra cipher suite tests\n");
  840. test_harness(&args);
  841. if (args.return_code != 0) {
  842. printf("error from script %d\n", args.return_code);
  843. args.return_code = EXIT_FAILURE;
  844. goto exit;
  845. }
  846. /* add dtls grouping tests */
  847. strcpy(argv0[1], "tests/test-dtls-group.conf");
  848. printf("starting dtls message grouping tests\n");
  849. test_harness(&args);
  850. if (args.return_code != 0) {
  851. printf("error from script %d\n", args.return_code);
  852. args.return_code = EXIT_FAILURE;
  853. goto exit;
  854. }
  855. /* add dtls session resumption tests */
  856. strcpy(argv0[1], "tests/test-dtls-resume.conf");
  857. printf("starting dtls session resumption tests\n");
  858. test_harness(&args);
  859. if (args.return_code != 0) {
  860. printf("error from script %d\n", args.return_code);
  861. args.return_code = EXIT_FAILURE;
  862. goto exit;
  863. }
  864. #ifdef HAVE_SECURE_RENEGOTIATION
  865. /* add dtls renegotiation tests */
  866. strcpy(argv0[1], "tests/test-dtls-reneg-client.conf");
  867. printf("starting dtls secure renegotiation client tests\n");
  868. test_harness(&args);
  869. if (args.return_code != 0) {
  870. printf("error from script %d\n", args.return_code);
  871. args.return_code = EXIT_FAILURE;
  872. goto exit;
  873. }
  874. strcpy(argv0[1], "tests/test-dtls-reneg-server.conf");
  875. printf("starting dtls secure renegotiation server tests\n");
  876. test_harness(&args);
  877. if (args.return_code != 0) {
  878. printf("error from script %d\n", args.return_code);
  879. args.return_code = EXIT_FAILURE;
  880. goto exit;
  881. }
  882. #endif
  883. #ifdef WOLFSSL_OLDTLS_SHA2_CIPHERSUITES
  884. /* add dtls extra suites */
  885. strcpy(argv0[1], "tests/test-dtls-sha2.conf");
  886. printf("starting dtls extra cipher suite tests - old TLS sha-2 cs\n");
  887. test_harness(&args);
  888. if (args.return_code != 0) {
  889. printf("error from script %d\n", args.return_code);
  890. args.return_code = EXIT_FAILURE;
  891. goto exit;
  892. }
  893. #endif
  894. #ifndef WOLFSSL_NO_DTLS_SIZE_CHECK
  895. /* failure tests */
  896. args.argc = 3;
  897. strcpy(argv0[1], "tests/test-dtls-fails.conf");
  898. strcpy(argv0[2], "expFail"); /* tests are expected to fail */
  899. printf("starting dtls tests that expect failure\n");
  900. test_harness(&args);
  901. if (args.return_code != 0) {
  902. printf("error from script %d\n", args.return_code);
  903. args.return_code = EXIT_FAILURE;
  904. goto exit;
  905. }
  906. strcpy(argv0[2], "");
  907. #endif
  908. #ifdef WOLFSSL_EXTRA_ALERTS
  909. /* failure tests */
  910. args.argc = 3;
  911. strcpy(argv0[1], "tests/test-dtls-fails-cipher.conf");
  912. strcpy(argv0[2], "expFail"); /* tests are expected to fail */
  913. printf("starting dtls cipher mismatch tests that expect failure\n");
  914. test_harness(&args);
  915. if (args.return_code != 0) {
  916. printf("error from script %d\n", args.return_code);
  917. args.return_code = EXIT_FAILURE;
  918. goto exit;
  919. }
  920. strcpy(argv0[2], "");
  921. #endif
  922. #endif
  923. #ifdef WOLFSSL_SCTP
  924. /* add dtls-sctp extra suites */
  925. strcpy(argv0[1], "tests/test-sctp.conf");
  926. printf("starting dtls-sctp extra cipher suite tests\n");
  927. test_harness(&args);
  928. if (args.return_code != 0) {
  929. printf("error from script %d\n", args.return_code);
  930. args.return_code = EXIT_FAILURE;
  931. goto exit;
  932. }
  933. #ifdef WOLFSSL_OLDTLS_SHA2_CIPHERSUITES
  934. /* add dtls-sctp extra suites */
  935. strcpy(argv0[1], "tests/test-sctp-sha2.conf");
  936. printf("starting dtls-sctp extra cipher suite tests - old TLS sha-2 cs\n");
  937. test_harness(&args);
  938. if (args.return_code != 0) {
  939. printf("error from script %d\n", args.return_code);
  940. args.return_code = EXIT_FAILURE;
  941. goto exit;
  942. }
  943. #endif
  944. #endif
  945. #ifndef WC_STRICT_SIG
  946. #if !defined(NO_RSA) && defined(HAVE_ECC) /* testing mixed ECC/RSA cert */
  947. /* add extra signature test suites */
  948. strcpy(argv0[1], "tests/test-sig.conf");
  949. printf("starting sig extra cipher suite tests\n");
  950. test_harness(&args);
  951. if (args.return_code != 0) {
  952. printf("error from script %d\n", args.return_code);
  953. args.return_code = EXIT_FAILURE;
  954. goto exit;
  955. }
  956. #endif /* HAVE_RSA and HAVE_ECC */
  957. #endif /* !WC_STRICT_SIG */
  958. #ifdef HAVE_QSH
  959. /* add QSH extra suites */
  960. strcpy(argv0[1], "tests/test-qsh.conf");
  961. printf("starting qsh extra cipher suite tests\n");
  962. test_harness(&args);
  963. if (args.return_code != 0) {
  964. printf("error from script %d\n", args.return_code);
  965. args.return_code = EXIT_FAILURE;
  966. goto exit;
  967. }
  968. #ifdef WOLFSSL_OLDTLS_SHA2_CIPHERSUITES
  969. strcpy(argv0[1], "tests/test-qsh-sha2.conf");
  970. printf("starting qsh extra cipher suite tests - old TLS sha-2 cs\n");
  971. test_harness(&args);
  972. if (args.return_code != 0) {
  973. printf("error from script %d\n", args.return_code);
  974. args.return_code = EXIT_FAILURE;
  975. goto exit;
  976. }
  977. #endif
  978. #endif
  979. #ifndef NO_PSK
  980. #ifndef WOLFSSL_NO_TLS12
  981. #if !defined(NO_RSA) || defined(HAVE_ECC)
  982. /* add psk cipher suites */
  983. strcpy(argv0[1], "tests/test-psk.conf");
  984. printf("starting psk cipher suite tests\n");
  985. test_harness(&args);
  986. if (args.return_code != 0) {
  987. printf("error from script %d\n", args.return_code);
  988. args.return_code = EXIT_FAILURE;
  989. goto exit;
  990. }
  991. #endif
  992. #endif
  993. #ifdef WOLFSSL_TLS13
  994. /* add psk extra suites */
  995. strcpy(argv0[1], "tests/test-tls13-psk.conf");
  996. printf("starting TLS 1.3 psk no identity extra cipher suite tests\n");
  997. test_harness(&args);
  998. if (args.return_code != 0) {
  999. printf("error from script %d\n", args.return_code);
  1000. args.return_code = EXIT_FAILURE;
  1001. goto exit;
  1002. }
  1003. #endif
  1004. #endif
  1005. #if defined(WOLFSSL_ENCRYPTED_KEYS) && !defined(NO_DES3) && !defined(NO_MD5) &&\
  1006. !defined(NO_SHA)
  1007. /* test encrypted keys */
  1008. strcpy(argv0[1], "tests/test-enckeys.conf");
  1009. printf("starting encrypted keys extra cipher suite tests\n");
  1010. test_harness(&args);
  1011. if (args.return_code != 0) {
  1012. printf("error from script %d\n", args.return_code);
  1013. args.return_code = EXIT_FAILURE;
  1014. goto exit;
  1015. }
  1016. #endif
  1017. #ifdef HAVE_MAX_FRAGMENT
  1018. /* Max fragment cipher suite tests */
  1019. strcpy(argv0[1], "tests/test-maxfrag.conf");
  1020. printf("starting max fragment cipher suite tests\n");
  1021. test_harness(&args);
  1022. if (args.return_code != 0) {
  1023. printf("error from script %d\n", args.return_code);
  1024. args.return_code = EXIT_FAILURE;
  1025. goto exit;
  1026. }
  1027. #ifdef WOLFSSL_DTLS
  1028. strcpy(argv0[1], "tests/test-maxfrag-dtls.conf");
  1029. printf("starting dtls max fragment cipher suite tests\n");
  1030. test_harness(&args);
  1031. if (args.return_code != 0) {
  1032. printf("error from script %d\n", args.return_code);
  1033. args.return_code = EXIT_FAILURE;
  1034. goto exit;
  1035. }
  1036. #endif
  1037. #endif
  1038. #ifdef WOLFSSL_ALT_CERT_CHAINS
  1039. /* tests for alt chains */
  1040. strcpy(argv0[1], "tests/test-altchains.conf");
  1041. printf("starting certificate alternate chain cipher suite tests\n");
  1042. test_harness(&args);
  1043. if (args.return_code != 0) {
  1044. printf("error from script %d\n", args.return_code);
  1045. args.return_code = EXIT_FAILURE;
  1046. goto exit;
  1047. }
  1048. #else
  1049. /* tests for chains */
  1050. strcpy(argv0[1], "tests/test-chains.conf");
  1051. printf("starting certificate chain cipher suite tests\n");
  1052. test_harness(&args);
  1053. if (args.return_code != 0) {
  1054. printf("error from script %d\n", args.return_code);
  1055. args.return_code = EXIT_FAILURE;
  1056. goto exit;
  1057. }
  1058. #endif
  1059. #ifdef WOLFSSL_TRUST_PEER_CERT
  1060. /* tests for trusted peer cert */
  1061. strcpy(argv0[1], "tests/test-trustpeer.conf");
  1062. printf("starting trusted peer certificate cipher suite tests\n");
  1063. test_harness(&args);
  1064. if (args.return_code != 0) {
  1065. printf("error from script %d\n", args.return_code);
  1066. args.return_code = EXIT_FAILURE;
  1067. goto exit;
  1068. }
  1069. #endif
  1070. /* tests for dh prime */
  1071. args.argc = 3;
  1072. strcpy(argv0[1], "tests/test-dhprime.conf");
  1073. strcpy(argv0[2], "doDH"); /* add DH prime flag */
  1074. printf("starting dh prime tests\n");
  1075. test_harness(&args);
  1076. if (args.return_code != 0) {
  1077. printf("error from script %d\n", args.return_code);
  1078. args.return_code = EXIT_FAILURE;
  1079. goto exit;
  1080. }
  1081. /* failure tests */
  1082. args.argc = 3;
  1083. strcpy(argv0[1], "tests/test-fails.conf");
  1084. strcpy(argv0[2], "expFail"); /* tests are expected to fail */
  1085. printf("starting tests that expect failure\n");
  1086. test_harness(&args);
  1087. if (args.return_code != 0) {
  1088. printf("error from script %d\n", args.return_code);
  1089. args.return_code = EXIT_FAILURE;
  1090. goto exit;
  1091. }
  1092. exit:
  1093. if (args.return_code == 0)
  1094. printf("\n Success -- All results as expected.\n");
  1095. printf(" End Cipher Suite Tests\n");
  1096. wolfSSL_CTX_free(cipherSuiteCtx);
  1097. wolfSSL_Cleanup();
  1098. #if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) \
  1099. && (defined(NO_MAIN_DRIVER) || defined(HAVE_STACK_SIZE))
  1100. wc_ecc_fp_free(); /* free per thread cache */
  1101. #endif
  1102. #ifdef WOLFSSL_ASYNC_CRYPT
  1103. wolfAsync_DevClose(&devId);
  1104. #endif
  1105. return args.return_code;
  1106. #else
  1107. return NOT_COMPILED_IN;
  1108. (void)argc;
  1109. (void)argv;
  1110. #endif /* !NO_WOLFSSL_SERVER && !NO_WOLFSSL_CLIENT */
  1111. }