ssltest.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #! /bin/sh
  2. # Tests ECC cipher suites using ssltest. Requires one argument which could
  3. # be aecdh or ecdh-ecdsa or ecdhe-ecdsa or ecdh-rsa or ecdhe-rsa.
  4. # A second optional argument can be one of ssl2 ssl3 or tls1
  5. if [ "$1" = "" ]; then
  6. (echo "Usage: $0 test [ protocol ]"
  7. echo " where test is one of aecdh, ecdh-ecdsa, ecdhe-ecdsa, ecdh-rsa, ecdhe-rsa"
  8. echo " and protocol (optional) is one of ssl2, ssl3, tls1"
  9. echo "Run RSAcertgen.sh, ECC-RSAcertgen.sh, ECCcertgen.sh first."
  10. ) >&2
  11. exit 1
  12. fi
  13. OPENSSL_DIR=../..
  14. CERTS_DIR=./Certs
  15. SSLTEST=$OPENSSL_DIR/test/ssltest
  16. # SSL protocol version to test (one of ssl2 ssl3 or tls1)"
  17. SSLVERSION=
  18. # These don't really require any certificates
  19. AECDH_CIPHER_LIST="AECDH-AES256-SHA AECDH-AES128-SHA AECDH-DES-CBC3-SHA AECDH-RC4-SHA AECDH-NULL-SHA"
  20. # These require ECC certificates signed with ECDSA
  21. # The EC public key must be authorized for key agreement.
  22. ECDH_ECDSA_CIPHER_LIST="ECDH-ECDSA-AES256-SHA ECDH-ECDSA-AES128-SHA ECDH-ECDSA-DES-CBC3-SHA ECDH-ECDSA-RC4-SHA ECDH-ECDSA-NULL-SHA"
  23. # These require ECC certificates.
  24. # The EC public key must be authorized for digital signature.
  25. ECDHE_ECDSA_CIPHER_LIST="ECDHE-ECDSA-AES256-SHA ECDHE-ECDSA-AES128-SHA ECDHE-ECDSA-DES-CBC3-SHA ECDHE-ECDSA-RC4-SHA ECDHE-ECDSA-NULL-SHA"
  26. # These require ECC certificates signed with RSA.
  27. # The EC public key must be authorized for key agreement.
  28. ECDH_RSA_CIPHER_LIST="ECDH-RSA-AES256-SHA ECDH-RSA-AES128-SHA ECDH-RSA-DES-CBC3-SHA ECDH-RSA-RC4-SHA ECDH-RSA-NULL-SHA"
  29. # These require RSA certificates.
  30. # The RSA public key must be authorized for digital signature.
  31. ECDHE_RSA_CIPHER_LIST="ECDHE-RSA-AES256-SHA ECDHE-RSA-AES128-SHA ECDHE-RSA-DES-CBC3-SHA ECDHE-RSA-RC4-SHA ECDHE-RSA-NULL-SHA"
  32. # List of Elliptic curves over which we wish to test generation of
  33. # ephemeral ECDH keys when using AECDH or ECDHE ciphers
  34. # NOTE: secp192r1 = prime192v1 and secp256r1 = prime256v1
  35. #ELLIPTIC_CURVE_LIST="secp112r1 sect113r2 secp128r1 sect131r1 secp160k1 sect163r2 wap-wsg-idm-ecid-wtls7 c2pnb163v3 c2pnb176v3 c2tnb191v3 secp192r1 prime192v3 sect193r2 secp224r1 wap-wsg-idm-ecid-wtls10 sect239k1 prime239v2 secp256r1 prime256v1 sect283k1 secp384r1 sect409r1 secp521r1 sect571r1"
  36. ELLIPTIC_CURVE_LIST="sect163k1 sect163r1 sect163r2 sect193r1 sect193r2 sect233k1 sect233r1 sect239k1 sect283k1 sect283r1 sect409k1 sect409r1 sect571k1 sect571r1 secp160k1 secp160r1 secp160r2 secp192k1 prime192v1 secp224k1 secp224r1 secp256k1 prime256v1 secp384r1 secp521r1"
  37. DEFAULT_CURVE="sect163r2"
  38. if [ "$2" = "" ]; then
  39. if [ "$SSL_VERSION" = "" ]; then
  40. SSL_VERSION=""
  41. else
  42. SSL_VERSION="-$SSL_VERSION"
  43. fi
  44. else
  45. SSL_VERSION="-$2"
  46. fi
  47. #==============================================================
  48. # Anonymous cipher suites do not require key or certificate files
  49. # but ssltest expects a cert file and complains if it can't
  50. # open the default one.
  51. SERVER_PEM=$OPENSSL_DIR/apps/server.pem
  52. if [ "$1" = "aecdh" ]; then
  53. for cipher in $AECDH_CIPHER_LIST
  54. do
  55. echo "Testing $cipher"
  56. $SSLTEST $SSL_VERSION -cert $SERVER_PEM -cipher $cipher
  57. done
  58. #--------------------------------------------------------------
  59. for curve in $ELLIPTIC_CURVE_LIST
  60. do
  61. echo "Testing AECDH-NULL-SHA (with $curve)"
  62. $SSLTEST $SSL_VERSION -cert $SERVER_PEM \
  63. -named_curve $curve -cipher AECDH-NULL-SHA
  64. done
  65. for curve in $ELLIPTIC_CURVE_LIST
  66. do
  67. echo "Testing AECDH-RC4-SHA (with $curve)"
  68. $SSLTEST $SSL_VERSION -cert $SERVER_PEM \
  69. -named_curve $curve -cipher AECDH-RC4-SHA
  70. done
  71. fi
  72. #==============================================================
  73. # Both ECDH-ECDSA and ECDHE-ECDSA cipher suites require
  74. # the server to have an ECC certificate signed with ECDSA.
  75. CA_PEM=$CERTS_DIR/secp160r1TestCA.pem
  76. SERVER_PEM=$CERTS_DIR/secp160r2TestServer.pem
  77. CLIENT_PEM=$CERTS_DIR/secp160r2TestClient.pem
  78. if [ "$1" = "ecdh-ecdsa" ]; then
  79. for cipher in $ECDH_ECDSA_CIPHER_LIST
  80. do
  81. echo "Testing $cipher (with server authentication)"
  82. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  83. -cert $SERVER_PEM -server_auth \
  84. -cipher $cipher
  85. echo "Testing $cipher (with server and client authentication)"
  86. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  87. -cert $SERVER_PEM -server_auth \
  88. -c_cert $CLIENT_PEM -client_auth \
  89. -cipher $cipher
  90. done
  91. fi
  92. #==============================================================
  93. if [ "$1" = "ecdhe-ecdsa" ]; then
  94. for cipher in $ECDHE_ECDSA_CIPHER_LIST
  95. do
  96. echo "Testing $cipher (with server authentication)"
  97. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  98. -cert $SERVER_PEM -server_auth \
  99. -cipher $cipher -named_curve $DEFAULT_CURVE
  100. echo "Testing $cipher (with server and client authentication)"
  101. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  102. -cert $SERVER_PEM -server_auth \
  103. -c_cert $CLIENT_PEM -client_auth \
  104. -cipher $cipher -named_curve $DEFAULT_CURVE
  105. done
  106. #--------------------------------------------------------------
  107. for curve in $ELLIPTIC_CURVE_LIST
  108. do
  109. echo "Testing ECDHE-ECDSA-AES128-SHA (2-way auth with $curve)"
  110. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  111. -cert $SERVER_PEM -server_auth \
  112. -c_cert $CLIENT_PEM -client_auth \
  113. -cipher ECDHE-ECDSA-AES128-SHA -named_curve $curve
  114. done
  115. fi
  116. #==============================================================
  117. # ECDH-RSA cipher suites require the server to have an ECC
  118. # certificate signed with RSA.
  119. CA_PEM=$CERTS_DIR/rsa1024TestCA.pem
  120. SERVER_PEM=$CERTS_DIR/sect163r1-rsaTestServer.pem
  121. CLIENT_PEM=$CERTS_DIR/sect163r1-rsaTestClient.pem
  122. if [ "$1" = "ecdh-rsa" ]; then
  123. for cipher in $ECDH_RSA_CIPHER_LIST
  124. do
  125. echo "Testing $cipher (with server authentication)"
  126. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  127. -cert $SERVER_PEM -server_auth \
  128. -cipher $cipher
  129. echo "Testing $cipher (with server and client authentication)"
  130. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  131. -cert $SERVER_PEM -server_auth \
  132. -c_cert $CLIENT_PEM -client_auth \
  133. -cipher $cipher
  134. done
  135. fi
  136. #==============================================================
  137. # ECDHE-RSA cipher suites require the server to have an RSA cert.
  138. CA_PEM=$CERTS_DIR/rsa1024TestCA.pem
  139. SERVER_PEM=$CERTS_DIR/rsa1024TestServer.pem
  140. CLIENT_PEM=$CERTS_DIR/rsa1024TestClient.pem
  141. if [ "$1" = "ecdhe-rsa" ]; then
  142. for cipher in $ECDHE_RSA_CIPHER_LIST
  143. do
  144. echo "Testing $cipher (with server authentication)"
  145. echo $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  146. -cert $SERVER_PEM -server_auth \
  147. -cipher $cipher -named_curve $DEFAULT_CURVE
  148. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  149. -cert $SERVER_PEM -server_auth \
  150. -cipher $cipher -named_curve $DEFAULT_CURVE
  151. echo "Testing $cipher (with server and client authentication)"
  152. $SSLTEST $SSL_VERSION -CAfile $CA_PEM \
  153. -cert $SERVER_PEM -server_auth \
  154. -c_cert $CLIENT_PEM -client_auth \
  155. -cipher $cipher -named_curve $DEFAULT_CURVE
  156. done
  157. fi
  158. #==============================================================