diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/regress/usr.bin/openssl/appstest.sh | 148 |
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 | ||
| 26 | openssl_bin=${OPENSSL:-/usr/bin/openssl} | ||
| 27 | |||
| 28 | uname_s=`uname -s | grep 'MINGW'` | ||
| 29 | if [ "$uname_s" = "" ] ; then | ||
| 30 | mingw=0 | ||
| 31 | else | ||
| 32 | mingw=1 | ||
| 33 | fi | ||
| 34 | |||
| 35 | function section_message { | 26 | function 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 | ||
| 73 | no_long_tests=0 | ||
| 74 | |||
| 75 | while [ "$1" != "" ]; do | ||
| 76 | case $1 in | ||
| 77 | -q | --quick ) shift | ||
| 78 | no_long_tests=1 | ||
| 79 | ;; | ||
| 80 | * ) usage | ||
| 81 | exit 1 | ||
| 82 | esac | ||
| 83 | done | ||
| 84 | |||
| 85 | #---------#---------#---------#---------#---------#---------#---------#--------- | 64 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 86 | 65 | function test_usage_lists_others { | |
| 87 | # | ||
| 88 | # create ssldir, and all files generated by this script goes under this dir. | ||
| 89 | # | ||
| 90 | ssldir="appstest_dir" | ||
| 91 | |||
| 92 | if [ -d $ssldir ] ; then | ||
| 93 | echo "directory [ $ssldir ] exists, this script deletes this directory ..." | ||
| 94 | /bin/rm -rf $ssldir | ||
| 95 | fi | ||
| 96 | |||
| 97 | mkdir -p $ssldir | ||
| 98 | |||
| 99 | export OPENSSL_CONF=$ssldir/openssl.cnf | ||
| 100 | touch $OPENSSL_CONF | ||
| 101 | |||
| 102 | user1_dir=$ssldir/user1 | ||
| 103 | mkdir -p $user1_dir | ||
| 104 | |||
| 105 | key_dir=$ssldir/key | ||
| 106 | mkdir -p $key_dir | ||
| 107 | |||
| 108 | #---------#---------#---------#---------#---------#---------#---------#--------- | ||
| 109 | |||
| 110 | # === COMMAND USAGE === | 66 | # === COMMAND USAGE === |
| 111 | section_message "COMMAND USAGE" | 67 | section_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 |
| 194 | check_exit_status $? | 150 | check_exit_status $? |
| 151 | } | ||
| 195 | 152 | ||
| 196 | #---------#---------#---------#---------#---------#---------#---------#--------- | 153 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 197 | 154 | function test_md { | |
| 198 | # === MESSAGE DIGEST COMMANDS === | 155 | # === MESSAGE DIGEST COMMANDS === |
| 199 | section_message "MESSAGE DIGEST COMMANDS" | 156 | section_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 $? |
| 225 | done | 182 | done |
| 183 | } | ||
| 226 | 184 | ||
| 227 | #---------#---------#---------#---------#---------#---------#---------#--------- | 185 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 228 | 186 | function test_encoding_cipher { | |
| 229 | # === ENCODING AND CIPHER COMMANDS === | 187 | # === ENCODING AND CIPHER COMMANDS === |
| 230 | section_message "ENCODING AND CIPHER COMMANDS" | 188 | section_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 $? |
| 253 | done | 211 | done |
| 212 | } | ||
| 254 | 213 | ||
| 255 | #---------#---------#---------#---------#---------#---------#---------#--------- | 214 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 256 | 215 | function test_key { | |
| 257 | # === various KEY operations === | 216 | # === various KEY operations === |
| 258 | section_message "various KEY operations" | 217 | section_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 |
| 429 | check_exit_status $? | 388 | check_exit_status $? |
| 389 | } | ||
| 430 | 390 | ||
| 431 | #---------#---------#---------#---------#---------#---------#---------#--------- | 391 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 432 | 392 | function test_pki { | |
| 433 | section_message "setup local CA" | 393 | section_message "setup local CA" |
| 434 | 394 | ||
| 435 | # | 395 | # |
| 436 | # prepare test openssl.cnf | 396 | # prepare test openssl.cnf |
| 437 | # | 397 | # |
| 438 | 398 | ||
| 439 | ca_dir=$ssldir/testCA | ||
| 440 | tsa_dir=$ssldir/testTSA | ||
| 441 | ocsp_dir=$ssldir/testOCSP | ||
| 442 | server_dir=$ssldir/server | ||
| 443 | |||
| 444 | cat << __EOF__ > $ssldir/openssl.cnf | 399 | cat << __EOF__ > $ssldir/openssl.cnf |
| 445 | oid_section = new_oids | 400 | oid_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 |
| 795 | check_exit_status $? | 750 | check_exit_status $? |
| 751 | } | ||
| 796 | 752 | ||
| 797 | #---------#---------#---------#---------#---------#---------#---------#--------- | 753 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 798 | 754 | function test_tsa { | |
| 799 | # --- TSA operations --- | 755 | # --- TSA operations --- |
| 800 | section_message "TSA operations" | 756 | section_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 |
| 835 | check_exit_status $? | 791 | check_exit_status $? |
| 792 | } | ||
| 836 | 793 | ||
| 837 | #---------#---------#---------#---------#---------#---------#---------#--------- | 794 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 838 | 795 | function test_smime { | |
| 839 | # --- S/MIME operations --- | 796 | # --- S/MIME operations --- |
| 840 | section_message "S/MIME operations" | 797 | section_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 |
| 863 | check_exit_status $? | 820 | check_exit_status $? |
| 821 | } | ||
| 864 | 822 | ||
| 865 | #---------#---------#---------#---------#---------#---------#---------#--------- | 823 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 866 | 824 | function test_ocsp { | |
| 867 | # --- OCSP operations --- | 825 | # --- OCSP operations --- |
| 868 | section_message "OCSP operations" | 826 | section_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 |
| 904 | check_exit_status $? | 862 | check_exit_status $? |
| 863 | } | ||
| 905 | 864 | ||
| 906 | #---------#---------#---------#---------#---------#---------#---------#--------- | 865 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 907 | 866 | function test_pkcs { | |
| 908 | # --- PKCS operations --- | 867 | # --- PKCS operations --- |
| 909 | section_message "PKCS operations" | 868 | section_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 |
| 939 | check_exit_status $? | 898 | check_exit_status $? |
| 899 | } | ||
| 940 | 900 | ||
| 941 | #---------#---------#---------#---------#---------#---------#---------#--------- | 901 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 942 | 902 | function test_server_client { | |
| 943 | # --- client/server operations (TLS) --- | 903 | # --- client/server operations (TLS) --- |
| 944 | section_message "client/server operations (TLS)" | 904 | section_message "client/server operations (TLS)" |
| 945 | 905 | ||
| @@ -1083,9 +1043,10 @@ $openssl_bin sess_id -in $sess_dat -text -out $sess_dat.out | |||
| 1083 | check_exit_status $? | 1043 | check_exit_status $? |
| 1084 | 1044 | ||
| 1085 | stop_s_server | 1045 | stop_s_server |
| 1046 | } | ||
| 1086 | 1047 | ||
| 1087 | #---------#---------#---------#---------#---------#---------#---------#--------- | 1048 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 1088 | 1049 | function test_speed { | |
| 1089 | # === PERFORMANCE === | 1050 | # === PERFORMANCE === |
| 1090 | section_message "PERFORMANCE" | 1051 | section_message "PERFORMANCE" |
| 1091 | 1052 | ||
| @@ -1096,18 +1057,81 @@ if [ $no_long_tests = 0 ] ; then | |||
| 1096 | else | 1057 | else |
| 1097 | start_message "SKIPPNG speed (quick mode)" | 1058 | start_message "SKIPPNG speed (quick mode)" |
| 1098 | fi | 1059 | fi |
| 1060 | } | ||
| 1099 | 1061 | ||
| 1100 | #---------#---------#---------#---------#---------#---------#---------#--------- | 1062 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 1101 | 1063 | function test_version { | |
| 1102 | # --- VERSION INFORMATION --- | 1064 | # --- VERSION INFORMATION --- |
| 1103 | section_message "VERSION INFORMATION" | 1065 | section_message "VERSION INFORMATION" |
| 1104 | 1066 | ||
| 1105 | start_message "version" | 1067 | start_message "version" |
| 1106 | $openssl_bin version -a | 1068 | $openssl_bin version -a |
| 1107 | check_exit_status $? | 1069 | check_exit_status $? |
| 1070 | } | ||
| 1108 | 1071 | ||
| 1109 | #---------#---------#---------#---------#---------#---------#---------#--------- | 1072 | #---------#---------#---------#---------#---------#---------#---------#--------- |
| 1110 | 1073 | ||
| 1074 | openssl_bin=${OPENSSL:-/usr/bin/openssl} | ||
| 1075 | |||
| 1076 | no_long_tests=0 | ||
| 1077 | |||
| 1078 | while [ "$1" != "" ]; do | ||
| 1079 | case $1 in | ||
| 1080 | -q | --quick ) shift | ||
| 1081 | no_long_tests=1 | ||
| 1082 | ;; | ||
| 1083 | * ) usage | ||
| 1084 | exit 1 | ||
| 1085 | esac | ||
| 1086 | done | ||
| 1087 | |||
| 1088 | # | ||
| 1089 | # create ssldir, and all files generated by this script goes under this dir. | ||
| 1090 | # | ||
| 1091 | ssldir="appstest_dir" | ||
| 1092 | |||
| 1093 | if [ -d $ssldir ] ; then | ||
| 1094 | echo "directory [ $ssldir ] exists, this script deletes this directory ..." | ||
| 1095 | /bin/rm -rf $ssldir | ||
| 1096 | fi | ||
| 1097 | |||
| 1098 | mkdir -p $ssldir | ||
| 1099 | |||
| 1100 | ca_dir=$ssldir/testCA | ||
| 1101 | tsa_dir=$ssldir/testTSA | ||
| 1102 | ocsp_dir=$ssldir/testOCSP | ||
| 1103 | server_dir=$ssldir/server | ||
| 1104 | user1_dir=$ssldir/user1 | ||
| 1105 | mkdir -p $user1_dir | ||
| 1106 | key_dir=$ssldir/key | ||
| 1107 | mkdir -p $key_dir | ||
| 1108 | |||
| 1109 | export OPENSSL_CONF=$ssldir/openssl.cnf | ||
| 1110 | touch $OPENSSL_CONF | ||
| 1111 | |||
| 1112 | uname_s=`uname -s | grep 'MINGW'` | ||
| 1113 | if [ "$uname_s" = "" ] ; then | ||
| 1114 | mingw=0 | ||
| 1115 | else | ||
| 1116 | mingw=1 | ||
| 1117 | fi | ||
| 1118 | |||
| 1119 | # | ||
| 1120 | # process tests | ||
| 1121 | # | ||
| 1122 | test_usage_lists_others | ||
| 1123 | test_md | ||
| 1124 | test_encoding_cipher | ||
| 1125 | test_key | ||
| 1126 | test_pki | ||
| 1127 | test_tsa | ||
| 1128 | test_smime | ||
| 1129 | test_ocsp | ||
| 1130 | test_pkcs | ||
| 1131 | test_server_client | ||
| 1132 | test_speed | ||
| 1133 | test_version | ||
| 1134 | |||
| 1111 | section_message "END" | 1135 | section_message "END" |
| 1112 | 1136 | ||
| 1113 | exit 0 | 1137 | exit 0 |
