Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ jobs:
- os: macos-latest
config: '--enable-wolfclu'
sanitize: ''
# Keeps the no-filesystem build (and the tests that skip on it)
# from rotting; cheap enough to run without ASAN.
- os: ubuntu-latest
config: '--enable-wolfclu'
sanitize: ''
clu_config: '--disable-filesystem'

name: ${{ matrix.os }} ${{ matrix.sanitize && 'ASAN' || '' }} (${{ matrix.config }})
name: ${{ matrix.os }} ${{ matrix.sanitize && 'ASAN' || '' }} (${{ matrix.config }}${{ matrix.clu_config && format(' / wolfclu {0}', matrix.clu_config) || '' }})
runs-on: ${{ matrix.os }}
timeout-minutes: 10

Expand Down Expand Up @@ -73,7 +79,8 @@ jobs:
working-directory: ./wolfclu
run: |
./autogen.sh
./configure ${{ matrix.sanitize }} --with-wolfssl=$GITHUB_WORKSPACE/build-dir
./configure ${{ matrix.sanitize }} ${{ matrix.clu_config }} \
--with-wolfssl=$GITHUB_WORKSPACE/build-dir
make -j

- name: Run tests
Expand Down
9 changes: 8 additions & 1 deletion src/server/clu_server_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include <wolfclu/clu_error_codes.h>
#include <wolfclu/clu_log.h>
#include <wolfclu/clu_optargs.h>
#include <wolfclu/server.h>

#ifndef WOLFCLU_NO_FILESYSTEM
#include <wolfclu/server.h>

static const struct option server_options[] = {
{"-port", required_argument, 0, WOLFCLU_PORT },
Expand Down Expand Up @@ -98,6 +98,7 @@ static int _addServerArg(const char** args, const char* in, int* idx)

int wolfCLU_Server(int argc, char** argv)
{
#ifndef WOLFCLU_NO_FILESYSTEM
func_args args;
int ret = WOLFCLU_SUCCESS;
int longIndex = 1;
Expand Down Expand Up @@ -206,4 +207,10 @@ int wolfCLU_Server(int argc, char** argv)
FreeTcpReady(&ready);

return ret;
#else
(void)argc;
(void)argv;
WOLFCLU_LOG(WOLFCLU_E0, "No filesystem support");
return WOLFCLU_FATAL_ERROR;
#endif
}
5 changes: 5 additions & 0 deletions src/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
* https://github.com/wolfSSL/wolfssl-examples/tree/master/tls
*/

/* Only compile when filesystem is enabled, like src/client/client.c. */
#ifndef WOLFCLU_NO_FILESYSTEM

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
Expand Down Expand Up @@ -3927,3 +3930,5 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
char* myoptarg = NULL;

#endif /* NO_MAIN_DRIVER */

#endif /* !WOLFCLU_NO_FILESYSTEM */
2 changes: 1 addition & 1 deletion src/sign-verify/clu_x509_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ static void wolfCLU_x509VerifyHelp(void)
"1 cert as -untrusted");

}
#endif

static X509* load_cert_from_file(const char* filename) {
WOLFSSL_BIO* bio = NULL;
Expand All @@ -75,6 +74,7 @@ static X509* load_cert_from_file(const char* filename) {

return cert;
}
#endif /* !WOLFCLU_NO_FILESYSTEM */

int wolfCLU_x509Verify(int argc, char** argv)
{
Expand Down
10 changes: 8 additions & 2 deletions src/tools/clu_base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#include <wolfclu/clu_log.h>
#include <wolfclu/clu_optargs.h>

#if !defined(WOLFCLU_NO_FILESYSTEM) && !defined(NO_CODING)
#define WOLFCLU_BASE64_ENABLED
#endif

#ifdef WOLFCLU_BASE64_ENABLED
static const struct option base64_options[] = {
{"-in", required_argument, 0, WOLFCLU_INFILE },
{"-out", required_argument, 0, WOLFCLU_OUTFILE },
Expand All @@ -44,11 +49,12 @@ static void wolfCLU_Base64Help(void)
WOLFCLU_LOG(WOLFCLU_L0, "\t-d Decode data");
WOLFCLU_LOG(WOLFCLU_L0, "\t-help Display this message");
}
#endif /* WOLFCLU_BASE64_ENABLED */

/* base64 setup function */
int wolfCLU_Base64Setup(int argc, char** argv)
{
#if !defined(WOLFCLU_NO_FILESYSTEM) && !defined(NO_CODING)
#ifdef WOLFCLU_BASE64_ENABLED
WOLFSSL_BIO *bioIn = NULL;
WOLFSSL_BIO *bioOut = NULL;
byte* input = NULL;
Expand Down Expand Up @@ -330,5 +336,5 @@ int wolfCLU_Base64Setup(int argc, char** argv)
wolfCLU_LogError("No filesystem support");
#endif
return WOLFCLU_FATAL_ERROR;
#endif /* !WOLFCLU_NO_FILESYSTEM */
#endif /* WOLFCLU_BASE64_ENABLED */
}
11 changes: 3 additions & 8 deletions tests/base64/base64-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@

# Allow importing the shared helper when run standalone or via the test runner
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from wolfclu_test import WOLFSSL_BIN, CERTS_DIR, run_wolfssl, test_main
from wolfclu_test import (WOLFSSL_BIN, CERTS_DIR, no_filesystem, run_wolfssl,
test_main)


@unittest.skipIf(no_filesystem(), "filesystem support disabled")
class Base64Test(unittest.TestCase):

@classmethod
def setUpClass(cls):
if not os.path.isdir(CERTS_DIR):
raise unittest.SkipTest("certs directory not found")

# Skip if filesystem support is disabled (Linux autotools build)
config_log = os.path.join(".", "config.log")
if os.path.isfile(config_log):
with open(config_log, "r") as f:
if "disable-filesystem" in f.read():
raise unittest.SkipTest("filesystem support disabled")

# Skip if base64 coding support is not compiled in
result = run_wolfssl("base64", "-in",
os.path.join(CERTS_DIR, "server-key.der"))
Expand Down
10 changes: 3 additions & 7 deletions tests/client/client-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
import unittest

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from wolfclu_test import WOLFSSL_BIN, CERTS_DIR, run_wolfssl, test_main
from wolfclu_test import (WOLFSSL_BIN, CERTS_DIR, no_filesystem, run_wolfssl,
test_main)


@unittest.skipIf(no_filesystem(), "filesystem support disabled")
class ClientTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
if not os.path.isdir(CERTS_DIR):
raise unittest.SkipTest("certs directory not found")

config_log = os.path.join(".", "config.log")
if os.path.isfile(config_log):
with open(config_log, "r") as f:
if "disable-filesystem" in f.read():
raise unittest.SkipTest("filesystem support disabled")

def test_s_client_x509(self):
"""Connect to a TLS server, extract cert, and verify PEM output."""
tmp_crt = "tmp.crt"
Expand Down
26 changes: 6 additions & 20 deletions tests/dgst/dgst-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,20 @@
import unittest

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from wolfclu_test import (CERTS_DIR, is_fips, not_compiled_in, run_wolfssl,
test_main, truncate_sparse)
from wolfclu_test import (CERTS_DIR, is_fips, no_filesystem, not_compiled_in,
run_wolfssl, test_main, truncate_sparse)

DGST_DIR = os.path.dirname(os.path.abspath(__file__))


@unittest.skipIf(no_filesystem(), "filesystem support disabled")
class DgstVerifyTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
if not os.path.isdir(CERTS_DIR):
raise unittest.SkipTest("certs directory not found")

config_log = os.path.join(".", "config.log")
if os.path.isfile(config_log):
with open(config_log, "r") as f:
if "disable-filesystem" in f.read():
raise unittest.SkipTest("filesystem support disabled")

def test_verify_sha256_rsa(self):
r = run_wolfssl("dgst", "-sha256", "-verify",
os.path.join(CERTS_DIR, "server-keyPub.pem"),
Expand Down Expand Up @@ -162,6 +157,7 @@ def test_complete_args_not_misflagged(self):
self.assertEqual(r.returncode, 0, r.stderr)


@unittest.skipIf(no_filesystem(), "filesystem support disabled")
class DgstLargeFileTest(unittest.TestCase):

LARGE_FILE = "large-test.txt"
Expand All @@ -171,12 +167,6 @@ def setUpClass(cls):
if not os.path.isdir(CERTS_DIR):
raise unittest.SkipTest("certs directory not found")

config_log = os.path.join(".", "config.log")
if os.path.isfile(config_log):
with open(config_log, "r") as f:
if "disable-filesystem" in f.read():
raise unittest.SkipTest("filesystem support disabled")

# Create large file: 5000 copies of server-key.der
der_path = os.path.join(CERTS_DIR, "server-key.der")
with open(der_path, "rb") as src:
Expand Down Expand Up @@ -354,6 +344,7 @@ def test_tampered_last_byte_fails_verify(self):
self.assertNotEqual(r.returncode, 0)


@unittest.skipIf(no_filesystem(), "filesystem support disabled")
class DgstSignVerifyRoundtripTest(unittest.TestCase):

@classmethod
Expand Down Expand Up @@ -397,6 +388,7 @@ def test_ecc_sign_verify_roundtrip(self):
self.assertEqual(r.returncode, 0, r.stderr)


@unittest.skipIf(no_filesystem(), "filesystem support disabled")
class DgstHmacTest(unittest.TestCase):
"""HMAC test vectors for `dgst -mac HMAC`.

Expand Down Expand Up @@ -445,12 +437,6 @@ class DgstHmacTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
config_log = os.path.join(".", "config.log")
if os.path.isfile(config_log):
with open(config_log, "r") as f:
if "disable-filesystem" in f.read():
raise unittest.SkipTest("filesystem support disabled")

cls._tmpdir = tempfile.mkdtemp(prefix="wolfclu-hmac-")
cls.data_file = os.path.join(cls._tmpdir, "data.bin")
with open(cls.data_file, "wb") as f:
Expand Down
9 changes: 2 additions & 7 deletions tests/dh/dh-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,17 @@
import unittest

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from wolfclu_test import CERTS_DIR, run_wolfssl, test_main
from wolfclu_test import CERTS_DIR, no_filesystem, run_wolfssl, test_main


@unittest.skipIf(no_filesystem(), "filesystem support disabled")
class DhParamTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
if not os.path.isdir(CERTS_DIR):
raise unittest.SkipTest("certs directory not found")

config_log = os.path.join(".", "config.log")
if os.path.isfile(config_log):
with open(config_log, "r") as f:
if "disable-filesystem" in f.read():
raise unittest.SkipTest("filesystem support disabled")

# Skip if DH not compiled in
r = run_wolfssl("dhparam", "1024")
combined = r.stdout + r.stderr
Expand Down
19 changes: 12 additions & 7 deletions tests/dsa/dsa-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import unittest

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from wolfclu_test import CERTS_DIR, run_wolfssl, test_main
from wolfclu_test import CERTS_DIR, no_filesystem, run_wolfssl, test_main


# `dsaparam` generates to stdout without a filesystem, so only the tests that
# pass a file path are skipped on a --disable-filesystem build.
needs_filesystem = unittest.skipIf(no_filesystem(),
"filesystem support disabled")


class DsaParamTest(unittest.TestCase):
Expand All @@ -16,12 +22,6 @@ def setUpClass(cls):
if not os.path.isdir(CERTS_DIR):
raise unittest.SkipTest("certs directory not found")

config_log = os.path.join(".", "config.log")
if os.path.isfile(config_log):
with open(config_log, "r") as f:
if "disable-filesystem" in f.read():
raise unittest.SkipTest("filesystem support disabled")

# Skip if DSA not compiled in
r = run_wolfssl("dsaparam", "1024")
combined = r.stdout + r.stderr
Expand All @@ -37,6 +37,7 @@ def test_dsaparam_zero_fails(self):
r = run_wolfssl("dsaparam", "0")
self.assertNotEqual(r.returncode, 0)

@needs_filesystem
def test_dsaparam_out_and_in(self):
params_file = "dsa.params"
self.addCleanup(lambda: os.remove(params_file)
Expand All @@ -49,6 +50,7 @@ def test_dsaparam_out_and_in(self):
self.assertEqual(r.returncode, 0, r.stderr)
self.assertIn("-----BEGIN DSA PARAMETERS-----", r.stdout)

@needs_filesystem
def test_dsaparam_noout(self):
params_file = "dsa.params"
self.addCleanup(lambda: os.remove(params_file)
Expand All @@ -61,6 +63,7 @@ def test_dsaparam_noout(self):
self.assertEqual(r.returncode, 0, r.stderr)
self.assertNotIn("-----BEGIN DSA PARAMETERS-----", r.stdout)

@needs_filesystem
def test_dsaparam_genkey(self):
params_file = "dsa.params"
self.addCleanup(lambda: os.remove(params_file)
Expand All @@ -74,6 +77,7 @@ def test_dsaparam_genkey(self):
self.assertIn("-----BEGIN DSA PARAMETERS-----", r.stdout)
self.assertIn("-----BEGIN DSA PRIVATE KEY-----", r.stdout)

@needs_filesystem
def test_dsaparam_genkey_noout(self):
params_file = "dsa.params"
self.addCleanup(lambda: os.remove(params_file)
Expand All @@ -87,6 +91,7 @@ def test_dsaparam_genkey_noout(self):
self.assertNotIn("-----BEGIN DSA PARAMETERS-----", r.stdout)
self.assertIn("-----BEGIN DSA PRIVATE KEY-----", r.stdout)

@needs_filesystem
def test_bad_input_fails(self):
r = run_wolfssl("dsaparam", "-in",
os.path.join(CERTS_DIR, "server-cert.pem"),
Expand Down
Loading
Loading