aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkinichiro <kinichiro.inoguchi@gmail.com>2016-10-18 17:13:56 +0900
committerBrent Cook <bcook@openbsd.org>2016-10-30 21:40:24 -0500
commit14905877a0eb85ebdc16162e820cda51f0895fc7 (patch)
treec8999f2188004e581e49480496139c7a5a9f7076
parentb434123987dc08fd47bd988bd3fe09277445001d (diff)
downloadportable-14905877a0eb85ebdc16162e820cda51f0895fc7.tar.gz
portable-14905877a0eb85ebdc16162e820cda51f0895fc7.tar.bz2
portable-14905877a0eb85ebdc16162e820cda51f0895fc7.zip
Enable tests on Visual Studio
- add patch for aeadtest.c to undef IN - add patch for ocsp_test.c to call BIO_sock_init() before getaddrinfo() - define STDERR_FILENO in unistd.h to build pkcs7test.c - add option ENABLE_VSTEST(default OFF) to enable test on Visual Studio - modify to pass test data file as an argument (aeadtest, evptest) - add Windows scripts (ocsptest, pq_test, ssltest, testdsa, testenc, testrsa) - do not build pidwraptest on MSVC - fix some indentations
-rw-r--r--CMakeLists.txt3
-rw-r--r--include/compat/unistd.h2
-rw-r--r--patches/aeadtest.c.patch15
-rw-r--r--patches/ocsp_test.c.patch14
-rw-r--r--tests/CMakeLists.txt64
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/ocsptest.bat11
-rw-r--r--tests/pq_test.bat14
-rw-r--r--tests/ssltest.bat18
-rw-r--r--tests/testdsa.bat38
-rw-r--r--tests/testenc.bat69
-rw-r--r--tests/testrsa.bat38
-rw-r--r--tests/testssl.bat157
13 files changed, 429 insertions, 28 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd2ef7b..93f3ff6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,7 @@ string(REGEX REPLACE "\\..*" "" TLS_MAJOR_VERSION ${TLS_VERSION})
26option(ENABLE_ASM "Enable assembly" ON) 26option(ENABLE_ASM "Enable assembly" ON)
27option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF) 27option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF)
28option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF) 28option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF)
29option(ENABLE_VSTEST "Enable test on Visual Studio" OFF)
29set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE) 30set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE)
30 31
31set(BUILD_NC true) 32set(BUILD_NC true)
@@ -294,6 +295,8 @@ add_subdirectory(tls)
294add_subdirectory(include) 295add_subdirectory(include)
295if(NOT MSVC) 296if(NOT MSVC)
296 add_subdirectory(man) 297 add_subdirectory(man)
298endif()
299if(NOT MSVC OR ENABLE_VSTEST)
297 add_subdirectory(tests) 300 add_subdirectory(tests)
298endif() 301endif()
299 302
diff --git a/include/compat/unistd.h b/include/compat/unistd.h
index 6c83e76..52255bb 100644
--- a/include/compat/unistd.h
+++ b/include/compat/unistd.h
@@ -14,6 +14,8 @@
14#include <io.h> 14#include <io.h>
15#include <process.h> 15#include <process.h>
16 16
17#define STDERR_FILENO 2
18
17#define R_OK 4 19#define R_OK 4
18#define W_OK 2 20#define W_OK 2
19#define X_OK 0 21#define X_OK 0
diff --git a/patches/aeadtest.c.patch b/patches/aeadtest.c.patch
new file mode 100644
index 0000000..ce62107
--- /dev/null
+++ b/patches/aeadtest.c.patch
@@ -0,0 +1,15 @@
1--- tests/aeadtest.c.orig 2016-10-18 17:03:33.845870889 +0900
2+++ tests/aeadtest.c 2016-10-18 17:11:19.880841283 +0900
3@@ -75,6 +75,12 @@
4
5 #define BUF_MAX 1024
6
7+#ifdef _MSC_VER
8+#ifdef IN
9+#undef IN
10+#endif
11+#endif
12+
13 /* These are the different types of line that are found in the input file. */
14 enum {
15 AEAD = 0, /* name of the AEAD algorithm. */
diff --git a/patches/ocsp_test.c.patch b/patches/ocsp_test.c.patch
new file mode 100644
index 0000000..aa427db
--- /dev/null
+++ b/patches/ocsp_test.c.patch
@@ -0,0 +1,14 @@
1--- tests/ocsp_test.c.orig 2016-10-18 18:12:39.854607509 +0900
2+++ tests/ocsp_test.c 2016-10-18 18:14:29.261600559 +0900
3@@ -16,6 +16,11 @@
4 hints.ai_family = AF_INET;
5 hints.ai_socktype = SOCK_STREAM;
6
7+#ifdef _MSC_VER
8+ if (BIO_sock_init() != 1)
9+ exit(-1);
10+#endif
11+
12 error = getaddrinfo(host, port, &hints, &res);
13 if (error != 0) {
14 perror("getaddrinfo()");
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 80a248e..7957235 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -14,8 +14,7 @@ add_definitions(-D_PATH_SSL_CA_FILE=\"${CMAKE_CURRENT_SOURCE_DIR}/../apps/openss
14# aeadtest 14# aeadtest
15add_executable(aeadtest aeadtest.c) 15add_executable(aeadtest aeadtest.c)
16target_link_libraries(aeadtest ${OPENSSL_LIBS}) 16target_link_libraries(aeadtest ${OPENSSL_LIBS})
17add_test(aeadtest ${CMAKE_CURRENT_SOURCE_DIR}/aeadtest.sh) 17add_test(aeadtest aeadtest ${CMAKE_CURRENT_SOURCE_DIR}/aeadtests.txt)
18set_tests_properties(aeadtest PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
19 18
20# aes_wrap 19# aes_wrap
21add_executable(aes_wrap aes_wrap.c) 20add_executable(aes_wrap aes_wrap.c)
@@ -25,9 +24,9 @@ add_test(aes_wrap aes_wrap)
25# arc4randomforktest 24# arc4randomforktest
26# Windows/mingw does not have fork, but Cygwin does. 25# Windows/mingw does not have fork, but Cygwin does.
27if(NOT CMAKE_HOST_WIN32 AND NOT CMAKE_SYSTEM_NAME MATCHES "MINGW") 26if(NOT CMAKE_HOST_WIN32 AND NOT CMAKE_SYSTEM_NAME MATCHES "MINGW")
28add_executable(arc4randomforktest arc4randomforktest.c) 27 add_executable(arc4randomforktest arc4randomforktest.c)
29target_link_libraries(arc4randomforktest ${OPENSSL_LIBS}) 28 target_link_libraries(arc4randomforktest ${OPENSSL_LIBS})
30add_test(arc4randomforktest ${CMAKE_CURRENT_SOURCE_DIR}/arc4randomforktest.sh) 29 add_test(arc4randomforktest ${CMAKE_CURRENT_SOURCE_DIR}/arc4randomforktest.sh)
31endif() 30endif()
32 31
33# asn1test 32# asn1test
@@ -136,19 +135,18 @@ add_test(enginetest enginetest)
136# evptest 135# evptest
137add_executable(evptest evptest.c) 136add_executable(evptest evptest.c)
138target_link_libraries(evptest ${OPENSSL_LIBS}) 137target_link_libraries(evptest ${OPENSSL_LIBS})
139add_test(evptest ${CMAKE_CURRENT_SOURCE_DIR}/evptest.sh) 138add_test(evptest evptest ${CMAKE_CURRENT_SOURCE_DIR}/evptests.txt)
140set_tests_properties(evptest PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
141 139
142# explicit_bzero 140# explicit_bzero
143# explicit_bzero relies on SA_ONSTACK, which is unavailable on Windows 141# explicit_bzero relies on SA_ONSTACK, which is unavailable on Windows
144if(NOT CMAKE_HOST_WIN32) 142if(NOT CMAKE_HOST_WIN32)
145if(HAVE_MEMMEM) 143 if(HAVE_MEMMEM)
146 add_executable(explicit_bzero explicit_bzero.c) 144 add_executable(explicit_bzero explicit_bzero.c)
147else() 145 else()
148 add_executable(explicit_bzero explicit_bzero.c memmem.c) 146 add_executable(explicit_bzero explicit_bzero.c memmem.c)
149endif() 147 endif()
150target_link_libraries(explicit_bzero ${OPENSSL_LIBS}) 148 target_link_libraries(explicit_bzero ${OPENSSL_LIBS})
151add_test(explicit_bzero explicit_bzero) 149 add_test(explicit_bzero explicit_bzero)
152endif() 150endif()
153 151
154# exptest 152# exptest
@@ -200,7 +198,11 @@ add_test(mont mont)
200if(ENABLE_EXTRATESTS) 198if(ENABLE_EXTRATESTS)
201 add_executable(ocsp_test ocsp_test.c) 199 add_executable(ocsp_test ocsp_test.c)
202 target_link_libraries(ocsp_test ${OPENSSL_LIBS}) 200 target_link_libraries(ocsp_test ${OPENSSL_LIBS})
203 add_test(ocsptest ${CMAKE_CURRENT_SOURCE_DIR}/ocsptest.sh) 201 if(NOT MSVC)
202 add_test(ocsptest ${CMAKE_CURRENT_SOURCE_DIR}/ocsptest.sh)
203 else()
204 add_test(ocsptest ${CMAKE_CURRENT_SOURCE_DIR}/ocsptest.bat)
205 endif()
204endif() 206endif()
205 207
206# optionstest 208# optionstest
@@ -216,7 +218,7 @@ add_test(pbkdf2 pbkdf2)
216# pidwraptest 218# pidwraptest
217# pidwraptest relies on an OS-specific way to give out pids and is generally 219# pidwraptest relies on an OS-specific way to give out pids and is generally
218# awkward on systems with slow fork 220# awkward on systems with slow fork
219if(ENABLE_EXTRATESTS) 221if(ENABLE_EXTRATESTS AND NOT MSVC)
220 add_executable(pidwraptest pidwraptest.c) 222 add_executable(pidwraptest pidwraptest.c)
221 target_link_libraries(pidwraptest ${OPENSSL_LIBS}) 223 target_link_libraries(pidwraptest ${OPENSSL_LIBS})
222 add_test(pidwraptest ${CMAKE_CURRENT_SOURCE_DIR}/pidwraptest.sh) 224 add_test(pidwraptest ${CMAKE_CURRENT_SOURCE_DIR}/pidwraptest.sh)
@@ -235,7 +237,11 @@ add_test(poly1305test poly1305test)
235# pq_test 237# pq_test
236add_executable(pq_test pq_test.c) 238add_executable(pq_test pq_test.c)
237target_link_libraries(pq_test ${OPENSSL_LIBS}) 239target_link_libraries(pq_test ${OPENSSL_LIBS})
238add_test(pq_test ${CMAKE_CURRENT_SOURCE_DIR}/pq_test.sh) 240if(NOT MSVC)
241 add_test(pq_test ${CMAKE_CURRENT_SOURCE_DIR}/pq_test.sh)
242else()
243 add_test(pq_test ${CMAKE_CURRENT_SOURCE_DIR}/pq_test.bat)
244endif()
239set_tests_properties(pq_test PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") 245set_tests_properties(pq_test PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
240 246
241# randtest 247# randtest
@@ -285,19 +291,35 @@ add_test(sha512test sha512test)
285# ssltest 291# ssltest
286add_executable(ssltest ssltest.c) 292add_executable(ssltest ssltest.c)
287target_link_libraries(ssltest ${OPENSSL_LIBS}) 293target_link_libraries(ssltest ${OPENSSL_LIBS})
288add_test(ssltest ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.sh) 294if(NOT MSVC)
295 add_test(ssltest ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.sh)
296else()
297 add_test(ssltest ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.bat)
298endif()
289set_tests_properties(ssltest PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") 299set_tests_properties(ssltest PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
290 300
291# testdsa 301# testdsa
292add_test(testdsa ${CMAKE_CURRENT_SOURCE_DIR}/testdsa.sh) 302if(NOT MSVC)
303 add_test(testdsa ${CMAKE_CURRENT_SOURCE_DIR}/testdsa.sh)
304else()
305 add_test(testdsa ${CMAKE_CURRENT_SOURCE_DIR}/testdsa.bat)
306endif()
293set_tests_properties(testdsa PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") 307set_tests_properties(testdsa PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
294 308
295# testenc 309# testenc
296add_test(testenc ${CMAKE_CURRENT_SOURCE_DIR}/testenc.sh) 310if(NOT MSVC)
311 add_test(testenc ${CMAKE_CURRENT_SOURCE_DIR}/testenc.sh)
312else()
313 add_test(testenc ${CMAKE_CURRENT_SOURCE_DIR}/testenc.bat)
314endif()
297set_tests_properties(testenc PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") 315set_tests_properties(testenc PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
298 316
299# testrsa 317# testrsa
300add_test(testrsa ${CMAKE_CURRENT_SOURCE_DIR}/testrsa.sh) 318if(NOT MSVC)
319 add_test(testrsa ${CMAKE_CURRENT_SOURCE_DIR}/testrsa.sh)
320else()
321 add_test(testrsa ${CMAKE_CURRENT_SOURCE_DIR}/testrsa.bat)
322endif()
301set_tests_properties(testrsa PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") 323set_tests_properties(testrsa PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
302 324
303# timingsafe 325# timingsafe
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5ba7b60..85720c2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -215,7 +215,7 @@ TESTS += ocsptest.sh
215check_PROGRAMS += ocsp_test 215check_PROGRAMS += ocsp_test
216ocsp_test_SOURCES = ocsp_test.c 216ocsp_test_SOURCES = ocsp_test.c
217endif 217endif
218EXTRA_DIST += ocsptest.sh 218EXTRA_DIST += ocsptest.sh ocsptest.bat
219 219
220# optionstest 220# optionstest
221TESTS += optionstest 221TESTS += optionstest
@@ -251,7 +251,7 @@ poly1305test_SOURCES = poly1305test.c
251TESTS += pq_test.sh 251TESTS += pq_test.sh
252check_PROGRAMS += pq_test 252check_PROGRAMS += pq_test
253pq_test_SOURCES = pq_test.c 253pq_test_SOURCES = pq_test.c
254EXTRA_DIST += pq_test.sh 254EXTRA_DIST += pq_test.sh pq_test.bat
255EXTRA_DIST += pq_expected.txt 255EXTRA_DIST += pq_expected.txt
256 256
257# randtest 257# randtest
@@ -303,21 +303,21 @@ sha512test_SOURCES = sha512test.c
303TESTS += ssltest.sh 303TESTS += ssltest.sh
304check_PROGRAMS += ssltest 304check_PROGRAMS += ssltest
305ssltest_SOURCES = ssltest.c 305ssltest_SOURCES = ssltest.c
306EXTRA_DIST += ssltest.sh 306EXTRA_DIST += ssltest.sh ssltest.bat
307EXTRA_DIST += testssl ca.pem server.pem 307EXTRA_DIST += testssl testssl.bat ca.pem server.pem
308 308
309# testdsa 309# testdsa
310TESTS += testdsa.sh 310TESTS += testdsa.sh
311EXTRA_DIST += testdsa.sh 311EXTRA_DIST += testdsa.sh testdsa.bat
312EXTRA_DIST += openssl.cnf 312EXTRA_DIST += openssl.cnf
313 313
314# testenc 314# testenc
315TESTS += testenc.sh 315TESTS += testenc.sh
316EXTRA_DIST += testenc.sh 316EXTRA_DIST += testenc.sh testenc.bat
317 317
318# testrsa 318# testrsa
319TESTS += testrsa.sh 319TESTS += testrsa.sh
320EXTRA_DIST += testrsa.sh 320EXTRA_DIST += testrsa.sh testrsa.bat
321 321
322# timingsafe 322# timingsafe
323TESTS += timingsafe 323TESTS += timingsafe
diff --git a/tests/ocsptest.bat b/tests/ocsptest.bat
new file mode 100644
index 0000000..fa0ae42
--- /dev/null
+++ b/tests/ocsptest.bat
@@ -0,0 +1,11 @@
1@echo off
2setlocal enabledelayedexpansion
3REM ocsptest.bat
4
5set TEST=Debug\ocsp_test.exe
6if not exist %TEST% exit /b 1
7
8%TEST% www.amazon.com 443 & if !errorlevel! neq 0 exit /b 1
9%TEST% cloudflare.com 443 & if !errorlevel! neq 0 exit /b 1
10
11endlocal
diff --git a/tests/pq_test.bat b/tests/pq_test.bat
new file mode 100644
index 0000000..b665874
--- /dev/null
+++ b/tests/pq_test.bat
@@ -0,0 +1,14 @@
1@echo off
2setlocal enabledelayedexpansion
3REM pq_test.bat
4
5set TEST=Debug\pq_test.exe
6if not exist %TEST% exit /b 1
7
8set pq_output=pq_output.txt
9if exist %pq_output% del %pq_output%
10
11%TEST% > %pq_output%
12fc /b %pq_output% %srcdir%\pq_expected.txt
13
14endlocal
diff --git a/tests/ssltest.bat b/tests/ssltest.bat
new file mode 100644
index 0000000..a7c3df5
--- /dev/null
+++ b/tests/ssltest.bat
@@ -0,0 +1,18 @@
1@echo off
2setlocal enabledelayedexpansion
3REM ssltest.bat
4
5set ssltest_bin=Debug\ssltest.exe
6if not exist %ssltest_bin% exit /b 1
7
8set openssl_bin=..\apps\openssl\Debug\openssl.exe
9if not exist %openssl_bin% exit /b 1
10
11if "%srcdir%"=="" (
12 set srcdir=.
13)
14
15%srcdir%\testssl.bat %srcdir%\server.pem %srcdir%\server.pem %srcdir%\ca.pem ^
16 %ssltest_bin% %openssl_bin%
17
18endlocal
diff --git a/tests/testdsa.bat b/tests/testdsa.bat
new file mode 100644
index 0000000..9a9690e
--- /dev/null
+++ b/tests/testdsa.bat
@@ -0,0 +1,38 @@
1@echo off
2setlocal enabledelayedexpansion
3REM testdsa.bat
4
5
6REM # Test DSA certificate generation of openssl
7
8set cmd=..\apps\openssl\Debug\openssl.exe
9if not exist %cmd% exit /b 1
10
11if "%srcdir%"=="" (
12 set srcdir=.
13)
14
15REM # Generate DSA paramter set
16%cmd% dsaparam 512 -out dsa512.pem
17if !errorlevel! neq 0 (
18 exit /b 1
19)
20
21
22REM # Generate a DSA certificate
23%cmd% req -config %srcdir%\openssl.cnf -x509 -newkey dsa:dsa512.pem -out testdsa.pem -keyout testdsa.key
24if !errorlevel! neq 0 (
25 exit /b 1
26)
27
28
29REM # Now check the certificate
30%cmd% x509 -text -in testdsa.pem
31if !errorlevel! neq 0 (
32 exit /b 1
33)
34
35del testdsa.key dsa512.pem testdsa.pem
36
37exit /b 0
38endlocal
diff --git a/tests/testenc.bat b/tests/testenc.bat
new file mode 100644
index 0000000..a925ec3
--- /dev/null
+++ b/tests/testenc.bat
@@ -0,0 +1,69 @@
1@echo off
2setlocal enabledelayedexpansion
3REM testenc.bat
4
5set test=p
6set cmd=..\apps\openssl\Debug\openssl.exe
7if not exist %cmd% exit /b 1
8
9set srcdir=..\..\tests
10
11copy %srcdir%\openssl.cnf %test%
12
13echo cat
14%cmd% enc -in %test% -out %test%.cipher
15%cmd% enc -in %test%.cipher -out %test%.clear
16fc /b %test% %test%.clear
17if !errorlevel! neq 0 (
18 exit /b 1
19) else (
20 del %test%.cipher %test%.clear
21)
22
23echo base64
24%cmd% enc -a -e -in %test% -out %test%.cipher
25%cmd% enc -a -d -in %test%.cipher -out %test%.clear
26fc /b %test% %test%.clear
27if !errorlevel! neq 0 (
28 exit /b 1
29) else (
30 del %test%.cipher %test%.clear
31)
32
33for %%i in (
34 aes-128-cbc aes-128-cfb aes-128-cfb1 aes-128-cfb8
35 aes-128-ecb aes-128-ofb aes-192-cbc aes-192-cfb
36 aes-192-cfb1 aes-192-cfb8 aes-192-ecb aes-192-ofb
37 aes-256-cbc aes-256-cfb aes-256-cfb1 aes-256-cfb8
38 aes-256-ecb aes-256-ofb
39 bf-cbc bf-cfb bf-ecb bf-ofb
40 cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb
41 des-cbc des-cfb des-cfb8 des-ecb des-ede
42 des-ede-cbc des-ede-cfb des-ede-ofb des-ede3
43 des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb desx-cbc
44 rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb
45 rc4 rc4-40
46) do (
47 echo %%i
48 %cmd% %%i -e -k test -in %test% -out %test%.%%i.cipher
49 %cmd% %%i -d -k test -in %test%.%%i.cipher -out %test%.%%i.clear
50 fc /b %test% %test%.%%i.clear
51 if !errorlevel! neq 0 (
52 exit /b 1
53 ) else (
54 del %test%.%%i.cipher %test%.%%i.clear
55 )
56
57 echo %%i base64
58 %cmd% %%i -a -e -k test -in %test% -out %test%.%%i.cipher
59 %cmd% %%i -a -d -k test -in %test%.%%i.cipher -out %test%.%%i.clear
60 fc /b %test% %test%.%%i.clear
61 if !errorlevel! neq 0 (
62 exit /b 1
63 ) else (
64 del %test%.%%i.cipher %test%.%%i.clear
65 )
66)
67
68del %test%
69endlocal
diff --git a/tests/testrsa.bat b/tests/testrsa.bat
new file mode 100644
index 0000000..6d88d21
--- /dev/null
+++ b/tests/testrsa.bat
@@ -0,0 +1,38 @@
1@echo off
2setlocal enabledelayedexpansion
3REM testrsa.bat
4
5
6REM # Test RSA certificate generation of openssl
7
8set cmd=..\apps\openssl\Debug\openssl.exe
9if not exist %cmd% exit /b 1
10
11if "%srcdir%"=="" (
12 set srcdir=.
13)
14
15REM # Generate RSA private key
16%cmd% genrsa -out rsakey.pem
17if !errorlevel! neq 0 (
18 exit /b 1
19)
20
21
22REM # Generate an RSA certificate
23%cmd% req -config %srcdir%\openssl.cnf -key rsakey.pem -new -x509 -days 365 -out rsacert.pem
24if !errorlevel! neq 0 (
25 exit /b 1
26)
27
28
29REM # Now check the certificate
30%cmd% x509 -text -in rsacert.pem
31if !errorlevel! neq 0 (
32 exit /b 1
33)
34
35del rsacert.pem rsakey.pem
36
37exit /b 0
38endlocal
diff --git a/tests/testssl.bat b/tests/testssl.bat
new file mode 100644
index 0000000..f164aeb
--- /dev/null
+++ b/tests/testssl.bat
@@ -0,0 +1,157 @@
1@echo off
2setlocal enabledelayedexpansion
3REM testssl.bat
4
5set key=%1
6set cert=%2
7set CA=-CAfile %3
8set ssltest=%4 -key %key% -cert %cert% -c_key %key% -c_cert %cert%
9set openssl=%5
10set extra=%6
11
12%openssl% version & if !errorlevel! neq 0 exit /b 1
13
14for /f "usebackq" %%s in (`%openssl% x509 -in %cert% -text -noout ^| find /c "DSA Public Key"`) do set lines=%%s
15if %lines% gtr 0 (
16 set dsa_cert=YES
17) else (
18 set dsa_cert=NO
19)
20
21REM #########################################################################
22
23echo test sslv2/sslv3
24%ssltest% %extra% & if !errorlevel! neq 0 exit /b 1
25
26echo test sslv2/sslv3 with server authentication
27%ssltest% -server_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
28
29echo test sslv2/sslv3 with client authentication
30%ssltest% -client_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
31
32echo test sslv2/sslv3 with both client and server authentication
33%ssltest% -server_auth -client_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
34
35echo test sslv2/sslv3 via BIO pair
36%ssltest% %extra% & if !errorlevel! neq 0 exit /b 1
37
38if %dsa_cert%==NO (
39 echo "test sslv2/sslv3 w/o (EC)DHE via BIO pair"
40 %ssltest% -bio_pair -no_dhe -no_ecdhe %extra% & if !errorlevel! neq 0 exit /b 1
41)
42
43echo test sslv2/sslv3 with 1024bit DHE via BIO pair
44%ssltest% -bio_pair -dhe1024dsa -v %extra% & if !errorlevel! neq 0 exit /b 1
45
46echo test sslv2/sslv3 with server authentication
47%ssltest% -bio_pair -server_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
48
49echo test sslv2/sslv3 with client authentication via BIO pair
50%ssltest% -bio_pair -client_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
51
52echo test sslv2/sslv3 with both client and server authentication via BIO pair
53%ssltest% -bio_pair -server_auth -client_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
54
55echo test sslv2/sslv3 with both client and server authentication via BIO pair and app verify
56%ssltest% -bio_pair -server_auth -client_auth -app_verify %CA% %extra% & if !errorlevel! neq 0 exit /b 1
57
58echo "Testing ciphersuites"
59for %%p in ( TLSv1.2 ) do (
60 echo "Testing ciphersuites for %%p"
61 for /f "usebackq" %%c in (`%openssl% ciphers -v "%%p+aRSA"`) do (
62 echo "Testing %%c"
63 %ssltest% -cipher %%c
64 if !errorlevel! neq 0 (
65 echo "Failed %%c"
66 exit /b 1
67 )
68 )
69)
70
71REM ##########################################################################
72
73for /f "usebackq" %%s in (`%openssl% no-dh`) do set nodh=%%s
74if %nodh%==no-dh (
75 echo skipping anonymous DH tests
76) else (
77 echo test tls1 with 1024bit anonymous DH, multiple handshakes
78 %ssltest% -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time %extra% & if !errorlevel! neq 0 exit /b 1
79)
80
81REM #for /f "usebackq" %%s in (`%openssl% no-rsa`) do set norsa=%%s
82REM #if %norsa%==no-rsa (
83REM # echo skipping RSA tests
84REM #) else (
85REM # echo "test tls1 with 1024bit RSA, no (EC)DHE, multiple handshakes"
86REM # %ssltest% -v -bio_pair -tls1 -cert ..\apps\server2.pem -no_dhe -no_ecdhe -num 10 -f -time %extra% & if !errorlevel! neq 0 exit /b 1
87REM #
88REM # for /f "usebackq" %%s in (`%openssl% no-dh`) do set nodh=%%s
89REM # if %nodh%==no-dh (
90REM # echo skipping RSA+DHE tests
91REM # ) else (
92REM # echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes
93REM # %ssltest% -v -bio_pair -tls1 -cert ..\apps\server2.pem -dhe1024dsa -num 10 -f -time %extra% & if !errorlevel! neq 0 exit /b 1
94REM # )
95REM #)
96
97REM #
98REM # DTLS tests
99REM #
100
101echo test dtlsv1
102%ssltest% -dtls1 %extra% & if !errorlevel! neq 0 exit /b 1
103
104echo test dtlsv1 with server authentication
105%ssltest% -dtls1 -server_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
106
107echo test dtlsv1 with client authentication
108%ssltest% -dtls1 -client_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
109
110echo test dtlsv1 with both client and server authentication
111%ssltest% -dtls1 -server_auth -client_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1
112
113echo "Testing DTLS ciphersuites"
114for %%p in ( SSLv3 ) do (
115 echo "Testing ciphersuites for %%p"
116 for /f "usebackq" %%c in (`%openssl% ciphers -v "RSA+%%p:-RC4"`) do (
117 echo "Testing %%c"
118 %ssltest% -cipher %%c -dtls1
119 if !errorlevel! neq 0 (
120 echo "Failed %%c"
121 exit /b 1
122 )
123 )
124)
125
126REM #
127REM # Next Protocol Negotiation tests
128REM #
129echo "Testing NPN..."
130%ssltest% -bio_pair -tls1 -npn_client & if !errorlevel! neq 0 exit /b 1
131%ssltest% -bio_pair -tls1 -npn_server & if !errorlevel! neq 0 exit /b 1
132%ssltest% -bio_pair -tls1 -npn_server_reject & if !errorlevel! neq 0 exit /b 1
133%ssltest% -bio_pair -tls1 -npn_client -npn_server_reject & if !errorlevel! neq 0 exit /b 1
134%ssltest% -bio_pair -tls1 -npn_client -npn_server & if !errorlevel! neq 0 exit /b 1
135%ssltest% -bio_pair -tls1 -npn_client -npn_server -num 2 & if !errorlevel! neq 0 exit /b 1
136%ssltest% -bio_pair -tls1 -npn_client -npn_server -num 2 -reuse & if !errorlevel! neq 0 exit /b 1
137
138REM #
139REM # ALPN tests
140REM #
141echo "Testing ALPN..."
142%ssltest% -bio_pair -tls1 -alpn_client foo -alpn_server bar & if !errorlevel! neq 0 exit /b 1
143%ssltest% -bio_pair -tls1 -alpn_client foo -alpn_server foo ^
144 -alpn_expected foo & if !errorlevel! neq 0 exit /b 1
145%ssltest% -bio_pair -tls1 -alpn_client foo,bar -alpn_server foo ^
146 -alpn_expected foo & if !errorlevel! neq 0 exit /b 1
147%ssltest% -bio_pair -tls1 -alpn_client bar,foo -alpn_server foo ^
148 -alpn_expected foo & if !errorlevel! neq 0 exit /b 1
149%ssltest% -bio_pair -tls1 -alpn_client bar,foo -alpn_server foo,bar ^
150 -alpn_expected foo & if !errorlevel! neq 0 exit /b 1
151%ssltest% -bio_pair -tls1 -alpn_client bar,foo -alpn_server bar,foo ^
152 -alpn_expected bar & if !errorlevel! neq 0 exit /b 1
153%ssltest% -bio_pair -tls1 -alpn_client foo,bar -alpn_server bar,foo ^
154 -alpn_expected bar & if !errorlevel! neq 0 exit /b 1
155%ssltest% -bio_pair -tls1 -alpn_client baz -alpn_server bar,foo & if !errorlevel! neq 0 exit /b 1
156
157endlocal