Home | History | Annotate | Download | only in android.testssl
      1 #!/bin/sh
      2 
      3 if [ "$1" = "" ]; then
      4   key=../apps/server.pem
      5 else
      6   key="$1"
      7 fi
      8 if [ "$2" = "" ]; then
      9   cert=../apps/server.pem
     10 else
     11   cert="$2"
     12 fi
     13 ssltest="adb shell /system/bin/ssltest -key $key -cert $cert -c_key $key -c_cert $cert"
     14 
     15 if adb shell /system/bin/openssl x509 -in $cert -text -noout | fgrep 'DSA Public Key' >/dev/null; then
     16   dsa_cert=YES
     17 else
     18   dsa_cert=NO
     19 fi
     20 
     21 if [ "$3" = "" ]; then
     22   CA="-CApath ../certs"
     23 else
     24   CA="-CAfile $3"
     25 fi
     26 
     27 if [ "$4" = "" ]; then
     28   extra=""
     29 else
     30   extra="$4"
     31 fi
     32 
     33 #############################################################################
     34 
     35 echo test sslv2
     36 $ssltest -ssl2 $extra || exit 1
     37 
     38 echo test sslv2 with server authentication
     39 $ssltest -ssl2 -server_auth $CA $extra || exit 1
     40 
     41 if [ $dsa_cert = NO ]; then
     42   echo test sslv2 with client authentication
     43   $ssltest -ssl2 -client_auth $CA $extra || exit 1
     44 
     45   echo test sslv2 with both client and server authentication
     46   $ssltest -ssl2 -server_auth -client_auth $CA $extra || exit 1
     47 fi
     48 
     49 echo test sslv3
     50 $ssltest -ssl3 $extra || exit 1
     51 
     52 echo test sslv3 with server authentication
     53 $ssltest -ssl3 -server_auth $CA $extra || exit 1
     54 
     55 echo test sslv3 with client authentication
     56 $ssltest -ssl3 -client_auth $CA $extra || exit 1
     57 
     58 echo test sslv3 with both client and server authentication
     59 $ssltest -ssl3 -server_auth -client_auth $CA $extra || exit 1
     60 
     61 echo test sslv2/sslv3
     62 $ssltest $extra || exit 1
     63 
     64 echo test sslv2/sslv3 with server authentication
     65 $ssltest -server_auth $CA $extra || exit 1
     66 
     67 echo test sslv2/sslv3 with client authentication
     68 $ssltest -client_auth $CA $extra || exit 1
     69 
     70 echo test sslv2/sslv3 with both client and server authentication
     71 $ssltest -server_auth -client_auth $CA $extra || exit 1
     72 
     73 echo test sslv2/sslv3 with both client and server authentication and handshake cutthrough
     74 $ssltest -server_auth -client_auth -cutthrough $CA $extra || exit 1
     75 
     76 echo test sslv2 via BIO pair
     77 $ssltest -bio_pair -ssl2 $extra || exit 1
     78 
     79 echo test sslv2 with server authentication via BIO pair
     80 $ssltest -bio_pair -ssl2 -server_auth $CA $extra || exit 1
     81 
     82 if [ $dsa_cert = NO ]; then
     83   echo test sslv2 with client authentication via BIO pair
     84   $ssltest -bio_pair -ssl2 -client_auth $CA $extra || exit 1
     85 
     86   echo test sslv2 with both client and server authentication via BIO pair
     87   $ssltest -bio_pair -ssl2 -server_auth -client_auth $CA $extra || exit 1
     88 fi
     89 
     90 echo test sslv3 via BIO pair
     91 $ssltest -bio_pair -ssl3 $extra || exit 1
     92 
     93 echo test sslv3 with server authentication via BIO pair
     94 $ssltest -bio_pair -ssl3 -server_auth $CA $extra || exit 1
     95 
     96 echo test sslv3 with client authentication via BIO pair
     97 $ssltest -bio_pair -ssl3 -client_auth $CA $extra || exit 1
     98 
     99 echo test sslv3 with both client and server authentication via BIO pair
    100 $ssltest -bio_pair -ssl3 -server_auth -client_auth $CA $extra || exit 1
    101 
    102 echo test sslv2/sslv3 via BIO pair
    103 $ssltest $extra || exit 1
    104 
    105 if [ $dsa_cert = NO ]; then
    106   echo 'test sslv2/sslv3 w/o (EC)DHE via BIO pair'
    107   $ssltest -bio_pair -no_dhe -no_ecdhe $extra || exit 1
    108 fi
    109 
    110 echo test sslv2/sslv3 with 1024bit DHE via BIO pair
    111 $ssltest -bio_pair -dhe1024dsa -v $extra || exit 1
    112 
    113 echo test sslv2/sslv3 with server authentication
    114 $ssltest -bio_pair -server_auth $CA $extra || exit 1
    115 
    116 echo test sslv2/sslv3 with client authentication via BIO pair
    117 $ssltest -bio_pair -client_auth $CA $extra || exit 1
    118 
    119 echo test sslv2/sslv3 with both client and server authentication via BIO pair
    120 $ssltest -bio_pair -server_auth -client_auth $CA $extra || exit 1
    121 
    122 echo test sslv2/sslv3 with both client and server authentication via BIO pair and app verify
    123 $ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1
    124 
    125 echo "Testing ciphersuites"
    126 for protocol in TLSv1.2 SSLv3; do
    127   echo "Testing ciphersuites for $protocol"
    128   for cipher in `adb shell /system/bin/openssl ciphers "RSA+$protocol" | tr ':' ' '`; do
    129     echo "Testing $cipher"
    130     prot=""
    131     if [ $protocol = "SSLv3" ] ; then
    132       prot="-ssl3"
    133     fi
    134     $ssltest -cipher $cipher $prot
    135     if [ $? -ne 0 ] ; then
    136 	  echo "Failed $cipher"
    137 	  exit 1
    138     fi
    139   done
    140 done
    141 
    142 #############################################################################
    143 
    144 if [ `adb shell /system/bin/openssl no-dh` = no-dh ]; then
    145   echo skipping anonymous DH tests
    146 else
    147   echo test tls1 with 1024bit anonymous DH, multiple handshakes
    148   $ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1
    149 fi
    150 
    151 if [ `adb shell /system/bin/openssl no-rsa` = no-dh ]; then
    152   echo skipping RSA tests
    153 else
    154   echo 'test tls1 with 1024bit RSA, no (EC)DHE, multiple handshakes'
    155   adb shell /system/bin/ssltest -v -bio_pair -tls1 -cert /sdcard/android.testssl/server2.pem -no_dhe -no_ecdhe -num 10 -f -time $extra || exit 1
    156 
    157   if [ `adb shell /system/bin/openssl no-dh` = no-dh ]; then
    158     echo skipping RSA+DHE tests
    159   else
    160     echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes
    161     adb shell /system/bin/ssltest -v -bio_pair -tls1 -cert /sdcard/android.testssl/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1
    162   fi
    163 fi
    164 
    165 echo test tls1 with PSK
    166 $ssltest -tls1 -cipher PSK -psk abc123 $extra || exit 1
    167 
    168 echo test tls1 with PSK via BIO pair
    169 $ssltest -bio_pair -tls1 -cipher PSK -psk abc123 $extra || exit 1
    170 
    171 if adb shell /system/bin/openssl no-srp; then
    172   echo skipping SRP tests
    173 else
    174   echo test tls1 with SRP
    175   $ssltest -tls1 -cipher SRP -srpuser test -srppass abc123
    176 
    177   echo test tls1 with SRP via BIO pair
    178   $ssltest -bio_pair -tls1 -cipher SRP -srpuser test -srppass abc123
    179 fi
    180 
    181 exit 0
    182