Extend ciphersuite test coverage.
[openssl.git] / test / testssl
index 81b8a9303885bada97d060663a699ae2c52d2617..d41a4bdf63df6f59872ccfc607fd8de4a69be56e 100644 (file)
@@ -10,7 +10,7 @@ if [ "$2" = "" ]; then
 else
   cert="$2"
 fi
-ssltest="../util/shlib_wrap.sh ./ssltest -key $key -cert $cert -c_key $key -c_cert $cert"
+ssltest="../util/shlib_wrap.sh ./ssltest -s_key $key -s_cert $cert -c_key $key -c_cert $cert"
 
 if ../util/shlib_wrap.sh ../apps/openssl x509 -in $cert -text -noout | fgrep 'DSA Public Key' >/dev/null; then
   dsa_cert=YES
@@ -124,7 +124,8 @@ test_cipher() {
     if [ $2 = "SSLv3" ] ; then
       prot="-ssl3"
     fi
-    $ssltest -cipher $_cipher $prot
+    _exarg=$3
+    $ssltest $_exarg -cipher $_cipher $prot
     if [ $? -ne 0 ] ; then
          echo "Failed $_cipher"
          exit 1
@@ -132,17 +133,31 @@ test_cipher() {
 }
 
 echo "Testing ciphersuites"
+exkeys=""
+ciphers="-EXP:-PSK:-SRP:-kDH:-kECDHe"
+if ../util/shlib_wrap.sh ../apps/openssl no-dhparam >/dev/null; then
+  echo "skipping DHE tests"
+  ciphers="$ciphers:-kDHE"
+fi
+if ../util/shlib_wrap.sh ../apps/openssl no-dsa >/dev/null; then
+  echo "skipping DSA tests"
+  ciphers="$ciphers:-aDSA"
+else
+  exkeys="$exkeys -s_cert certD.ss -s_key keyD.ss"
+fi
+
+if ../util/shlib_wrap.sh ../apps/openssl no-ec >/dev/null; then
+  echo "skipping EC tests"
+  ciphers="$ciphers:!aECDSA:!kECDH"
+else
+  exkeys="$exkeys -s_cert certE.ss -s_key keyE.ss"
+fi
+
 for protocol in TLSv1.2 SSLv3; do
   echo "Testing ciphersuites for $protocol"
-  for cipher in `../util/shlib_wrap.sh ../apps/openssl ciphers "RSA+$protocol" | tr ':' ' '`; do
-    test_cipher $cipher $protocol
+  for cipher in `../util/shlib_wrap.sh ../apps/openssl ciphers "$protocol:$ciphers" | tr ':' ' '`; do
+    test_cipher $cipher $protocol "$exkeys"
   done
-  if ../util/shlib_wrap.sh ../apps/openssl no-dhparam; then
-    echo "skipping RSA+DHE tests"
-  else
-    for cipher in `../util/shlib_wrap.sh ../apps/openssl ciphers "EDH+aRSA+$protocol:-EXP" | tr ':' ' '`; do
-      test_cipher $cipher $protocol
-    done
     echo "testing connection with weak DH, expecting failure"
     if [ $protocol = "SSLv3" ] ; then
       $ssltest -s_cipher "EDH" -c_cipher "EDH:@SECLEVEL=1" -dhe512 -ssl3
@@ -153,14 +168,6 @@ for protocol in TLSv1.2 SSLv3; do
       echo "FAIL: connection with weak DH succeeded"
       exit 1
     fi
-  fi
-  if ../util/shlib_wrap.sh ../apps/openssl no-ec; then
-    echo "skipping RSA+ECDHE tests"
-  else
-    for cipher in `../util/shlib_wrap.sh ../apps/openssl ciphers "EECDH+aRSA+$protocol:-EXP" | tr ':' ' '`; do
-      test_cipher $cipher $protocol
-    done
-  fi
 done
 
 #############################################################################
@@ -176,13 +183,13 @@ if ../util/shlib_wrap.sh ../apps/openssl no-rsa; then
   echo skipping RSA tests
 else
   echo 'test tls1 with 1024bit RSA, no (EC)DHE, multiple handshakes'
-  ../util/shlib_wrap.sh ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -no_ecdhe -num 10 -f -time $extra || exit 1
+  ../util/shlib_wrap.sh ./ssltest -v -bio_pair -tls1 -s_cert ../apps/server2.pem -no_dhe -no_ecdhe -num 10 -f -time $extra || exit 1
 
   if ../util/shlib_wrap.sh ../apps/openssl no-dhparam; then
     echo skipping RSA+DHE tests
   else
     echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes
-    ../util/shlib_wrap.sh ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1
+    ../util/shlib_wrap.sh ./ssltest -v -bio_pair -tls1 -s_cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1
   fi
 fi