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.
 
 
 
 
 
 

1003 rivejä
22 KiB

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