ssl_stat.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /* ssl/ssl_stat.c */
  2. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  3. * All rights reserved.
  4. *
  5. * This package is an SSL implementation written
  6. * by Eric Young (eay@cryptsoft.com).
  7. * The implementation was written so as to conform with Netscapes SSL.
  8. *
  9. * This library is free for commercial and non-commercial use as long as
  10. * the following conditions are aheared to. The following conditions
  11. * apply to all code found in this distribution, be it the RC4, RSA,
  12. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  13. * included with this distribution is covered by the same copyright terms
  14. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  15. *
  16. * Copyright remains Eric Young's, and as such any Copyright notices in
  17. * the code are not to be removed.
  18. * If this package is used in a product, Eric Young should be given attribution
  19. * as the author of the parts of the library used.
  20. * This can be in the form of a textual message at program startup or
  21. * in documentation (online or textual) provided with the package.
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions
  25. * are met:
  26. * 1. Redistributions of source code must retain the copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * 2. Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in the
  30. * documentation and/or other materials provided with the distribution.
  31. * 3. All advertising materials mentioning features or use of this software
  32. * must display the following acknowledgement:
  33. * "This product includes cryptographic software written by
  34. * Eric Young (eay@cryptsoft.com)"
  35. * The word 'cryptographic' can be left out if the rouines from the library
  36. * being used are not cryptographic related :-).
  37. * 4. If you include any Windows specific code (or a derivative thereof) from
  38. * the apps directory (application code) you must include an acknowledgement:
  39. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  40. *
  41. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  42. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  43. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  44. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  45. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  46. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  47. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  48. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  49. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  50. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  51. * SUCH DAMAGE.
  52. *
  53. * The licence and distribution terms for any publically available version or
  54. * derivative of this code cannot be changed. i.e. this code cannot simply be
  55. * copied and put under another distribution licence
  56. * [including the GNU Public Licence.]
  57. */
  58. /* ====================================================================
  59. * Copyright 2005 Nokia. All rights reserved.
  60. *
  61. * The portions of the attached software ("Contribution") is developed by
  62. * Nokia Corporation and is licensed pursuant to the OpenSSL open source
  63. * license.
  64. *
  65. * The Contribution, originally written by Mika Kousa and Pasi Eronen of
  66. * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
  67. * support (see RFC 4279) to OpenSSL.
  68. *
  69. * No patent licenses or other rights except those expressly stated in
  70. * the OpenSSL open source license shall be deemed granted or received
  71. * expressly, by implication, estoppel, or otherwise.
  72. *
  73. * No assurances are provided by Nokia that the Contribution does not
  74. * infringe the patent or other intellectual property rights of any third
  75. * party or that the license provides you with all the necessary rights
  76. * to make use of the Contribution.
  77. *
  78. * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
  79. * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
  80. * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
  81. * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
  82. * OTHERWISE.
  83. */
  84. #include <stdio.h>
  85. #include "ssl_locl.h"
  86. const char *SSL_state_string_long(const SSL *s)
  87. {
  88. const char *str;
  89. switch (s->state)
  90. {
  91. case SSL_ST_BEFORE: str="before SSL initialization"; break;
  92. case SSL_ST_ACCEPT: str="before accept initialization"; break;
  93. case SSL_ST_CONNECT: str="before connect initialization"; break;
  94. case SSL_ST_OK: str="SSL negotiation finished successfully"; break;
  95. case SSL_ST_RENEGOTIATE: str="SSL renegotiate ciphers"; break;
  96. case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initialization"; break;
  97. case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break;
  98. case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break;
  99. case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break;
  100. #ifndef OPENSSL_NO_SSL2
  101. case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break;
  102. case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break;
  103. case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break;
  104. case SSL2_ST_SEND_CLIENT_HELLO_B: str="SSLv2 write client hello B"; break;
  105. case SSL2_ST_GET_SERVER_HELLO_A: str="SSLv2 read server hello A"; break;
  106. case SSL2_ST_GET_SERVER_HELLO_B: str="SSLv2 read server hello B"; break;
  107. case SSL2_ST_SEND_CLIENT_MASTER_KEY_A: str="SSLv2 write client master key A"; break;
  108. case SSL2_ST_SEND_CLIENT_MASTER_KEY_B: str="SSLv2 write client master key B"; break;
  109. case SSL2_ST_SEND_CLIENT_FINISHED_A: str="SSLv2 write client finished A"; break;
  110. case SSL2_ST_SEND_CLIENT_FINISHED_B: str="SSLv2 write client finished B"; break;
  111. case SSL2_ST_SEND_CLIENT_CERTIFICATE_A: str="SSLv2 write client certificate A"; break;
  112. case SSL2_ST_SEND_CLIENT_CERTIFICATE_B: str="SSLv2 write client certificate B"; break;
  113. case SSL2_ST_SEND_CLIENT_CERTIFICATE_C: str="SSLv2 write client certificate C"; break;
  114. case SSL2_ST_SEND_CLIENT_CERTIFICATE_D: str="SSLv2 write client certificate D"; break;
  115. case SSL2_ST_GET_SERVER_VERIFY_A: str="SSLv2 read server verify A"; break;
  116. case SSL2_ST_GET_SERVER_VERIFY_B: str="SSLv2 read server verify B"; break;
  117. case SSL2_ST_GET_SERVER_FINISHED_A: str="SSLv2 read server finished A"; break;
  118. case SSL2_ST_GET_SERVER_FINISHED_B: str="SSLv2 read server finished B"; break;
  119. case SSL2_ST_GET_CLIENT_HELLO_A: str="SSLv2 read client hello A"; break;
  120. case SSL2_ST_GET_CLIENT_HELLO_B: str="SSLv2 read client hello B"; break;
  121. case SSL2_ST_GET_CLIENT_HELLO_C: str="SSLv2 read client hello C"; break;
  122. case SSL2_ST_SEND_SERVER_HELLO_A: str="SSLv2 write server hello A"; break;
  123. case SSL2_ST_SEND_SERVER_HELLO_B: str="SSLv2 write server hello B"; break;
  124. case SSL2_ST_GET_CLIENT_MASTER_KEY_A: str="SSLv2 read client master key A"; break;
  125. case SSL2_ST_GET_CLIENT_MASTER_KEY_B: str="SSLv2 read client master key B"; break;
  126. case SSL2_ST_SEND_SERVER_VERIFY_A: str="SSLv2 write server verify A"; break;
  127. case SSL2_ST_SEND_SERVER_VERIFY_B: str="SSLv2 write server verify B"; break;
  128. case SSL2_ST_SEND_SERVER_VERIFY_C: str="SSLv2 write server verify C"; break;
  129. case SSL2_ST_GET_CLIENT_FINISHED_A: str="SSLv2 read client finished A"; break;
  130. case SSL2_ST_GET_CLIENT_FINISHED_B: str="SSLv2 read client finished B"; break;
  131. case SSL2_ST_SEND_SERVER_FINISHED_A: str="SSLv2 write server finished A"; break;
  132. case SSL2_ST_SEND_SERVER_FINISHED_B: str="SSLv2 write server finished B"; break;
  133. case SSL2_ST_SEND_REQUEST_CERTIFICATE_A: str="SSLv2 write request certificate A"; break;
  134. case SSL2_ST_SEND_REQUEST_CERTIFICATE_B: str="SSLv2 write request certificate B"; break;
  135. case SSL2_ST_SEND_REQUEST_CERTIFICATE_C: str="SSLv2 write request certificate C"; break;
  136. case SSL2_ST_SEND_REQUEST_CERTIFICATE_D: str="SSLv2 write request certificate D"; break;
  137. case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="SSLv2 X509 read server certificate"; break;
  138. case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break;
  139. #endif
  140. #ifndef OPENSSL_NO_SSL3
  141. /* SSLv3 additions */
  142. case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break;
  143. case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break;
  144. case SSL3_ST_CR_SRVR_HELLO_A: str="SSLv3 read server hello A"; break;
  145. case SSL3_ST_CR_SRVR_HELLO_B: str="SSLv3 read server hello B"; break;
  146. case SSL3_ST_CR_CERT_A: str="SSLv3 read server certificate A"; break;
  147. case SSL3_ST_CR_CERT_B: str="SSLv3 read server certificate B"; break;
  148. case SSL3_ST_CR_KEY_EXCH_A: str="SSLv3 read server key exchange A"; break;
  149. case SSL3_ST_CR_KEY_EXCH_B: str="SSLv3 read server key exchange B"; break;
  150. case SSL3_ST_CR_CERT_REQ_A: str="SSLv3 read server certificate request A"; break;
  151. case SSL3_ST_CR_CERT_REQ_B: str="SSLv3 read server certificate request B"; break;
  152. case SSL3_ST_CR_SESSION_TICKET_A: str="SSLv3 read server session ticket A";break;
  153. case SSL3_ST_CR_SESSION_TICKET_B: str="SSLv3 read server session ticket B";break;
  154. case SSL3_ST_CR_SRVR_DONE_A: str="SSLv3 read server done A"; break;
  155. case SSL3_ST_CR_SRVR_DONE_B: str="SSLv3 read server done B"; break;
  156. case SSL3_ST_CW_CERT_A: str="SSLv3 write client certificate A"; break;
  157. case SSL3_ST_CW_CERT_B: str="SSLv3 write client certificate B"; break;
  158. case SSL3_ST_CW_CERT_C: str="SSLv3 write client certificate C"; break;
  159. case SSL3_ST_CW_CERT_D: str="SSLv3 write client certificate D"; break;
  160. case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break;
  161. case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break;
  162. case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break;
  163. case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify B"; break;
  164. case SSL3_ST_CW_CHANGE_A:
  165. case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break;
  166. case SSL3_ST_CW_CHANGE_B:
  167. case SSL3_ST_SW_CHANGE_B: str="SSLv3 write change cipher spec B"; break;
  168. case SSL3_ST_CW_FINISHED_A:
  169. case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break;
  170. case SSL3_ST_CW_FINISHED_B:
  171. case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished B"; break;
  172. case SSL3_ST_CR_CHANGE_A:
  173. case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break;
  174. case SSL3_ST_CR_CHANGE_B:
  175. case SSL3_ST_SR_CHANGE_B: str="SSLv3 read change cipher spec B"; break;
  176. case SSL3_ST_CR_FINISHED_A:
  177. case SSL3_ST_SR_FINISHED_A: str="SSLv3 read finished A"; break;
  178. case SSL3_ST_CR_FINISHED_B:
  179. case SSL3_ST_SR_FINISHED_B: str="SSLv3 read finished B"; break;
  180. case SSL3_ST_CW_FLUSH:
  181. case SSL3_ST_SW_FLUSH: str="SSLv3 flush data"; break;
  182. case SSL3_ST_SR_CLNT_HELLO_A: str="SSLv3 read client hello A"; break;
  183. case SSL3_ST_SR_CLNT_HELLO_B: str="SSLv3 read client hello B"; break;
  184. case SSL3_ST_SR_CLNT_HELLO_C: str="SSLv3 read client hello C"; break;
  185. case SSL3_ST_SW_HELLO_REQ_A: str="SSLv3 write hello request A"; break;
  186. case SSL3_ST_SW_HELLO_REQ_B: str="SSLv3 write hello request B"; break;
  187. case SSL3_ST_SW_HELLO_REQ_C: str="SSLv3 write hello request C"; break;
  188. case SSL3_ST_SW_SRVR_HELLO_A: str="SSLv3 write server hello A"; break;
  189. case SSL3_ST_SW_SRVR_HELLO_B: str="SSLv3 write server hello B"; break;
  190. case SSL3_ST_SW_CERT_A: str="SSLv3 write certificate A"; break;
  191. case SSL3_ST_SW_CERT_B: str="SSLv3 write certificate B"; break;
  192. case SSL3_ST_SW_KEY_EXCH_A: str="SSLv3 write key exchange A"; break;
  193. case SSL3_ST_SW_KEY_EXCH_B: str="SSLv3 write key exchange B"; break;
  194. case SSL3_ST_SW_CERT_REQ_A: str="SSLv3 write certificate request A"; break;
  195. case SSL3_ST_SW_CERT_REQ_B: str="SSLv3 write certificate request B"; break;
  196. case SSL3_ST_SW_SESSION_TICKET_A: str="SSLv3 write session ticket A"; break;
  197. case SSL3_ST_SW_SESSION_TICKET_B: str="SSLv3 write session ticket B"; break;
  198. case SSL3_ST_SW_SRVR_DONE_A: str="SSLv3 write server done A"; break;
  199. case SSL3_ST_SW_SRVR_DONE_B: str="SSLv3 write server done B"; break;
  200. case SSL3_ST_SR_CERT_A: str="SSLv3 read client certificate A"; break;
  201. case SSL3_ST_SR_CERT_B: str="SSLv3 read client certificate B"; break;
  202. case SSL3_ST_SR_KEY_EXCH_A: str="SSLv3 read client key exchange A"; break;
  203. case SSL3_ST_SR_KEY_EXCH_B: str="SSLv3 read client key exchange B"; break;
  204. case SSL3_ST_SR_CERT_VRFY_A: str="SSLv3 read certificate verify A"; break;
  205. case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break;
  206. #ifndef OPENSSL_NO_SRP
  207. case SSL3_ST_SR_CLNT_HELLO_SRP_USERNAME: str="SSLv3 waiting for a SRP username"; break;
  208. #endif
  209. #endif
  210. #if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
  211. /* SSLv2/v3 compatibility states */
  212. /* client */
  213. case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break;
  214. case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break;
  215. case SSL23_ST_CR_SRVR_HELLO_A: str="SSLv2/v3 read server hello A"; break;
  216. case SSL23_ST_CR_SRVR_HELLO_B: str="SSLv2/v3 read server hello B"; break;
  217. /* server */
  218. case SSL23_ST_SR_CLNT_HELLO_A: str="SSLv2/v3 read client hello A"; break;
  219. case SSL23_ST_SR_CLNT_HELLO_B: str="SSLv2/v3 read client hello B"; break;
  220. #endif
  221. /* DTLS */
  222. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: str="DTLS1 read hello verify request A"; break;
  223. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: str="DTLS1 read hello verify request B"; break;
  224. case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: str="DTLS1 write hello verify request A"; break;
  225. case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: str="DTLS1 write hello verify request B"; break;
  226. default: str="unknown state"; break;
  227. }
  228. return(str);
  229. }
  230. const char *SSL_rstate_string_long(const SSL *s)
  231. {
  232. const char *str;
  233. switch (s->rstate)
  234. {
  235. case SSL_ST_READ_HEADER: str="read header"; break;
  236. case SSL_ST_READ_BODY: str="read body"; break;
  237. case SSL_ST_READ_DONE: str="read done"; break;
  238. default: str="unknown"; break;
  239. }
  240. return(str);
  241. }
  242. const char *SSL_state_string(const SSL *s)
  243. {
  244. const char *str;
  245. switch (s->state)
  246. {
  247. case SSL_ST_BEFORE: str="PINIT "; break;
  248. case SSL_ST_ACCEPT: str="AINIT "; break;
  249. case SSL_ST_CONNECT: str="CINIT "; break;
  250. case SSL_ST_OK: str="SSLOK "; break;
  251. #ifndef OPENSSL_NO_SSL2
  252. case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break;
  253. case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break;
  254. case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break;
  255. case SSL2_ST_SEND_CLIENT_HELLO_B: str="2SCH_B"; break;
  256. case SSL2_ST_GET_SERVER_HELLO_A: str="2GSH_A"; break;
  257. case SSL2_ST_GET_SERVER_HELLO_B: str="2GSH_B"; break;
  258. case SSL2_ST_SEND_CLIENT_MASTER_KEY_A: str="2SCMKA"; break;
  259. case SSL2_ST_SEND_CLIENT_MASTER_KEY_B: str="2SCMKB"; break;
  260. case SSL2_ST_SEND_CLIENT_FINISHED_A: str="2SCF_A"; break;
  261. case SSL2_ST_SEND_CLIENT_FINISHED_B: str="2SCF_B"; break;
  262. case SSL2_ST_SEND_CLIENT_CERTIFICATE_A: str="2SCC_A"; break;
  263. case SSL2_ST_SEND_CLIENT_CERTIFICATE_B: str="2SCC_B"; break;
  264. case SSL2_ST_SEND_CLIENT_CERTIFICATE_C: str="2SCC_C"; break;
  265. case SSL2_ST_SEND_CLIENT_CERTIFICATE_D: str="2SCC_D"; break;
  266. case SSL2_ST_GET_SERVER_VERIFY_A: str="2GSV_A"; break;
  267. case SSL2_ST_GET_SERVER_VERIFY_B: str="2GSV_B"; break;
  268. case SSL2_ST_GET_SERVER_FINISHED_A: str="2GSF_A"; break;
  269. case SSL2_ST_GET_SERVER_FINISHED_B: str="2GSF_B"; break;
  270. case SSL2_ST_GET_CLIENT_HELLO_A: str="2GCH_A"; break;
  271. case SSL2_ST_GET_CLIENT_HELLO_B: str="2GCH_B"; break;
  272. case SSL2_ST_GET_CLIENT_HELLO_C: str="2GCH_C"; break;
  273. case SSL2_ST_SEND_SERVER_HELLO_A: str="2SSH_A"; break;
  274. case SSL2_ST_SEND_SERVER_HELLO_B: str="2SSH_B"; break;
  275. case SSL2_ST_GET_CLIENT_MASTER_KEY_A: str="2GCMKA"; break;
  276. case SSL2_ST_GET_CLIENT_MASTER_KEY_B: str="2GCMKA"; break;
  277. case SSL2_ST_SEND_SERVER_VERIFY_A: str="2SSV_A"; break;
  278. case SSL2_ST_SEND_SERVER_VERIFY_B: str="2SSV_B"; break;
  279. case SSL2_ST_SEND_SERVER_VERIFY_C: str="2SSV_C"; break;
  280. case SSL2_ST_GET_CLIENT_FINISHED_A: str="2GCF_A"; break;
  281. case SSL2_ST_GET_CLIENT_FINISHED_B: str="2GCF_B"; break;
  282. case SSL2_ST_SEND_SERVER_FINISHED_A: str="2SSF_A"; break;
  283. case SSL2_ST_SEND_SERVER_FINISHED_B: str="2SSF_B"; break;
  284. case SSL2_ST_SEND_REQUEST_CERTIFICATE_A: str="2SRC_A"; break;
  285. case SSL2_ST_SEND_REQUEST_CERTIFICATE_B: str="2SRC_B"; break;
  286. case SSL2_ST_SEND_REQUEST_CERTIFICATE_C: str="2SRC_C"; break;
  287. case SSL2_ST_SEND_REQUEST_CERTIFICATE_D: str="2SRC_D"; break;
  288. case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="2X9GSC"; break;
  289. case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break;
  290. #endif
  291. #ifndef OPENSSL_NO_SSL3
  292. /* SSLv3 additions */
  293. case SSL3_ST_SW_FLUSH:
  294. case SSL3_ST_CW_FLUSH: str="3FLUSH"; break;
  295. case SSL3_ST_CW_CLNT_HELLO_A: str="3WCH_A"; break;
  296. case SSL3_ST_CW_CLNT_HELLO_B: str="3WCH_B"; break;
  297. case SSL3_ST_CR_SRVR_HELLO_A: str="3RSH_A"; break;
  298. case SSL3_ST_CR_SRVR_HELLO_B: str="3RSH_B"; break;
  299. case SSL3_ST_CR_CERT_A: str="3RSC_A"; break;
  300. case SSL3_ST_CR_CERT_B: str="3RSC_B"; break;
  301. case SSL3_ST_CR_KEY_EXCH_A: str="3RSKEA"; break;
  302. case SSL3_ST_CR_KEY_EXCH_B: str="3RSKEB"; break;
  303. case SSL3_ST_CR_CERT_REQ_A: str="3RCR_A"; break;
  304. case SSL3_ST_CR_CERT_REQ_B: str="3RCR_B"; break;
  305. case SSL3_ST_CR_SRVR_DONE_A: str="3RSD_A"; break;
  306. case SSL3_ST_CR_SRVR_DONE_B: str="3RSD_B"; break;
  307. case SSL3_ST_CW_CERT_A: str="3WCC_A"; break;
  308. case SSL3_ST_CW_CERT_B: str="3WCC_B"; break;
  309. case SSL3_ST_CW_CERT_C: str="3WCC_C"; break;
  310. case SSL3_ST_CW_CERT_D: str="3WCC_D"; break;
  311. case SSL3_ST_CW_KEY_EXCH_A: str="3WCKEA"; break;
  312. case SSL3_ST_CW_KEY_EXCH_B: str="3WCKEB"; break;
  313. case SSL3_ST_CW_CERT_VRFY_A: str="3WCV_A"; break;
  314. case SSL3_ST_CW_CERT_VRFY_B: str="3WCV_B"; break;
  315. case SSL3_ST_SW_CHANGE_A:
  316. case SSL3_ST_CW_CHANGE_A: str="3WCCSA"; break;
  317. case SSL3_ST_SW_CHANGE_B:
  318. case SSL3_ST_CW_CHANGE_B: str="3WCCSB"; break;
  319. case SSL3_ST_SW_FINISHED_A:
  320. case SSL3_ST_CW_FINISHED_A: str="3WFINA"; break;
  321. case SSL3_ST_SW_FINISHED_B:
  322. case SSL3_ST_CW_FINISHED_B: str="3WFINB"; break;
  323. case SSL3_ST_SR_CHANGE_A:
  324. case SSL3_ST_CR_CHANGE_A: str="3RCCSA"; break;
  325. case SSL3_ST_SR_CHANGE_B:
  326. case SSL3_ST_CR_CHANGE_B: str="3RCCSB"; break;
  327. case SSL3_ST_SR_FINISHED_A:
  328. case SSL3_ST_CR_FINISHED_A: str="3RFINA"; break;
  329. case SSL3_ST_SR_FINISHED_B:
  330. case SSL3_ST_CR_FINISHED_B: str="3RFINB"; break;
  331. case SSL3_ST_SW_HELLO_REQ_A: str="3WHR_A"; break;
  332. case SSL3_ST_SW_HELLO_REQ_B: str="3WHR_B"; break;
  333. case SSL3_ST_SW_HELLO_REQ_C: str="3WHR_C"; break;
  334. case SSL3_ST_SR_CLNT_HELLO_A: str="3RCH_A"; break;
  335. case SSL3_ST_SR_CLNT_HELLO_B: str="3RCH_B"; break;
  336. case SSL3_ST_SR_CLNT_HELLO_C: str="3RCH_C"; break;
  337. case SSL3_ST_SW_SRVR_HELLO_A: str="3WSH_A"; break;
  338. case SSL3_ST_SW_SRVR_HELLO_B: str="3WSH_B"; break;
  339. case SSL3_ST_SW_CERT_A: str="3WSC_A"; break;
  340. case SSL3_ST_SW_CERT_B: str="3WSC_B"; break;
  341. case SSL3_ST_SW_KEY_EXCH_A: str="3WSKEA"; break;
  342. case SSL3_ST_SW_KEY_EXCH_B: str="3WSKEB"; break;
  343. case SSL3_ST_SW_CERT_REQ_A: str="3WCR_A"; break;
  344. case SSL3_ST_SW_CERT_REQ_B: str="3WCR_B"; break;
  345. case SSL3_ST_SW_SRVR_DONE_A: str="3WSD_A"; break;
  346. case SSL3_ST_SW_SRVR_DONE_B: str="3WSD_B"; break;
  347. case SSL3_ST_SR_CERT_A: str="3RCC_A"; break;
  348. case SSL3_ST_SR_CERT_B: str="3RCC_B"; break;
  349. case SSL3_ST_SR_KEY_EXCH_A: str="3RCKEA"; break;
  350. case SSL3_ST_SR_KEY_EXCH_B: str="3RCKEB"; break;
  351. case SSL3_ST_SR_CERT_VRFY_A: str="3RCV_A"; break;
  352. case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break;
  353. #endif
  354. #if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
  355. /* SSLv2/v3 compatibility states */
  356. /* client */
  357. case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break;
  358. case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break;
  359. case SSL23_ST_CR_SRVR_HELLO_A: str="23RSHA"; break;
  360. case SSL23_ST_CR_SRVR_HELLO_B: str="23RSHA"; break;
  361. /* server */
  362. case SSL23_ST_SR_CLNT_HELLO_A: str="23RCHA"; break;
  363. case SSL23_ST_SR_CLNT_HELLO_B: str="23RCHB"; break;
  364. #endif
  365. /* DTLS */
  366. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: str="DRCHVA"; break;
  367. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: str="DRCHVB"; break;
  368. case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: str="DWCHVA"; break;
  369. case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: str="DWCHVB"; break;
  370. default: str="UNKWN "; break;
  371. }
  372. return(str);
  373. }
  374. const char *SSL_alert_type_string_long(int value)
  375. {
  376. value>>=8;
  377. if (value == SSL3_AL_WARNING)
  378. return("warning");
  379. else if (value == SSL3_AL_FATAL)
  380. return("fatal");
  381. else
  382. return("unknown");
  383. }
  384. const char *SSL_alert_type_string(int value)
  385. {
  386. value>>=8;
  387. if (value == SSL3_AL_WARNING)
  388. return("W");
  389. else if (value == SSL3_AL_FATAL)
  390. return("F");
  391. else
  392. return("U");
  393. }
  394. const char *SSL_alert_desc_string(int value)
  395. {
  396. const char *str;
  397. switch (value & 0xff)
  398. {
  399. case SSL3_AD_CLOSE_NOTIFY: str="CN"; break;
  400. case SSL3_AD_UNEXPECTED_MESSAGE: str="UM"; break;
  401. case SSL3_AD_BAD_RECORD_MAC: str="BM"; break;
  402. case SSL3_AD_DECOMPRESSION_FAILURE: str="DF"; break;
  403. case SSL3_AD_HANDSHAKE_FAILURE: str="HF"; break;
  404. case SSL3_AD_NO_CERTIFICATE: str="NC"; break;
  405. case SSL3_AD_BAD_CERTIFICATE: str="BC"; break;
  406. case SSL3_AD_UNSUPPORTED_CERTIFICATE: str="UC"; break;
  407. case SSL3_AD_CERTIFICATE_REVOKED: str="CR"; break;
  408. case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break;
  409. case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break;
  410. case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break;
  411. case TLS1_AD_DECRYPTION_FAILED: str="DC"; break;
  412. case TLS1_AD_RECORD_OVERFLOW: str="RO"; break;
  413. case TLS1_AD_UNKNOWN_CA: str="CA"; break;
  414. case TLS1_AD_ACCESS_DENIED: str="AD"; break;
  415. case TLS1_AD_DECODE_ERROR: str="DE"; break;
  416. case TLS1_AD_DECRYPT_ERROR: str="CY"; break;
  417. case TLS1_AD_EXPORT_RESTRICTION: str="ER"; break;
  418. case TLS1_AD_PROTOCOL_VERSION: str="PV"; break;
  419. case TLS1_AD_INSUFFICIENT_SECURITY: str="IS"; break;
  420. case TLS1_AD_INTERNAL_ERROR: str="IE"; break;
  421. case TLS1_AD_USER_CANCELLED: str="US"; break;
  422. case TLS1_AD_NO_RENEGOTIATION: str="NR"; break;
  423. case TLS1_AD_UNSUPPORTED_EXTENSION: str="UE"; break;
  424. case TLS1_AD_CERTIFICATE_UNOBTAINABLE: str="CO"; break;
  425. case TLS1_AD_UNRECOGNIZED_NAME: str="UN"; break;
  426. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE: str="BR"; break;
  427. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE: str="BH"; break;
  428. case TLS1_AD_UNKNOWN_PSK_IDENTITY: str="UP"; break;
  429. default: str="UK"; break;
  430. }
  431. return(str);
  432. }
  433. const char *SSL_alert_desc_string_long(int value)
  434. {
  435. const char *str;
  436. switch (value & 0xff)
  437. {
  438. case SSL3_AD_CLOSE_NOTIFY:
  439. str="close notify";
  440. break;
  441. case SSL3_AD_UNEXPECTED_MESSAGE:
  442. str="unexpected_message";
  443. break;
  444. case SSL3_AD_BAD_RECORD_MAC:
  445. str="bad record mac";
  446. break;
  447. case SSL3_AD_DECOMPRESSION_FAILURE:
  448. str="decompression failure";
  449. break;
  450. case SSL3_AD_HANDSHAKE_FAILURE:
  451. str="handshake failure";
  452. break;
  453. case SSL3_AD_NO_CERTIFICATE:
  454. str="no certificate";
  455. break;
  456. case SSL3_AD_BAD_CERTIFICATE:
  457. str="bad certificate";
  458. break;
  459. case SSL3_AD_UNSUPPORTED_CERTIFICATE:
  460. str="unsupported certificate";
  461. break;
  462. case SSL3_AD_CERTIFICATE_REVOKED:
  463. str="certificate revoked";
  464. break;
  465. case SSL3_AD_CERTIFICATE_EXPIRED:
  466. str="certificate expired";
  467. break;
  468. case SSL3_AD_CERTIFICATE_UNKNOWN:
  469. str="certificate unknown";
  470. break;
  471. case SSL3_AD_ILLEGAL_PARAMETER:
  472. str="illegal parameter";
  473. break;
  474. case TLS1_AD_DECRYPTION_FAILED:
  475. str="decryption failed";
  476. break;
  477. case TLS1_AD_RECORD_OVERFLOW:
  478. str="record overflow";
  479. break;
  480. case TLS1_AD_UNKNOWN_CA:
  481. str="unknown CA";
  482. break;
  483. case TLS1_AD_ACCESS_DENIED:
  484. str="access denied";
  485. break;
  486. case TLS1_AD_DECODE_ERROR:
  487. str="decode error";
  488. break;
  489. case TLS1_AD_DECRYPT_ERROR:
  490. str="decrypt error";
  491. break;
  492. case TLS1_AD_EXPORT_RESTRICTION:
  493. str="export restriction";
  494. break;
  495. case TLS1_AD_PROTOCOL_VERSION:
  496. str="protocol version";
  497. break;
  498. case TLS1_AD_INSUFFICIENT_SECURITY:
  499. str="insufficient security";
  500. break;
  501. case TLS1_AD_INTERNAL_ERROR:
  502. str="internal error";
  503. break;
  504. case TLS1_AD_USER_CANCELLED:
  505. str="user canceled";
  506. break;
  507. case TLS1_AD_NO_RENEGOTIATION:
  508. str="no renegotiation";
  509. break;
  510. case TLS1_AD_UNSUPPORTED_EXTENSION:
  511. str="unsupported extension";
  512. break;
  513. case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
  514. str="certificate unobtainable";
  515. break;
  516. case TLS1_AD_UNRECOGNIZED_NAME:
  517. str="unrecognized name";
  518. break;
  519. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
  520. str="bad certificate status response";
  521. break;
  522. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
  523. str="bad certificate hash value";
  524. break;
  525. case TLS1_AD_UNKNOWN_PSK_IDENTITY:
  526. str="unknown PSK identity";
  527. break;
  528. #ifndef OPENSSL_NO_SRP
  529. case TLS1_AD_MISSING_SRP_USERNAME:
  530. str="no srp username";
  531. break;
  532. #endif
  533. default: str="unknown"; break;
  534. }
  535. return(str);
  536. }
  537. const char *SSL_rstate_string(const SSL *s)
  538. {
  539. const char *str;
  540. switch (s->rstate)
  541. {
  542. case SSL_ST_READ_HEADER:str="RH"; break;
  543. case SSL_ST_READ_BODY: str="RB"; break;
  544. case SSL_ST_READ_DONE: str="RD"; break;
  545. default: str="unknown"; break;
  546. }
  547. return(str);
  548. }