Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

ssl_stat.c 20 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  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. /* DTLS */
  276. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
  277. str = "DTLS1 read hello verify request A";
  278. break;
  279. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
  280. str = "DTLS1 read hello verify request B";
  281. break;
  282. default:
  283. str = "unknown state";
  284. break;
  285. }
  286. return str;
  287. }
  288. const char *SSL_rstate_string_long(const SSL *s) {
  289. const char *str;
  290. switch (s->rstate) {
  291. case SSL_ST_READ_HEADER:
  292. str = "read header";
  293. break;
  294. case SSL_ST_READ_BODY:
  295. str = "read body";
  296. break;
  297. case SSL_ST_READ_DONE:
  298. str = "read done";
  299. break;
  300. default:
  301. str = "unknown";
  302. break;
  303. }
  304. return str;
  305. }
  306. const char *SSL_state_string(const SSL *s) {
  307. const char *str;
  308. switch (s->state) {
  309. case SSL_ST_ACCEPT:
  310. str = "AINIT ";
  311. break;
  312. case SSL_ST_CONNECT:
  313. str = "CINIT ";
  314. break;
  315. case SSL_ST_OK:
  316. str = "SSLOK ";
  317. break;
  318. /* SSLv3 additions */
  319. case SSL3_ST_SW_FLUSH:
  320. case SSL3_ST_CW_FLUSH:
  321. str = "3FLUSH";
  322. break;
  323. case SSL3_ST_CW_CLNT_HELLO_A:
  324. str = "3WCH_A";
  325. break;
  326. case SSL3_ST_CW_CLNT_HELLO_B:
  327. str = "3WCH_B";
  328. break;
  329. case SSL3_ST_CR_SRVR_HELLO_A:
  330. str = "3RSH_A";
  331. break;
  332. case SSL3_ST_CR_SRVR_HELLO_B:
  333. str = "3RSH_B";
  334. break;
  335. case SSL3_ST_CR_CERT_A:
  336. str = "3RSC_A";
  337. break;
  338. case SSL3_ST_CR_CERT_B:
  339. str = "3RSC_B";
  340. break;
  341. case SSL3_ST_CR_KEY_EXCH_A:
  342. str = "3RSKEA";
  343. break;
  344. case SSL3_ST_CR_KEY_EXCH_B:
  345. str = "3RSKEB";
  346. break;
  347. case SSL3_ST_CR_CERT_REQ_A:
  348. str = "3RCR_A";
  349. break;
  350. case SSL3_ST_CR_CERT_REQ_B:
  351. str = "3RCR_B";
  352. break;
  353. case SSL3_ST_CR_SRVR_DONE_A:
  354. str = "3RSD_A";
  355. break;
  356. case SSL3_ST_CR_SRVR_DONE_B:
  357. str = "3RSD_B";
  358. break;
  359. case SSL3_ST_CW_CERT_A:
  360. str = "3WCC_A";
  361. break;
  362. case SSL3_ST_CW_CERT_B:
  363. str = "3WCC_B";
  364. break;
  365. case SSL3_ST_CW_CERT_C:
  366. str = "3WCC_C";
  367. break;
  368. case SSL3_ST_CW_CERT_D:
  369. str = "3WCC_D";
  370. break;
  371. case SSL3_ST_CW_KEY_EXCH_A:
  372. str = "3WCKEA";
  373. break;
  374. case SSL3_ST_CW_KEY_EXCH_B:
  375. str = "3WCKEB";
  376. break;
  377. case SSL3_ST_CW_CERT_VRFY_A:
  378. str = "3WCV_A";
  379. break;
  380. case SSL3_ST_CW_CERT_VRFY_B:
  381. str = "3WCV_B";
  382. break;
  383. case SSL3_ST_SW_CHANGE_A:
  384. case SSL3_ST_CW_CHANGE_A:
  385. str = "3WCCSA";
  386. break;
  387. case SSL3_ST_SW_CHANGE_B:
  388. case SSL3_ST_CW_CHANGE_B:
  389. str = "3WCCSB";
  390. break;
  391. case SSL3_ST_SW_FINISHED_A:
  392. case SSL3_ST_CW_FINISHED_A:
  393. str = "3WFINA";
  394. break;
  395. case SSL3_ST_SW_FINISHED_B:
  396. case SSL3_ST_CW_FINISHED_B:
  397. str = "3WFINB";
  398. break;
  399. case SSL3_ST_CR_CHANGE:
  400. case SSL3_ST_SR_CHANGE:
  401. str = "3RCCS_";
  402. break;
  403. case SSL3_ST_SR_FINISHED_A:
  404. case SSL3_ST_CR_FINISHED_A:
  405. str = "3RFINA";
  406. break;
  407. case SSL3_ST_SR_FINISHED_B:
  408. case SSL3_ST_CR_FINISHED_B:
  409. str = "3RFINB";
  410. break;
  411. case SSL3_ST_SW_HELLO_REQ_A:
  412. str = "3WHR_A";
  413. break;
  414. case SSL3_ST_SW_HELLO_REQ_B:
  415. str = "3WHR_B";
  416. break;
  417. case SSL3_ST_SW_HELLO_REQ_C:
  418. str = "3WHR_C";
  419. break;
  420. case SSL3_ST_SR_CLNT_HELLO_A:
  421. str = "3RCH_A";
  422. break;
  423. case SSL3_ST_SR_CLNT_HELLO_B:
  424. str = "3RCH_B";
  425. break;
  426. case SSL3_ST_SR_CLNT_HELLO_C:
  427. str = "3RCH_C";
  428. break;
  429. case SSL3_ST_SR_CLNT_HELLO_D:
  430. str = "3RCH_D";
  431. break;
  432. case SSL3_ST_SW_SRVR_HELLO_A:
  433. str = "3WSH_A";
  434. break;
  435. case SSL3_ST_SW_SRVR_HELLO_B:
  436. str = "3WSH_B";
  437. break;
  438. case SSL3_ST_SW_CERT_A:
  439. str = "3WSC_A";
  440. break;
  441. case SSL3_ST_SW_CERT_B:
  442. str = "3WSC_B";
  443. break;
  444. case SSL3_ST_SW_KEY_EXCH_A:
  445. str = "3WSKEA";
  446. break;
  447. case SSL3_ST_SW_KEY_EXCH_B:
  448. str = "3WSKEB";
  449. break;
  450. case SSL3_ST_SW_CERT_REQ_A:
  451. str = "3WCR_A";
  452. break;
  453. case SSL3_ST_SW_CERT_REQ_B:
  454. str = "3WCR_B";
  455. break;
  456. case SSL3_ST_SW_SRVR_DONE_A:
  457. str = "3WSD_A";
  458. break;
  459. case SSL3_ST_SW_SRVR_DONE_B:
  460. str = "3WSD_B";
  461. break;
  462. case SSL3_ST_SR_CERT_A:
  463. str = "3RCC_A";
  464. break;
  465. case SSL3_ST_SR_CERT_B:
  466. str = "3RCC_B";
  467. break;
  468. case SSL3_ST_SR_KEY_EXCH_A:
  469. str = "3RCKEA";
  470. break;
  471. case SSL3_ST_SR_KEY_EXCH_B:
  472. str = "3RCKEB";
  473. break;
  474. case SSL3_ST_SR_CERT_VRFY_A:
  475. str = "3RCV_A";
  476. break;
  477. case SSL3_ST_SR_CERT_VRFY_B:
  478. str = "3RCV_B";
  479. break;
  480. /* DTLS */
  481. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
  482. str = "DRCHVA";
  483. break;
  484. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
  485. str = "DRCHVB";
  486. break;
  487. default:
  488. str = "UNKWN ";
  489. break;
  490. }
  491. return str;
  492. }
  493. const char *SSL_alert_type_string_long(int value) {
  494. value >>= 8;
  495. if (value == SSL3_AL_WARNING) {
  496. return "warning";
  497. } else if (value == SSL3_AL_FATAL) {
  498. return "fatal";
  499. }
  500. return "unknown";
  501. }
  502. const char *SSL_alert_type_string(int value) {
  503. value >>= 8;
  504. if (value == SSL3_AL_WARNING) {
  505. return "W";
  506. } else if (value == SSL3_AL_FATAL) {
  507. return "F";
  508. }
  509. return "U";
  510. }
  511. const char *SSL_alert_desc_string(int value) {
  512. const char *str;
  513. switch (value & 0xff) {
  514. case SSL3_AD_CLOSE_NOTIFY:
  515. str = "CN";
  516. break;
  517. case SSL3_AD_UNEXPECTED_MESSAGE:
  518. str = "UM";
  519. break;
  520. case SSL3_AD_BAD_RECORD_MAC:
  521. str = "BM";
  522. break;
  523. case SSL3_AD_DECOMPRESSION_FAILURE:
  524. str = "DF";
  525. break;
  526. case SSL3_AD_HANDSHAKE_FAILURE:
  527. str = "HF";
  528. break;
  529. case SSL3_AD_NO_CERTIFICATE:
  530. str = "NC";
  531. break;
  532. case SSL3_AD_BAD_CERTIFICATE:
  533. str = "BC";
  534. break;
  535. case SSL3_AD_UNSUPPORTED_CERTIFICATE:
  536. str = "UC";
  537. break;
  538. case SSL3_AD_CERTIFICATE_REVOKED:
  539. str = "CR";
  540. break;
  541. case SSL3_AD_CERTIFICATE_EXPIRED:
  542. str = "CE";
  543. break;
  544. case SSL3_AD_CERTIFICATE_UNKNOWN:
  545. str = "CU";
  546. break;
  547. case SSL3_AD_ILLEGAL_PARAMETER:
  548. str = "IP";
  549. break;
  550. case TLS1_AD_DECRYPTION_FAILED:
  551. str = "DC";
  552. break;
  553. case TLS1_AD_RECORD_OVERFLOW:
  554. str = "RO";
  555. break;
  556. case TLS1_AD_UNKNOWN_CA:
  557. str = "CA";
  558. break;
  559. case TLS1_AD_ACCESS_DENIED:
  560. str = "AD";
  561. break;
  562. case TLS1_AD_DECODE_ERROR:
  563. str = "DE";
  564. break;
  565. case TLS1_AD_DECRYPT_ERROR:
  566. str = "CY";
  567. break;
  568. case TLS1_AD_EXPORT_RESTRICTION:
  569. str = "ER";
  570. break;
  571. case TLS1_AD_PROTOCOL_VERSION:
  572. str = "PV";
  573. break;
  574. case TLS1_AD_INSUFFICIENT_SECURITY:
  575. str = "IS";
  576. break;
  577. case TLS1_AD_INTERNAL_ERROR:
  578. str = "IE";
  579. break;
  580. case TLS1_AD_USER_CANCELLED:
  581. str = "US";
  582. break;
  583. case TLS1_AD_NO_RENEGOTIATION:
  584. str = "NR";
  585. break;
  586. case TLS1_AD_UNSUPPORTED_EXTENSION:
  587. str = "UE";
  588. break;
  589. case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
  590. str = "CO";
  591. break;
  592. case TLS1_AD_UNRECOGNIZED_NAME:
  593. str = "UN";
  594. break;
  595. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
  596. str = "BR";
  597. break;
  598. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
  599. str = "BH";
  600. break;
  601. case TLS1_AD_UNKNOWN_PSK_IDENTITY:
  602. str = "UP";
  603. break;
  604. default:
  605. str = "UK";
  606. break;
  607. }
  608. return str;
  609. }
  610. const char *SSL_alert_desc_string_long(int value) {
  611. const char *str;
  612. switch (value & 0xff) {
  613. case SSL3_AD_CLOSE_NOTIFY:
  614. str = "close notify";
  615. break;
  616. case SSL3_AD_UNEXPECTED_MESSAGE:
  617. str = "unexpected_message";
  618. break;
  619. case SSL3_AD_BAD_RECORD_MAC:
  620. str = "bad record mac";
  621. break;
  622. case SSL3_AD_DECOMPRESSION_FAILURE:
  623. str = "decompression failure";
  624. break;
  625. case SSL3_AD_HANDSHAKE_FAILURE:
  626. str = "handshake failure";
  627. break;
  628. case SSL3_AD_NO_CERTIFICATE:
  629. str = "no certificate";
  630. break;
  631. case SSL3_AD_BAD_CERTIFICATE:
  632. str = "bad certificate";
  633. break;
  634. case SSL3_AD_UNSUPPORTED_CERTIFICATE:
  635. str = "unsupported certificate";
  636. break;
  637. case SSL3_AD_CERTIFICATE_REVOKED:
  638. str = "certificate revoked";
  639. break;
  640. case SSL3_AD_CERTIFICATE_EXPIRED:
  641. str = "certificate expired";
  642. break;
  643. case SSL3_AD_CERTIFICATE_UNKNOWN:
  644. str = "certificate unknown";
  645. break;
  646. case SSL3_AD_ILLEGAL_PARAMETER:
  647. str = "illegal parameter";
  648. break;
  649. case TLS1_AD_DECRYPTION_FAILED:
  650. str = "decryption failed";
  651. break;
  652. case TLS1_AD_RECORD_OVERFLOW:
  653. str = "record overflow";
  654. break;
  655. case TLS1_AD_UNKNOWN_CA:
  656. str = "unknown CA";
  657. break;
  658. case TLS1_AD_ACCESS_DENIED:
  659. str = "access denied";
  660. break;
  661. case TLS1_AD_DECODE_ERROR:
  662. str = "decode error";
  663. break;
  664. case TLS1_AD_DECRYPT_ERROR:
  665. str = "decrypt error";
  666. break;
  667. case TLS1_AD_EXPORT_RESTRICTION:
  668. str = "export restriction";
  669. break;
  670. case TLS1_AD_PROTOCOL_VERSION:
  671. str = "protocol version";
  672. break;
  673. case TLS1_AD_INSUFFICIENT_SECURITY:
  674. str = "insufficient security";
  675. break;
  676. case TLS1_AD_INTERNAL_ERROR:
  677. str = "internal error";
  678. break;
  679. case TLS1_AD_USER_CANCELLED:
  680. str = "user canceled";
  681. break;
  682. case TLS1_AD_NO_RENEGOTIATION:
  683. str = "no renegotiation";
  684. break;
  685. case TLS1_AD_UNSUPPORTED_EXTENSION:
  686. str = "unsupported extension";
  687. break;
  688. case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
  689. str = "certificate unobtainable";
  690. break;
  691. case TLS1_AD_UNRECOGNIZED_NAME:
  692. str = "unrecognized name";
  693. break;
  694. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
  695. str = "bad certificate status response";
  696. break;
  697. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
  698. str = "bad certificate hash value";
  699. break;
  700. case TLS1_AD_UNKNOWN_PSK_IDENTITY:
  701. str = "unknown PSK identity";
  702. break;
  703. default:
  704. str = "unknown";
  705. break;
  706. }
  707. return str;
  708. }
  709. const char *SSL_rstate_string(const SSL *s) {
  710. const char *str;
  711. switch (s->rstate) {
  712. case SSL_ST_READ_HEADER:
  713. str = "RH";
  714. break;
  715. case SSL_ST_READ_BODY:
  716. str = "RB";
  717. break;
  718. case SSL_ST_READ_DONE:
  719. str = "RD";
  720. break;
  721. default:
  722. str = "unknown";
  723. break;
  724. }
  725. return str;
  726. }