ssl.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _SSL_H_
  14. #define _SSL_H_
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <stdlib.h>
  19. #include "ssl_x509.h"
  20. #include "ssl_pkey.h"
  21. /*
  22. {
  23. */
  24. #define SSL_CB_ALERT 0x4000
  25. #define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT (1 << 0)
  26. #define X509_CHECK_FLAG_NO_WILDCARDS (1 << 1)
  27. #define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS (1 << 2)
  28. #define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS (1 << 3)
  29. #define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS (1 << 4)
  30. mbedtls_x509_crt *
  31. ssl_ctx_get_mbedtls_x509_crt(SSL_CTX *ssl_ctx);
  32. mbedtls_x509_crt *
  33. ssl_get_peer_mbedtls_x509_crt(SSL *ssl);
  34. int SSL_set_sni_callback(SSL *ssl, int(*cb)(void *, mbedtls_ssl_context *,
  35. const unsigned char *, size_t), void *param);
  36. void SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx);
  37. int SSL_CTX_add_client_CA_ASN1(SSL_CTX *ssl, int len,
  38. const unsigned char *d);
  39. SSL *SSL_SSL_from_mbedtls_ssl_context(mbedtls_ssl_context *msc);
  40. /**
  41. * @brief create a SSL context
  42. *
  43. * @param method - the SSL context method point
  44. *
  45. * @return the context point
  46. */
  47. SSL_CTX* SSL_CTX_new(const SSL_METHOD *method);
  48. /**
  49. * @brief free a SSL context
  50. *
  51. * @param method - the SSL context point
  52. *
  53. * @return none
  54. */
  55. void SSL_CTX_free(SSL_CTX *ctx);
  56. /**
  57. * @brief create a SSL
  58. *
  59. * @param ctx - the SSL context point
  60. *
  61. * @return the SSL point
  62. */
  63. SSL* SSL_new(SSL_CTX *ctx);
  64. /**
  65. * @brief free the SSL
  66. *
  67. * @param ssl - the SSL point
  68. *
  69. * @return none
  70. */
  71. void SSL_free(SSL *ssl);
  72. /**
  73. * @brief connect to the remote SSL server
  74. *
  75. * @param ssl - the SSL point
  76. *
  77. * @return result
  78. * 1 : OK
  79. * -1 : failed
  80. */
  81. int SSL_connect(SSL *ssl);
  82. /**
  83. * @brief accept the remote connection
  84. *
  85. * @param ssl - the SSL point
  86. *
  87. * @return result
  88. * 1 : OK
  89. * -1 : failed
  90. */
  91. int SSL_accept(SSL *ssl);
  92. /**
  93. * @brief read data from to remote
  94. *
  95. * @param ssl - the SSL point which has been connected
  96. * @param buffer - the received data buffer point
  97. * @param len - the received data length
  98. *
  99. * @return result
  100. * > 0 : OK, and return received data bytes
  101. * = 0 : connection is closed
  102. * < 0 : an error catch
  103. */
  104. int SSL_read(SSL *ssl, void *buffer, int len);
  105. /**
  106. * @brief send the data to remote
  107. *
  108. * @param ssl - the SSL point which has been connected
  109. * @param buffer - the send data buffer point
  110. * @param len - the send data length
  111. *
  112. * @return result
  113. * > 0 : OK, and return sent data bytes
  114. * = 0 : connection is closed
  115. * < 0 : an error catch
  116. */
  117. int SSL_write(SSL *ssl, const void *buffer, int len);
  118. /**
  119. * @brief get the verifying result of the SSL certification
  120. *
  121. * @param ssl - the SSL point
  122. *
  123. * @return the result of verifying
  124. */
  125. long SSL_get_verify_result(const SSL *ssl);
  126. /**
  127. * @brief shutdown the connection
  128. *
  129. * @param ssl - the SSL point
  130. *
  131. * @return result
  132. * 1 : OK
  133. * 0 : shutdown is not finished
  134. * -1 : an error catch
  135. */
  136. int SSL_shutdown(SSL *ssl);
  137. /**
  138. * @brief bind the socket file description into the SSL
  139. *
  140. * @param ssl - the SSL point
  141. * @param fd - socket handle
  142. *
  143. * @return result
  144. * 1 : OK
  145. * 0 : failed
  146. */
  147. int SSL_set_fd(SSL *ssl, int fd);
  148. /**
  149. * @brief These functions load the private key into the SSL_CTX or SSL object
  150. *
  151. * @param ctx - the SSL context point
  152. * @param pkey - private key object point
  153. *
  154. * @return result
  155. * 1 : OK
  156. * 0 : failed
  157. */
  158. int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
  159. /**
  160. * @brief These functions load the certification into the SSL_CTX or SSL object
  161. *
  162. * @param ctx - the SSL context point
  163. * @param pkey - certification object point
  164. *
  165. * @return result
  166. * 1 : OK
  167. * 0 : failed
  168. */
  169. int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);
  170. /**
  171. * @brief create the target SSL context client method
  172. *
  173. * @param none
  174. *
  175. * @return the SSLV2.3 version SSL context client method
  176. */
  177. const SSL_METHOD* SSLv23_client_method(void);
  178. /**
  179. * @brief create the target SSL context client method
  180. *
  181. * @param none
  182. *
  183. * @return the TLSV1.0 version SSL context client method
  184. */
  185. const SSL_METHOD* TLSv1_client_method(void);
  186. /**
  187. * @brief create the target SSL context client method
  188. *
  189. * @param none
  190. *
  191. * @return the SSLV1.0 version SSL context client method
  192. */
  193. const SSL_METHOD* SSLv3_client_method(void);
  194. /**
  195. * @brief create the target SSL context client method
  196. *
  197. * @param none
  198. *
  199. * @return the TLSV1.1 version SSL context client method
  200. */
  201. const SSL_METHOD* TLSv1_1_client_method(void);
  202. /**
  203. * @brief create the target SSL context client method
  204. *
  205. * @param none
  206. *
  207. * @return the TLSV1.2 version SSL context client method
  208. */
  209. const SSL_METHOD* TLSv1_2_client_method(void);
  210. /**
  211. * @brief create the target SSL context server method
  212. *
  213. * @param none
  214. *
  215. * @return the TLS any version SSL context client method
  216. */
  217. const SSL_METHOD* TLS_client_method(void);
  218. /**
  219. * @brief create the target SSL context server method
  220. *
  221. * @param none
  222. *
  223. * @return the SSLV2.3 version SSL context server method
  224. */
  225. const SSL_METHOD* SSLv23_server_method(void);
  226. /**
  227. * @brief create the target SSL context server method
  228. *
  229. * @param none
  230. *
  231. * @return the TLSV1.1 version SSL context server method
  232. */
  233. const SSL_METHOD* TLSv1_1_server_method(void);
  234. /**
  235. * @brief create the target SSL context server method
  236. *
  237. * @param none
  238. *
  239. * @return the TLSV1.2 version SSL context server method
  240. */
  241. const SSL_METHOD* TLSv1_2_server_method(void);
  242. /**
  243. * @brief create the target SSL context server method
  244. *
  245. * @param none
  246. *
  247. * @return the TLSV1.0 version SSL context server method
  248. */
  249. const SSL_METHOD* TLSv1_server_method(void);
  250. /**
  251. * @brief create the target SSL context server method
  252. *
  253. * @param none
  254. *
  255. * @return the SSLV3.0 version SSL context server method
  256. */
  257. const SSL_METHOD* SSLv3_server_method(void);
  258. /**
  259. * @brief create the target SSL context server method
  260. *
  261. * @param none
  262. *
  263. * @return the TLS any version SSL context server method
  264. */
  265. const SSL_METHOD* TLS_server_method(void);
  266. /**
  267. * @brief set the SSL context ALPN select callback function
  268. *
  269. * @param ctx - SSL context point
  270. * @param cb - ALPN select callback function
  271. * @param arg - ALPN select callback function entry private data point
  272. *
  273. * @return none
  274. */
  275. void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, next_proto_cb cb,
  276. void *arg);
  277. void SSL_set_alpn_select_cb(SSL *ssl, void *arg);
  278. /**
  279. * @brief set the SSL context ALPN select protocol
  280. *
  281. * @param ctx - SSL context point
  282. * @param protos - ALPN protocol name
  283. * @param protos_len - ALPN protocol name bytes
  284. *
  285. * @return result
  286. * 0 : OK
  287. * 1 : failed
  288. */
  289. int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, unsigned int protos_len);
  290. /**
  291. * @brief set the SSL context next ALPN select callback function
  292. *
  293. * @param ctx - SSL context point
  294. * @param cb - ALPN select callback function
  295. * @param arg - ALPN select callback function entry private data point
  296. *
  297. * @return none
  298. */
  299. void SSL_CTX_set_next_proto_select_cb(SSL_CTX *ctx,
  300. int (*cb) (SSL *ssl,
  301. unsigned char **out,
  302. unsigned char *outlen,
  303. const unsigned char *in,
  304. unsigned int inlen,
  305. void *arg),
  306. void *arg);
  307. void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,
  308. unsigned int *len);
  309. void _ssl_set_alpn_list(const SSL *ssl);
  310. /**
  311. * @brief get SSL error code
  312. *
  313. * @param ssl - SSL point
  314. * @param ret_code - SSL return code
  315. *
  316. * @return SSL error number
  317. */
  318. int SSL_get_error(const SSL *ssl, int ret_code);
  319. /**
  320. * @brief clear the SSL error code
  321. *
  322. * @param none
  323. *
  324. * @return none
  325. */
  326. void ERR_clear_error(void);
  327. /**
  328. * @brief get the current SSL error code
  329. *
  330. * @param none
  331. *
  332. * @return current SSL error number
  333. */
  334. int ERR_get_error(void);
  335. /**
  336. * @brief register the SSL error strings
  337. *
  338. * @param none
  339. *
  340. * @return none
  341. */
  342. void ERR_load_SSL_strings(void);
  343. /**
  344. * @brief initialize the SSL library
  345. *
  346. * @param none
  347. *
  348. * @return none
  349. */
  350. void SSL_library_init(void);
  351. /**
  352. * @brief generates a human-readable string representing the error code e
  353. * and store it into the "ret" point memory
  354. *
  355. * @param e - error code
  356. * @param ret - memory point to store the string
  357. *
  358. * @return the result string point
  359. */
  360. char *ERR_error_string(unsigned long e, char *ret);
  361. /**
  362. * @brief add the SSL context option
  363. *
  364. * @param ctx - SSL context point
  365. * @param opt - new SSL context option
  366. *
  367. * @return the SSL context option
  368. */
  369. unsigned long SSL_CTX_set_options(SSL_CTX *ctx, unsigned long opt);
  370. /**
  371. * @brief add the SSL context mode
  372. *
  373. * @param ctx - SSL context point
  374. * @param mod - new SSL context mod
  375. *
  376. * @return result
  377. * 1 : OK
  378. * 0 : failed
  379. */
  380. int SSL_CTX_set_mode(SSL_CTX *ctx, int mod);
  381. /*
  382. }
  383. */
  384. /**
  385. * @brief perform the SSL handshake
  386. *
  387. * @param ssl - SSL point
  388. *
  389. * @return result
  390. * 1 : OK
  391. * 0 : failed
  392. * -1 : a error catch
  393. */
  394. int SSL_do_handshake(SSL *ssl);
  395. /**
  396. * @brief get the SSL current version
  397. *
  398. * @param ssl - SSL point
  399. *
  400. * @return the version string
  401. */
  402. const char *SSL_get_version(const SSL *ssl);
  403. /**
  404. * @brief set the SSL context version
  405. *
  406. * @param ctx - SSL context point
  407. * @param meth - SSL method point
  408. *
  409. * @return result
  410. * 1 : OK
  411. * 0 : failed
  412. */
  413. int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);
  414. /**
  415. * @brief get the bytes numbers which are to be read
  416. *
  417. * @param ssl - SSL point
  418. *
  419. * @return bytes number
  420. */
  421. int SSL_pending(const SSL *ssl);
  422. /**
  423. * @brief check if SSL want nothing
  424. *
  425. * @param ssl - SSL point
  426. *
  427. * @return result
  428. * 0 : false
  429. * 1 : true
  430. */
  431. int SSL_want_nothing(const SSL *ssl);
  432. /**
  433. * @brief check if SSL want to read
  434. *
  435. * @param ssl - SSL point
  436. *
  437. * @return result
  438. * 0 : false
  439. * 1 : true
  440. */
  441. int SSL_want_read(const SSL *ssl);
  442. /**
  443. * @brief check if SSL want to write
  444. *
  445. * @param ssl - SSL point
  446. *
  447. * @return result
  448. * 0 : false
  449. * 1 : true
  450. */
  451. int SSL_want_write(const SSL *ssl);
  452. /**
  453. * @brief get the SSL context current method
  454. *
  455. * @param ctx - SSL context point
  456. *
  457. * @return the SSL context current method
  458. */
  459. const SSL_METHOD *SSL_CTX_get_ssl_method(SSL_CTX *ctx);
  460. /**
  461. * @brief get the SSL current method
  462. *
  463. * @param ssl - SSL point
  464. *
  465. * @return the SSL current method
  466. */
  467. const SSL_METHOD *SSL_get_ssl_method(SSL *ssl);
  468. /**
  469. * @brief set the SSL method
  470. *
  471. * @param ssl - SSL point
  472. * @param meth - SSL method point
  473. *
  474. * @return result
  475. * 1 : OK
  476. * 0 : failed
  477. */
  478. int SSL_set_ssl_method(SSL *ssl, const SSL_METHOD *method);
  479. /**
  480. * @brief add CA client certification into the SSL
  481. *
  482. * @param ssl - SSL point
  483. * @param x - CA certification point
  484. *
  485. * @return result
  486. * 1 : OK
  487. * 0 : failed
  488. */
  489. int SSL_add_client_CA(SSL *ssl, X509 *x);
  490. /**
  491. * @brief add CA client certification into the SSL context
  492. *
  493. * @param ctx - SSL context point
  494. * @param x - CA certification point
  495. *
  496. * @return result
  497. * 1 : OK
  498. * 0 : failed
  499. */
  500. int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);
  501. /**
  502. * @brief set the SSL CA certification list
  503. *
  504. * @param ssl - SSL point
  505. * @param name_list - CA certification list
  506. *
  507. * @return none
  508. */
  509. void SSL_set_client_CA_list(SSL *ssl, STACK_OF(X509_NAME) *name_list);
  510. /**
  511. * @brief set the SSL context CA certification list
  512. *
  513. * @param ctx - SSL context point
  514. * @param name_list - CA certification list
  515. *
  516. * @return none
  517. */
  518. void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);
  519. /**
  520. * @briefget the SSL CA certification list
  521. *
  522. * @param ssl - SSL point
  523. *
  524. * @return CA certification list
  525. */
  526. STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *ssl);
  527. /**
  528. * @brief get the SSL context CA certification list
  529. *
  530. * @param ctx - SSL context point
  531. *
  532. * @return CA certification list
  533. */
  534. STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *ctx);
  535. /**
  536. * @brief get the SSL certification point
  537. *
  538. * @param ssl - SSL point
  539. *
  540. * @return SSL certification point
  541. */
  542. X509 *SSL_get_certificate(const SSL *ssl);
  543. /**
  544. * @brief get the SSL private key point
  545. *
  546. * @param ssl - SSL point
  547. *
  548. * @return SSL private key point
  549. */
  550. EVP_PKEY *SSL_get_privatekey(const SSL *ssl);
  551. /**
  552. * @brief set the SSL information callback function
  553. *
  554. * @param ssl - SSL point
  555. * @param cb - information callback function
  556. *
  557. * @return none
  558. */
  559. void SSL_set_info_callback(SSL *ssl, void (*cb) (const SSL *ssl, int type, int val));
  560. /**
  561. * @brief get the SSL state
  562. *
  563. * @param ssl - SSL point
  564. *
  565. * @return SSL state
  566. */
  567. OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl);
  568. /**
  569. * @brief set the SSL context read buffer length
  570. *
  571. * @param ctx - SSL context point
  572. * @param len - read buffer length
  573. *
  574. * @return none
  575. */
  576. void SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len);
  577. /**
  578. * @brief set the SSL read buffer length
  579. *
  580. * @param ssl - SSL point
  581. * @param len - read buffer length
  582. *
  583. * @return none
  584. */
  585. void SSL_set_default_read_buffer_len(SSL *ssl, size_t len);
  586. /**
  587. * @brief set the SSL security level
  588. *
  589. * @param ssl - SSL point
  590. * @param level - security level
  591. *
  592. * @return none
  593. */
  594. void SSL_set_security_level(SSL *ssl, int level);
  595. /**
  596. * @brief get the SSL security level
  597. *
  598. * @param ssl - SSL point
  599. *
  600. * @return security level
  601. */
  602. int SSL_get_security_level(const SSL *ssl);
  603. /**
  604. * @brief get the SSL verifying mode of the SSL context
  605. *
  606. * @param ctx - SSL context point
  607. *
  608. * @return verifying mode
  609. */
  610. int SSL_CTX_get_verify_mode(const SSL_CTX *ctx);
  611. /**
  612. * @brief get the SSL verifying depth of the SSL context
  613. *
  614. * @param ctx - SSL context point
  615. *
  616. * @return verifying depth
  617. */
  618. int SSL_CTX_get_verify_depth(const SSL_CTX *ctx);
  619. /**
  620. * @brief set the SSL context verifying of the SSL context
  621. *
  622. * @param ctx - SSL context point
  623. * @param mode - verifying mode
  624. * @param verify_callback - verifying callback function
  625. *
  626. * @return none
  627. */
  628. void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, int (*verify_callback)(int, X509_STORE_CTX *));
  629. /**
  630. * @brief set the SSL verifying of the SSL context
  631. *
  632. * @param ctx - SSL point
  633. * @param mode - verifying mode
  634. * @param verify_callback - verifying callback function
  635. *
  636. * @return none
  637. */
  638. void SSL_set_verify(SSL *s, int mode, int (*verify_callback)(int, X509_STORE_CTX *));
  639. /**
  640. * @brief set the SSL verify depth of the SSL context
  641. *
  642. * @param ctx - SSL context point
  643. * @param depth - verifying depth
  644. *
  645. * @return none
  646. */
  647. void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);
  648. /**
  649. * @brief certification verifying callback function
  650. *
  651. * @param preverify_ok - verifying result
  652. * @param x509_ctx - X509 certification point
  653. *
  654. * @return verifying result
  655. */
  656. int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx);
  657. /**
  658. * @brief set the session timeout time
  659. *
  660. * @param ctx - SSL context point
  661. * @param t - new session timeout time
  662. *
  663. * @return old session timeout time
  664. */
  665. long SSL_CTX_set_timeout(SSL_CTX *ctx, long t);
  666. /**
  667. * @brief get the session timeout time
  668. *
  669. * @param ctx - SSL context point
  670. *
  671. * @return current session timeout time
  672. */
  673. long SSL_CTX_get_timeout(const SSL_CTX *ctx);
  674. /**
  675. * @brief set the SSL context cipher through the list string
  676. *
  677. * @param ctx - SSL context point
  678. * @param str - cipher controller list string
  679. *
  680. * @return result
  681. * 1 : OK
  682. * 0 : failed
  683. */
  684. int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str);
  685. /**
  686. * @brief set the SSL cipher through the list string
  687. *
  688. * @param ssl - SSL point
  689. * @param str - cipher controller list string
  690. *
  691. * @return result
  692. * 1 : OK
  693. * 0 : failed
  694. */
  695. int SSL_set_cipher_list(SSL *ssl, const char *str);
  696. /**
  697. * @brief get the SSL cipher list string
  698. *
  699. * @param ssl - SSL point
  700. *
  701. * @return cipher controller list string
  702. */
  703. const char *SSL_get_cipher_list(const SSL *ssl, int n);
  704. /**
  705. * @brief get the SSL cipher
  706. *
  707. * @param ssl - SSL point
  708. *
  709. * @return current cipher
  710. */
  711. const SSL_CIPHER *SSL_get_current_cipher(const SSL *ssl);
  712. /**
  713. * @brief get the SSL cipher string
  714. *
  715. * @param ssl - SSL point
  716. *
  717. * @return cipher string
  718. */
  719. const char *SSL_get_cipher(const SSL *ssl);
  720. /**
  721. * @brief get the SSL context object X509 certification storage
  722. *
  723. * @param ctx - SSL context point
  724. *
  725. * @return x509 certification storage
  726. */
  727. X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx);
  728. /**
  729. * @brief set the SSL context object X509 certification store
  730. *
  731. * @param ctx - SSL context point
  732. * @param store - X509 certification store
  733. *
  734. * @return none
  735. */
  736. void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store);
  737. /**
  738. * @brief get the SSL specifical statement
  739. *
  740. * @param ssl - SSL point
  741. *
  742. * @return specifical statement
  743. */
  744. int SSL_want(const SSL *ssl);
  745. /**
  746. * @brief check if the SSL is SSL_X509_LOOKUP state
  747. *
  748. * @param ssl - SSL point
  749. *
  750. * @return result
  751. * 1 : OK
  752. * 0 : failed
  753. */
  754. int SSL_want_x509_lookup(const SSL *ssl);
  755. /**
  756. * @brief reset the SSL
  757. *
  758. * @param ssl - SSL point
  759. *
  760. * @return result
  761. * 1 : OK
  762. * 0 : failed
  763. */
  764. int SSL_clear(SSL *ssl);
  765. /**
  766. * @brief get the socket handle of the SSL
  767. *
  768. * @param ssl - SSL point
  769. *
  770. * @return result
  771. * >= 0 : yes, and return socket handle
  772. * < 0 : a error catch
  773. */
  774. int SSL_get_fd(const SSL *ssl);
  775. /**
  776. * @brief get the read only socket handle of the SSL
  777. *
  778. * @param ssl - SSL point
  779. *
  780. * @return result
  781. * >= 0 : yes, and return socket handle
  782. * < 0 : a error catch
  783. */
  784. int SSL_get_rfd(const SSL *ssl);
  785. /**
  786. * @brief get the write only socket handle of the SSL
  787. *
  788. * @param ssl - SSL point
  789. *
  790. * @return result
  791. * >= 0 : yes, and return socket handle
  792. * < 0 : a error catch
  793. */
  794. int SSL_get_wfd(const SSL *ssl);
  795. /**
  796. * @brief set the SSL if we can read as many as data
  797. *
  798. * @param ssl - SSL point
  799. * @param yes - enable the function
  800. *
  801. * @return none
  802. */
  803. void SSL_set_read_ahead(SSL *s, int yes);
  804. /**
  805. * @brief set the SSL context if we can read as many as data
  806. *
  807. * @param ctx - SSL context point
  808. * @param yes - enbale the function
  809. *
  810. * @return none
  811. */
  812. void SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes);
  813. /**
  814. * @brief get the SSL ahead signal if we can read as many as data
  815. *
  816. * @param ssl - SSL point
  817. *
  818. * @return SSL context ahead signal
  819. */
  820. int SSL_get_read_ahead(const SSL *ssl);
  821. /**
  822. * @brief get the SSL context ahead signal if we can read as many as data
  823. *
  824. * @param ctx - SSL context point
  825. *
  826. * @return SSL context ahead signal
  827. */
  828. long SSL_CTX_get_read_ahead(SSL_CTX *ctx);
  829. /**
  830. * @brief check if some data can be read
  831. *
  832. * @param ssl - SSL point
  833. *
  834. * @return
  835. * 1 : there are bytes to be read
  836. * 0 : no data
  837. */
  838. int SSL_has_pending(const SSL *ssl);
  839. /**
  840. * @brief load the X509 certification into SSL context
  841. *
  842. * @param ctx - SSL context point
  843. * @param x - X509 certification point
  844. *
  845. * @return result
  846. * 1 : OK
  847. * 0 : failed
  848. */
  849. int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);//loads the certificate x into ctx
  850. /**
  851. * @brief load the ASN1 certification into SSL context
  852. *
  853. * @param ctx - SSL context point
  854. * @param len - certification length
  855. * @param d - data point
  856. *
  857. * @return result
  858. * 1 : OK
  859. * 0 : failed
  860. */
  861. int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d);
  862. /**
  863. * @brief load the certification file into SSL context
  864. *
  865. * @param ctx - SSL context point
  866. * @param file - certification file name
  867. * @param type - certification encoding type
  868. *
  869. * @return result
  870. * 1 : OK
  871. * 0 : failed
  872. */
  873. int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);
  874. /**
  875. * @brief load the certification chain file into SSL context
  876. *
  877. * @param ctx - SSL context point
  878. * @param file - certification chain file name
  879. *
  880. * @return result
  881. * 1 : OK
  882. * 0 : failed
  883. */
  884. int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);
  885. /**
  886. * @brief load the ASN1 private key into SSL context
  887. *
  888. * @param ctx - SSL context point
  889. * @param d - data point
  890. * @param len - private key length
  891. *
  892. * @return result
  893. * 1 : OK
  894. * 0 : failed
  895. */
  896. int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, const unsigned char *d, long len);//adds the private key of type pk stored at memory location d (length len) to ctx
  897. /**
  898. * @brief load the private key file into SSL context
  899. *
  900. * @param ctx - SSL context point
  901. * @param file - private key file name
  902. * @param type - private key encoding type
  903. *
  904. * @return result
  905. * 1 : OK
  906. * 0 : failed
  907. */
  908. int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);
  909. /**
  910. * @brief load the RSA private key into SSL context
  911. *
  912. * @param ctx - SSL context point
  913. * @param x - RSA private key point
  914. *
  915. * @return result
  916. * 1 : OK
  917. * 0 : failed
  918. */
  919. int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
  920. /**
  921. * @brief load the RSA ASN1 private key into SSL context
  922. *
  923. * @param ctx - SSL context point
  924. * @param d - data point
  925. * @param len - RSA private key length
  926. *
  927. * @return result
  928. * 1 : OK
  929. * 0 : failed
  930. */
  931. int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len);
  932. /**
  933. * @brief load the RSA private key file into SSL context
  934. *
  935. * @param ctx - SSL context point
  936. * @param file - RSA private key file name
  937. * @param type - private key encoding type
  938. *
  939. * @return result
  940. * 1 : OK
  941. * 0 : failed
  942. */
  943. int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type);
  944. /**
  945. * @brief check if the private key and certification is matched
  946. *
  947. * @param ctx - SSL context point
  948. *
  949. * @return result
  950. * 1 : OK
  951. * 0 : failed
  952. */
  953. int SSL_CTX_check_private_key(const SSL_CTX *ctx);
  954. /**
  955. * @brief set the SSL context server information
  956. *
  957. * @param ctx - SSL context point
  958. * @param serverinfo - server information string
  959. * @param serverinfo_length - server information length
  960. *
  961. * @return result
  962. * 1 : OK
  963. * 0 : failed
  964. */
  965. int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo, size_t serverinfo_length);
  966. /**
  967. * @brief load the SSL context server infomation file into SSL context
  968. *
  969. * @param ctx - SSL context point
  970. * @param file - server information file
  971. *
  972. * @return result
  973. * 1 : OK
  974. * 0 : failed
  975. */
  976. int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file);
  977. /**
  978. * @brief SSL select next function
  979. *
  980. * @param out - point of output data point
  981. * @param outlen - output data length
  982. * @param in - input data
  983. * @param inlen - input data length
  984. * @param client - client data point
  985. * @param client_len -client data length
  986. *
  987. * @return NPN state
  988. * OPENSSL_NPN_UNSUPPORTED : not support
  989. * OPENSSL_NPN_NEGOTIATED : negotiated
  990. * OPENSSL_NPN_NO_OVERLAP : no overlap
  991. */
  992. int SSL_select_next_proto(unsigned char **out, unsigned char *outlen,
  993. const unsigned char *in, unsigned int inlen,
  994. const unsigned char *client, unsigned int client_len);
  995. /**
  996. * @brief load the extra certification chain into the SSL context
  997. *
  998. * @param ctx - SSL context point
  999. * @param x509 - X509 certification
  1000. *
  1001. * @return result
  1002. * 1 : OK
  1003. * 0 : failed
  1004. */
  1005. long SSL_CTX_add_extra_chain_cert(SSL_CTX *ctx, X509 *);
  1006. /**
  1007. * @brief control the SSL context
  1008. *
  1009. * @param ctx - SSL context point
  1010. * @param cmd - command
  1011. * @param larg - parameter length
  1012. * @param parg - parameter point
  1013. *
  1014. * @return result
  1015. * 1 : OK
  1016. * 0 : failed
  1017. */
  1018. long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg);
  1019. /**
  1020. * @brief get the SSL context cipher
  1021. *
  1022. * @param ctx - SSL context point
  1023. *
  1024. * @return SSL context cipher
  1025. */
  1026. STACK *SSL_CTX_get_ciphers(const SSL_CTX *ctx);
  1027. /**
  1028. * @brief check if the SSL context can read as many as data
  1029. *
  1030. * @param ctx - SSL context point
  1031. *
  1032. * @return result
  1033. * 1 : OK
  1034. * 0 : failed
  1035. */
  1036. long SSL_CTX_get_default_read_ahead(SSL_CTX *ctx);
  1037. /**
  1038. * @brief get the SSL context extra data
  1039. *
  1040. * @param ctx - SSL context point
  1041. * @param idx - index
  1042. *
  1043. * @return data point
  1044. */
  1045. void *SSL_CTX_get_ex_data(const SSL_CTX *ctx, int idx);
  1046. /**
  1047. * @brief get the SSL context quiet shutdown option
  1048. *
  1049. * @param ctx - SSL context point
  1050. *
  1051. * @return quiet shutdown option
  1052. */
  1053. int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);
  1054. /**
  1055. * @brief load the SSL context CA file
  1056. *
  1057. * @param ctx - SSL context point
  1058. * @param CAfile - CA certification file
  1059. * @param CApath - CA certification file path
  1060. *
  1061. * @return result
  1062. * 1 : OK
  1063. * 0 : failed
  1064. */
  1065. int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath);
  1066. /**
  1067. * @brief add SSL context reference count by '1'
  1068. *
  1069. * @param ctx - SSL context point
  1070. *
  1071. * @return result
  1072. * 1 : OK
  1073. * 0 : failed
  1074. */
  1075. int SSL_CTX_up_ref(SSL_CTX *ctx);
  1076. /**
  1077. * @brief set SSL context application private data
  1078. *
  1079. * @param ctx - SSL context point
  1080. * @param arg - private data
  1081. *
  1082. * @return result
  1083. * 1 : OK
  1084. * 0 : failed
  1085. */
  1086. int SSL_CTX_set_app_data(SSL_CTX *ctx, void *arg);
  1087. /**
  1088. * @brief set SSL context client certification callback function
  1089. *
  1090. * @param ctx - SSL context point
  1091. * @param cb - callback function
  1092. *
  1093. * @return none
  1094. */
  1095. void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
  1096. /**
  1097. * @brief set the SSL context if we can read as many as data
  1098. *
  1099. * @param ctx - SSL context point
  1100. * @param m - enable the fuction
  1101. *
  1102. * @return none
  1103. */
  1104. void SSL_CTX_set_default_read_ahead(SSL_CTX *ctx, int m);
  1105. /**
  1106. * @brief set SSL context default verifying path
  1107. *
  1108. * @param ctx - SSL context point
  1109. *
  1110. * @return result
  1111. * 1 : OK
  1112. * 0 : failed
  1113. */
  1114. int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
  1115. /**
  1116. * @brief set SSL context default verifying directory
  1117. *
  1118. * @param ctx - SSL context point
  1119. *
  1120. * @return result
  1121. * 1 : OK
  1122. * 0 : failed
  1123. */
  1124. int SSL_CTX_set_default_verify_dir(SSL_CTX *ctx);
  1125. /**
  1126. * @brief set SSL context default verifying file
  1127. *
  1128. * @param ctx - SSL context point
  1129. *
  1130. * @return result
  1131. * 1 : OK
  1132. * 0 : failed
  1133. */
  1134. int SSL_CTX_set_default_verify_file(SSL_CTX *ctx);
  1135. /**
  1136. * @brief set SSL context extra data
  1137. *
  1138. * @param ctx - SSL context point
  1139. * @param idx - data index
  1140. * @param arg - data point
  1141. *
  1142. * @return result
  1143. * 1 : OK
  1144. * 0 : failed
  1145. */
  1146. int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, char *arg);
  1147. /**
  1148. * @brief clear the SSL context option bit of "op"
  1149. *
  1150. * @param ctx - SSL context point
  1151. * @param op - option
  1152. *
  1153. * @return SSL context option
  1154. */
  1155. unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op);
  1156. /**
  1157. * @brief get the SSL context option
  1158. *
  1159. * @param ctx - SSL context point
  1160. * @param op - option
  1161. *
  1162. * @return SSL context option
  1163. */
  1164. unsigned long SSL_CTX_get_options(SSL_CTX *ctx);
  1165. /**
  1166. * @brief set the SSL context quiet shutdown mode
  1167. *
  1168. * @param ctx - SSL context point
  1169. * @param mode - mode
  1170. *
  1171. * @return none
  1172. */
  1173. void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);
  1174. /**
  1175. * @brief get the SSL context X509 certification
  1176. *
  1177. * @param ctx - SSL context point
  1178. *
  1179. * @return X509 certification
  1180. */
  1181. X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx);
  1182. /**
  1183. * @brief get the SSL context private key
  1184. *
  1185. * @param ctx - SSL context point
  1186. *
  1187. * @return private key
  1188. */
  1189. EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx);
  1190. /**
  1191. * @brief set SSL context PSK identity hint
  1192. *
  1193. * @param ctx - SSL context point
  1194. * @param hint - PSK identity hint
  1195. *
  1196. * @return result
  1197. * 1 : OK
  1198. * 0 : failed
  1199. */
  1200. int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
  1201. /**
  1202. * @brief set SSL context PSK server callback function
  1203. *
  1204. * @param ctx - SSL context point
  1205. * @param callback - callback function
  1206. *
  1207. * @return none
  1208. */
  1209. void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx,
  1210. unsigned int (*callback)(SSL *ssl,
  1211. const char *identity,
  1212. unsigned char *psk,
  1213. int max_psk_len));
  1214. /**
  1215. * @brief get alert description string
  1216. *
  1217. * @param value - alert value
  1218. *
  1219. * @return alert description string
  1220. */
  1221. const char *SSL_alert_desc_string(int value);
  1222. /**
  1223. * @brief get alert description long string
  1224. *
  1225. * @param value - alert value
  1226. *
  1227. * @return alert description long string
  1228. */
  1229. const char *SSL_alert_desc_string_long(int value);
  1230. /**
  1231. * @brief get alert type string
  1232. *
  1233. * @param value - alert value
  1234. *
  1235. * @return alert type string
  1236. */
  1237. const char *SSL_alert_type_string(int value);
  1238. /**
  1239. * @brief get alert type long string
  1240. *
  1241. * @param value - alert value
  1242. *
  1243. * @return alert type long string
  1244. */
  1245. const char *SSL_alert_type_string_long(int value);
  1246. /**
  1247. * @brief get SSL context of the SSL
  1248. *
  1249. * @param ssl - SSL point
  1250. *
  1251. * @return SSL context
  1252. */
  1253. SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);
  1254. /**
  1255. * @brief get SSL application data
  1256. *
  1257. * @param ssl - SSL point
  1258. *
  1259. * @return application data
  1260. */
  1261. char *SSL_get_app_data(SSL *ssl);
  1262. /**
  1263. * @brief get SSL cipher bits
  1264. *
  1265. * @param ssl - SSL point
  1266. * @param alg_bits - algorithm bits
  1267. *
  1268. * @return strength bits
  1269. */
  1270. int SSL_get_cipher_bits(const SSL *ssl, int *alg_bits);
  1271. /**
  1272. * @brief get SSL cipher name
  1273. *
  1274. * @param ssl - SSL point
  1275. *
  1276. * @return SSL cipher name
  1277. */
  1278. char *SSL_get_cipher_name(const SSL *ssl);
  1279. /**
  1280. * @brief get SSL cipher version
  1281. *
  1282. * @param ssl - SSL point
  1283. *
  1284. * @return SSL cipher version
  1285. */
  1286. char *SSL_get_cipher_version(const SSL *ssl);
  1287. /**
  1288. * @brief get SSL extra data
  1289. *
  1290. * @param ssl - SSL point
  1291. * @param idx - data index
  1292. *
  1293. * @return extra data
  1294. */
  1295. char *SSL_get_ex_data(const SSL *ssl, int idx);
  1296. /**
  1297. * @brief get index of the SSL extra data X509 storage context
  1298. *
  1299. * @param none
  1300. *
  1301. * @return data index
  1302. */
  1303. int SSL_get_ex_data_X509_STORE_CTX_idx(void);
  1304. /**
  1305. * @brief get peer certification chain
  1306. *
  1307. * @param ssl - SSL point
  1308. *
  1309. * @return certification chain
  1310. */
  1311. STACK *SSL_get_peer_cert_chain(const SSL *ssl);
  1312. /**
  1313. * @brief get peer certification
  1314. *
  1315. * @param ssl - SSL point
  1316. *
  1317. * @return certification
  1318. */
  1319. X509 *SSL_get_peer_certificate(const SSL *ssl);
  1320. /**
  1321. * @brief get SSL quiet shutdown mode
  1322. *
  1323. * @param ssl - SSL point
  1324. *
  1325. * @return quiet shutdown mode
  1326. */
  1327. int SSL_get_quiet_shutdown(const SSL *ssl);
  1328. /**
  1329. * @brief get SSL read only IO handle
  1330. *
  1331. * @param ssl - SSL point
  1332. *
  1333. * @return IO handle
  1334. */
  1335. BIO *SSL_get_rbio(const SSL *ssl);
  1336. /**
  1337. * @brief get SSL shared ciphers
  1338. *
  1339. * @param ssl - SSL point
  1340. * @param buf - buffer to store the ciphers
  1341. * @param len - buffer len
  1342. *
  1343. * @return shared ciphers
  1344. */
  1345. char *SSL_get_shared_ciphers(const SSL *ssl, char *buf, int len);
  1346. /**
  1347. * @brief get SSL shutdown mode
  1348. *
  1349. * @param ssl - SSL point
  1350. *
  1351. * @return shutdown mode
  1352. */
  1353. int SSL_get_shutdown(const SSL *ssl);
  1354. /**
  1355. * @brief get SSL session time
  1356. *
  1357. * @param ssl - SSL point
  1358. *
  1359. * @return session time
  1360. */
  1361. long SSL_get_time(const SSL *ssl);
  1362. /**
  1363. * @brief get SSL session timeout time
  1364. *
  1365. * @param ssl - SSL point
  1366. *
  1367. * @return session timeout time
  1368. */
  1369. long SSL_get_timeout(const SSL *ssl);
  1370. /**
  1371. * @brief get SSL verifying mode
  1372. *
  1373. * @param ssl - SSL point
  1374. *
  1375. * @return verifying mode
  1376. */
  1377. int SSL_get_verify_mode(const SSL *ssl);
  1378. /**
  1379. * @brief get SSL verify parameters
  1380. *
  1381. * @param ssl - SSL point
  1382. *
  1383. * @return verify parameters
  1384. */
  1385. X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl);
  1386. /**
  1387. * @brief set expected hostname the peer cert CN should have
  1388. *
  1389. * @param param - verify parameters from SSL_get0_param()
  1390. *
  1391. * @param name - the expected hostname
  1392. *
  1393. * @param namelen - the length of the hostname, or 0 if NUL terminated
  1394. *
  1395. * @return verify parameters
  1396. */
  1397. int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,
  1398. const char *name, size_t namelen);
  1399. /**
  1400. * @brief set parameters for X509 host verify action
  1401. *
  1402. * @param param -verify parameters from SSL_get0_param()
  1403. *
  1404. * @param flags - bitfield of X509_CHECK_FLAG_... parameters to set
  1405. *
  1406. * @return 1 for success, 0 for failure
  1407. */
  1408. int X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,
  1409. unsigned long flags);
  1410. /**
  1411. * @brief clear parameters for X509 host verify action
  1412. *
  1413. * @param param -verify parameters from SSL_get0_param()
  1414. *
  1415. * @param flags - bitfield of X509_CHECK_FLAG_... parameters to clear
  1416. *
  1417. * @return 1 for success, 0 for failure
  1418. */
  1419. int X509_VERIFY_PARAM_clear_hostflags(X509_VERIFY_PARAM *param,
  1420. unsigned long flags);
  1421. /**
  1422. * @brief get SSL write only IO handle
  1423. *
  1424. * @param ssl - SSL point
  1425. *
  1426. * @return IO handle
  1427. */
  1428. BIO *SSL_get_wbio(const SSL *ssl);
  1429. /**
  1430. * @brief load SSL client CA certification file
  1431. *
  1432. * @param file - file name
  1433. *
  1434. * @return certification loading object
  1435. */
  1436. STACK *SSL_load_client_CA_file(const char *file);
  1437. /**
  1438. * @brief add SSL reference by '1'
  1439. *
  1440. * @param ssl - SSL point
  1441. *
  1442. * @return result
  1443. * 1 : OK
  1444. * 0 : failed
  1445. */
  1446. int SSL_up_ref(SSL *ssl);
  1447. /**
  1448. * @brief read and put data into buf, but not clear the SSL low-level storage
  1449. *
  1450. * @param ssl - SSL point
  1451. * @param buf - storage buffer point
  1452. * @param num - data bytes
  1453. *
  1454. * @return result
  1455. * > 0 : OK, and return read bytes
  1456. * = 0 : connect is closed
  1457. * < 0 : a error catch
  1458. */
  1459. int SSL_peek(SSL *ssl, void *buf, int num);
  1460. /**
  1461. * @brief make SSL renegotiate
  1462. *
  1463. * @param ssl - SSL point
  1464. *
  1465. * @return result
  1466. * 1 : OK
  1467. * 0 : failed
  1468. */
  1469. int SSL_renegotiate(SSL *ssl);
  1470. /**
  1471. * @brief get the state string where SSL is reading
  1472. *
  1473. * @param ssl - SSL point
  1474. *
  1475. * @return state string
  1476. */
  1477. const char *SSL_rstate_string(SSL *ssl);
  1478. /**
  1479. * @brief get the statement long string where SSL is reading
  1480. *
  1481. * @param ssl - SSL point
  1482. *
  1483. * @return statement long string
  1484. */
  1485. const char *SSL_rstate_string_long(SSL *ssl);
  1486. /**
  1487. * @brief set SSL accept statement
  1488. *
  1489. * @param ssl - SSL point
  1490. *
  1491. * @return none
  1492. */
  1493. void SSL_set_accept_state(SSL *ssl);
  1494. /**
  1495. * @brief set SSL application data
  1496. *
  1497. * @param ssl - SSL point
  1498. * @param arg - SSL application data point
  1499. *
  1500. * @return none
  1501. */
  1502. void SSL_set_app_data(SSL *ssl, char *arg);
  1503. /**
  1504. * @brief set SSL BIO
  1505. *
  1506. * @param ssl - SSL point
  1507. * @param rbio - read only IO
  1508. * @param wbio - write only IO
  1509. *
  1510. * @return none
  1511. */
  1512. void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio);
  1513. /**
  1514. * @brief clear SSL option
  1515. *
  1516. * @param ssl - SSL point
  1517. * @param op - clear option
  1518. *
  1519. * @return SSL option
  1520. */
  1521. unsigned long SSL_clear_options(SSL *ssl, unsigned long op);
  1522. /**
  1523. * @brief get SSL option
  1524. *
  1525. * @param ssl - SSL point
  1526. *
  1527. * @return SSL option
  1528. */
  1529. unsigned long SSL_get_options(SSL *ssl);
  1530. /**
  1531. * @brief clear SSL option
  1532. *
  1533. * @param ssl - SSL point
  1534. * @param op - setting option
  1535. *
  1536. * @return SSL option
  1537. */
  1538. unsigned long SSL_set_options(SSL *ssl, unsigned long op);
  1539. /**
  1540. * @brief set SSL quiet shutdown mode
  1541. *
  1542. * @param ssl - SSL point
  1543. * @param mode - quiet shutdown mode
  1544. *
  1545. * @return none
  1546. */
  1547. void SSL_set_quiet_shutdown(SSL *ssl, int mode);
  1548. /**
  1549. * @brief set SSL shutdown mode
  1550. *
  1551. * @param ssl - SSL point
  1552. * @param mode - shutdown mode
  1553. *
  1554. * @return none
  1555. */
  1556. void SSL_set_shutdown(SSL *ssl, int mode);
  1557. /**
  1558. * @brief set SSL session time
  1559. *
  1560. * @param ssl - SSL point
  1561. * @param t - session time
  1562. *
  1563. * @return session time
  1564. */
  1565. long SSL_set_time(SSL *ssl, long t);
  1566. /**
  1567. * @brief set SSL session timeout time
  1568. *
  1569. * @param ssl - SSL point
  1570. * @param t - session timeout time
  1571. *
  1572. * @return session timeout time
  1573. */
  1574. long SSL_set_timeout(SSL *ssl, long t);
  1575. /**
  1576. * @brief get SSL statement string
  1577. *
  1578. * @param ssl - SSL point
  1579. *
  1580. * @return SSL statement string
  1581. */
  1582. char *SSL_state_string(const SSL *ssl);
  1583. /**
  1584. * @brief get SSL statement long string
  1585. *
  1586. * @param ssl - SSL point
  1587. *
  1588. * @return SSL statement long string
  1589. */
  1590. char *SSL_state_string_long(const SSL *ssl);
  1591. /**
  1592. * @brief get SSL renegotiation count
  1593. *
  1594. * @param ssl - SSL point
  1595. *
  1596. * @return renegotiation count
  1597. */
  1598. long SSL_total_renegotiations(SSL *ssl);
  1599. /**
  1600. * @brief get SSL version
  1601. *
  1602. * @param ssl - SSL point
  1603. *
  1604. * @return SSL version
  1605. */
  1606. int SSL_version(const SSL *ssl);
  1607. /**
  1608. * @brief set SSL PSK identity hint
  1609. *
  1610. * @param ssl - SSL point
  1611. * @param hint - identity hint
  1612. *
  1613. * @return result
  1614. * 1 : OK
  1615. * 0 : failed
  1616. */
  1617. int SSL_use_psk_identity_hint(SSL *ssl, const char *hint);
  1618. /**
  1619. * @brief get SSL PSK identity hint
  1620. *
  1621. * @param ssl - SSL point
  1622. *
  1623. * @return identity hint
  1624. */
  1625. const char *SSL_get_psk_identity_hint(SSL *ssl);
  1626. /**
  1627. * @brief get SSL PSK identity
  1628. *
  1629. * @param ssl - SSL point
  1630. *
  1631. * @return identity
  1632. */
  1633. const char *SSL_get_psk_identity(SSL *ssl);
  1634. #ifdef __cplusplus
  1635. }
  1636. #endif
  1637. #endif