From a914ca74f20b9757a39c9fcb0b140d6f2cdb8f0d Mon Sep 17 00:00:00 2001 From: lchristina26 Date: Tue, 27 Oct 2015 21:24:21 -0600 Subject: [PATCH 1/6] updates for VxWorks --- IDE/WORKBENCH/README.md | 82 ++++++++++++++++++++++++++---------- wolfssl/wolfcrypt/settings.h | 4 ++ 2 files changed, 63 insertions(+), 23 deletions(-) diff --git a/IDE/WORKBENCH/README.md b/IDE/WORKBENCH/README.md index 486b90b04..9229e50a4 100644 --- a/IDE/WORKBENCH/README.md +++ b/IDE/WORKBENCH/README.md @@ -1,23 +1,54 @@ ## Wind River Workbench using VxWorks with wolfSSL ###SETUP: -####Steps (There are many ways to set this up, this is one example) -1. Open WorkBench and go to File > Import > Existing Projects Into Workspace -2. Make sure the correct path to wolfSSL header files(wolfssl/wolfssl) is -selected by right clicking the project and going to Properties > Build -Properties > Paths. If you need to change this to a different path, do so now. -3. Right click on the project and go to Import > Filesystem. Choose your path -to the wolfSSL library here. Uncheck everything except the src and wolfcrypt -directories. Only keep wolfcrypt/test/test.h, not test.c. Also uncheck test -and benchmark directories and aes\_asm.asm and aes\_asm.s files from wolfcrypt/src. -4. In wolfSSL/test.h, make sure certs are in the proper directory, or move. -5. The wolfcrypt source files, namely misc.c, may need to be moved directly under -a wolfcrypt folder within the project. It will be \/wolfcrypt/src/misc.c. -Alnternatively, add wolfssl to the include path, #include -\. -6. Make sure TFM\_X86 is undefined. +####Steps +1. Start by creating a new VxWorks image in Workbench by going to File > New > +Project and then select VxWorks Image Project. +2. Include the path to the wolfSSL header files(wolfssl/wolfssl): +Right click the project and go to Properties > Build Properties > Paths. + Choose Browse and select the wolfssl directory. Click ok. +3. Add preprocessor definitions: +Right click on project, go to Properties > Build Properties > Variables. +Highlight EXTRA\_DEFINE. Click Edit and add the following to this line: +-DWOLFSSL\_VXWORKS. +This can also be done in wolfssl/wolfcrypt/settings.h by uncommenting the + #define WOLFSSL_VXWORKS +line. +If there is not a filesystem set up, add -DUSE\_CERT\_BUFFERS\_2048 to the +variables or #define USE\_CERT\_BUFFERS\_2048 at the top of settings.h. +If there is a filesystem, paths may need to be changed to the path of +filesystem for certificate files. +4. Right click on the project and go to Import > Filesystem. Choose the path +to the wolfSSL library here. Uncheck everything except the src and wolfcrypt +directories. +In the wolfcrypt/src folder, uncheck aes\_asm.asm and aes\_asm.s. +5. If NO\_\_DEV\_RANDOM remains defined in wolfssl/wolfcrypt/settings.h under +\#ifdef WOLFSSL\_VXWORKS, a new GenerateSeed() function will need to be defined +in wolfcrypt/src/random.c. + +####Testing wolfSSL with VxWorks: +1. In usrAppInit.c, make a call to the wolfCrypt test application by adding +the following to the usrAppInit() function: + + typedef struct func_args { + int argc; + char** argv; + int return_code; + } func_args; + + func_args args; + + wolfcrypt_test(&args); +2. Include these header files in usrAppInit.c: + #include + #include + #include + #include +3. Start the simulator and check that all wolfCrypt tests pass. If there is a +certificate file error, adjust the caCert file locations in +wolfcrypt/test/test.c or wolfssl/test.h to those of the filesystem in use. ####Necessary Files -You will need the following files to replicate this build: +The following files are required to replicate this build: * vxsim\_linux\_1\_0\_2\_2 (directory) * Includes * compilers/gnu-4.8.1.5/include/c++/4.8 @@ -29,7 +60,7 @@ You will need the following files to replicate this build: * vsb\_vxsim\_linux/krnl/h/public * vsb\_vxsim\_linux/krnl/configlette * vsb\_vxsim\_linux/h -* usrAppInit.c (should be created when you create a new VxWorks image) +* usrAppInit.c (should be created when with new VxWorks image) * Include this at the top: #include #include @@ -47,20 +78,25 @@ You will need the following files to replicate this build: wolfcrypt\_test(NULL); /* client\_test(NULL); */ /*server\_test(&args);*/ -* usrRtpAppInit.c (should be created when you create a new VxWorks image) +* usrRtpAppInit.c (should be created when with new VxWorks image) Leave unchanged * This project was tested with a pre-built image in the VxWorks distribution -called vsb\_vxsim\_linux. \ $(VSB\_DIR) line in the .wpj file may need to be -changed according to the VxWorks package being used. +called vsb\_vxsim\_linux. ###VXWORKS SIMULATOR: +######The VxWorks simulator was used for testing the wolfSSL example +######applications (server, client, benchmark, and test). +######These are the steps to reproduce this testing method. + In "Open Connection Details" under VxWorks Simulator which is in the connections -dropdown. After the project has been build, choose the corresponding kernel image, typically called project/default/VxWorks. Select simnetd from the dropdown and enter 192.168.200.1 as the IP address. +dropdown. After the project has been build, choose the corresponding kernel +image, typically called project/default/VxWorks. Select simnetd from the +dropdown and enter 192.168.200.1 as the IP address. To connect to a server running on the VxWorks Simulator, enter these commands into the host terminal (for Ubuntu 14.04): sudo openvpn --mktun --dev tap0 In Wind River directory: vxworks-7/host/x86-linux2/bin/vxsimnetd -This will start the vxsimnetd application. Leave it open. The IP address to -connect to the server is the same as above. +This will start the vxsimnetd application. Leave it open. The IP address to +connect to the server is the same as above. diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 6d38dfc2e..8fd9d629f 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -305,6 +305,10 @@ #ifdef WOLFSSL_VXWORKS + #define WOLFSSL_HAVE_MIN + #define USE_FAST_MATH + #define TFM_TIMING_RESISTANT + #define NO_MAIN_DRIVER #define NO_DEV_RANDOM #define NO_WRITEV #endif From 723fc3761bf7dfed461527e366e50d2cecbecdfb Mon Sep 17 00:00:00 2001 From: lchristina26 Date: Thu, 29 Oct 2015 13:39:02 -0600 Subject: [PATCH 2/6] Example client/server compatible with VxWorks --- IDE/WORKBENCH/README.md | 65 ++++++++++++++++++++++++++++++++-------- examples/client/client.c | 2 ++ examples/server/server.c | 2 ++ 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/IDE/WORKBENCH/README.md b/IDE/WORKBENCH/README.md index 9229e50a4..919c84ba0 100644 --- a/IDE/WORKBENCH/README.md +++ b/IDE/WORKBENCH/README.md @@ -1,6 +1,6 @@ ## Wind River Workbench using VxWorks with wolfSSL -###SETUP: -####Steps +###1 SETUP: +####1.1 Steps 1. Start by creating a new VxWorks image in Workbench by going to File > New > Project and then select VxWorks Image Project. 2. Include the path to the wolfSSL header files(wolfssl/wolfssl): @@ -13,10 +13,11 @@ Highlight EXTRA\_DEFINE. Click Edit and add the following to this line: This can also be done in wolfssl/wolfcrypt/settings.h by uncommenting the #define WOLFSSL_VXWORKS line. -If there is not a filesystem set up, add -DUSE\_CERT\_BUFFERS\_2048 to the -variables or #define USE\_CERT\_BUFFERS\_2048 at the top of settings.h. +If there is not a filesystem set up, add -DUSE\_CERT\_BUFFERS\_2048 and +-DNO\_FILESYSTEM to the variables or #define USE\_CERT\_BUFFERS\_2048 and +\#define NO\_FILESYSTEM at the top of settings.h. If there is a filesystem, paths may need to be changed to the path of -filesystem for certificate files. +filesystem for certificate files in wolfssl/test.h. 4. Right click on the project and go to Import > Filesystem. Choose the path to the wolfSSL library here. Uncheck everything except the src and wolfcrypt directories. @@ -25,7 +26,11 @@ In the wolfcrypt/src folder, uncheck aes\_asm.asm and aes\_asm.s. \#ifdef WOLFSSL\_VXWORKS, a new GenerateSeed() function will need to be defined in wolfcrypt/src/random.c. -####Testing wolfSSL with VxWorks: +####1.2 Testing wolfSSL with VxWorks: +#####1.2.1 wolfCrypt Test Application +The wolfCrypt test application will test each of the cryptographic algorithms +and output the status for each. This should return success for each algorithm +if everything is working. 1. In usrAppInit.c, make a call to the wolfCrypt test application by adding the following to the usrAppInit() function: @@ -47,7 +52,41 @@ the following to the usrAppInit() function: certificate file error, adjust the caCert file locations in wolfcrypt/test/test.c or wolfssl/test.h to those of the filesystem in use. -####Necessary Files +#####1.2.2 Example Client +The wolfSSL example client can be found in wolfssl/examples/client. +1. Add client.c and client.h from the examples/client folder to the Workbench +project. +2. In usrAppInit.c, inlucde the func\_args as described in the Test Application +section, and add a call to the client function: + client_test(&args); +3. Add the client.h header file to the includes at the top of usrAppInit.c. +4. The wolfSSLIP will need to be changed to the IP address the server is +running on. If using the VxWorks Simulator, localhost will not work. NAT should +be selected in the Simulator Connection Advanced setup. +5. Start the example server from within the wolfSSL directory on the host +machine: + ./examples/server/server -d -b +The -d option disables peer checks, -b allows for binding to any interface. +6. Start the example client in Workbench. + +#####1.2.3 Example Server +The example server requires more configuration than the client if using the +VxWorks simulator. +1. Add server.c and server.h from the wolfssl/examples/server folder to the +Workbench project. +2. In usrAppInit.c, inlcude the func\args as described in the Test and Client +applications and add a call to the server function: + server_test(&args); +3. Add the server.h header file to the includes at the top of usrAppInit.c. +4. Start the server by following the directions in Section 2 for setting up +the VxWorks Simulator. +5. Start the client on the host machine: + ./examples/client/client -d +The -d option disables peer checks. +Note: If there are certificate file errors, the file paths in wolfssl/test.h +will need to be adjusted to follow the paths located on the filesystem used +by the VxWorks project. +####1.3 Necessary Files The following files are required to replicate this build: * vxsim\_linux\_1\_0\_2\_2 (directory) * Includes @@ -83,20 +122,20 @@ The following files are required to replicate this build: * This project was tested with a pre-built image in the VxWorks distribution called vsb\_vxsim\_linux. -###VXWORKS SIMULATOR: +###2 VXWORKS SIMULATOR: ######The VxWorks simulator was used for testing the wolfSSL example ######applications (server, client, benchmark, and test). ######These are the steps to reproduce this testing method. -In "Open Connection Details" under VxWorks Simulator which is in the connections -dropdown. After the project has been build, choose the corresponding kernel -image, typically called project/default/VxWorks. Select simnetd from the -dropdown and enter 192.168.200.1 as the IP address. +Go to "Open Connection Details" under VxWorks Simulator which is in the connections +dropdown. Choose the corresponding kernel image, typically called +project/default/VxWorks. Select simnetd from the dropdown and enter +192.168.200.1 as the IP address. To connect to a server running on the VxWorks Simulator, enter these commands into the host terminal (for Ubuntu 14.04): sudo openvpn --mktun --dev tap0 In Wind River directory: - vxworks-7/host/x86-linux2/bin/vxsimnetd + sudo vxworks-7/host/x86-linux2/bin/vxsimnetd This will start the vxsimnetd application. Leave it open. The IP address to connect to the server is the same as above. diff --git a/examples/client/client.c b/examples/client/client.c index dc4a80f0a..fc9e1ec56 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -464,6 +464,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args) StackTrap(); +#ifndef WOLFSSL_VXWORKS while ((ch = mygetopt(argc, argv, "?gdeDusmNrwRitfxXUPCh:p:v:l:A:c:k:Z:b:zS:L:ToO:aB:")) != -1) { @@ -697,6 +698,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args) } myoptind = 0; /* reset for test cases */ +#endif /* !WOLFSSL_VXWORKS */ if (externalTest) { /* detect build cases that wouldn't allow test against wolfssl.com */ diff --git a/examples/server/server.c b/examples/server/server.c index 455d9b2fa..c13c21d50 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -314,6 +314,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args) fdOpenSession(Task_self()); #endif +#ifndef WOLFSSL_VXWORKS while ((ch = mygetopt(argc, argv, "?dbstnNufrRawPIp:v:l:A:c:k:Z:S:oO:D:L:ieB:")) != -1) { switch (ch) { @@ -494,6 +495,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args) } myoptind = 0; /* reset for test cases */ +#endif /* !WOLFSSL_VXWORKS */ /* sort out DTLS versus TLS versions */ if (version == CLIENT_INVALID_VERSION) { From dd99948bcd2f2e78e88470c173fc0d0181635047 Mon Sep 17 00:00:00 2001 From: lchristina26 Date: Thu, 29 Oct 2015 13:41:17 -0600 Subject: [PATCH 3/6] Workbench readme update --- IDE/WORKBENCH/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/IDE/WORKBENCH/README.md b/IDE/WORKBENCH/README.md index 919c84ba0..a75f79799 100644 --- a/IDE/WORKBENCH/README.md +++ b/IDE/WORKBENCH/README.md @@ -123,8 +123,7 @@ The following files are required to replicate this build: called vsb\_vxsim\_linux. ###2 VXWORKS SIMULATOR: -######The VxWorks simulator was used for testing the wolfSSL example -######applications (server, client, benchmark, and test). +######The VxWorks simulator was used for testing the wolfSSL example applications (server, client, benchmark, and test). ######These are the steps to reproduce this testing method. Go to "Open Connection Details" under VxWorks Simulator which is in the connections From 4061346f779897b13f5c5352e5d9b948160fdeb9 Mon Sep 17 00:00:00 2001 From: lchristina26 Date: Thu, 29 Oct 2015 13:44:22 -0600 Subject: [PATCH 4/6] more readme updates --- IDE/WORKBENCH/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/IDE/WORKBENCH/README.md b/IDE/WORKBENCH/README.md index a75f79799..7158596ce 100644 --- a/IDE/WORKBENCH/README.md +++ b/IDE/WORKBENCH/README.md @@ -31,6 +31,7 @@ in wolfcrypt/src/random.c. The wolfCrypt test application will test each of the cryptographic algorithms and output the status for each. This should return success for each algorithm if everything is working. + 1. In usrAppInit.c, make a call to the wolfCrypt test application by adding the following to the usrAppInit() function: @@ -54,6 +55,7 @@ wolfcrypt/test/test.c or wolfssl/test.h to those of the filesystem in use. #####1.2.2 Example Client The wolfSSL example client can be found in wolfssl/examples/client. + 1. Add client.c and client.h from the examples/client folder to the Workbench project. 2. In usrAppInit.c, inlucde the func\_args as described in the Test Application @@ -72,10 +74,15 @@ The -d option disables peer checks, -b allows for binding to any interface. #####1.2.3 Example Server The example server requires more configuration than the client if using the VxWorks simulator. + 1. Add server.c and server.h from the wolfssl/examples/server folder to the Workbench project. 2. In usrAppInit.c, inlcude the func\args as described in the Test and Client applications and add a call to the server function: + func_args args = { 0 }; + tcp_ready ready; + InitTcpReady(&ready); + args.signal = &ready; server_test(&args); 3. Add the server.h header file to the includes at the top of usrAppInit.c. 4. Start the server by following the directions in Section 2 for setting up From 1a96ff6766120e855e1a867f76a0518b3f1489d0 Mon Sep 17 00:00:00 2001 From: lchristina26 Date: Thu, 29 Oct 2015 13:45:58 -0600 Subject: [PATCH 5/6] readme updates --- IDE/WORKBENCH/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/IDE/WORKBENCH/README.md b/IDE/WORKBENCH/README.md index 7158596ce..4d5c6c56a 100644 --- a/IDE/WORKBENCH/README.md +++ b/IDE/WORKBENCH/README.md @@ -35,20 +35,20 @@ if everything is working. 1. In usrAppInit.c, make a call to the wolfCrypt test application by adding the following to the usrAppInit() function: - typedef struct func_args { - int argc; - char** argv; - int return_code; - } func_args; + typedef struct func_args { + int argc; + char** argv; + int return_code; + } func_args; - func_args args; + func_args args; wolfcrypt_test(&args); 2. Include these header files in usrAppInit.c: - #include - #include - #include - #include + #include + #include + #include + #include 3. Start the simulator and check that all wolfCrypt tests pass. If there is a certificate file error, adjust the caCert file locations in wolfcrypt/test/test.c or wolfssl/test.h to those of the filesystem in use. From 5bcb7e98cbc987e4a692abe5d70b1ba917bb1f8d Mon Sep 17 00:00:00 2001 From: lchristina26 Date: Thu, 29 Oct 2015 13:47:40 -0600 Subject: [PATCH 6/6] readme updates --- IDE/WORKBENCH/README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/IDE/WORKBENCH/README.md b/IDE/WORKBENCH/README.md index 4d5c6c56a..3b4f9deea 100644 --- a/IDE/WORKBENCH/README.md +++ b/IDE/WORKBENCH/README.md @@ -79,11 +79,13 @@ VxWorks simulator. Workbench project. 2. In usrAppInit.c, inlcude the func\args as described in the Test and Client applications and add a call to the server function: - func_args args = { 0 }; - tcp_ready ready; - InitTcpReady(&ready); - args.signal = &ready; - server_test(&args); + + func_args args = { 0 }; + tcp_ready ready; + InitTcpReady(&ready); + args.signal = &ready; + server_test(&args); + 3. Add the server.h header file to the includes at the top of usrAppInit.c. 4. Start the server by following the directions in Section 2 for setting up the VxWorks Simulator. @@ -93,6 +95,7 @@ The -d option disables peer checks. Note: If there are certificate file errors, the file paths in wolfssl/test.h will need to be adjusted to follow the paths located on the filesystem used by the VxWorks project. + ####1.3 Necessary Files The following files are required to replicate this build: * vxsim\_linux\_1\_0\_2\_2 (directory)