You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ssl_stat.c 22 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  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 "internal.h"
  86. const char *SSL_state_string_long(const SSL *s) {
  87. const char *str;
  88. switch (s->state) {
  89. case SSL_ST_ACCEPT:
  90. str = "before accept initialization";
  91. break;
  92. case SSL_ST_CONNECT:
  93. str = "before connect initialization";
  94. break;
  95. case SSL_ST_OK:
  96. str = "SSL negotiation finished successfully";
  97. break;
  98. case SSL_ST_RENEGOTIATE:
  99. str = "SSL renegotiate ciphers";
  100. break;
  101. /* SSLv3 additions */
  102. case SSL3_ST_CW_CLNT_HELLO_A:
  103. str = "SSLv3 write client hello A";
  104. break;
  105. case SSL3_ST_CW_CLNT_HELLO_B:
  106. str = "SSLv3 write client hello B";
  107. break;
  108. case SSL3_ST_CR_SRVR_HELLO_A:
  109. str = "SSLv3 read server hello A";
  110. break;
  111. case SSL3_ST_CR_SRVR_HELLO_B:
  112. str = "SSLv3 read server hello B";
  113. break;
  114. case SSL3_ST_CR_CERT_A:
  115. str = "SSLv3 read server certificate A";
  116. break;
  117. case SSL3_ST_CR_CERT_B:
  118. str = "SSLv3 read server certificate B";
  119. break;
  120. case SSL3_ST_CR_KEY_EXCH_A:
  121. str = "SSLv3 read server key exchange A";
  122. break;
  123. case SSL3_ST_CR_KEY_EXCH_B:
  124. str = "SSLv3 read server key exchange B";
  125. break;
  126. case SSL3_ST_CR_CERT_REQ_A:
  127. str = "SSLv3 read server certificate request A";
  128. break;
  129. case SSL3_ST_CR_CERT_REQ_B:
  130. str = "SSLv3 read server certificate request B";
  131. break;
  132. case SSL3_ST_CR_SESSION_TICKET_A:
  133. str = "SSLv3 read server session ticket A";
  134. break;
  135. case SSL3_ST_CR_SESSION_TICKET_B:
  136. str = "SSLv3 read server session ticket B";
  137. break;
  138. case SSL3_ST_CR_SRVR_DONE_A:
  139. str = "SSLv3 read server done A";
  140. break;
  141. case SSL3_ST_CR_SRVR_DONE_B:
  142. str = "SSLv3 read server done B";
  143. break;
  144. case SSL3_ST_CW_CERT_A:
  145. str = "SSLv3 write client certificate A";
  146. break;
  147. case SSL3_ST_CW_CERT_B:
  148. str = "SSLv3 write client certificate B";
  149. break;
  150. case SSL3_ST_CW_CERT_C:
  151. str = "SSLv3 write client certificate C";
  152. break;
  153. case SSL3_ST_CW_CERT_D:
  154. str = "SSLv3 write client certificate D";
  155. break;
  156. case SSL3_ST_CW_KEY_EXCH_A:
  157. str = "SSLv3 write client key exchange A";
  158. break;
  159. case SSL3_ST_CW_KEY_EXCH_B:
  160. str = "SSLv3 write client key exchange B";
  161. break;
  162. case SSL3_ST_CW_CERT_VRFY_A:
  163. str = "SSLv3 write certificate verify A";
  164. break;
  165. case SSL3_ST_CW_CERT_VRFY_B:
  166. str = "SSLv3 write certificate verify B";
  167. break;
  168. case SSL3_ST_CW_CHANGE_A:
  169. case SSL3_ST_SW_CHANGE_A:
  170. str = "SSLv3 write change cipher spec A";
  171. break;
  172. case SSL3_ST_CW_CHANGE_B:
  173. case SSL3_ST_SW_CHANGE_B:
  174. str = "SSLv3 write change cipher spec B";
  175. break;
  176. case SSL3_ST_CW_FINISHED_A:
  177. case SSL3_ST_SW_FINISHED_A:
  178. str = "SSLv3 write finished A";
  179. break;
  180. case SSL3_ST_CW_FINISHED_B:
  181. case SSL3_ST_SW_FINISHED_B:
  182. str = "SSLv3 write finished B";
  183. break;
  184. case SSL3_ST_CR_CHANGE:
  185. case SSL3_ST_SR_CHANGE:
  186. str = "SSLv3 read change cipher spec";
  187. break;
  188. case SSL3_ST_CR_FINISHED_A:
  189. case SSL3_ST_SR_FINISHED_A:
  190. str = "SSLv3 read finished A";
  191. break;
  192. case SSL3_ST_CR_FINISHED_B:
  193. case SSL3_ST_SR_FINISHED_B:
  194. str = "SSLv3 read finished B";
  195. break;
  196. case SSL3_ST_CW_FLUSH:
  197. case SSL3_ST_SW_FLUSH:
  198. str = "SSLv3 flush data";
  199. break;
  200. case SSL3_ST_SR_CLNT_HELLO_A:
  201. str = "SSLv3 read client hello A";
  202. break;
  203. case SSL3_ST_SR_CLNT_HELLO_B:
  204. str = "SSLv3 read client hello B";
  205. break;
  206. case SSL3_ST_SR_CLNT_HELLO_C:
  207. str = "SSLv3 read client hello C";
  208. break;
  209. case SSL3_ST_SR_CLNT_HELLO_D:
  210. str = "SSLv3 read client hello D";
  211. break;
  212. case SSL3_ST_SW_HELLO_REQ_A:
  213. str = "SSLv3 write hello request A";
  214. break;
  215. case SSL3_ST_SW_HELLO_REQ_B:
  216. str = "SSLv3 write hello request B";
  217. break;
  218. case SSL3_ST_SW_HELLO_REQ_C:
  219. str = "SSLv3 write hello request C";
  220. break;
  221. case SSL3_ST_SW_SRVR_HELLO_A:
  222. str = "SSLv3 write server hello A";
  223. break;
  224. case SSL3_ST_SW_SRVR_HELLO_B:
  225. str = "SSLv3 write server hello B";
  226. break;
  227. case SSL3_ST_SW_CERT_A:
  228. str = "SSLv3 write certificate A";
  229. break;
  230. case SSL3_ST_SW_CERT_B:
  231. str = "SSLv3 write certificate B";
  232. break;
  233. case SSL3_ST_SW_KEY_EXCH_A:
  234. str = "SSLv3 write key exchange A";
  235. break;
  236. case SSL3_ST_SW_KEY_EXCH_B:
  237. str = "SSLv3 write key exchange B";
  238. break;
  239. case SSL3_ST_SW_CERT_REQ_A:
  240. str = "SSLv3 write certificate request A";
  241. break;
  242. case SSL3_ST_SW_CERT_REQ_B:
  243. str = "SSLv3 write certificate request B";
  244. break;
  245. case SSL3_ST_SW_SESSION_TICKET_A:
  246. str = "SSLv3 write session ticket A";
  247. break;
  248. case SSL3_ST_SW_SESSION_TICKET_B:
  249. str = "SSLv3 write session ticket B";
  250. break;
  251. case SSL3_ST_SW_SRVR_DONE_A:
  252. str = "SSLv3 write server done A";
  253. break;
  254. case SSL3_ST_SW_SRVR_DONE_B:
  255. str = "SSLv3 write server done B";
  256. break;
  257. case SSL3_ST_SR_CERT_A:
  258. str = "SSLv3 read client certificate A";
  259. break;
  260. case SSL3_ST_SR_CERT_B:
  261. str = "SSLv3 read client certificate B";
  262. break;
  263. case SSL3_ST_SR_KEY_EXCH_A:
  264. str = "SSLv3 read client key exchange A";
  265. break;
  266. case SSL3_ST_SR_KEY_EXCH_B:
  267. str = "SSLv3 read client key exchange B";
  268. break;
  269. case SSL3_ST_SR_CERT_VRFY_A:
  270. str = "SSLv3 read certificate verify A";
  271. break;
  272. case SSL3_ST_SR_CERT_VRFY_B:
  273. str = "SSLv3 read certificate verify B";
  274. break;
  275. /* SSLv2/v3 compatibility states */
  276. /* client */
  277. case SSL23_ST_CW_CLNT_HELLO_A:
  278. str = "SSLv2/v3 write client hello A";
  279. break;
  280. case SSL23_ST_CW_CLNT_HELLO_B:
  281. str = "SSLv2/v3 write client hello B";
  282. break;
  283. case SSL23_ST_CR_SRVR_HELLO_A:
  284. str = "SSLv2/v3 read server hello A";
  285. break;
  286. case SSL23_ST_CR_SRVR_HELLO_B:
  287. str = "SSLv2/v3 read server hello B";
  288. break;
  289. /* server */
  290. case SSL23_ST_SR_CLNT_HELLO:
  291. str = "SSLv2/v3 read client hello";
  292. break;
  293. case SSL23_ST_SR_V2_CLNT_HELLO:
  294. str = "SSLv2/v3 read v2 client hello";
  295. break;
  296. case SSL23_ST_SR_SWITCH_VERSION:
  297. str = "SSLv2/v3 switch version";
  298. break;
  299. /* DTLS */
  300. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
  301. str = "DTLS1 read hello verify request A";
  302. break;
  303. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
  304. str = "DTLS1 read hello verify request B";
  305. break;
  306. default:
  307. str = "unknown state";
  308. break;
  309. }
  310. return str;
  311. }
  312. const char *SSL_rstate_string_long(const SSL *s) {
  313. const char *str;
  314. switch (s->rstate) {
  315. case SSL_ST_READ_HEADER:
  316. str = "read header";
  317. break;
  318. case SSL_ST_READ_BODY:
  319. str = "read body";
  320. break;
  321. case SSL_ST_READ_DONE:
  322. str = "read done";
  323. break;
  324. default:
  325. str = "unknown";
  326. break;
  327. }
  328. return str;
  329. }
  330. const char *SSL_state_string(const SSL *s) {
  331. const char *str;
  332. switch (s->state) {
  333. case SSL_ST_ACCEPT:
  334. str = "AINIT ";
  335. break;
  336. case SSL_ST_CONNECT:
  337. str = "CINIT ";
  338. break;
  339. case SSL_ST_OK:
  340. str = "SSLOK ";
  341. break;
  342. /* SSLv3 additions */
  343. case SSL3_ST_SW_FLUSH:
  344. case SSL3_ST_CW_FLUSH:
  345. str = "3FLUSH";
  346. break;
  347. case SSL3_ST_CW_CLNT_HELLO_A:
  348. str = "3WCH_A";
  349. break;
  350. case SSL3_ST_CW_CLNT_HELLO_B:
  351. str = "3WCH_B";
  352. break;
  353. case SSL3_ST_CR_SRVR_HELLO_A:
  354. str = "3RSH_A";
  355. break;
  356. case SSL3_ST_CR_SRVR_HELLO_B:
  357. str = "3RSH_B";
  358. break;
  359. case SSL3_ST_CR_CERT_A:
  360. str = "3RSC_A";
  361. break;
  362. case SSL3_ST_CR_CERT_B:
  363. str = "3RSC_B";
  364. break;
  365. case SSL3_ST_CR_KEY_EXCH_A:
  366. str = "3RSKEA";
  367. break;
  368. case SSL3_ST_CR_KEY_EXCH_B:
  369. str = "3RSKEB";
  370. break;
  371. case SSL3_ST_CR_CERT_REQ_A:
  372. str = "3RCR_A";
  373. break;
  374. case SSL3_ST_CR_CERT_REQ_B:
  375. str = "3RCR_B";
  376. break;
  377. case SSL3_ST_CR_SRVR_DONE_A:
  378. str = "3RSD_A";
  379. break;
  380. case SSL3_ST_CR_SRVR_DONE_B:
  381. str = "3RSD_B";
  382. break;
  383. case SSL3_ST_CW_CERT_A:
  384. str = "3WCC_A";
  385. break;
  386. case SSL3_ST_CW_CERT_B:
  387. str = "3WCC_B";
  388. break;
  389. case SSL3_ST_CW_CERT_C:
  390. str = "3WCC_C";
  391. break;
  392. case SSL3_ST_CW_CERT_D:
  393. str = "3WCC_D";
  394. break;
  395. case SSL3_ST_CW_KEY_EXCH_A:
  396. str = "3WCKEA";
  397. break;
  398. case SSL3_ST_CW_KEY_EXCH_B:
  399. str = "3WCKEB";
  400. break;
  401. case SSL3_ST_CW_CERT_VRFY_A:
  402. str = "3WCV_A";
  403. break;
  404. case SSL3_ST_CW_CERT_VRFY_B:
  405. str = "3WCV_B";
  406. break;
  407. case SSL3_ST_SW_CHANGE_A:
  408. case SSL3_ST_CW_CHANGE_A:
  409. str = "3WCCSA";
  410. break;
  411. case SSL3_ST_SW_CHANGE_B:
  412. case SSL3_ST_CW_CHANGE_B:
  413. str = "3WCCSB";
  414. break;
  415. case SSL3_ST_SW_FINISHED_A:
  416. case SSL3_ST_CW_FINISHED_A:
  417. str = "3WFINA";
  418. break;
  419. case SSL3_ST_SW_FINISHED_B:
  420. case SSL3_ST_CW_FINISHED_B:
  421. str = "3WFINB";
  422. break;
  423. case SSL3_ST_CR_CHANGE:
  424. case SSL3_ST_SR_CHANGE:
  425. str = "3RCCS_";
  426. break;
  427. case SSL3_ST_SR_FINISHED_A:
  428. case SSL3_ST_CR_FINISHED_A:
  429. str = "3RFINA";
  430. break;
  431. case SSL3_ST_SR_FINISHED_B:
  432. case SSL3_ST_CR_FINISHED_B:
  433. str = "3RFINB";
  434. break;
  435. case SSL3_ST_SW_HELLO_REQ_A:
  436. str = "3WHR_A";
  437. break;
  438. case SSL3_ST_SW_HELLO_REQ_B:
  439. str = "3WHR_B";
  440. break;
  441. case SSL3_ST_SW_HELLO_REQ_C:
  442. str = "3WHR_C";
  443. break;
  444. case SSL3_ST_SR_CLNT_HELLO_A:
  445. str = "3RCH_A";
  446. break;
  447. case SSL3_ST_SR_CLNT_HELLO_B:
  448. str = "3RCH_B";
  449. break;
  450. case SSL3_ST_SR_CLNT_HELLO_C:
  451. str = "3RCH_C";
  452. break;
  453. case SSL3_ST_SR_CLNT_HELLO_D:
  454. str = "3RCH_D";
  455. break;
  456. case SSL3_ST_SW_SRVR_HELLO_A:
  457. str = "3WSH_A";
  458. break;
  459. case SSL3_ST_SW_SRVR_HELLO_B:
  460. str = "3WSH_B";
  461. break;
  462. case SSL3_ST_SW_CERT_A:
  463. str = "3WSC_A";
  464. break;
  465. case SSL3_ST_SW_CERT_B:
  466. str = "3WSC_B";
  467. break;
  468. case SSL3_ST_SW_KEY_EXCH_A:
  469. str = "3WSKEA";
  470. break;
  471. case SSL3_ST_SW_KEY_EXCH_B:
  472. str = "3WSKEB";
  473. break;
  474. case SSL3_ST_SW_CERT_REQ_A:
  475. str = "3WCR_A";
  476. break;
  477. case SSL3_ST_SW_CERT_REQ_B:
  478. str = "3WCR_B";
  479. break;
  480. case SSL3_ST_SW_SRVR_DONE_A:
  481. str = "3WSD_A";
  482. break;
  483. case SSL3_ST_SW_SRVR_DONE_B:
  484. str = "3WSD_B";
  485. break;
  486. case SSL3_ST_SR_CERT_A:
  487. str = "3RCC_A";
  488. break;
  489. case SSL3_ST_SR_CERT_B:
  490. str = "3RCC_B";
  491. break;
  492. case SSL3_ST_SR_KEY_EXCH_A:
  493. str = "3RCKEA";
  494. break;
  495. case SSL3_ST_SR_KEY_EXCH_B:
  496. str = "3RCKEB";
  497. break;
  498. case SSL3_ST_SR_CERT_VRFY_A:
  499. str = "3RCV_A";
  500. break;
  501. case SSL3_ST_SR_CERT_VRFY_B:
  502. str = "3RCV_B";
  503. break;
  504. /* SSLv2/v3 compatibility states */
  505. /* client */
  506. case SSL23_ST_CW_CLNT_HELLO_A:
  507. str = "23WCHA";
  508. break;
  509. case SSL23_ST_CW_CLNT_HELLO_B:
  510. str = "23WCHB";
  511. break;
  512. case SSL23_ST_CR_SRVR_HELLO_A:
  513. str = "23RSHA";
  514. break;
  515. case SSL23_ST_CR_SRVR_HELLO_B:
  516. str = "23RSHA";
  517. break;
  518. /* server */
  519. case SSL23_ST_SR_CLNT_HELLO:
  520. str = "23RCH_";
  521. break;
  522. case SSL23_ST_SR_V2_CLNT_HELLO:
  523. str = "23R2CH";
  524. break;
  525. case SSL23_ST_SR_SWITCH_VERSION:
  526. str = "23RSW_";
  527. break;
  528. /* DTLS */
  529. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
  530. str = "DRCHVA";
  531. break;
  532. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
  533. str = "DRCHVB";
  534. break;
  535. default:
  536. str = "UNKWN ";
  537. break;
  538. }
  539. return str;
  540. }
  541. const char *SSL_alert_type_string_long(int value) {
  542. value >>= 8;
  543. if (value == SSL3_AL_WARNING) {
  544. return "warning";
  545. } else if (value == SSL3_AL_FATAL) {
  546. return "fatal";
  547. }
  548. return "unknown";
  549. }
  550. const char *SSL_alert_type_string(int value) {
  551. value >>= 8;
  552. if (value == SSL3_AL_WARNING) {
  553. return "W";
  554. } else if (value == SSL3_AL_FATAL) {
  555. return "F";
  556. }
  557. return "U";
  558. }
  559. const char *SSL_alert_desc_string(int value) {
  560. const char *str;
  561. switch (value & 0xff) {
  562. case SSL3_AD_CLOSE_NOTIFY:
  563. str = "CN";
  564. break;
  565. case SSL3_AD_UNEXPECTED_MESSAGE:
  566. str = "UM";
  567. break;
  568. case SSL3_AD_BAD_RECORD_MAC:
  569. str = "BM";
  570. break;
  571. case SSL3_AD_DECOMPRESSION_FAILURE:
  572. str = "DF";
  573. break;
  574. case SSL3_AD_HANDSHAKE_FAILURE:
  575. str = "HF";
  576. break;
  577. case SSL3_AD_NO_CERTIFICATE:
  578. str = "NC";
  579. break;
  580. case SSL3_AD_BAD_CERTIFICATE:
  581. str = "BC";
  582. break;
  583. case SSL3_AD_UNSUPPORTED_CERTIFICATE:
  584. str = "UC";
  585. break;
  586. case SSL3_AD_CERTIFICATE_REVOKED:
  587. str = "CR";
  588. break;
  589. case SSL3_AD_CERTIFICATE_EXPIRED:
  590. str = "CE";
  591. break;
  592. case SSL3_AD_CERTIFICATE_UNKNOWN:
  593. str = "CU";
  594. break;
  595. case SSL3_AD_ILLEGAL_PARAMETER:
  596. str = "IP";
  597. break;
  598. case TLS1_AD_DECRYPTION_FAILED:
  599. str = "DC";
  600. break;
  601. case TLS1_AD_RECORD_OVERFLOW:
  602. str = "RO";
  603. break;
  604. case TLS1_AD_UNKNOWN_CA:
  605. str = "CA";
  606. break;
  607. case TLS1_AD_ACCESS_DENIED:
  608. str = "AD";
  609. break;
  610. case TLS1_AD_DECODE_ERROR:
  611. str = "DE";
  612. break;
  613. case TLS1_AD_DECRYPT_ERROR:
  614. str = "CY";
  615. break;
  616. case TLS1_AD_EXPORT_RESTRICTION:
  617. str = "ER";
  618. break;
  619. case TLS1_AD_PROTOCOL_VERSION:
  620. str = "PV";
  621. break;
  622. case TLS1_AD_INSUFFICIENT_SECURITY:
  623. str = "IS";
  624. break;
  625. case TLS1_AD_INTERNAL_ERROR:
  626. str = "IE";
  627. break;
  628. case TLS1_AD_USER_CANCELLED:
  629. str = "US";
  630. break;
  631. case TLS1_AD_NO_RENEGOTIATION:
  632. str = "NR";
  633. break;
  634. case TLS1_AD_UNSUPPORTED_EXTENSION:
  635. str = "UE";
  636. break;
  637. case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
  638. str = "CO";
  639. break;
  640. case TLS1_AD_UNRECOGNIZED_NAME:
  641. str = "UN";
  642. break;
  643. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
  644. str = "BR";
  645. break;
  646. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
  647. str = "BH";
  648. break;
  649. case TLS1_AD_UNKNOWN_PSK_IDENTITY:
  650. str = "UP";
  651. break;
  652. default:
  653. str = "UK";
  654. break;
  655. }
  656. return str;
  657. }
  658. const char *SSL_alert_desc_string_long(int value) {
  659. const char *str;
  660. switch (value & 0xff) {
  661. case SSL3_AD_CLOSE_NOTIFY:
  662. str = "close notify";
  663. break;
  664. case SSL3_AD_UNEXPECTED_MESSAGE:
  665. str = "unexpected_message";
  666. break;
  667. case SSL3_AD_BAD_RECORD_MAC:
  668. str = "bad record mac";
  669. break;
  670. case SSL3_AD_DECOMPRESSION_FAILURE:
  671. str = "decompression failure";
  672. break;
  673. case SSL3_AD_HANDSHAKE_FAILURE:
  674. str = "handshake failure";
  675. break;
  676. case SSL3_AD_NO_CERTIFICATE:
  677. str = "no certificate";
  678. break;
  679. case SSL3_AD_BAD_CERTIFICATE:
  680. str = "bad certificate";
  681. break;
  682. case SSL3_AD_UNSUPPORTED_CERTIFICATE:
  683. str = "unsupported certificate";
  684. break;
  685. case SSL3_AD_CERTIFICATE_REVOKED:
  686. str = "certificate revoked";
  687. break;
  688. case SSL3_AD_CERTIFICATE_EXPIRED:
  689. str = "certificate expired";
  690. break;
  691. case SSL3_AD_CERTIFICATE_UNKNOWN:
  692. str = "certificate unknown";
  693. break;
  694. case SSL3_AD_ILLEGAL_PARAMETER:
  695. str = "illegal parameter";
  696. break;
  697. case TLS1_AD_DECRYPTION_FAILED:
  698. str = "decryption failed";
  699. break;
  700. case TLS1_AD_RECORD_OVERFLOW:
  701. str = "record overflow";
  702. break;
  703. case TLS1_AD_UNKNOWN_CA:
  704. str = "unknown CA";
  705. break;
  706. case TLS1_AD_ACCESS_DENIED:
  707. str = "access denied";
  708. break;
  709. case TLS1_AD_DECODE_ERROR:
  710. str = "decode error";
  711. break;
  712. case TLS1_AD_DECRYPT_ERROR:
  713. str = "decrypt error";
  714. break;
  715. case TLS1_AD_EXPORT_RESTRICTION:
  716. str = "export restriction";
  717. break;
  718. case TLS1_AD_PROTOCOL_VERSION:
  719. str = "protocol version";
  720. break;
  721. case TLS1_AD_INSUFFICIENT_SECURITY:
  722. str = "insufficient security";
  723. break;
  724. case TLS1_AD_INTERNAL_ERROR:
  725. str = "internal error";
  726. break;
  727. case TLS1_AD_USER_CANCELLED:
  728. str = "user canceled";
  729. break;
  730. case TLS1_AD_NO_RENEGOTIATION:
  731. str = "no renegotiation";
  732. break;
  733. case TLS1_AD_UNSUPPORTED_EXTENSION:
  734. str = "unsupported extension";
  735. break;
  736. case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
  737. str = "certificate unobtainable";
  738. break;
  739. case TLS1_AD_UNRECOGNIZED_NAME:
  740. str = "unrecognized name";
  741. break;
  742. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
  743. str = "bad certificate status response";
  744. break;
  745. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
  746. str = "bad certificate hash value";
  747. break;
  748. case TLS1_AD_UNKNOWN_PSK_IDENTITY:
  749. str = "unknown PSK identity";
  750. break;
  751. default:
  752. str = "unknown";
  753. break;
  754. }
  755. return str;
  756. }
  757. const char *SSL_rstate_string(const SSL *s) {
  758. const char *str;
  759. switch (s->rstate) {
  760. case SSL_ST_READ_HEADER:
  761. str = "RH";
  762. break;
  763. case SSL_ST_READ_BODY:
  764. str = "RB";
  765. break;
  766. case SSL_ST_READ_DONE:
  767. str = "RD";
  768. break;
  769. default:
  770. str = "unknown";
  771. break;
  772. }
  773. return str;
  774. }