2011-07-26 13:27:22 -07:00
|
|
|
/* testsuite.c
|
|
|
|
|
*
|
2022-12-30 17:12:11 -07:00
|
|
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
2011-07-26 13:27:22 -07:00
|
|
|
*
|
2016-03-17 16:02:13 -06:00
|
|
|
* This file is part of wolfSSL.
|
2011-07-26 13:27:22 -07:00
|
|
|
*
|
2014-12-29 10:27:03 -07:00
|
|
|
* wolfSSL is free software; you can redistribute it and/or modify
|
2011-07-26 13:27:22 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
2014-12-29 10:27:03 -07:00
|
|
|
* wolfSSL is distributed in the hope that it will be useful,
|
2011-07-26 13:27:22 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2016-03-17 16:02:13 -06:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
2011-07-26 13:27:22 -07:00
|
|
|
*/
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2016-03-17 16:02:13 -06:00
|
|
|
|
2011-08-24 16:37:16 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
2011-08-04 16:42:55 -06:00
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
#include <wolfssl/wolfcrypt/settings.h>
|
2023-05-24 11:58:41 +02:00
|
|
|
#include <wolfssl/wolfcrypt/types.h>
|
2013-04-10 12:17:23 -07:00
|
|
|
|
2015-02-25 13:34:29 -08:00
|
|
|
#include <wolfssl/ssl.h>
|
2014-12-29 10:27:03 -07:00
|
|
|
#include <wolfssl/test.h>
|
2017-09-25 18:47:36 -07:00
|
|
|
#include <wolfcrypt/test/test.h>
|
2012-09-19 23:38:41 -07:00
|
|
|
|
2015-10-09 22:04:41 -06:00
|
|
|
|
2014-02-11 18:59:20 -08:00
|
|
|
#ifndef SINGLE_THREADED
|
|
|
|
|
|
2017-09-25 18:47:36 -07:00
|
|
|
#ifdef OPENSSL_EXTRA
|
2014-12-29 10:27:03 -07:00
|
|
|
#include <wolfssl/openssl/ssl.h>
|
2017-09-25 18:47:36 -07:00
|
|
|
#endif
|
2014-12-29 10:27:03 -07:00
|
|
|
#include <wolfssl/wolfcrypt/sha256.h>
|
2021-02-12 09:06:19 -08:00
|
|
|
#include <wolfssl/wolfcrypt/ecc.h>
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2017-09-25 18:47:36 -07:00
|
|
|
#include <examples/echoclient/echoclient.h>
|
|
|
|
|
#include <examples/echoserver/echoserver.h>
|
|
|
|
|
#include <examples/server/server.h>
|
|
|
|
|
#include <examples/client/client.h>
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2023-08-18 15:05:23 +02:00
|
|
|
#include "tests/utils.h"
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2016-11-14 12:47:24 -08:00
|
|
|
#ifndef NO_SHA256
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
void file_test(const char* file, byte* check);
|
2016-11-14 12:47:24 -08:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2017-06-26 23:05:32 -07:00
|
|
|
#if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT)
|
2020-09-22 23:18:10 -05:00
|
|
|
|
|
|
|
|
#ifdef HAVE_STACK_SIZE
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
static THREAD_RETURN simple_test(func_args *args);
|
2020-09-22 23:18:10 -05:00
|
|
|
#else
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
static void simple_test(func_args *args);
|
2020-09-22 23:18:10 -05:00
|
|
|
#endif
|
2021-05-10 10:32:55 +10:00
|
|
|
static int test_tls(func_args* server_args);
|
2023-05-24 11:58:41 +02:00
|
|
|
#if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
|
|
|
|
|
defined(HAVE_CRL) && defined(HAVE_CRL_MONITOR)
|
2023-05-23 17:03:18 +02:00
|
|
|
static int test_crl_monitor(void);
|
2023-05-24 11:58:41 +02:00
|
|
|
#endif
|
2021-05-10 10:32:55 +10:00
|
|
|
static void show_ciphers(void);
|
|
|
|
|
static void cleanup_output(void);
|
|
|
|
|
static int validate_cleanup_output(void);
|
2013-03-26 22:00:39 -07:00
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
enum {
|
|
|
|
|
NUMARGS = 3
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-04 11:52:37 -07:00
|
|
|
static const char *outputName;
|
2017-06-26 23:05:32 -07:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2012-08-01 17:33:49 -07:00
|
|
|
int myoptind = 0;
|
|
|
|
|
char* myoptarg = NULL;
|
|
|
|
|
|
2014-05-08 15:52:20 -07:00
|
|
|
#ifndef NO_TESTSUITE_MAIN_DRIVER
|
2014-05-09 11:55:59 -07:00
|
|
|
|
|
|
|
|
static int testsuite_test(int argc, char** argv);
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
return testsuite_test(argc, argv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* NO_TESTSUITE_MAIN_DRIVER */
|
|
|
|
|
|
2020-09-22 23:18:10 -05:00
|
|
|
#ifdef HAVE_STACK_SIZE
|
2021-05-10 10:32:55 +10:00
|
|
|
/* Wrap TLS echo client to free thread locals. */
|
2020-09-22 23:18:10 -05:00
|
|
|
static void *echoclient_test_wrapper(void* args) {
|
|
|
|
|
echoclient_test(args);
|
2020-10-29 16:17:25 +10:00
|
|
|
|
|
|
|
|
#if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS)
|
|
|
|
|
wc_ecc_fp_free(); /* free per thread cache */
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-09-22 23:18:10 -05:00
|
|
|
return (void *)0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2014-05-08 15:52:20 -07:00
|
|
|
|
|
|
|
|
int testsuite_test(int argc, char** argv)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2022-03-10 18:21:07 +09:00
|
|
|
#if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
|
|
|
|
|
(!defined(WOLF_CRYPTO_CB_ONLY_RSA) && !defined(WOLF_CRYPTO_CB_ONLY_ECC))
|
2011-02-05 11:14:47 -08:00
|
|
|
func_args server_args;
|
|
|
|
|
|
|
|
|
|
tcp_ready ready;
|
2022-04-12 12:45:02 +10:00
|
|
|
#if !defined(NETOS)
|
2011-02-05 11:14:47 -08:00
|
|
|
THREAD_TYPE serverThread;
|
|
|
|
|
|
2022-04-12 12:45:02 +10:00
|
|
|
int ret;
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-02-04 11:52:37 -07:00
|
|
|
#ifndef USE_WINDOWS_API
|
2022-02-10 15:54:39 -06:00
|
|
|
const char *tempDir = NULL;
|
|
|
|
|
char tempName[128];
|
|
|
|
|
int tempName_len;
|
|
|
|
|
int tempName_Xnum;
|
2015-02-04 11:52:37 -07:00
|
|
|
#else
|
|
|
|
|
char tempName[] = "fnXXXXXX";
|
2022-02-10 15:54:39 -06:00
|
|
|
const int tempName_len = 8;
|
|
|
|
|
const int tempName_Xnum = 6;
|
2015-02-04 11:52:37 -07:00
|
|
|
#endif
|
2020-09-22 23:18:10 -05:00
|
|
|
#ifdef HAVE_STACK_SIZE
|
2021-05-10 10:32:55 +10:00
|
|
|
void *serverThreadStackContext = NULL;
|
2020-09-22 23:18:10 -05:00
|
|
|
#endif
|
2015-02-04 11:52:37 -07:00
|
|
|
|
2022-02-10 15:54:39 -06:00
|
|
|
#ifndef USE_WINDOWS_API
|
|
|
|
|
#ifdef XGETENV
|
|
|
|
|
tempDir = XGETENV("TMPDIR");
|
|
|
|
|
if (tempDir == NULL)
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
tempDir = "/tmp";
|
|
|
|
|
}
|
|
|
|
|
XSTRLCPY(tempName, tempDir, sizeof(tempName));
|
|
|
|
|
XSTRLCAT(tempName, "/testsuite-output-XXXXXX", sizeof(tempName));
|
|
|
|
|
tempName_len = (int)XSTRLEN(tempName);
|
|
|
|
|
tempName_Xnum = 6;
|
|
|
|
|
#endif /* !USE_WINDOWS_API */
|
|
|
|
|
|
2016-05-05 15:31:25 -06:00
|
|
|
#ifdef HAVE_WNR
|
2017-06-26 23:05:32 -07:00
|
|
|
if (wc_InitNetRandom(wnrConfig, NULL, 5000) != 0) {
|
|
|
|
|
err_sys("Whitewood netRandom global config failed");
|
|
|
|
|
return -1237;
|
|
|
|
|
}
|
2016-05-05 15:31:25 -06:00
|
|
|
#endif /* HAVE_WNR */
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
StartTCP();
|
|
|
|
|
|
2013-03-26 22:00:39 -07:00
|
|
|
server_args.argc = argc;
|
|
|
|
|
server_args.argv = argv;
|
2011-06-16 11:46:45 -07:00
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
wolfSSL_Init();
|
|
|
|
|
#if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND)
|
|
|
|
|
wolfSSL_Debugging_ON();
|
2011-06-16 11:46:45 -07:00
|
|
|
#endif
|
2011-09-23 16:13:02 -07:00
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
#if !defined(WOLFSSL_TIRTOS)
|
2016-11-14 12:47:24 -08:00
|
|
|
ChangeToWolfRoot();
|
2014-05-08 15:52:20 -07:00
|
|
|
#endif
|
|
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
#ifdef WOLFSSL_TIRTOS
|
2014-09-08 19:40:03 -07:00
|
|
|
fdOpenSession(Task_self());
|
2014-05-08 15:52:20 -07:00
|
|
|
#endif
|
|
|
|
|
|
2013-03-26 22:00:39 -07:00
|
|
|
server_args.signal = &ready;
|
|
|
|
|
InitTcpReady(&ready);
|
|
|
|
|
|
2016-02-04 12:06:24 -08:00
|
|
|
#ifndef NO_CRYPT_TEST
|
2014-12-29 10:27:03 -07:00
|
|
|
/* wc_ test */
|
2020-09-22 23:18:10 -05:00
|
|
|
#ifdef HAVE_STACK_SIZE
|
|
|
|
|
StackSizeCheck(&server_args, wolfcrypt_test);
|
|
|
|
|
#else
|
2021-11-05 18:16:08 -05:00
|
|
|
wolfcrypt_test(&server_args);
|
2020-09-22 23:18:10 -05:00
|
|
|
#endif
|
2013-03-26 22:00:39 -07:00
|
|
|
if (server_args.return_code != 0) return server_args.return_code;
|
2016-02-04 12:06:24 -08:00
|
|
|
#endif
|
|
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
/* Simple wolfSSL client server test */
|
2020-09-22 23:18:10 -05:00
|
|
|
#ifdef HAVE_STACK_SIZE
|
|
|
|
|
StackSizeCheck(&server_args, (THREAD_RETURN (*)(void *))simple_test);
|
|
|
|
|
#else
|
|
|
|
|
simple_test(&server_args);
|
|
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
if (server_args.return_code != 0) return server_args.return_code;
|
2021-08-23 16:29:30 -06:00
|
|
|
#if !defined(NETOS)
|
2015-01-13 13:27:01 -07:00
|
|
|
/* Echo input wolfSSL client server test */
|
2020-09-22 23:18:10 -05:00
|
|
|
#ifdef HAVE_STACK_SIZE
|
2021-05-10 10:32:55 +10:00
|
|
|
StackSizeCheck_launch(&server_args, echoserver_test, &serverThread,
|
|
|
|
|
&serverThreadStackContext);
|
2020-09-22 23:18:10 -05:00
|
|
|
#else
|
|
|
|
|
start_thread(echoserver_test, &server_args, &serverThread);
|
|
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2021-05-10 10:32:55 +10:00
|
|
|
/* Create unique file name */
|
2022-02-10 15:54:39 -06:00
|
|
|
outputName = mymktemp(tempName, tempName_len, tempName_Xnum);
|
2021-05-10 10:32:55 +10:00
|
|
|
if (outputName == NULL) {
|
|
|
|
|
printf("Could not create unique file name");
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2021-05-10 10:32:55 +10:00
|
|
|
ret = test_tls(&server_args);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
cleanup_output();
|
|
|
|
|
return ret;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
|
2021-05-10 10:32:55 +10:00
|
|
|
/* Server won't quit unless TLS test has worked. */
|
|
|
|
|
#ifdef HAVE_STACK_SIZE
|
|
|
|
|
fputs("reaping echoserver_test: ", stdout);
|
|
|
|
|
StackSizeCheck_reap(serverThread, serverThreadStackContext);
|
|
|
|
|
#else
|
|
|
|
|
join_thread(serverThread);
|
|
|
|
|
#endif
|
|
|
|
|
if (server_args.return_code != 0) {
|
|
|
|
|
cleanup_output();
|
|
|
|
|
return server_args.return_code;
|
2014-08-15 10:56:38 -07:00
|
|
|
}
|
2023-05-23 17:03:18 +02:00
|
|
|
|
2023-05-24 11:58:41 +02:00
|
|
|
#if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
|
|
|
|
|
defined(HAVE_CRL) && defined(HAVE_CRL_MONITOR)
|
2023-05-23 17:03:18 +02:00
|
|
|
ret = test_crl_monitor();
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
cleanup_output();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-08-23 16:29:30 -06:00
|
|
|
#endif /* !NETOS */
|
2014-08-15 10:56:38 -07:00
|
|
|
|
2021-05-10 10:32:55 +10:00
|
|
|
show_ciphers();
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2021-08-23 16:29:30 -06:00
|
|
|
#if !defined(NETOS)
|
2021-05-10 10:32:55 +10:00
|
|
|
ret = validate_cleanup_output();
|
|
|
|
|
if (ret != 0)
|
|
|
|
|
return EXIT_FAILURE;
|
2021-08-23 16:29:30 -06:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
wolfSSL_Cleanup();
|
2011-02-05 11:14:47 -08:00
|
|
|
FreeTcpReady(&ready);
|
|
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
#ifdef WOLFSSL_TIRTOS
|
2014-09-08 19:40:03 -07:00
|
|
|
fdCloseSession(Task_self());
|
2014-05-08 15:52:20 -07:00
|
|
|
#endif
|
2014-05-09 11:55:59 -07:00
|
|
|
|
2016-05-05 15:31:25 -06:00
|
|
|
#ifdef HAVE_WNR
|
|
|
|
|
if (wc_FreeNetRandom() < 0)
|
|
|
|
|
err_sys("Failed to free netRandom context");
|
|
|
|
|
#endif /* HAVE_WNR */
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
printf("\nAll tests passed!\n");
|
2017-06-26 23:05:32 -07:00
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
(void)argc;
|
|
|
|
|
(void)argv;
|
|
|
|
|
#endif /* !NO_WOLFSSL_SERVER && !NO_WOLFSSL_CLIENT */
|
|
|
|
|
|
2017-03-31 13:11:23 -07:00
|
|
|
return EXIT_SUCCESS;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
|
2023-05-23 17:03:18 +02:00
|
|
|
#if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
|
2023-05-24 11:58:41 +02:00
|
|
|
defined(HAVE_CRL) && defined(HAVE_CRL_MONITOR)
|
2023-05-23 17:03:18 +02:00
|
|
|
#define CRL_MONITOR_TEST_ROUNDS 6
|
2023-07-03 14:21:27 +02:00
|
|
|
#define CRL_MONITOR_REM_FILE_ATTEMPTS 20
|
2023-05-23 17:03:18 +02:00
|
|
|
|
|
|
|
|
static int test_crl_monitor(void)
|
|
|
|
|
{
|
|
|
|
|
func_args server_args;
|
|
|
|
|
func_args client_args;
|
|
|
|
|
THREAD_TYPE serverThread;
|
|
|
|
|
tcp_ready ready;
|
|
|
|
|
char buf[128];
|
|
|
|
|
char tmpDir[16];
|
|
|
|
|
char rounds[4];
|
2023-07-28 17:00:14 +02:00
|
|
|
char portNum[8];
|
2023-05-24 11:53:57 +02:00
|
|
|
const char* serverArgv[] = {
|
2023-05-23 17:03:18 +02:00
|
|
|
"testsuite",
|
|
|
|
|
"-A", "certs/ca-cert.pem",
|
|
|
|
|
"--crl-dir", tmpDir,
|
|
|
|
|
"-C", rounds,
|
2023-05-24 11:58:41 +02:00
|
|
|
"--quieter",
|
2023-07-28 17:00:14 +02:00
|
|
|
"-x",
|
|
|
|
|
"-p", "0"
|
2023-05-23 17:03:18 +02:00
|
|
|
};
|
2023-05-24 11:53:57 +02:00
|
|
|
const char* clientArgv[] = {
|
2023-05-23 17:03:18 +02:00
|
|
|
"testsuite",
|
|
|
|
|
"-C",
|
|
|
|
|
"-c", "certs/server-cert.pem",
|
|
|
|
|
"-k", "certs/server-key.pem",
|
2023-05-24 11:58:41 +02:00
|
|
|
"--quieter",
|
2023-07-28 17:00:14 +02:00
|
|
|
"-H", "exitWithRet",
|
|
|
|
|
"-p", portNum
|
2023-05-23 17:03:18 +02:00
|
|
|
};
|
|
|
|
|
int ret = -1;
|
2023-07-03 14:21:27 +02:00
|
|
|
int i = -1, j;
|
2023-05-23 17:03:18 +02:00
|
|
|
|
2023-05-24 11:58:41 +02:00
|
|
|
printf("\nRunning CRL monitor test\n");
|
|
|
|
|
|
2023-05-23 17:03:18 +02:00
|
|
|
sprintf(rounds, "%d", CRL_MONITOR_TEST_ROUNDS);
|
|
|
|
|
|
|
|
|
|
XMEMSET(&server_args, 0, sizeof(func_args));
|
|
|
|
|
XMEMSET(&client_args, 0, sizeof(func_args));
|
|
|
|
|
|
|
|
|
|
/* Create temp dir */
|
|
|
|
|
if (create_tmp_dir(tmpDir, sizeof(tmpDir) - 1) == NULL) {
|
|
|
|
|
fprintf(stderr, "Failed to create tmp dir");
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-24 11:53:57 +02:00
|
|
|
server_args.argv = (char**)serverArgv;
|
2023-05-23 17:03:18 +02:00
|
|
|
server_args.argc = sizeof(serverArgv) / sizeof(*serverArgv);
|
|
|
|
|
client_args.signal = server_args.signal = &ready;
|
2023-05-24 11:53:57 +02:00
|
|
|
client_args.argv = (char**)clientArgv;
|
2023-05-23 17:03:18 +02:00
|
|
|
client_args.argc = sizeof(clientArgv) / sizeof(*clientArgv);
|
|
|
|
|
|
|
|
|
|
InitTcpReady(&ready);
|
|
|
|
|
start_thread(server_test, &server_args, &serverThread);
|
|
|
|
|
wait_tcp_ready(&server_args);
|
2023-07-28 17:00:14 +02:00
|
|
|
sprintf(portNum, "%d", server_args.signal->port);
|
2023-05-23 17:03:18 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < CRL_MONITOR_TEST_ROUNDS; i++) {
|
|
|
|
|
int expectFail;
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
|
/* succeed on even rounds */
|
|
|
|
|
sprintf(buf, "%s/%s", tmpDir, "crl.pem");
|
2024-01-17 21:38:26 -08:00
|
|
|
if (STAGE_FILE("certs/crl/crl.pem", buf) != 0) {
|
2023-07-03 14:21:27 +02:00
|
|
|
fprintf(stderr, "[%d] Failed to copy file to %s\n", i, buf);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2023-05-23 17:03:18 +02:00
|
|
|
sprintf(buf, "%s/%s", tmpDir, "crl.revoked");
|
|
|
|
|
/* The monitor can be holding the file handle and this will cause
|
2023-07-03 14:21:27 +02:00
|
|
|
* the remove call to fail. Let's give the monitor a some time to
|
2023-05-23 17:03:18 +02:00
|
|
|
* finish up. */
|
2023-07-03 14:21:27 +02:00
|
|
|
for (j = 0; j < CRL_MONITOR_REM_FILE_ATTEMPTS; j++) {
|
|
|
|
|
/* i == 0 since there is nothing to delete in the first round */
|
|
|
|
|
if (i == 0 || rem_file(buf) == 0)
|
|
|
|
|
break;
|
|
|
|
|
XSLEEP_MS(100);
|
|
|
|
|
}
|
|
|
|
|
if (j == CRL_MONITOR_REM_FILE_ATTEMPTS) {
|
|
|
|
|
fprintf(stderr, "[%d] Failed to remove file %s\n", i, buf);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2023-05-23 17:03:18 +02:00
|
|
|
expectFail = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* fail on odd rounds */
|
|
|
|
|
sprintf(buf, "%s/%s", tmpDir, "crl.revoked");
|
2024-01-17 21:38:26 -08:00
|
|
|
if (STAGE_FILE("certs/crl/crl.revoked", buf) != 0) {
|
2023-07-03 14:21:27 +02:00
|
|
|
fprintf(stderr, "[%d] Failed to copy file to %s\n", i, buf);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2023-05-23 17:03:18 +02:00
|
|
|
sprintf(buf, "%s/%s", tmpDir, "crl.pem");
|
|
|
|
|
/* The monitor can be holding the file handle and this will cause
|
2023-07-03 14:21:27 +02:00
|
|
|
* the remove call to fail. Let's give the monitor a some time to
|
2023-05-23 17:03:18 +02:00
|
|
|
* finish up. */
|
2023-07-03 14:21:27 +02:00
|
|
|
for (j = 0; j < CRL_MONITOR_REM_FILE_ATTEMPTS; j++) {
|
|
|
|
|
if (rem_file(buf) == 0)
|
|
|
|
|
break;
|
|
|
|
|
XSLEEP_MS(100);
|
|
|
|
|
}
|
|
|
|
|
if (j == CRL_MONITOR_REM_FILE_ATTEMPTS) {
|
|
|
|
|
fprintf(stderr, "[%d] Failed to remove file %s\n", i, buf);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2023-05-23 17:03:18 +02:00
|
|
|
expectFail = 1;
|
|
|
|
|
}
|
2023-07-03 14:21:27 +02:00
|
|
|
/* Give server a moment to register the file change */
|
|
|
|
|
XSLEEP_MS(100);
|
2023-05-24 11:58:41 +02:00
|
|
|
|
2023-05-23 17:03:18 +02:00
|
|
|
client_args.return_code = 0;
|
|
|
|
|
client_test(&client_args);
|
|
|
|
|
|
|
|
|
|
if (!expectFail) {
|
2023-07-03 14:21:27 +02:00
|
|
|
if (client_args.return_code != 0) {
|
|
|
|
|
fprintf(stderr, "[%d] Incorrect return %d\n", i,
|
|
|
|
|
client_args.return_code);
|
2023-05-23 17:03:18 +02:00
|
|
|
goto cleanup;
|
2023-07-03 14:21:27 +02:00
|
|
|
}
|
2023-05-23 17:03:18 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2023-07-03 14:21:27 +02:00
|
|
|
if (client_args.return_code == 0) {
|
|
|
|
|
fprintf(stderr, "[%d] Expected failure\n", i);
|
2023-05-23 17:03:18 +02:00
|
|
|
goto cleanup;
|
2023-07-03 14:21:27 +02:00
|
|
|
}
|
2023-05-23 17:03:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
join_thread(serverThread);
|
|
|
|
|
ret = 0;
|
|
|
|
|
cleanup:
|
2023-07-03 14:21:27 +02:00
|
|
|
if (ret != 0 && i >= 0)
|
|
|
|
|
fprintf(stderr, "test_crl_monitor failed on iteration %d\n", i);
|
2023-05-23 17:03:18 +02:00
|
|
|
sprintf(buf, "%s/%s", tmpDir, "crl.pem");
|
|
|
|
|
rem_file(buf);
|
|
|
|
|
sprintf(buf, "%s/%s", tmpDir, "crl.revoked");
|
|
|
|
|
rem_file(buf);
|
|
|
|
|
(void)rem_dir(tmpDir);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-03-10 18:21:07 +09:00
|
|
|
#if !defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
|
|
|
|
|
(!defined(WOLF_CRYPTO_CB_ONLY_RSA) && !defined(WOLF_CRYPTO_CB_ONLY_ECC))
|
2021-05-10 10:32:55 +10:00
|
|
|
/* Perform a basic TLS handshake.
|
|
|
|
|
*
|
|
|
|
|
* First connection to echo a file.
|
|
|
|
|
* Second to tell TLS server to quit.
|
|
|
|
|
*
|
|
|
|
|
* @param [in,out] server_args Object sent to server thread.
|
|
|
|
|
* @return 0 on success.
|
|
|
|
|
* @return echoclient error return code on failure.
|
|
|
|
|
*/
|
|
|
|
|
static int test_tls(func_args* server_args)
|
|
|
|
|
{
|
|
|
|
|
func_args echo_args;
|
|
|
|
|
char* myArgv[NUMARGS];
|
2022-02-10 15:54:39 -06:00
|
|
|
char arg[3][128];
|
2021-05-10 10:32:55 +10:00
|
|
|
|
2023-05-24 11:58:41 +02:00
|
|
|
printf("\nRunning TLS test\n");
|
|
|
|
|
|
2021-05-10 10:32:55 +10:00
|
|
|
/* Set up command line arguments for echoclient to send input file
|
|
|
|
|
* and write echoed data to temporary output file. */
|
|
|
|
|
myArgv[0] = arg[0];
|
|
|
|
|
myArgv[1] = arg[1];
|
|
|
|
|
myArgv[2] = arg[2];
|
|
|
|
|
|
|
|
|
|
echo_args.argc = 3;
|
|
|
|
|
echo_args.argv = myArgv;
|
|
|
|
|
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
XSTRLCPY(arg[0], "testsuite", sizeof(arg[0]));
|
|
|
|
|
XSTRLCPY(arg[1], "input", sizeof(arg[1]));
|
|
|
|
|
XSTRLCPY(arg[2], outputName, sizeof(arg[2]));
|
2021-05-10 10:32:55 +10:00
|
|
|
|
|
|
|
|
/* Share the signal, it has the new port number in it. */
|
|
|
|
|
echo_args.signal = server_args->signal;
|
|
|
|
|
|
|
|
|
|
/* Ready to execute client - wait for server to be ready. */
|
|
|
|
|
wait_tcp_ready(server_args);
|
|
|
|
|
|
|
|
|
|
/* Do a client TLS connection. */
|
|
|
|
|
#ifdef HAVE_STACK_SIZE
|
|
|
|
|
fputs("echoclient_test #1: ", stdout);
|
|
|
|
|
StackSizeCheck(&echo_args, echoclient_test_wrapper);
|
|
|
|
|
#else
|
|
|
|
|
echoclient_test(&echo_args);
|
|
|
|
|
#endif
|
|
|
|
|
if (echo_args.return_code != 0)
|
|
|
|
|
return echo_args.return_code;
|
|
|
|
|
|
|
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
/* Ensure server is ready for UDP data. */
|
|
|
|
|
wait_tcp_ready(server_args);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Next client connection - send quit to shutdown server. */
|
|
|
|
|
echo_args.argc = 2;
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
XSTRLCPY(arg[1], "quit", sizeof(arg[1]));
|
2021-05-10 10:32:55 +10:00
|
|
|
|
|
|
|
|
/* Do a client TLS connection. */
|
|
|
|
|
#ifdef HAVE_STACK_SIZE
|
|
|
|
|
fputs("echoclient_test #2: ", stdout);
|
|
|
|
|
StackSizeCheck(&echo_args, echoclient_test_wrapper);
|
|
|
|
|
#else
|
|
|
|
|
echoclient_test(&echo_args);
|
|
|
|
|
#endif
|
|
|
|
|
if (echo_args.return_code != 0)
|
|
|
|
|
return echo_args.return_code;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Show cipher suites available. */
|
2022-06-20 10:54:55 -05:00
|
|
|
static void show_ciphers(void)
|
2021-05-10 10:32:55 +10:00
|
|
|
{
|
|
|
|
|
char ciphers[WOLFSSL_CIPHER_LIST_MAX_SIZE];
|
|
|
|
|
XMEMSET(ciphers, 0, sizeof(ciphers));
|
|
|
|
|
wolfSSL_get_ciphers(ciphers, sizeof(ciphers)-1);
|
|
|
|
|
printf("ciphers = %s\n", ciphers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Cleanup temporary output file. */
|
2022-06-20 10:54:55 -05:00
|
|
|
static void cleanup_output(void)
|
2021-05-10 10:32:55 +10:00
|
|
|
{
|
|
|
|
|
remove(outputName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Validate output equals input using a hash. Remove temporary output file.
|
|
|
|
|
*
|
|
|
|
|
* @return 0 on success.
|
|
|
|
|
* @return 1 on failure.
|
|
|
|
|
*/
|
2022-06-20 10:54:55 -05:00
|
|
|
static int validate_cleanup_output(void)
|
2021-05-10 10:32:55 +10:00
|
|
|
{
|
|
|
|
|
#ifndef NO_SHA256
|
|
|
|
|
byte input[WC_SHA256_DIGEST_SIZE];
|
|
|
|
|
byte output[WC_SHA256_DIGEST_SIZE];
|
|
|
|
|
|
|
|
|
|
file_test("input", input);
|
|
|
|
|
file_test(outputName, output);
|
|
|
|
|
#endif
|
|
|
|
|
cleanup_output();
|
|
|
|
|
#ifndef NO_SHA256
|
|
|
|
|
if (memcmp(input, output, sizeof(input)) != 0)
|
|
|
|
|
return 1;
|
|
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Simple server.
|
|
|
|
|
*
|
|
|
|
|
* @param [in] args Object for server data in thread.
|
|
|
|
|
* @return Return code.
|
|
|
|
|
*/
|
2020-09-22 23:18:10 -05:00
|
|
|
#ifdef HAVE_STACK_SIZE
|
|
|
|
|
static THREAD_RETURN simple_test(func_args* args)
|
|
|
|
|
#else
|
|
|
|
|
static void simple_test(func_args* args)
|
|
|
|
|
#endif
|
2013-03-26 22:00:39 -07:00
|
|
|
{
|
|
|
|
|
THREAD_TYPE serverThread;
|
|
|
|
|
|
2020-01-15 22:15:38 +10:00
|
|
|
int i;
|
|
|
|
|
|
2013-03-26 22:00:39 -07:00
|
|
|
func_args svrArgs;
|
2014-02-11 17:56:59 -08:00
|
|
|
char *svrArgv[9];
|
2020-01-15 22:15:38 +10:00
|
|
|
char argvs[9][32];
|
2013-03-26 22:00:39 -07:00
|
|
|
|
|
|
|
|
func_args cliArgs;
|
|
|
|
|
char *cliArgv[NUMARGS];
|
2020-01-15 22:15:38 +10:00
|
|
|
char argvc[3][32];
|
|
|
|
|
|
2023-05-24 11:58:41 +02:00
|
|
|
printf("\nRunning simple test\n");
|
|
|
|
|
|
2020-01-15 22:15:38 +10:00
|
|
|
for (i = 0; i < 9; i++)
|
|
|
|
|
svrArgv[i] = argvs[i];
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
|
cliArgv[i] = argvc[i];
|
2013-03-26 22:00:39 -07:00
|
|
|
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
XSTRLCPY(argvs[0], "SimpleServer", sizeof(argvs[0]));
|
2013-03-26 22:00:39 -07:00
|
|
|
svrArgs.argc = 1;
|
|
|
|
|
svrArgs.argv = svrArgv;
|
|
|
|
|
svrArgs.return_code = 0;
|
2014-12-29 10:27:03 -07:00
|
|
|
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_SNIFFER) && \
|
|
|
|
|
!defined(WOLFSSL_TIRTOS)
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
XSTRLCPY(argvs[svrArgs.argc++], "-p", sizeof(argvs[svrArgs.argc]));
|
|
|
|
|
XSTRLCPY(argvs[svrArgs.argc++], "0", sizeof(argvs[svrArgs.argc]));
|
2014-02-11 17:56:59 -08:00
|
|
|
#endif
|
2013-03-26 22:00:39 -07:00
|
|
|
/* Set the last arg later, when it is known. */
|
|
|
|
|
|
|
|
|
|
args->return_code = 0;
|
|
|
|
|
svrArgs.signal = args->signal;
|
|
|
|
|
start_thread(server_test, &svrArgs, &serverThread);
|
|
|
|
|
wait_tcp_ready(&svrArgs);
|
2015-01-03 19:09:48 -07:00
|
|
|
|
2013-03-26 22:00:39 -07:00
|
|
|
/* Setting the actual port number. */
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
XSTRLCPY(argvc[0], "SimpleClient", sizeof(argvc[0]));
|
2020-04-08 09:46:22 +10:00
|
|
|
cliArgs.argv = cliArgv;
|
|
|
|
|
cliArgs.return_code = 0;
|
2021-05-10 10:32:55 +10:00
|
|
|
#ifndef USE_WINDOWS_API
|
|
|
|
|
cliArgs.argc = NUMARGS;
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
XSTRLCPY(argvc[1], "-p", sizeof(argvc[1]));
|
2022-07-11 22:27:43 -05:00
|
|
|
(void)snprintf(argvc[2], sizeof(argvc[2]), "%d", (int)svrArgs.signal->port);
|
2021-05-10 10:32:55 +10:00
|
|
|
#else
|
|
|
|
|
cliArgs.argc = 1;
|
|
|
|
|
#endif
|
2013-03-26 22:00:39 -07:00
|
|
|
|
|
|
|
|
client_test(&cliArgs);
|
|
|
|
|
if (cliArgs.return_code != 0) {
|
|
|
|
|
args->return_code = cliArgs.return_code;
|
2020-09-22 23:18:10 -05:00
|
|
|
#ifdef HAVE_STACK_SIZE
|
2020-12-16 16:44:22 +10:00
|
|
|
return (THREAD_RETURN)0;
|
2020-09-22 23:18:10 -05:00
|
|
|
#else
|
2013-03-26 22:00:39 -07:00
|
|
|
return;
|
2020-09-22 23:18:10 -05:00
|
|
|
#endif
|
2013-03-26 22:00:39 -07:00
|
|
|
}
|
|
|
|
|
join_thread(serverThread);
|
|
|
|
|
if (svrArgs.return_code != 0) args->return_code = svrArgs.return_code;
|
2020-09-22 23:18:10 -05:00
|
|
|
#ifdef HAVE_STACK_SIZE
|
2020-12-16 16:44:22 +10:00
|
|
|
return (THREAD_RETURN)0;
|
2020-09-22 23:18:10 -05:00
|
|
|
#endif
|
2013-03-26 22:00:39 -07:00
|
|
|
}
|
2017-06-26 23:05:32 -07:00
|
|
|
#endif /* !NO_WOLFSSL_SERVER && !NO_WOLFSSL_CLIENT */
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2016-11-14 12:47:24 -08:00
|
|
|
#ifndef NO_SHA256
|
2021-05-10 10:32:55 +10:00
|
|
|
/* Create SHA-256 hash of the file based on filename.
|
|
|
|
|
*
|
|
|
|
|
* @param [in] file Name of file.
|
2023-07-24 19:23:01 +02:00
|
|
|
* @param [out] check Buffer to hold SHA-256 hash.
|
2021-05-10 10:32:55 +10:00
|
|
|
*/
|
2012-09-20 15:39:15 -07:00
|
|
|
void file_test(const char* file, byte* check)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
|
|
|
|
FILE* f;
|
2014-03-25 17:11:15 -07:00
|
|
|
int i = 0, j, ret;
|
2017-09-25 18:47:36 -07:00
|
|
|
wc_Sha256 sha256;
|
2011-02-05 11:14:47 -08:00
|
|
|
byte buf[1024];
|
2017-09-25 18:47:36 -07:00
|
|
|
byte shasum[WC_SHA256_DIGEST_SIZE];
|
2015-01-03 19:09:48 -07:00
|
|
|
|
2015-01-01 14:48:33 -07:00
|
|
|
ret = wc_InitSha256(&sha256);
|
2014-03-25 17:11:15 -07:00
|
|
|
if (ret != 0) {
|
2015-01-01 14:48:33 -07:00
|
|
|
printf("Can't wc_InitSha256 %d\n", ret);
|
2014-03-25 17:11:15 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
if( !( f = fopen( file, "rb" ) )) {
|
|
|
|
|
printf("Can't open %s\n", file);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-04-08 11:42:31 -03:00
|
|
|
while( ( i = (int)fread(buf, 1, sizeof(buf), f )) > 0 ) {
|
2024-05-11 15:24:54 -05:00
|
|
|
if (ferror(f)) {
|
|
|
|
|
printf("I/O error reading %s\n", file);
|
|
|
|
|
fclose(f);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-08 10:14:53 -04:00
|
|
|
ret = wc_Sha256Update(&sha256, buf, (word32)i);
|
2014-04-08 11:42:31 -03:00
|
|
|
if (ret != 0) {
|
2015-01-01 14:48:33 -07:00
|
|
|
printf("Can't wc_Sha256Update %d\n", ret);
|
2015-10-09 10:57:55 -06:00
|
|
|
fclose(f);
|
2014-04-08 11:42:31 -03:00
|
|
|
return;
|
|
|
|
|
}
|
2024-05-11 15:24:54 -05:00
|
|
|
if (feof(f))
|
|
|
|
|
break;
|
2014-04-08 11:42:31 -03:00
|
|
|
}
|
2015-01-03 19:09:48 -07:00
|
|
|
|
2015-01-01 14:48:33 -07:00
|
|
|
ret = wc_Sha256Final(&sha256, shasum);
|
2020-10-01 01:10:52 -05:00
|
|
|
wc_Sha256Free(&sha256);
|
|
|
|
|
|
2014-04-08 11:42:31 -03:00
|
|
|
if (ret != 0) {
|
2015-01-01 14:48:33 -07:00
|
|
|
printf("Can't wc_Sha256Final %d\n", ret);
|
2015-10-09 10:57:55 -06:00
|
|
|
fclose(f);
|
2014-04-08 11:42:31 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-29 11:11:25 -07:00
|
|
|
XMEMCPY(check, shasum, sizeof(shasum));
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2017-09-25 18:47:36 -07:00
|
|
|
for(j = 0; j < WC_SHA256_DIGEST_SIZE; ++j )
|
2012-11-26 18:40:43 -08:00
|
|
|
printf( "%02x", shasum[j] );
|
2015-01-03 19:09:48 -07:00
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
printf(" %s\n", file);
|
|
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
}
|
2016-11-14 12:47:24 -08:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2014-02-11 18:59:20 -08:00
|
|
|
#else /* SINGLE_THREADED */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int myoptind = 0;
|
|
|
|
|
char* myoptarg = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
2021-05-10 10:32:55 +10:00
|
|
|
func_args wolfcrypt_test_args;
|
2014-02-11 18:59:20 -08:00
|
|
|
|
2021-05-10 10:32:55 +10:00
|
|
|
wolfcrypt_test_args.argc = argc;
|
|
|
|
|
wolfcrypt_test_args.argv = argv;
|
2014-02-11 18:59:20 -08:00
|
|
|
|
2017-02-08 18:52:16 -07:00
|
|
|
wolfSSL_Init();
|
2015-10-28 23:54:08 -07:00
|
|
|
ChangeToWolfRoot();
|
2014-02-11 18:59:20 -08:00
|
|
|
|
2021-05-10 10:32:55 +10:00
|
|
|
/* No TLS - only doing cryptographic algorithm testing. */
|
|
|
|
|
wolfcrypt_test(&wolfcrypt_test_args);
|
|
|
|
|
if (wolfcrypt_test_args.return_code != 0)
|
|
|
|
|
return wolfcrypt_test_args.return_code;
|
2014-02-11 18:59:20 -08:00
|
|
|
|
2017-02-08 18:52:16 -07:00
|
|
|
wolfSSL_Cleanup();
|
2014-02-11 18:59:20 -08:00
|
|
|
printf("\nAll tests passed!\n");
|
2022-05-05 08:08:09 -07:00
|
|
|
return EXIT_SUCCESS;
|
2014-02-11 18:59:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SINGLE_THREADED */
|
|
|
|
|
|