ssl_stat.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  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. case SSL_ST_BEFORE:
  91. str = "before SSL initialization";
  92. break;
  93. case SSL_ST_ACCEPT:
  94. str = "before accept initialization";
  95. break;
  96. case SSL_ST_CONNECT:
  97. str = "before connect initialization";
  98. break;
  99. case SSL_ST_OK:
  100. str = "SSL negotiation finished successfully";
  101. break;
  102. case SSL_ST_RENEGOTIATE:
  103. str = "SSL renegotiate ciphers";
  104. break;
  105. case SSL_ST_BEFORE | SSL_ST_CONNECT:
  106. str = "before/connect initialization";
  107. break;
  108. case SSL_ST_OK | SSL_ST_CONNECT:
  109. str = "ok/connect SSL initialization";
  110. break;
  111. case SSL_ST_BEFORE | SSL_ST_ACCEPT:
  112. str = "before/accept initialization";
  113. break;
  114. case SSL_ST_OK | SSL_ST_ACCEPT:
  115. str = "ok/accept SSL initialization";
  116. break;
  117. case SSL_ST_ERR:
  118. str = "error";
  119. break;
  120. #ifndef OPENSSL_NO_SSL2
  121. case SSL2_ST_CLIENT_START_ENCRYPTION:
  122. str = "SSLv2 client start encryption";
  123. break;
  124. case SSL2_ST_SERVER_START_ENCRYPTION:
  125. str = "SSLv2 server start encryption";
  126. break;
  127. case SSL2_ST_SEND_CLIENT_HELLO_A:
  128. str = "SSLv2 write client hello A";
  129. break;
  130. case SSL2_ST_SEND_CLIENT_HELLO_B:
  131. str = "SSLv2 write client hello B";
  132. break;
  133. case SSL2_ST_GET_SERVER_HELLO_A:
  134. str = "SSLv2 read server hello A";
  135. break;
  136. case SSL2_ST_GET_SERVER_HELLO_B:
  137. str = "SSLv2 read server hello B";
  138. break;
  139. case SSL2_ST_SEND_CLIENT_MASTER_KEY_A:
  140. str = "SSLv2 write client master key A";
  141. break;
  142. case SSL2_ST_SEND_CLIENT_MASTER_KEY_B:
  143. str = "SSLv2 write client master key B";
  144. break;
  145. case SSL2_ST_SEND_CLIENT_FINISHED_A:
  146. str = "SSLv2 write client finished A";
  147. break;
  148. case SSL2_ST_SEND_CLIENT_FINISHED_B:
  149. str = "SSLv2 write client finished B";
  150. break;
  151. case SSL2_ST_SEND_CLIENT_CERTIFICATE_A:
  152. str = "SSLv2 write client certificate A";
  153. break;
  154. case SSL2_ST_SEND_CLIENT_CERTIFICATE_B:
  155. str = "SSLv2 write client certificate B";
  156. break;
  157. case SSL2_ST_SEND_CLIENT_CERTIFICATE_C:
  158. str = "SSLv2 write client certificate C";
  159. break;
  160. case SSL2_ST_SEND_CLIENT_CERTIFICATE_D:
  161. str = "SSLv2 write client certificate D";
  162. break;
  163. case SSL2_ST_GET_SERVER_VERIFY_A:
  164. str = "SSLv2 read server verify A";
  165. break;
  166. case SSL2_ST_GET_SERVER_VERIFY_B:
  167. str = "SSLv2 read server verify B";
  168. break;
  169. case SSL2_ST_GET_SERVER_FINISHED_A:
  170. str = "SSLv2 read server finished A";
  171. break;
  172. case SSL2_ST_GET_SERVER_FINISHED_B:
  173. str = "SSLv2 read server finished B";
  174. break;
  175. case SSL2_ST_GET_CLIENT_HELLO_A:
  176. str = "SSLv2 read client hello A";
  177. break;
  178. case SSL2_ST_GET_CLIENT_HELLO_B:
  179. str = "SSLv2 read client hello B";
  180. break;
  181. case SSL2_ST_GET_CLIENT_HELLO_C:
  182. str = "SSLv2 read client hello C";
  183. break;
  184. case SSL2_ST_SEND_SERVER_HELLO_A:
  185. str = "SSLv2 write server hello A";
  186. break;
  187. case SSL2_ST_SEND_SERVER_HELLO_B:
  188. str = "SSLv2 write server hello B";
  189. break;
  190. case SSL2_ST_GET_CLIENT_MASTER_KEY_A:
  191. str = "SSLv2 read client master key A";
  192. break;
  193. case SSL2_ST_GET_CLIENT_MASTER_KEY_B:
  194. str = "SSLv2 read client master key B";
  195. break;
  196. case SSL2_ST_SEND_SERVER_VERIFY_A:
  197. str = "SSLv2 write server verify A";
  198. break;
  199. case SSL2_ST_SEND_SERVER_VERIFY_B:
  200. str = "SSLv2 write server verify B";
  201. break;
  202. case SSL2_ST_SEND_SERVER_VERIFY_C:
  203. str = "SSLv2 write server verify C";
  204. break;
  205. case SSL2_ST_GET_CLIENT_FINISHED_A:
  206. str = "SSLv2 read client finished A";
  207. break;
  208. case SSL2_ST_GET_CLIENT_FINISHED_B:
  209. str = "SSLv2 read client finished B";
  210. break;
  211. case SSL2_ST_SEND_SERVER_FINISHED_A:
  212. str = "SSLv2 write server finished A";
  213. break;
  214. case SSL2_ST_SEND_SERVER_FINISHED_B:
  215. str = "SSLv2 write server finished B";
  216. break;
  217. case SSL2_ST_SEND_REQUEST_CERTIFICATE_A:
  218. str = "SSLv2 write request certificate A";
  219. break;
  220. case SSL2_ST_SEND_REQUEST_CERTIFICATE_B:
  221. str = "SSLv2 write request certificate B";
  222. break;
  223. case SSL2_ST_SEND_REQUEST_CERTIFICATE_C:
  224. str = "SSLv2 write request certificate C";
  225. break;
  226. case SSL2_ST_SEND_REQUEST_CERTIFICATE_D:
  227. str = "SSLv2 write request certificate D";
  228. break;
  229. case SSL2_ST_X509_GET_SERVER_CERTIFICATE:
  230. str = "SSLv2 X509 read server certificate";
  231. break;
  232. case SSL2_ST_X509_GET_CLIENT_CERTIFICATE:
  233. str = "SSLv2 X509 read client certificate";
  234. break;
  235. #endif
  236. #ifndef OPENSSL_NO_SSL3
  237. /* SSLv3 additions */
  238. case SSL3_ST_CW_CLNT_HELLO_A:
  239. str = "SSLv3 write client hello A";
  240. break;
  241. case SSL3_ST_CW_CLNT_HELLO_B:
  242. str = "SSLv3 write client hello B";
  243. break;
  244. case SSL3_ST_CR_SRVR_HELLO_A:
  245. str = "SSLv3 read server hello A";
  246. break;
  247. case SSL3_ST_CR_SRVR_HELLO_B:
  248. str = "SSLv3 read server hello B";
  249. break;
  250. case SSL3_ST_CR_CERT_A:
  251. str = "SSLv3 read server certificate A";
  252. break;
  253. case SSL3_ST_CR_CERT_B:
  254. str = "SSLv3 read server certificate B";
  255. break;
  256. case SSL3_ST_CR_KEY_EXCH_A:
  257. str = "SSLv3 read server key exchange A";
  258. break;
  259. case SSL3_ST_CR_KEY_EXCH_B:
  260. str = "SSLv3 read server key exchange B";
  261. break;
  262. case SSL3_ST_CR_CERT_REQ_A:
  263. str = "SSLv3 read server certificate request A";
  264. break;
  265. case SSL3_ST_CR_CERT_REQ_B:
  266. str = "SSLv3 read server certificate request B";
  267. break;
  268. case SSL3_ST_CR_SESSION_TICKET_A:
  269. str = "SSLv3 read server session ticket A";
  270. break;
  271. case SSL3_ST_CR_SESSION_TICKET_B:
  272. str = "SSLv3 read server session ticket B";
  273. break;
  274. case SSL3_ST_CR_SRVR_DONE_A:
  275. str = "SSLv3 read server done A";
  276. break;
  277. case SSL3_ST_CR_SRVR_DONE_B:
  278. str = "SSLv3 read server done B";
  279. break;
  280. case SSL3_ST_CW_CERT_A:
  281. str = "SSLv3 write client certificate A";
  282. break;
  283. case SSL3_ST_CW_CERT_B:
  284. str = "SSLv3 write client certificate B";
  285. break;
  286. case SSL3_ST_CW_CERT_C:
  287. str = "SSLv3 write client certificate C";
  288. break;
  289. case SSL3_ST_CW_CERT_D:
  290. str = "SSLv3 write client certificate D";
  291. break;
  292. case SSL3_ST_CW_KEY_EXCH_A:
  293. str = "SSLv3 write client key exchange A";
  294. break;
  295. case SSL3_ST_CW_KEY_EXCH_B:
  296. str = "SSLv3 write client key exchange B";
  297. break;
  298. case SSL3_ST_CW_CERT_VRFY_A:
  299. str = "SSLv3 write certificate verify A";
  300. break;
  301. case SSL3_ST_CW_CERT_VRFY_B:
  302. str = "SSLv3 write certificate verify B";
  303. break;
  304. case SSL3_ST_CW_CHANGE_A:
  305. case SSL3_ST_SW_CHANGE_A:
  306. str = "SSLv3 write change cipher spec A";
  307. break;
  308. case SSL3_ST_CW_CHANGE_B:
  309. case SSL3_ST_SW_CHANGE_B:
  310. str = "SSLv3 write change cipher spec B";
  311. break;
  312. case SSL3_ST_CW_FINISHED_A:
  313. case SSL3_ST_SW_FINISHED_A:
  314. str = "SSLv3 write finished A";
  315. break;
  316. case SSL3_ST_CW_FINISHED_B:
  317. case SSL3_ST_SW_FINISHED_B:
  318. str = "SSLv3 write finished B";
  319. break;
  320. case SSL3_ST_CR_CHANGE_A:
  321. case SSL3_ST_SR_CHANGE_A:
  322. str = "SSLv3 read change cipher spec A";
  323. break;
  324. case SSL3_ST_CR_CHANGE_B:
  325. case SSL3_ST_SR_CHANGE_B:
  326. str = "SSLv3 read change cipher spec B";
  327. break;
  328. case SSL3_ST_CR_FINISHED_A:
  329. case SSL3_ST_SR_FINISHED_A:
  330. str = "SSLv3 read finished A";
  331. break;
  332. case SSL3_ST_CR_FINISHED_B:
  333. case SSL3_ST_SR_FINISHED_B:
  334. str = "SSLv3 read finished B";
  335. break;
  336. case SSL3_ST_CW_FLUSH:
  337. case SSL3_ST_SW_FLUSH:
  338. str = "SSLv3 flush data";
  339. break;
  340. case SSL3_ST_SR_CLNT_HELLO_A:
  341. str = "SSLv3 read client hello A";
  342. break;
  343. case SSL3_ST_SR_CLNT_HELLO_B:
  344. str = "SSLv3 read client hello B";
  345. break;
  346. case SSL3_ST_SR_CLNT_HELLO_C:
  347. str = "SSLv3 read client hello C";
  348. break;
  349. case SSL3_ST_SW_HELLO_REQ_A:
  350. str = "SSLv3 write hello request A";
  351. break;
  352. case SSL3_ST_SW_HELLO_REQ_B:
  353. str = "SSLv3 write hello request B";
  354. break;
  355. case SSL3_ST_SW_HELLO_REQ_C:
  356. str = "SSLv3 write hello request C";
  357. break;
  358. case SSL3_ST_SW_SRVR_HELLO_A:
  359. str = "SSLv3 write server hello A";
  360. break;
  361. case SSL3_ST_SW_SRVR_HELLO_B:
  362. str = "SSLv3 write server hello B";
  363. break;
  364. case SSL3_ST_SW_CERT_A:
  365. str = "SSLv3 write certificate A";
  366. break;
  367. case SSL3_ST_SW_CERT_B:
  368. str = "SSLv3 write certificate B";
  369. break;
  370. case SSL3_ST_SW_KEY_EXCH_A:
  371. str = "SSLv3 write key exchange A";
  372. break;
  373. case SSL3_ST_SW_KEY_EXCH_B:
  374. str = "SSLv3 write key exchange B";
  375. break;
  376. case SSL3_ST_SW_CERT_REQ_A:
  377. str = "SSLv3 write certificate request A";
  378. break;
  379. case SSL3_ST_SW_CERT_REQ_B:
  380. str = "SSLv3 write certificate request B";
  381. break;
  382. case SSL3_ST_SW_SESSION_TICKET_A:
  383. str = "SSLv3 write session ticket A";
  384. break;
  385. case SSL3_ST_SW_SESSION_TICKET_B:
  386. str = "SSLv3 write session ticket B";
  387. break;
  388. case SSL3_ST_SW_SRVR_DONE_A:
  389. str = "SSLv3 write server done A";
  390. break;
  391. case SSL3_ST_SW_SRVR_DONE_B:
  392. str = "SSLv3 write server done B";
  393. break;
  394. case SSL3_ST_SR_CERT_A:
  395. str = "SSLv3 read client certificate A";
  396. break;
  397. case SSL3_ST_SR_CERT_B:
  398. str = "SSLv3 read client certificate B";
  399. break;
  400. case SSL3_ST_SR_KEY_EXCH_A:
  401. str = "SSLv3 read client key exchange A";
  402. break;
  403. case SSL3_ST_SR_KEY_EXCH_B:
  404. str = "SSLv3 read client key exchange B";
  405. break;
  406. case SSL3_ST_SR_CERT_VRFY_A:
  407. str = "SSLv3 read certificate verify A";
  408. break;
  409. case SSL3_ST_SR_CERT_VRFY_B:
  410. str = "SSLv3 read certificate verify B";
  411. break;
  412. #endif
  413. /* SSLv2/v3 compatibility states */
  414. /* client */
  415. case SSL23_ST_CW_CLNT_HELLO_A:
  416. str = "SSLv2/v3 write client hello A";
  417. break;
  418. case SSL23_ST_CW_CLNT_HELLO_B:
  419. str = "SSLv2/v3 write client hello B";
  420. break;
  421. case SSL23_ST_CR_SRVR_HELLO_A:
  422. str = "SSLv2/v3 read server hello A";
  423. break;
  424. case SSL23_ST_CR_SRVR_HELLO_B:
  425. str = "SSLv2/v3 read server hello B";
  426. break;
  427. /* server */
  428. case SSL23_ST_SR_CLNT_HELLO_A:
  429. str = "SSLv2/v3 read client hello A";
  430. break;
  431. case SSL23_ST_SR_CLNT_HELLO_B:
  432. str = "SSLv2/v3 read client hello B";
  433. break;
  434. /* DTLS */
  435. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
  436. str = "DTLS1 read hello verify request A";
  437. break;
  438. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
  439. str = "DTLS1 read hello verify request B";
  440. break;
  441. case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
  442. str = "DTLS1 write hello verify request A";
  443. break;
  444. case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
  445. str = "DTLS1 write hello verify request B";
  446. break;
  447. default:
  448. str = "unknown state";
  449. break;
  450. }
  451. return (str);
  452. }
  453. const char *SSL_rstate_string_long(const SSL *s)
  454. {
  455. const char *str;
  456. switch (s->rstate) {
  457. case SSL_ST_READ_HEADER:
  458. str = "read header";
  459. break;
  460. case SSL_ST_READ_BODY:
  461. str = "read body";
  462. break;
  463. case SSL_ST_READ_DONE:
  464. str = "read done";
  465. break;
  466. default:
  467. str = "unknown";
  468. break;
  469. }
  470. return (str);
  471. }
  472. const char *SSL_state_string(const SSL *s)
  473. {
  474. const char *str;
  475. switch (s->state) {
  476. case SSL_ST_BEFORE:
  477. str = "PINIT ";
  478. break;
  479. case SSL_ST_ACCEPT:
  480. str = "AINIT ";
  481. break;
  482. case SSL_ST_CONNECT:
  483. str = "CINIT ";
  484. break;
  485. case SSL_ST_OK:
  486. str = "SSLOK ";
  487. break;
  488. case SSL_ST_ERR:
  489. str = "SSLERR";
  490. break;
  491. #ifndef OPENSSL_NO_SSL2
  492. case SSL2_ST_CLIENT_START_ENCRYPTION:
  493. str = "2CSENC";
  494. break;
  495. case SSL2_ST_SERVER_START_ENCRYPTION:
  496. str = "2SSENC";
  497. break;
  498. case SSL2_ST_SEND_CLIENT_HELLO_A:
  499. str = "2SCH_A";
  500. break;
  501. case SSL2_ST_SEND_CLIENT_HELLO_B:
  502. str = "2SCH_B";
  503. break;
  504. case SSL2_ST_GET_SERVER_HELLO_A:
  505. str = "2GSH_A";
  506. break;
  507. case SSL2_ST_GET_SERVER_HELLO_B:
  508. str = "2GSH_B";
  509. break;
  510. case SSL2_ST_SEND_CLIENT_MASTER_KEY_A:
  511. str = "2SCMKA";
  512. break;
  513. case SSL2_ST_SEND_CLIENT_MASTER_KEY_B:
  514. str = "2SCMKB";
  515. break;
  516. case SSL2_ST_SEND_CLIENT_FINISHED_A:
  517. str = "2SCF_A";
  518. break;
  519. case SSL2_ST_SEND_CLIENT_FINISHED_B:
  520. str = "2SCF_B";
  521. break;
  522. case SSL2_ST_SEND_CLIENT_CERTIFICATE_A:
  523. str = "2SCC_A";
  524. break;
  525. case SSL2_ST_SEND_CLIENT_CERTIFICATE_B:
  526. str = "2SCC_B";
  527. break;
  528. case SSL2_ST_SEND_CLIENT_CERTIFICATE_C:
  529. str = "2SCC_C";
  530. break;
  531. case SSL2_ST_SEND_CLIENT_CERTIFICATE_D:
  532. str = "2SCC_D";
  533. break;
  534. case SSL2_ST_GET_SERVER_VERIFY_A:
  535. str = "2GSV_A";
  536. break;
  537. case SSL2_ST_GET_SERVER_VERIFY_B:
  538. str = "2GSV_B";
  539. break;
  540. case SSL2_ST_GET_SERVER_FINISHED_A:
  541. str = "2GSF_A";
  542. break;
  543. case SSL2_ST_GET_SERVER_FINISHED_B:
  544. str = "2GSF_B";
  545. break;
  546. case SSL2_ST_GET_CLIENT_HELLO_A:
  547. str = "2GCH_A";
  548. break;
  549. case SSL2_ST_GET_CLIENT_HELLO_B:
  550. str = "2GCH_B";
  551. break;
  552. case SSL2_ST_GET_CLIENT_HELLO_C:
  553. str = "2GCH_C";
  554. break;
  555. case SSL2_ST_SEND_SERVER_HELLO_A:
  556. str = "2SSH_A";
  557. break;
  558. case SSL2_ST_SEND_SERVER_HELLO_B:
  559. str = "2SSH_B";
  560. break;
  561. case SSL2_ST_GET_CLIENT_MASTER_KEY_A:
  562. str = "2GCMKA";
  563. break;
  564. case SSL2_ST_GET_CLIENT_MASTER_KEY_B:
  565. str = "2GCMKA";
  566. break;
  567. case SSL2_ST_SEND_SERVER_VERIFY_A:
  568. str = "2SSV_A";
  569. break;
  570. case SSL2_ST_SEND_SERVER_VERIFY_B:
  571. str = "2SSV_B";
  572. break;
  573. case SSL2_ST_SEND_SERVER_VERIFY_C:
  574. str = "2SSV_C";
  575. break;
  576. case SSL2_ST_GET_CLIENT_FINISHED_A:
  577. str = "2GCF_A";
  578. break;
  579. case SSL2_ST_GET_CLIENT_FINISHED_B:
  580. str = "2GCF_B";
  581. break;
  582. case SSL2_ST_SEND_SERVER_FINISHED_A:
  583. str = "2SSF_A";
  584. break;
  585. case SSL2_ST_SEND_SERVER_FINISHED_B:
  586. str = "2SSF_B";
  587. break;
  588. case SSL2_ST_SEND_REQUEST_CERTIFICATE_A:
  589. str = "2SRC_A";
  590. break;
  591. case SSL2_ST_SEND_REQUEST_CERTIFICATE_B:
  592. str = "2SRC_B";
  593. break;
  594. case SSL2_ST_SEND_REQUEST_CERTIFICATE_C:
  595. str = "2SRC_C";
  596. break;
  597. case SSL2_ST_SEND_REQUEST_CERTIFICATE_D:
  598. str = "2SRC_D";
  599. break;
  600. case SSL2_ST_X509_GET_SERVER_CERTIFICATE:
  601. str = "2X9GSC";
  602. break;
  603. case SSL2_ST_X509_GET_CLIENT_CERTIFICATE:
  604. str = "2X9GCC";
  605. break;
  606. #endif
  607. #ifndef OPENSSL_NO_SSL3
  608. /* SSLv3 additions */
  609. case SSL3_ST_SW_FLUSH:
  610. case SSL3_ST_CW_FLUSH:
  611. str = "3FLUSH";
  612. break;
  613. case SSL3_ST_CW_CLNT_HELLO_A:
  614. str = "3WCH_A";
  615. break;
  616. case SSL3_ST_CW_CLNT_HELLO_B:
  617. str = "3WCH_B";
  618. break;
  619. case SSL3_ST_CR_SRVR_HELLO_A:
  620. str = "3RSH_A";
  621. break;
  622. case SSL3_ST_CR_SRVR_HELLO_B:
  623. str = "3RSH_B";
  624. break;
  625. case SSL3_ST_CR_CERT_A:
  626. str = "3RSC_A";
  627. break;
  628. case SSL3_ST_CR_CERT_B:
  629. str = "3RSC_B";
  630. break;
  631. case SSL3_ST_CR_KEY_EXCH_A:
  632. str = "3RSKEA";
  633. break;
  634. case SSL3_ST_CR_KEY_EXCH_B:
  635. str = "3RSKEB";
  636. break;
  637. case SSL3_ST_CR_CERT_REQ_A:
  638. str = "3RCR_A";
  639. break;
  640. case SSL3_ST_CR_CERT_REQ_B:
  641. str = "3RCR_B";
  642. break;
  643. case SSL3_ST_CR_SRVR_DONE_A:
  644. str = "3RSD_A";
  645. break;
  646. case SSL3_ST_CR_SRVR_DONE_B:
  647. str = "3RSD_B";
  648. break;
  649. case SSL3_ST_CW_CERT_A:
  650. str = "3WCC_A";
  651. break;
  652. case SSL3_ST_CW_CERT_B:
  653. str = "3WCC_B";
  654. break;
  655. case SSL3_ST_CW_CERT_C:
  656. str = "3WCC_C";
  657. break;
  658. case SSL3_ST_CW_CERT_D:
  659. str = "3WCC_D";
  660. break;
  661. case SSL3_ST_CW_KEY_EXCH_A:
  662. str = "3WCKEA";
  663. break;
  664. case SSL3_ST_CW_KEY_EXCH_B:
  665. str = "3WCKEB";
  666. break;
  667. case SSL3_ST_CW_CERT_VRFY_A:
  668. str = "3WCV_A";
  669. break;
  670. case SSL3_ST_CW_CERT_VRFY_B:
  671. str = "3WCV_B";
  672. break;
  673. case SSL3_ST_SW_CHANGE_A:
  674. case SSL3_ST_CW_CHANGE_A:
  675. str = "3WCCSA";
  676. break;
  677. case SSL3_ST_SW_CHANGE_B:
  678. case SSL3_ST_CW_CHANGE_B:
  679. str = "3WCCSB";
  680. break;
  681. case SSL3_ST_SW_FINISHED_A:
  682. case SSL3_ST_CW_FINISHED_A:
  683. str = "3WFINA";
  684. break;
  685. case SSL3_ST_SW_FINISHED_B:
  686. case SSL3_ST_CW_FINISHED_B:
  687. str = "3WFINB";
  688. break;
  689. case SSL3_ST_SR_CHANGE_A:
  690. case SSL3_ST_CR_CHANGE_A:
  691. str = "3RCCSA";
  692. break;
  693. case SSL3_ST_SR_CHANGE_B:
  694. case SSL3_ST_CR_CHANGE_B:
  695. str = "3RCCSB";
  696. break;
  697. case SSL3_ST_SR_FINISHED_A:
  698. case SSL3_ST_CR_FINISHED_A:
  699. str = "3RFINA";
  700. break;
  701. case SSL3_ST_SR_FINISHED_B:
  702. case SSL3_ST_CR_FINISHED_B:
  703. str = "3RFINB";
  704. break;
  705. case SSL3_ST_SW_HELLO_REQ_A:
  706. str = "3WHR_A";
  707. break;
  708. case SSL3_ST_SW_HELLO_REQ_B:
  709. str = "3WHR_B";
  710. break;
  711. case SSL3_ST_SW_HELLO_REQ_C:
  712. str = "3WHR_C";
  713. break;
  714. case SSL3_ST_SR_CLNT_HELLO_A:
  715. str = "3RCH_A";
  716. break;
  717. case SSL3_ST_SR_CLNT_HELLO_B:
  718. str = "3RCH_B";
  719. break;
  720. case SSL3_ST_SR_CLNT_HELLO_C:
  721. str = "3RCH_C";
  722. break;
  723. case SSL3_ST_SW_SRVR_HELLO_A:
  724. str = "3WSH_A";
  725. break;
  726. case SSL3_ST_SW_SRVR_HELLO_B:
  727. str = "3WSH_B";
  728. break;
  729. case SSL3_ST_SW_CERT_A:
  730. str = "3WSC_A";
  731. break;
  732. case SSL3_ST_SW_CERT_B:
  733. str = "3WSC_B";
  734. break;
  735. case SSL3_ST_SW_KEY_EXCH_A:
  736. str = "3WSKEA";
  737. break;
  738. case SSL3_ST_SW_KEY_EXCH_B:
  739. str = "3WSKEB";
  740. break;
  741. case SSL3_ST_SW_CERT_REQ_A:
  742. str = "3WCR_A";
  743. break;
  744. case SSL3_ST_SW_CERT_REQ_B:
  745. str = "3WCR_B";
  746. break;
  747. case SSL3_ST_SW_SRVR_DONE_A:
  748. str = "3WSD_A";
  749. break;
  750. case SSL3_ST_SW_SRVR_DONE_B:
  751. str = "3WSD_B";
  752. break;
  753. case SSL3_ST_SR_CERT_A:
  754. str = "3RCC_A";
  755. break;
  756. case SSL3_ST_SR_CERT_B:
  757. str = "3RCC_B";
  758. break;
  759. case SSL3_ST_SR_KEY_EXCH_A:
  760. str = "3RCKEA";
  761. break;
  762. case SSL3_ST_SR_KEY_EXCH_B:
  763. str = "3RCKEB";
  764. break;
  765. case SSL3_ST_SR_CERT_VRFY_A:
  766. str = "3RCV_A";
  767. break;
  768. case SSL3_ST_SR_CERT_VRFY_B:
  769. str = "3RCV_B";
  770. break;
  771. #endif
  772. /* SSLv2/v3 compatibility states */
  773. /* client */
  774. case SSL23_ST_CW_CLNT_HELLO_A:
  775. str = "23WCHA";
  776. break;
  777. case SSL23_ST_CW_CLNT_HELLO_B:
  778. str = "23WCHB";
  779. break;
  780. case SSL23_ST_CR_SRVR_HELLO_A:
  781. str = "23RSHA";
  782. break;
  783. case SSL23_ST_CR_SRVR_HELLO_B:
  784. str = "23RSHA";
  785. break;
  786. /* server */
  787. case SSL23_ST_SR_CLNT_HELLO_A:
  788. str = "23RCHA";
  789. break;
  790. case SSL23_ST_SR_CLNT_HELLO_B:
  791. str = "23RCHB";
  792. break;
  793. /* DTLS */
  794. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
  795. str = "DRCHVA";
  796. break;
  797. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
  798. str = "DRCHVB";
  799. break;
  800. case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
  801. str = "DWCHVA";
  802. break;
  803. case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
  804. str = "DWCHVB";
  805. break;
  806. default:
  807. str = "UNKWN ";
  808. break;
  809. }
  810. return (str);
  811. }
  812. const char *SSL_alert_type_string_long(int value)
  813. {
  814. value >>= 8;
  815. if (value == SSL3_AL_WARNING)
  816. return ("warning");
  817. else if (value == SSL3_AL_FATAL)
  818. return ("fatal");
  819. else
  820. return ("unknown");
  821. }
  822. const char *SSL_alert_type_string(int value)
  823. {
  824. value >>= 8;
  825. if (value == SSL3_AL_WARNING)
  826. return ("W");
  827. else if (value == SSL3_AL_FATAL)
  828. return ("F");
  829. else
  830. return ("U");
  831. }
  832. const char *SSL_alert_desc_string(int value)
  833. {
  834. const char *str;
  835. switch (value & 0xff) {
  836. case SSL3_AD_CLOSE_NOTIFY:
  837. str = "CN";
  838. break;
  839. case SSL3_AD_UNEXPECTED_MESSAGE:
  840. str = "UM";
  841. break;
  842. case SSL3_AD_BAD_RECORD_MAC:
  843. str = "BM";
  844. break;
  845. case SSL3_AD_DECOMPRESSION_FAILURE:
  846. str = "DF";
  847. break;
  848. case SSL3_AD_HANDSHAKE_FAILURE:
  849. str = "HF";
  850. break;
  851. case SSL3_AD_NO_CERTIFICATE:
  852. str = "NC";
  853. break;
  854. case SSL3_AD_BAD_CERTIFICATE:
  855. str = "BC";
  856. break;
  857. case SSL3_AD_UNSUPPORTED_CERTIFICATE:
  858. str = "UC";
  859. break;
  860. case SSL3_AD_CERTIFICATE_REVOKED:
  861. str = "CR";
  862. break;
  863. case SSL3_AD_CERTIFICATE_EXPIRED:
  864. str = "CE";
  865. break;
  866. case SSL3_AD_CERTIFICATE_UNKNOWN:
  867. str = "CU";
  868. break;
  869. case SSL3_AD_ILLEGAL_PARAMETER:
  870. str = "IP";
  871. break;
  872. case TLS1_AD_DECRYPTION_FAILED:
  873. str = "DC";
  874. break;
  875. case TLS1_AD_RECORD_OVERFLOW:
  876. str = "RO";
  877. break;
  878. case TLS1_AD_UNKNOWN_CA:
  879. str = "CA";
  880. break;
  881. case TLS1_AD_ACCESS_DENIED:
  882. str = "AD";
  883. break;
  884. case TLS1_AD_DECODE_ERROR:
  885. str = "DE";
  886. break;
  887. case TLS1_AD_DECRYPT_ERROR:
  888. str = "CY";
  889. break;
  890. case TLS1_AD_EXPORT_RESTRICTION:
  891. str = "ER";
  892. break;
  893. case TLS1_AD_PROTOCOL_VERSION:
  894. str = "PV";
  895. break;
  896. case TLS1_AD_INSUFFICIENT_SECURITY:
  897. str = "IS";
  898. break;
  899. case TLS1_AD_INTERNAL_ERROR:
  900. str = "IE";
  901. break;
  902. case TLS1_AD_USER_CANCELLED:
  903. str = "US";
  904. break;
  905. case TLS1_AD_NO_RENEGOTIATION:
  906. str = "NR";
  907. break;
  908. case TLS1_AD_UNSUPPORTED_EXTENSION:
  909. str = "UE";
  910. break;
  911. case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
  912. str = "CO";
  913. break;
  914. case TLS1_AD_UNRECOGNIZED_NAME:
  915. str = "UN";
  916. break;
  917. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
  918. str = "BR";
  919. break;
  920. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
  921. str = "BH";
  922. break;
  923. case TLS1_AD_UNKNOWN_PSK_IDENTITY:
  924. str = "UP";
  925. break;
  926. default:
  927. str = "UK";
  928. break;
  929. }
  930. return (str);
  931. }
  932. const char *SSL_alert_desc_string_long(int value)
  933. {
  934. const char *str;
  935. switch (value & 0xff) {
  936. case SSL3_AD_CLOSE_NOTIFY:
  937. str = "close notify";
  938. break;
  939. case SSL3_AD_UNEXPECTED_MESSAGE:
  940. str = "unexpected_message";
  941. break;
  942. case SSL3_AD_BAD_RECORD_MAC:
  943. str = "bad record mac";
  944. break;
  945. case SSL3_AD_DECOMPRESSION_FAILURE:
  946. str = "decompression failure";
  947. break;
  948. case SSL3_AD_HANDSHAKE_FAILURE:
  949. str = "handshake failure";
  950. break;
  951. case SSL3_AD_NO_CERTIFICATE:
  952. str = "no certificate";
  953. break;
  954. case SSL3_AD_BAD_CERTIFICATE:
  955. str = "bad certificate";
  956. break;
  957. case SSL3_AD_UNSUPPORTED_CERTIFICATE:
  958. str = "unsupported certificate";
  959. break;
  960. case SSL3_AD_CERTIFICATE_REVOKED:
  961. str = "certificate revoked";
  962. break;
  963. case SSL3_AD_CERTIFICATE_EXPIRED:
  964. str = "certificate expired";
  965. break;
  966. case SSL3_AD_CERTIFICATE_UNKNOWN:
  967. str = "certificate unknown";
  968. break;
  969. case SSL3_AD_ILLEGAL_PARAMETER:
  970. str = "illegal parameter";
  971. break;
  972. case TLS1_AD_DECRYPTION_FAILED:
  973. str = "decryption failed";
  974. break;
  975. case TLS1_AD_RECORD_OVERFLOW:
  976. str = "record overflow";
  977. break;
  978. case TLS1_AD_UNKNOWN_CA:
  979. str = "unknown CA";
  980. break;
  981. case TLS1_AD_ACCESS_DENIED:
  982. str = "access denied";
  983. break;
  984. case TLS1_AD_DECODE_ERROR:
  985. str = "decode error";
  986. break;
  987. case TLS1_AD_DECRYPT_ERROR:
  988. str = "decrypt error";
  989. break;
  990. case TLS1_AD_EXPORT_RESTRICTION:
  991. str = "export restriction";
  992. break;
  993. case TLS1_AD_PROTOCOL_VERSION:
  994. str = "protocol version";
  995. break;
  996. case TLS1_AD_INSUFFICIENT_SECURITY:
  997. str = "insufficient security";
  998. break;
  999. case TLS1_AD_INTERNAL_ERROR:
  1000. str = "internal error";
  1001. break;
  1002. case TLS1_AD_USER_CANCELLED:
  1003. str = "user canceled";
  1004. break;
  1005. case TLS1_AD_NO_RENEGOTIATION:
  1006. str = "no renegotiation";
  1007. break;
  1008. case TLS1_AD_UNSUPPORTED_EXTENSION:
  1009. str = "unsupported extension";
  1010. break;
  1011. case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
  1012. str = "certificate unobtainable";
  1013. break;
  1014. case TLS1_AD_UNRECOGNIZED_NAME:
  1015. str = "unrecognized name";
  1016. break;
  1017. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
  1018. str = "bad certificate status response";
  1019. break;
  1020. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
  1021. str = "bad certificate hash value";
  1022. break;
  1023. case TLS1_AD_UNKNOWN_PSK_IDENTITY:
  1024. str = "unknown PSK identity";
  1025. break;
  1026. default:
  1027. str = "unknown";
  1028. break;
  1029. }
  1030. return (str);
  1031. }
  1032. const char *SSL_rstate_string(const SSL *s)
  1033. {
  1034. const char *str;
  1035. switch (s->rstate) {
  1036. case SSL_ST_READ_HEADER:
  1037. str = "RH";
  1038. break;
  1039. case SSL_ST_READ_BODY:
  1040. str = "RB";
  1041. break;
  1042. case SSL_ST_READ_DONE:
  1043. str = "RD";
  1044. break;
  1045. default:
  1046. str = "unknown";
  1047. break;
  1048. }
  1049. return (str);
  1050. }