diff options
author | kinichiro <kinichiro.inoguchi@gmail.com> | 2016-10-18 17:13:56 +0900 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2016-10-30 21:40:24 -0500 |
commit | 14905877a0eb85ebdc16162e820cda51f0895fc7 (patch) | |
tree | c8999f2188004e581e49480496139c7a5a9f7076 | |
parent | b434123987dc08fd47bd988bd3fe09277445001d (diff) | |
download | portable-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.txt | 3 | ||||
-rw-r--r-- | include/compat/unistd.h | 2 | ||||
-rw-r--r-- | patches/aeadtest.c.patch | 15 | ||||
-rw-r--r-- | patches/ocsp_test.c.patch | 14 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 64 | ||||
-rw-r--r-- | tests/Makefile.am | 14 | ||||
-rw-r--r-- | tests/ocsptest.bat | 11 | ||||
-rw-r--r-- | tests/pq_test.bat | 14 | ||||
-rw-r--r-- | tests/ssltest.bat | 18 | ||||
-rw-r--r-- | tests/testdsa.bat | 38 | ||||
-rw-r--r-- | tests/testenc.bat | 69 | ||||
-rw-r--r-- | tests/testrsa.bat | 38 | ||||
-rw-r--r-- | tests/testssl.bat | 157 |
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}) | |||
26 | option(ENABLE_ASM "Enable assembly" ON) | 26 | option(ENABLE_ASM "Enable assembly" ON) |
27 | option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF) | 27 | option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF) |
28 | option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF) | 28 | option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF) |
29 | option(ENABLE_VSTEST "Enable test on Visual Studio" OFF) | ||
29 | set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE) | 30 | set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE) |
30 | 31 | ||
31 | set(BUILD_NC true) | 32 | set(BUILD_NC true) |
@@ -294,6 +295,8 @@ add_subdirectory(tls) | |||
294 | add_subdirectory(include) | 295 | add_subdirectory(include) |
295 | if(NOT MSVC) | 296 | if(NOT MSVC) |
296 | add_subdirectory(man) | 297 | add_subdirectory(man) |
298 | endif() | ||
299 | if(NOT MSVC OR ENABLE_VSTEST) | ||
297 | add_subdirectory(tests) | 300 | add_subdirectory(tests) |
298 | endif() | 301 | endif() |
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 |
15 | add_executable(aeadtest aeadtest.c) | 15 | add_executable(aeadtest aeadtest.c) |
16 | target_link_libraries(aeadtest ${OPENSSL_LIBS}) | 16 | target_link_libraries(aeadtest ${OPENSSL_LIBS}) |
17 | add_test(aeadtest ${CMAKE_CURRENT_SOURCE_DIR}/aeadtest.sh) | 17 | add_test(aeadtest aeadtest ${CMAKE_CURRENT_SOURCE_DIR}/aeadtests.txt) |
18 | set_tests_properties(aeadtest PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") | ||
19 | 18 | ||
20 | # aes_wrap | 19 | # aes_wrap |
21 | add_executable(aes_wrap aes_wrap.c) | 20 | add_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. |
27 | if(NOT CMAKE_HOST_WIN32 AND NOT CMAKE_SYSTEM_NAME MATCHES "MINGW") | 26 | if(NOT CMAKE_HOST_WIN32 AND NOT CMAKE_SYSTEM_NAME MATCHES "MINGW") |
28 | add_executable(arc4randomforktest arc4randomforktest.c) | 27 | add_executable(arc4randomforktest arc4randomforktest.c) |
29 | target_link_libraries(arc4randomforktest ${OPENSSL_LIBS}) | 28 | target_link_libraries(arc4randomforktest ${OPENSSL_LIBS}) |
30 | add_test(arc4randomforktest ${CMAKE_CURRENT_SOURCE_DIR}/arc4randomforktest.sh) | 29 | add_test(arc4randomforktest ${CMAKE_CURRENT_SOURCE_DIR}/arc4randomforktest.sh) |
31 | endif() | 30 | endif() |
32 | 31 | ||
33 | # asn1test | 32 | # asn1test |
@@ -136,19 +135,18 @@ add_test(enginetest enginetest) | |||
136 | # evptest | 135 | # evptest |
137 | add_executable(evptest evptest.c) | 136 | add_executable(evptest evptest.c) |
138 | target_link_libraries(evptest ${OPENSSL_LIBS}) | 137 | target_link_libraries(evptest ${OPENSSL_LIBS}) |
139 | add_test(evptest ${CMAKE_CURRENT_SOURCE_DIR}/evptest.sh) | 138 | add_test(evptest evptest ${CMAKE_CURRENT_SOURCE_DIR}/evptests.txt) |
140 | set_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 |
144 | if(NOT CMAKE_HOST_WIN32) | 142 | if(NOT CMAKE_HOST_WIN32) |
145 | if(HAVE_MEMMEM) | 143 | if(HAVE_MEMMEM) |
146 | add_executable(explicit_bzero explicit_bzero.c) | 144 | add_executable(explicit_bzero explicit_bzero.c) |
147 | else() | 145 | else() |
148 | add_executable(explicit_bzero explicit_bzero.c memmem.c) | 146 | add_executable(explicit_bzero explicit_bzero.c memmem.c) |
149 | endif() | 147 | endif() |
150 | target_link_libraries(explicit_bzero ${OPENSSL_LIBS}) | 148 | target_link_libraries(explicit_bzero ${OPENSSL_LIBS}) |
151 | add_test(explicit_bzero explicit_bzero) | 149 | add_test(explicit_bzero explicit_bzero) |
152 | endif() | 150 | endif() |
153 | 151 | ||
154 | # exptest | 152 | # exptest |
@@ -200,7 +198,11 @@ add_test(mont mont) | |||
200 | if(ENABLE_EXTRATESTS) | 198 | if(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() | ||
204 | endif() | 206 | endif() |
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 |
219 | if(ENABLE_EXTRATESTS) | 221 | if(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 |
236 | add_executable(pq_test pq_test.c) | 238 | add_executable(pq_test pq_test.c) |
237 | target_link_libraries(pq_test ${OPENSSL_LIBS}) | 239 | target_link_libraries(pq_test ${OPENSSL_LIBS}) |
238 | add_test(pq_test ${CMAKE_CURRENT_SOURCE_DIR}/pq_test.sh) | 240 | if(NOT MSVC) |
241 | add_test(pq_test ${CMAKE_CURRENT_SOURCE_DIR}/pq_test.sh) | ||
242 | else() | ||
243 | add_test(pq_test ${CMAKE_CURRENT_SOURCE_DIR}/pq_test.bat) | ||
244 | endif() | ||
239 | set_tests_properties(pq_test PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") | 245 | set_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 |
286 | add_executable(ssltest ssltest.c) | 292 | add_executable(ssltest ssltest.c) |
287 | target_link_libraries(ssltest ${OPENSSL_LIBS}) | 293 | target_link_libraries(ssltest ${OPENSSL_LIBS}) |
288 | add_test(ssltest ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.sh) | 294 | if(NOT MSVC) |
295 | add_test(ssltest ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.sh) | ||
296 | else() | ||
297 | add_test(ssltest ${CMAKE_CURRENT_SOURCE_DIR}/ssltest.bat) | ||
298 | endif() | ||
289 | set_tests_properties(ssltest PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") | 299 | set_tests_properties(ssltest PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") |
290 | 300 | ||
291 | # testdsa | 301 | # testdsa |
292 | add_test(testdsa ${CMAKE_CURRENT_SOURCE_DIR}/testdsa.sh) | 302 | if(NOT MSVC) |
303 | add_test(testdsa ${CMAKE_CURRENT_SOURCE_DIR}/testdsa.sh) | ||
304 | else() | ||
305 | add_test(testdsa ${CMAKE_CURRENT_SOURCE_DIR}/testdsa.bat) | ||
306 | endif() | ||
293 | set_tests_properties(testdsa PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") | 307 | set_tests_properties(testdsa PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") |
294 | 308 | ||
295 | # testenc | 309 | # testenc |
296 | add_test(testenc ${CMAKE_CURRENT_SOURCE_DIR}/testenc.sh) | 310 | if(NOT MSVC) |
311 | add_test(testenc ${CMAKE_CURRENT_SOURCE_DIR}/testenc.sh) | ||
312 | else() | ||
313 | add_test(testenc ${CMAKE_CURRENT_SOURCE_DIR}/testenc.bat) | ||
314 | endif() | ||
297 | set_tests_properties(testenc PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") | 315 | set_tests_properties(testenc PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") |
298 | 316 | ||
299 | # testrsa | 317 | # testrsa |
300 | add_test(testrsa ${CMAKE_CURRENT_SOURCE_DIR}/testrsa.sh) | 318 | if(NOT MSVC) |
319 | add_test(testrsa ${CMAKE_CURRENT_SOURCE_DIR}/testrsa.sh) | ||
320 | else() | ||
321 | add_test(testrsa ${CMAKE_CURRENT_SOURCE_DIR}/testrsa.bat) | ||
322 | endif() | ||
301 | set_tests_properties(testrsa PROPERTIES ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") | 323 | set_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 | |||
215 | check_PROGRAMS += ocsp_test | 215 | check_PROGRAMS += ocsp_test |
216 | ocsp_test_SOURCES = ocsp_test.c | 216 | ocsp_test_SOURCES = ocsp_test.c |
217 | endif | 217 | endif |
218 | EXTRA_DIST += ocsptest.sh | 218 | EXTRA_DIST += ocsptest.sh ocsptest.bat |
219 | 219 | ||
220 | # optionstest | 220 | # optionstest |
221 | TESTS += optionstest | 221 | TESTS += optionstest |
@@ -251,7 +251,7 @@ poly1305test_SOURCES = poly1305test.c | |||
251 | TESTS += pq_test.sh | 251 | TESTS += pq_test.sh |
252 | check_PROGRAMS += pq_test | 252 | check_PROGRAMS += pq_test |
253 | pq_test_SOURCES = pq_test.c | 253 | pq_test_SOURCES = pq_test.c |
254 | EXTRA_DIST += pq_test.sh | 254 | EXTRA_DIST += pq_test.sh pq_test.bat |
255 | EXTRA_DIST += pq_expected.txt | 255 | EXTRA_DIST += pq_expected.txt |
256 | 256 | ||
257 | # randtest | 257 | # randtest |
@@ -303,21 +303,21 @@ sha512test_SOURCES = sha512test.c | |||
303 | TESTS += ssltest.sh | 303 | TESTS += ssltest.sh |
304 | check_PROGRAMS += ssltest | 304 | check_PROGRAMS += ssltest |
305 | ssltest_SOURCES = ssltest.c | 305 | ssltest_SOURCES = ssltest.c |
306 | EXTRA_DIST += ssltest.sh | 306 | EXTRA_DIST += ssltest.sh ssltest.bat |
307 | EXTRA_DIST += testssl ca.pem server.pem | 307 | EXTRA_DIST += testssl testssl.bat ca.pem server.pem |
308 | 308 | ||
309 | # testdsa | 309 | # testdsa |
310 | TESTS += testdsa.sh | 310 | TESTS += testdsa.sh |
311 | EXTRA_DIST += testdsa.sh | 311 | EXTRA_DIST += testdsa.sh testdsa.bat |
312 | EXTRA_DIST += openssl.cnf | 312 | EXTRA_DIST += openssl.cnf |
313 | 313 | ||
314 | # testenc | 314 | # testenc |
315 | TESTS += testenc.sh | 315 | TESTS += testenc.sh |
316 | EXTRA_DIST += testenc.sh | 316 | EXTRA_DIST += testenc.sh testenc.bat |
317 | 317 | ||
318 | # testrsa | 318 | # testrsa |
319 | TESTS += testrsa.sh | 319 | TESTS += testrsa.sh |
320 | EXTRA_DIST += testrsa.sh | 320 | EXTRA_DIST += testrsa.sh testrsa.bat |
321 | 321 | ||
322 | # timingsafe | 322 | # timingsafe |
323 | TESTS += timingsafe | 323 | TESTS += 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 | ||
2 | setlocal enabledelayedexpansion | ||
3 | REM ocsptest.bat | ||
4 | |||
5 | set TEST=Debug\ocsp_test.exe | ||
6 | if 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 | |||
11 | endlocal | ||
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 | ||
2 | setlocal enabledelayedexpansion | ||
3 | REM pq_test.bat | ||
4 | |||
5 | set TEST=Debug\pq_test.exe | ||
6 | if not exist %TEST% exit /b 1 | ||
7 | |||
8 | set pq_output=pq_output.txt | ||
9 | if exist %pq_output% del %pq_output% | ||
10 | |||
11 | %TEST% > %pq_output% | ||
12 | fc /b %pq_output% %srcdir%\pq_expected.txt | ||
13 | |||
14 | endlocal | ||
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 | ||
2 | setlocal enabledelayedexpansion | ||
3 | REM ssltest.bat | ||
4 | |||
5 | set ssltest_bin=Debug\ssltest.exe | ||
6 | if not exist %ssltest_bin% exit /b 1 | ||
7 | |||
8 | set openssl_bin=..\apps\openssl\Debug\openssl.exe | ||
9 | if not exist %openssl_bin% exit /b 1 | ||
10 | |||
11 | if "%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 | |||
18 | endlocal | ||
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 | ||
2 | setlocal enabledelayedexpansion | ||
3 | REM testdsa.bat | ||
4 | |||
5 | |||
6 | REM # Test DSA certificate generation of openssl | ||
7 | |||
8 | set cmd=..\apps\openssl\Debug\openssl.exe | ||
9 | if not exist %cmd% exit /b 1 | ||
10 | |||
11 | if "%srcdir%"=="" ( | ||
12 | set srcdir=. | ||
13 | ) | ||
14 | |||
15 | REM # Generate DSA paramter set | ||
16 | %cmd% dsaparam 512 -out dsa512.pem | ||
17 | if !errorlevel! neq 0 ( | ||
18 | exit /b 1 | ||
19 | ) | ||
20 | |||
21 | |||
22 | REM # Generate a DSA certificate | ||
23 | %cmd% req -config %srcdir%\openssl.cnf -x509 -newkey dsa:dsa512.pem -out testdsa.pem -keyout testdsa.key | ||
24 | if !errorlevel! neq 0 ( | ||
25 | exit /b 1 | ||
26 | ) | ||
27 | |||
28 | |||
29 | REM # Now check the certificate | ||
30 | %cmd% x509 -text -in testdsa.pem | ||
31 | if !errorlevel! neq 0 ( | ||
32 | exit /b 1 | ||
33 | ) | ||
34 | |||
35 | del testdsa.key dsa512.pem testdsa.pem | ||
36 | |||
37 | exit /b 0 | ||
38 | endlocal | ||
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 | ||
2 | setlocal enabledelayedexpansion | ||
3 | REM testenc.bat | ||
4 | |||
5 | set test=p | ||
6 | set cmd=..\apps\openssl\Debug\openssl.exe | ||
7 | if not exist %cmd% exit /b 1 | ||
8 | |||
9 | set srcdir=..\..\tests | ||
10 | |||
11 | copy %srcdir%\openssl.cnf %test% | ||
12 | |||
13 | echo cat | ||
14 | %cmd% enc -in %test% -out %test%.cipher | ||
15 | %cmd% enc -in %test%.cipher -out %test%.clear | ||
16 | fc /b %test% %test%.clear | ||
17 | if !errorlevel! neq 0 ( | ||
18 | exit /b 1 | ||
19 | ) else ( | ||
20 | del %test%.cipher %test%.clear | ||
21 | ) | ||
22 | |||
23 | echo base64 | ||
24 | %cmd% enc -a -e -in %test% -out %test%.cipher | ||
25 | %cmd% enc -a -d -in %test%.cipher -out %test%.clear | ||
26 | fc /b %test% %test%.clear | ||
27 | if !errorlevel! neq 0 ( | ||
28 | exit /b 1 | ||
29 | ) else ( | ||
30 | del %test%.cipher %test%.clear | ||
31 | ) | ||
32 | |||
33 | for %%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 | |||
68 | del %test% | ||
69 | endlocal | ||
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 | ||
2 | setlocal enabledelayedexpansion | ||
3 | REM testrsa.bat | ||
4 | |||
5 | |||
6 | REM # Test RSA certificate generation of openssl | ||
7 | |||
8 | set cmd=..\apps\openssl\Debug\openssl.exe | ||
9 | if not exist %cmd% exit /b 1 | ||
10 | |||
11 | if "%srcdir%"=="" ( | ||
12 | set srcdir=. | ||
13 | ) | ||
14 | |||
15 | REM # Generate RSA private key | ||
16 | %cmd% genrsa -out rsakey.pem | ||
17 | if !errorlevel! neq 0 ( | ||
18 | exit /b 1 | ||
19 | ) | ||
20 | |||
21 | |||
22 | REM # Generate an RSA certificate | ||
23 | %cmd% req -config %srcdir%\openssl.cnf -key rsakey.pem -new -x509 -days 365 -out rsacert.pem | ||
24 | if !errorlevel! neq 0 ( | ||
25 | exit /b 1 | ||
26 | ) | ||
27 | |||
28 | |||
29 | REM # Now check the certificate | ||
30 | %cmd% x509 -text -in rsacert.pem | ||
31 | if !errorlevel! neq 0 ( | ||
32 | exit /b 1 | ||
33 | ) | ||
34 | |||
35 | del rsacert.pem rsakey.pem | ||
36 | |||
37 | exit /b 0 | ||
38 | endlocal | ||
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 | ||
2 | setlocal enabledelayedexpansion | ||
3 | REM testssl.bat | ||
4 | |||
5 | set key=%1 | ||
6 | set cert=%2 | ||
7 | set CA=-CAfile %3 | ||
8 | set ssltest=%4 -key %key% -cert %cert% -c_key %key% -c_cert %cert% | ||
9 | set openssl=%5 | ||
10 | set extra=%6 | ||
11 | |||
12 | %openssl% version & if !errorlevel! neq 0 exit /b 1 | ||
13 | |||
14 | for /f "usebackq" %%s in (`%openssl% x509 -in %cert% -text -noout ^| find /c "DSA Public Key"`) do set lines=%%s | ||
15 | if %lines% gtr 0 ( | ||
16 | set dsa_cert=YES | ||
17 | ) else ( | ||
18 | set dsa_cert=NO | ||
19 | ) | ||
20 | |||
21 | REM ######################################################################### | ||
22 | |||
23 | echo test sslv2/sslv3 | ||
24 | %ssltest% %extra% & if !errorlevel! neq 0 exit /b 1 | ||
25 | |||
26 | echo test sslv2/sslv3 with server authentication | ||
27 | %ssltest% -server_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1 | ||
28 | |||
29 | echo test sslv2/sslv3 with client authentication | ||
30 | %ssltest% -client_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1 | ||
31 | |||
32 | echo 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 | |||
35 | echo test sslv2/sslv3 via BIO pair | ||
36 | %ssltest% %extra% & if !errorlevel! neq 0 exit /b 1 | ||
37 | |||
38 | if %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 | |||
43 | echo test sslv2/sslv3 with 1024bit DHE via BIO pair | ||
44 | %ssltest% -bio_pair -dhe1024dsa -v %extra% & if !errorlevel! neq 0 exit /b 1 | ||
45 | |||
46 | echo test sslv2/sslv3 with server authentication | ||
47 | %ssltest% -bio_pair -server_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1 | ||
48 | |||
49 | echo 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 | |||
52 | echo 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 | |||
55 | echo 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 | |||
58 | echo "Testing ciphersuites" | ||
59 | for %%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 | |||
71 | REM ########################################################################## | ||
72 | |||
73 | for /f "usebackq" %%s in (`%openssl% no-dh`) do set nodh=%%s | ||
74 | if %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 | |||
81 | REM #for /f "usebackq" %%s in (`%openssl% no-rsa`) do set norsa=%%s | ||
82 | REM #if %norsa%==no-rsa ( | ||
83 | REM # echo skipping RSA tests | ||
84 | REM #) else ( | ||
85 | REM # echo "test tls1 with 1024bit RSA, no (EC)DHE, multiple handshakes" | ||
86 | REM # %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 | ||
87 | REM # | ||
88 | REM # for /f "usebackq" %%s in (`%openssl% no-dh`) do set nodh=%%s | ||
89 | REM # if %nodh%==no-dh ( | ||
90 | REM # echo skipping RSA+DHE tests | ||
91 | REM # ) else ( | ||
92 | REM # echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes | ||
93 | REM # %ssltest% -v -bio_pair -tls1 -cert ..\apps\server2.pem -dhe1024dsa -num 10 -f -time %extra% & if !errorlevel! neq 0 exit /b 1 | ||
94 | REM # ) | ||
95 | REM #) | ||
96 | |||
97 | REM # | ||
98 | REM # DTLS tests | ||
99 | REM # | ||
100 | |||
101 | echo test dtlsv1 | ||
102 | %ssltest% -dtls1 %extra% & if !errorlevel! neq 0 exit /b 1 | ||
103 | |||
104 | echo test dtlsv1 with server authentication | ||
105 | %ssltest% -dtls1 -server_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1 | ||
106 | |||
107 | echo test dtlsv1 with client authentication | ||
108 | %ssltest% -dtls1 -client_auth %CA% %extra% & if !errorlevel! neq 0 exit /b 1 | ||
109 | |||
110 | echo 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 | |||
113 | echo "Testing DTLS ciphersuites" | ||
114 | for %%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 | |||
126 | REM # | ||
127 | REM # Next Protocol Negotiation tests | ||
128 | REM # | ||
129 | echo "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 | |||
138 | REM # | ||
139 | REM # ALPN tests | ||
140 | REM # | ||
141 | echo "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 | |||
157 | endlocal | ||