Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

592 rindas
16 KiB

  1. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  2. * All rights reserved.
  3. *
  4. * This package is an SSL implementation written
  5. * by Eric Young (eay@cryptsoft.com).
  6. * The implementation was written so as to conform with Netscapes SSL.
  7. *
  8. * This library is free for commercial and non-commercial use as long as
  9. * the following conditions are aheared to. The following conditions
  10. * apply to all code found in this distribution, be it the RC4, RSA,
  11. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  12. * included with this distribution is covered by the same copyright terms
  13. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  14. *
  15. * Copyright remains Eric Young's, and as such any Copyright notices in
  16. * the code are not to be removed.
  17. * If this package is used in a product, Eric Young should be given attribution
  18. * as the author of the parts of the library used.
  19. * This can be in the form of a textual message at program startup or
  20. * in documentation (online or textual) provided with the package.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. All advertising materials mentioning features or use of this software
  31. * must display the following acknowledgement:
  32. * "This product includes cryptographic software written by
  33. * Eric Young (eay@cryptsoft.com)"
  34. * The word 'cryptographic' can be left out if the rouines from the library
  35. * being used are not cryptographic related :-).
  36. * 4. If you include any Windows specific code (or a derivative thereof) from
  37. * the apps directory (application code) you must include an acknowledgement:
  38. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * The licence and distribution terms for any publically available version or
  53. * derivative of this code cannot be changed. i.e. this code cannot simply be
  54. * copied and put under another distribution licence
  55. * [including the GNU Public Licence.]
  56. */
  57. /* ====================================================================
  58. * Copyright 2005 Nokia. All rights reserved.
  59. *
  60. * The portions of the attached software ("Contribution") is developed by
  61. * Nokia Corporation and is licensed pursuant to the OpenSSL open source
  62. * license.
  63. *
  64. * The Contribution, originally written by Mika Kousa and Pasi Eronen of
  65. * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
  66. * support (see RFC 4279) to OpenSSL.
  67. *
  68. * No patent licenses or other rights except those expressly stated in
  69. * the OpenSSL open source license shall be deemed granted or received
  70. * expressly, by implication, estoppel, or otherwise.
  71. *
  72. * No assurances are provided by Nokia that the Contribution does not
  73. * infringe the patent or other intellectual property rights of any third
  74. * party or that the license provides you with all the necessary rights
  75. * to make use of the Contribution.
  76. *
  77. * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
  78. * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
  79. * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
  80. * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
  81. * OTHERWISE.
  82. */
  83. #include <openssl/ssl.h>
  84. #include "internal.h"
  85. const char *SSL_state_string_long(const SSL *ssl) {
  86. switch (ssl->state) {
  87. case SSL_ST_ACCEPT:
  88. return "before accept initialization";
  89. case SSL_ST_CONNECT:
  90. return "before connect initialization";
  91. case SSL_ST_OK:
  92. return "SSL negotiation finished successfully";
  93. case SSL_ST_RENEGOTIATE:
  94. return "SSL renegotiate ciphers";
  95. /* SSLv3 additions */
  96. case SSL3_ST_CW_CLNT_HELLO_A:
  97. return "SSLv3 write client hello A";
  98. case SSL3_ST_CW_CLNT_HELLO_B:
  99. return "SSLv3 write client hello B";
  100. case SSL3_ST_CR_SRVR_HELLO_A:
  101. return "SSLv3 read server hello A";
  102. case SSL3_ST_CR_SRVR_HELLO_B:
  103. return "SSLv3 read server hello B";
  104. case SSL3_ST_CR_CERT_A:
  105. return "SSLv3 read server certificate A";
  106. case SSL3_ST_CR_CERT_B:
  107. return "SSLv3 read server certificate B";
  108. case SSL3_ST_CR_KEY_EXCH_A:
  109. return "SSLv3 read server key exchange A";
  110. case SSL3_ST_CR_KEY_EXCH_B:
  111. return "SSLv3 read server key exchange B";
  112. case SSL3_ST_CR_CERT_REQ_A:
  113. return "SSLv3 read server certificate request A";
  114. case SSL3_ST_CR_CERT_REQ_B:
  115. return "SSLv3 read server certificate request B";
  116. case SSL3_ST_CR_SESSION_TICKET_A:
  117. return "SSLv3 read server session ticket A";
  118. case SSL3_ST_CR_SESSION_TICKET_B:
  119. return "SSLv3 read server session ticket B";
  120. case SSL3_ST_CR_SRVR_DONE_A:
  121. return "SSLv3 read server done A";
  122. case SSL3_ST_CR_SRVR_DONE_B:
  123. return "SSLv3 read server done B";
  124. case SSL3_ST_CW_CERT_A:
  125. return "SSLv3 write client certificate A";
  126. case SSL3_ST_CW_CERT_B:
  127. return "SSLv3 write client certificate B";
  128. case SSL3_ST_CW_CERT_C:
  129. return "SSLv3 write client certificate C";
  130. case SSL3_ST_CW_CERT_D:
  131. return "SSLv3 write client certificate D";
  132. case SSL3_ST_CW_KEY_EXCH_A:
  133. return "SSLv3 write client key exchange A";
  134. case SSL3_ST_CW_KEY_EXCH_B:
  135. return "SSLv3 write client key exchange B";
  136. case SSL3_ST_CW_CERT_VRFY_A:
  137. return "SSLv3 write certificate verify A";
  138. case SSL3_ST_CW_CERT_VRFY_B:
  139. return "SSLv3 write certificate verify B";
  140. case SSL3_ST_CW_CHANGE_A:
  141. case SSL3_ST_SW_CHANGE_A:
  142. return "SSLv3 write change cipher spec A";
  143. case SSL3_ST_CW_CHANGE_B:
  144. case SSL3_ST_SW_CHANGE_B:
  145. return "SSLv3 write change cipher spec B";
  146. case SSL3_ST_CW_FINISHED_A:
  147. case SSL3_ST_SW_FINISHED_A:
  148. return "SSLv3 write finished A";
  149. case SSL3_ST_CW_FINISHED_B:
  150. case SSL3_ST_SW_FINISHED_B:
  151. return "SSLv3 write finished B";
  152. case SSL3_ST_CR_CHANGE:
  153. case SSL3_ST_SR_CHANGE:
  154. return "SSLv3 read change cipher spec";
  155. case SSL3_ST_CR_FINISHED_A:
  156. case SSL3_ST_SR_FINISHED_A:
  157. return "SSLv3 read finished A";
  158. case SSL3_ST_CR_FINISHED_B:
  159. case SSL3_ST_SR_FINISHED_B:
  160. return "SSLv3 read finished B";
  161. case SSL3_ST_CW_FLUSH:
  162. case SSL3_ST_SW_FLUSH:
  163. return "SSLv3 flush data";
  164. case SSL3_ST_SR_CLNT_HELLO_A:
  165. return "SSLv3 read client hello A";
  166. case SSL3_ST_SR_CLNT_HELLO_B:
  167. return "SSLv3 read client hello B";
  168. case SSL3_ST_SR_CLNT_HELLO_C:
  169. return "SSLv3 read client hello C";
  170. case SSL3_ST_SR_CLNT_HELLO_D:
  171. return "SSLv3 read client hello D";
  172. case SSL3_ST_SW_HELLO_REQ_A:
  173. return "SSLv3 write hello request A";
  174. case SSL3_ST_SW_HELLO_REQ_B:
  175. return "SSLv3 write hello request B";
  176. case SSL3_ST_SW_HELLO_REQ_C:
  177. return "SSLv3 write hello request C";
  178. case SSL3_ST_SW_SRVR_HELLO_A:
  179. return "SSLv3 write server hello A";
  180. case SSL3_ST_SW_SRVR_HELLO_B:
  181. return "SSLv3 write server hello B";
  182. case SSL3_ST_SW_CERT_A:
  183. return "SSLv3 write certificate A";
  184. case SSL3_ST_SW_CERT_B:
  185. return "SSLv3 write certificate B";
  186. case SSL3_ST_SW_KEY_EXCH_A:
  187. return "SSLv3 write key exchange A";
  188. case SSL3_ST_SW_KEY_EXCH_B:
  189. return "SSLv3 write key exchange B";
  190. case SSL3_ST_SW_CERT_REQ_A:
  191. return "SSLv3 write certificate request A";
  192. case SSL3_ST_SW_CERT_REQ_B:
  193. return "SSLv3 write certificate request B";
  194. case SSL3_ST_SW_SESSION_TICKET_A:
  195. return "SSLv3 write session ticket A";
  196. case SSL3_ST_SW_SESSION_TICKET_B:
  197. return "SSLv3 write session ticket B";
  198. case SSL3_ST_SW_SRVR_DONE_A:
  199. return "SSLv3 write server done A";
  200. case SSL3_ST_SW_SRVR_DONE_B:
  201. return "SSLv3 write server done B";
  202. case SSL3_ST_SR_CERT_A:
  203. return "SSLv3 read client certificate A";
  204. case SSL3_ST_SR_CERT_B:
  205. return "SSLv3 read client certificate B";
  206. case SSL3_ST_SR_KEY_EXCH_A:
  207. return "SSLv3 read client key exchange A";
  208. case SSL3_ST_SR_KEY_EXCH_B:
  209. return "SSLv3 read client key exchange B";
  210. case SSL3_ST_SR_CERT_VRFY_A:
  211. return "SSLv3 read certificate verify A";
  212. case SSL3_ST_SR_CERT_VRFY_B:
  213. return "SSLv3 read certificate verify B";
  214. /* DTLS */
  215. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
  216. return "DTLS1 read hello verify request A";
  217. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
  218. return "DTLS1 read hello verify request B";
  219. default:
  220. return "unknown state";
  221. }
  222. }
  223. const char *SSL_state_string(const SSL *ssl) {
  224. switch (ssl->state) {
  225. case SSL_ST_ACCEPT:
  226. return "AINIT ";
  227. case SSL_ST_CONNECT:
  228. return "CINIT ";
  229. case SSL_ST_OK:
  230. return "SSLOK ";
  231. /* SSLv3 additions */
  232. case SSL3_ST_SW_FLUSH:
  233. case SSL3_ST_CW_FLUSH:
  234. return "3FLUSH";
  235. case SSL3_ST_CW_CLNT_HELLO_A:
  236. return "3WCH_A";
  237. case SSL3_ST_CW_CLNT_HELLO_B:
  238. return "3WCH_B";
  239. case SSL3_ST_CR_SRVR_HELLO_A:
  240. return "3RSH_A";
  241. case SSL3_ST_CR_SRVR_HELLO_B:
  242. return "3RSH_B";
  243. case SSL3_ST_CR_CERT_A:
  244. return "3RSC_A";
  245. case SSL3_ST_CR_CERT_B:
  246. return "3RSC_B";
  247. case SSL3_ST_CR_KEY_EXCH_A:
  248. return "3RSKEA";
  249. case SSL3_ST_CR_KEY_EXCH_B:
  250. return "3RSKEB";
  251. case SSL3_ST_CR_CERT_REQ_A:
  252. return "3RCR_A";
  253. case SSL3_ST_CR_CERT_REQ_B:
  254. return "3RCR_B";
  255. case SSL3_ST_CR_SRVR_DONE_A:
  256. return "3RSD_A";
  257. case SSL3_ST_CR_SRVR_DONE_B:
  258. return "3RSD_B";
  259. case SSL3_ST_CW_CERT_A:
  260. return "3WCC_A";
  261. case SSL3_ST_CW_CERT_B:
  262. return "3WCC_B";
  263. case SSL3_ST_CW_CERT_C:
  264. return "3WCC_C";
  265. case SSL3_ST_CW_CERT_D:
  266. return "3WCC_D";
  267. case SSL3_ST_CW_KEY_EXCH_A:
  268. return "3WCKEA";
  269. case SSL3_ST_CW_KEY_EXCH_B:
  270. return "3WCKEB";
  271. case SSL3_ST_CW_CERT_VRFY_A:
  272. return "3WCV_A";
  273. case SSL3_ST_CW_CERT_VRFY_B:
  274. return "3WCV_B";
  275. case SSL3_ST_SW_CHANGE_A:
  276. case SSL3_ST_CW_CHANGE_A:
  277. return "3WCCSA";
  278. case SSL3_ST_SW_CHANGE_B:
  279. case SSL3_ST_CW_CHANGE_B:
  280. return "3WCCSB";
  281. case SSL3_ST_SW_FINISHED_A:
  282. case SSL3_ST_CW_FINISHED_A:
  283. return "3WFINA";
  284. case SSL3_ST_SW_FINISHED_B:
  285. case SSL3_ST_CW_FINISHED_B:
  286. return "3WFINB";
  287. case SSL3_ST_CR_CHANGE:
  288. case SSL3_ST_SR_CHANGE:
  289. return "3RCCS_";
  290. case SSL3_ST_SR_FINISHED_A:
  291. case SSL3_ST_CR_FINISHED_A:
  292. return "3RFINA";
  293. case SSL3_ST_SR_FINISHED_B:
  294. case SSL3_ST_CR_FINISHED_B:
  295. return "3RFINB";
  296. case SSL3_ST_SW_HELLO_REQ_A:
  297. return "3WHR_A";
  298. case SSL3_ST_SW_HELLO_REQ_B:
  299. return "3WHR_B";
  300. case SSL3_ST_SW_HELLO_REQ_C:
  301. return "3WHR_C";
  302. case SSL3_ST_SR_CLNT_HELLO_A:
  303. return "3RCH_A";
  304. case SSL3_ST_SR_CLNT_HELLO_B:
  305. return "3RCH_B";
  306. case SSL3_ST_SR_CLNT_HELLO_C:
  307. return "3RCH_C";
  308. case SSL3_ST_SR_CLNT_HELLO_D:
  309. return "3RCH_D";
  310. case SSL3_ST_SW_SRVR_HELLO_A:
  311. return "3WSH_A";
  312. case SSL3_ST_SW_SRVR_HELLO_B:
  313. return "3WSH_B";
  314. case SSL3_ST_SW_CERT_A:
  315. return "3WSC_A";
  316. case SSL3_ST_SW_CERT_B:
  317. return "3WSC_B";
  318. case SSL3_ST_SW_KEY_EXCH_A:
  319. return "3WSKEA";
  320. case SSL3_ST_SW_KEY_EXCH_B:
  321. return "3WSKEB";
  322. case SSL3_ST_SW_CERT_REQ_A:
  323. return "3WCR_A";
  324. case SSL3_ST_SW_CERT_REQ_B:
  325. return "3WCR_B";
  326. case SSL3_ST_SW_SRVR_DONE_A:
  327. return "3WSD_A";
  328. case SSL3_ST_SW_SRVR_DONE_B:
  329. return "3WSD_B";
  330. case SSL3_ST_SR_CERT_A:
  331. return "3RCC_A";
  332. case SSL3_ST_SR_CERT_B:
  333. return "3RCC_B";
  334. case SSL3_ST_SR_KEY_EXCH_A:
  335. return "3RCKEA";
  336. case SSL3_ST_SR_KEY_EXCH_B:
  337. return "3RCKEB";
  338. case SSL3_ST_SR_CERT_VRFY_A:
  339. return "3RCV_A";
  340. case SSL3_ST_SR_CERT_VRFY_B:
  341. return "3RCV_B";
  342. /* DTLS */
  343. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
  344. return "DRCHVA";
  345. case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
  346. return "DRCHVB";
  347. default:
  348. return "UNKWN ";
  349. }
  350. }
  351. const char *SSL_alert_type_string_long(int value) {
  352. value >>= 8;
  353. if (value == SSL3_AL_WARNING) {
  354. return "warning";
  355. } else if (value == SSL3_AL_FATAL) {
  356. return "fatal";
  357. }
  358. return "unknown";
  359. }
  360. const char *SSL_alert_type_string(int value) {
  361. return "!";
  362. }
  363. const char *SSL_alert_desc_string(int value) {
  364. return "!!";
  365. }
  366. const char *SSL_alert_desc_string_long(int value) {
  367. switch (value & 0xff) {
  368. case SSL3_AD_CLOSE_NOTIFY:
  369. return "close notify";
  370. case SSL3_AD_UNEXPECTED_MESSAGE:
  371. return "unexpected_message";
  372. case SSL3_AD_BAD_RECORD_MAC:
  373. return "bad record mac";
  374. case SSL3_AD_DECOMPRESSION_FAILURE:
  375. return "decompression failure";
  376. case SSL3_AD_HANDSHAKE_FAILURE:
  377. return "handshake failure";
  378. case SSL3_AD_NO_CERTIFICATE:
  379. return "no certificate";
  380. case SSL3_AD_BAD_CERTIFICATE:
  381. return "bad certificate";
  382. case SSL3_AD_UNSUPPORTED_CERTIFICATE:
  383. return "unsupported certificate";
  384. case SSL3_AD_CERTIFICATE_REVOKED:
  385. return "certificate revoked";
  386. case SSL3_AD_CERTIFICATE_EXPIRED:
  387. return "certificate expired";
  388. case SSL3_AD_CERTIFICATE_UNKNOWN:
  389. return "certificate unknown";
  390. case SSL3_AD_ILLEGAL_PARAMETER:
  391. return "illegal parameter";
  392. case TLS1_AD_DECRYPTION_FAILED:
  393. return "decryption failed";
  394. case TLS1_AD_RECORD_OVERFLOW:
  395. return "record overflow";
  396. case TLS1_AD_UNKNOWN_CA:
  397. return "unknown CA";
  398. case TLS1_AD_ACCESS_DENIED:
  399. return "access denied";
  400. case TLS1_AD_DECODE_ERROR:
  401. return "decode error";
  402. case TLS1_AD_DECRYPT_ERROR:
  403. return "decrypt error";
  404. case TLS1_AD_EXPORT_RESTRICTION:
  405. return "export restriction";
  406. case TLS1_AD_PROTOCOL_VERSION:
  407. return "protocol version";
  408. case TLS1_AD_INSUFFICIENT_SECURITY:
  409. return "insufficient security";
  410. case TLS1_AD_INTERNAL_ERROR:
  411. return "internal error";
  412. case TLS1_AD_USER_CANCELLED:
  413. return "user canceled";
  414. case TLS1_AD_NO_RENEGOTIATION:
  415. return "no renegotiation";
  416. case TLS1_AD_UNSUPPORTED_EXTENSION:
  417. return "unsupported extension";
  418. case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
  419. return "certificate unobtainable";
  420. case TLS1_AD_UNRECOGNIZED_NAME:
  421. return "unrecognized name";
  422. case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
  423. return "bad certificate status response";
  424. case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
  425. return "bad certificate hash value";
  426. case TLS1_AD_UNKNOWN_PSK_IDENTITY:
  427. return "unknown PSK identity";
  428. case SSL3_AD_INAPPROPRIATE_FALLBACK:
  429. return "inappropriate fallback";
  430. default:
  431. return "unknown";
  432. }
  433. }