summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/regress/usr.bin/openssl/appstest.sh148
1 files changed, 86 insertions, 62 deletions
diff --git a/src/regress/usr.bin/openssl/appstest.sh b/src/regress/usr.bin/openssl/appstest.sh
index 744153412b..f2666011c3 100755
--- a/src/regress/usr.bin/openssl/appstest.sh
+++ b/src/regress/usr.bin/openssl/appstest.sh
@@ -1,6 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $OpenBSD: appstest.sh,v 1.11 2018/09/08 03:39:51 inoguchi Exp $ 3# $OpenBSD: appstest.sh,v 1.12 2018/09/08 09:34:12 inoguchi Exp $
4# 4#
5# Copyright (c) 2016 Kinichiro Inoguchi <inoguchi@openbsd.org> 5# Copyright (c) 2016 Kinichiro Inoguchi <inoguchi@openbsd.org>
6# 6#
@@ -23,15 +23,6 @@
23# output : all files generated by this script go under $ssldir 23# output : all files generated by this script go under $ssldir
24# 24#
25 25
26openssl_bin=${OPENSSL:-/usr/bin/openssl}
27
28uname_s=`uname -s | grep 'MINGW'`
29if [ "$uname_s" = "" ] ; then
30 mingw=0
31else
32 mingw=1
33fi
34
35function section_message { 26function section_message {
36 echo "" 27 echo ""
37 echo "#---------#---------#---------#---------#---------#---------#---------#--------" 28 echo "#---------#---------#---------#---------#---------#---------#---------#--------"
@@ -70,43 +61,8 @@ function usage {
70 echo "usage: appstest.sh [-q]" 61 echo "usage: appstest.sh [-q]"
71} 62}
72 63
73no_long_tests=0
74
75while [ "$1" != "" ]; do
76 case $1 in
77 -q | --quick ) shift
78 no_long_tests=1
79 ;;
80 * ) usage
81 exit 1
82 esac
83done
84
85#---------#---------#---------#---------#---------#---------#---------#--------- 64#---------#---------#---------#---------#---------#---------#---------#---------
86 65function test_usage_lists_others {
87#
88# create ssldir, and all files generated by this script goes under this dir.
89#
90ssldir="appstest_dir"
91
92if [ -d $ssldir ] ; then
93 echo "directory [ $ssldir ] exists, this script deletes this directory ..."
94 /bin/rm -rf $ssldir
95fi
96
97mkdir -p $ssldir
98
99export OPENSSL_CONF=$ssldir/openssl.cnf
100touch $OPENSSL_CONF
101
102user1_dir=$ssldir/user1
103mkdir -p $user1_dir
104
105key_dir=$ssldir/key
106mkdir -p $key_dir
107
108#---------#---------#---------#---------#---------#---------#---------#---------
109
110# === COMMAND USAGE === 66# === COMMAND USAGE ===
111section_message "COMMAND USAGE" 67section_message "COMMAND USAGE"
112 68
@@ -192,9 +148,10 @@ check_exit_status $?
192 148
193$openssl_bin rand -hex 100 149$openssl_bin rand -hex 100
194check_exit_status $? 150check_exit_status $?
151}
195 152
196#---------#---------#---------#---------#---------#---------#---------#--------- 153#---------#---------#---------#---------#---------#---------#---------#---------
197 154function test_md {
198# === MESSAGE DIGEST COMMANDS === 155# === MESSAGE DIGEST COMMANDS ===
199section_message "MESSAGE DIGEST COMMANDS" 156section_message "MESSAGE DIGEST COMMANDS"
200 157
@@ -223,9 +180,10 @@ for d in $digests ; do
223 -out $dgstdat.$d.cmac $dgstdat 180 -out $dgstdat.$d.cmac $dgstdat
224 check_exit_status $? 181 check_exit_status $?
225done 182done
183}
226 184
227#---------#---------#---------#---------#---------#---------#---------#--------- 185#---------#---------#---------#---------#---------#---------#---------#---------
228 186function test_encoding_cipher {
229# === ENCODING AND CIPHER COMMANDS === 187# === ENCODING AND CIPHER COMMANDS ===
230section_message "ENCODING AND CIPHER COMMANDS" 188section_message "ENCODING AND CIPHER COMMANDS"
231 189
@@ -251,9 +209,10 @@ for c in $ciphers ; do
251 cmp $encfile $encfile-$c.dec 209 cmp $encfile $encfile-$c.dec
252 check_exit_status $? 210 check_exit_status $?
253done 211done
212}
254 213
255#---------#---------#---------#---------#---------#---------#---------#--------- 214#---------#---------#---------#---------#---------#---------#---------#---------
256 215function test_key {
257# === various KEY operations === 216# === various KEY operations ===
258section_message "various KEY operations" 217section_message "various KEY operations"
259 218
@@ -427,20 +386,16 @@ check_exit_status $?
427 386
428$openssl_bin pkeyutl -verifyrecover -in $pkeyutlsig -inkey $genpkey_rsa 387$openssl_bin pkeyutl -verifyrecover -in $pkeyutlsig -inkey $genpkey_rsa
429check_exit_status $? 388check_exit_status $?
389}
430 390
431#---------#---------#---------#---------#---------#---------#---------#--------- 391#---------#---------#---------#---------#---------#---------#---------#---------
432 392function test_pki {
433section_message "setup local CA" 393section_message "setup local CA"
434 394
435# 395#
436# prepare test openssl.cnf 396# prepare test openssl.cnf
437# 397#
438 398
439ca_dir=$ssldir/testCA
440tsa_dir=$ssldir/testTSA
441ocsp_dir=$ssldir/testOCSP
442server_dir=$ssldir/server
443
444cat << __EOF__ > $ssldir/openssl.cnf 399cat << __EOF__ > $ssldir/openssl.cnf
445oid_section = new_oids 400oid_section = new_oids
446[ new_oids ] 401[ new_oids ]
@@ -793,9 +748,10 @@ user1_cert=$user1_dir/user1_cert.pem
793$openssl_bin ca -batch -cert $ca_cert -keyfile $ca_key -key $ca_pass \ 748$openssl_bin ca -batch -cert $ca_cert -keyfile $ca_key -key $ca_pass \
794 -in $user1_csr -out $user1_cert 749 -in $user1_csr -out $user1_cert
795check_exit_status $? 750check_exit_status $?
751}
796 752
797#---------#---------#---------#---------#---------#---------#---------#--------- 753#---------#---------#---------#---------#---------#---------#---------#---------
798 754function test_tsa {
799# --- TSA operations --- 755# --- TSA operations ---
800section_message "TSA operations" 756section_message "TSA operations"
801 757
@@ -833,9 +789,10 @@ start_message "ts ... verify time stamp response"
833 789
834$openssl_bin ts -verify -queryfile $tsa_tsq -in $tsa_tsr -CAfile $ca_cert -untrusted $tsa_cert 790$openssl_bin ts -verify -queryfile $tsa_tsq -in $tsa_tsr -CAfile $ca_cert -untrusted $tsa_cert
835check_exit_status $? 791check_exit_status $?
792}
836 793
837#---------#---------#---------#---------#---------#---------#---------#--------- 794#---------#---------#---------#---------#---------#---------#---------#---------
838 795function test_smime {
839# --- S/MIME operations --- 796# --- S/MIME operations ---
840section_message "S/MIME operations" 797section_message "S/MIME operations"
841 798
@@ -861,9 +818,10 @@ start_message "smime ... verify message"
861 818
862$openssl_bin smime -verify -in $smime_msg -signer $user1_cert -CAfile $ca_cert -out $smime_ver 819$openssl_bin smime -verify -in $smime_msg -signer $user1_cert -CAfile $ca_cert -out $smime_ver
863check_exit_status $? 820check_exit_status $?
821}
864 822
865#---------#---------#---------#---------#---------#---------#---------#--------- 823#---------#---------#---------#---------#---------#---------#---------#---------
866 824function test_ocsp {
867# --- OCSP operations --- 825# --- OCSP operations ---
868section_message "OCSP operations" 826section_message "OCSP operations"
869 827
@@ -902,9 +860,10 @@ ocsp_qry=$user1_dir/ocsp_qry.der
902$openssl_bin ocsp -issuer $ca_cert -cert $server_cert -cert $revoke_cert \ 860$openssl_bin ocsp -issuer $ca_cert -cert $server_cert -cert $revoke_cert \
903 -CAfile $ca_cert -url http://localhost:$ocsp_port -resp_text -respout $ocsp_qry > $ocsp_qry.out 2>&1 861 -CAfile $ca_cert -url http://localhost:$ocsp_port -resp_text -respout $ocsp_qry > $ocsp_qry.out 2>&1
904check_exit_status $? 862check_exit_status $?
863}
905 864
906#---------#---------#---------#---------#---------#---------#---------#--------- 865#---------#---------#---------#---------#---------#---------#---------#---------
907 866function test_pkcs {
908# --- PKCS operations --- 867# --- PKCS operations ---
909section_message "PKCS operations" 868section_message "PKCS operations"
910 869
@@ -937,9 +896,10 @@ start_message "pkcs12 ... to PEM"
937$openssl_bin pkcs12 -in $server_cert.p12 -passin pass:$pkcs_pass \ 896$openssl_bin pkcs12 -in $server_cert.p12 -passin pass:$pkcs_pass \
938 -passout pass:$pkcs_pass -out $server_cert.p12.pem 897 -passout pass:$pkcs_pass -out $server_cert.p12.pem
939check_exit_status $? 898check_exit_status $?
899}
940 900
941#---------#---------#---------#---------#---------#---------#---------#--------- 901#---------#---------#---------#---------#---------#---------#---------#---------
942 902function test_server_client {
943# --- client/server operations (TLS) --- 903# --- client/server operations (TLS) ---
944section_message "client/server operations (TLS)" 904section_message "client/server operations (TLS)"
945 905
@@ -1083,9 +1043,10 @@ $openssl_bin sess_id -in $sess_dat -text -out $sess_dat.out
1083check_exit_status $? 1043check_exit_status $?
1084 1044
1085stop_s_server 1045stop_s_server
1046}
1086 1047
1087#---------#---------#---------#---------#---------#---------#---------#--------- 1048#---------#---------#---------#---------#---------#---------#---------#---------
1088 1049function test_speed {
1089# === PERFORMANCE === 1050# === PERFORMANCE ===
1090section_message "PERFORMANCE" 1051section_message "PERFORMANCE"
1091 1052
@@ -1096,18 +1057,81 @@ if [ $no_long_tests = 0 ] ; then
1096else 1057else
1097 start_message "SKIPPNG speed (quick mode)" 1058 start_message "SKIPPNG speed (quick mode)"
1098fi 1059fi
1060}
1099 1061
1100#---------#---------#---------#---------#---------#---------#---------#--------- 1062#---------#---------#---------#---------#---------#---------#---------#---------
1101 1063function test_version {
1102# --- VERSION INFORMATION --- 1064# --- VERSION INFORMATION ---
1103section_message "VERSION INFORMATION" 1065section_message "VERSION INFORMATION"
1104 1066
1105start_message "version" 1067start_message "version"
1106$openssl_bin version -a 1068$openssl_bin version -a
1107check_exit_status $? 1069check_exit_status $?
1070}
1108 1071
1109#---------#---------#---------#---------#---------#---------#---------#--------- 1072#---------#---------#---------#---------#---------#---------#---------#---------
1110 1073
1074openssl_bin=${OPENSSL:-/usr/bin/openssl}
1075
1076no_long_tests=0
1077
1078while [ "$1" != "" ]; do
1079 case $1 in
1080 -q | --quick ) shift
1081 no_long_tests=1
1082 ;;
1083 * ) usage
1084 exit 1
1085 esac
1086done
1087
1088#
1089# create ssldir, and all files generated by this script goes under this dir.
1090#
1091ssldir="appstest_dir"
1092
1093if [ -d $ssldir ] ; then
1094 echo "directory [ $ssldir ] exists, this script deletes this directory ..."
1095 /bin/rm -rf $ssldir
1096fi
1097
1098mkdir -p $ssldir
1099
1100ca_dir=$ssldir/testCA
1101tsa_dir=$ssldir/testTSA
1102ocsp_dir=$ssldir/testOCSP
1103server_dir=$ssldir/server
1104user1_dir=$ssldir/user1
1105mkdir -p $user1_dir
1106key_dir=$ssldir/key
1107mkdir -p $key_dir
1108
1109export OPENSSL_CONF=$ssldir/openssl.cnf
1110touch $OPENSSL_CONF
1111
1112uname_s=`uname -s | grep 'MINGW'`
1113if [ "$uname_s" = "" ] ; then
1114 mingw=0
1115else
1116 mingw=1
1117fi
1118
1119#
1120# process tests
1121#
1122test_usage_lists_others
1123test_md
1124test_encoding_cipher
1125test_key
1126test_pki
1127test_tsa
1128test_smime
1129test_ocsp
1130test_pkcs
1131test_server_client
1132test_speed
1133test_version
1134
1111section_message "END" 1135section_message "END"
1112 1136
1113exit 0 1137exit 0