tls.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /*
  2. * SSL/TLS interface definition
  3. * Copyright (c) 2004-2013, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef TLS_H
  9. #define TLS_H
  10. struct tls_connection;
  11. struct tls_random {
  12. const u8 *client_random;
  13. size_t client_random_len;
  14. const u8 *server_random;
  15. size_t server_random_len;
  16. };
  17. enum tls_event {
  18. TLS_CERT_CHAIN_SUCCESS,
  19. TLS_CERT_CHAIN_FAILURE,
  20. TLS_PEER_CERTIFICATE,
  21. TLS_ALERT
  22. };
  23. /*
  24. * Note: These are used as identifier with external programs and as such, the
  25. * values must not be changed.
  26. */
  27. enum tls_fail_reason {
  28. TLS_FAIL_UNSPECIFIED = 0,
  29. TLS_FAIL_UNTRUSTED = 1,
  30. TLS_FAIL_REVOKED = 2,
  31. TLS_FAIL_NOT_YET_VALID = 3,
  32. TLS_FAIL_EXPIRED = 4,
  33. TLS_FAIL_SUBJECT_MISMATCH = 5,
  34. TLS_FAIL_ALTSUBJECT_MISMATCH = 6,
  35. TLS_FAIL_BAD_CERTIFICATE = 7,
  36. TLS_FAIL_SERVER_CHAIN_PROBE = 8,
  37. TLS_FAIL_DOMAIN_SUFFIX_MISMATCH = 9,
  38. TLS_FAIL_DOMAIN_MISMATCH = 10,
  39. };
  40. #define TLS_MAX_ALT_SUBJECT 10
  41. union tls_event_data {
  42. struct {
  43. int depth;
  44. const char *subject;
  45. enum tls_fail_reason reason;
  46. const char *reason_txt;
  47. const struct wpabuf *cert;
  48. } cert_fail;
  49. struct {
  50. int depth;
  51. const char *subject;
  52. const struct wpabuf *cert;
  53. const u8 *hash;
  54. size_t hash_len;
  55. const char *altsubject[TLS_MAX_ALT_SUBJECT];
  56. int num_altsubject;
  57. } peer_cert;
  58. struct {
  59. int is_local;
  60. const char *type;
  61. const char *description;
  62. } alert;
  63. };
  64. struct tls_config {
  65. const char *opensc_engine_path;
  66. const char *pkcs11_engine_path;
  67. const char *pkcs11_module_path;
  68. int fips_mode;
  69. int cert_in_cb;
  70. const char *openssl_ciphers;
  71. unsigned int tls_session_lifetime;
  72. void (*event_cb)(void *ctx, enum tls_event ev,
  73. union tls_event_data *data);
  74. void *cb_ctx;
  75. };
  76. #define TLS_CONN_ALLOW_SIGN_RSA_MD5 BIT(0)
  77. #define TLS_CONN_DISABLE_TIME_CHECKS BIT(1)
  78. #define TLS_CONN_DISABLE_SESSION_TICKET BIT(2)
  79. #define TLS_CONN_REQUEST_OCSP BIT(3)
  80. #define TLS_CONN_REQUIRE_OCSP BIT(4)
  81. #define TLS_CONN_DISABLE_TLSv1_1 BIT(5)
  82. #define TLS_CONN_DISABLE_TLSv1_2 BIT(6)
  83. #define TLS_CONN_EAP_FAST BIT(7)
  84. #define TLS_CONN_DISABLE_TLSv1_0 BIT(8)
  85. /**
  86. * struct tls_connection_params - Parameters for TLS connection
  87. * @ca_cert: File or reference name for CA X.509 certificate in PEM or DER
  88. * format
  89. * @ca_cert_blob: ca_cert as inlined data or %NULL if not used
  90. * @ca_cert_blob_len: ca_cert_blob length
  91. * @ca_path: Path to CA certificates (OpenSSL specific)
  92. * @subject_match: String to match in the subject of the peer certificate or
  93. * %NULL to allow all subjects
  94. * @altsubject_match: String to match in the alternative subject of the peer
  95. * certificate or %NULL to allow all alternative subjects
  96. * @suffix_match: String to suffix match in the dNSName or CN of the peer
  97. * certificate or %NULL to allow all domain names. This may allow subdomains an
  98. * wildcard certificates. Each domain name label must have a full match.
  99. * @domain_match: String to match in the dNSName or CN of the peer
  100. * certificate or %NULL to allow all domain names. This requires a full,
  101. * case-insensitive match.
  102. * @client_cert: File or reference name for client X.509 certificate in PEM or
  103. * DER format
  104. * @client_cert_blob: client_cert as inlined data or %NULL if not used
  105. * @client_cert_blob_len: client_cert_blob length
  106. * @private_key: File or reference name for client private key in PEM or DER
  107. * format (traditional format (RSA PRIVATE KEY) or PKCS#8 (PRIVATE KEY)
  108. * @private_key_blob: private_key as inlined data or %NULL if not used
  109. * @private_key_blob_len: private_key_blob length
  110. * @private_key_passwd: Passphrase for decrypted private key, %NULL if no
  111. * passphrase is used.
  112. * @dh_file: File name for DH/DSA data in PEM format, or %NULL if not used
  113. * @dh_blob: dh_file as inlined data or %NULL if not used
  114. * @dh_blob_len: dh_blob length
  115. * @engine: 1 = use engine (e.g., a smartcard) for private key operations
  116. * (this is OpenSSL specific for now)
  117. * @engine_id: engine id string (this is OpenSSL specific for now)
  118. * @ppin: pointer to the pin variable in the configuration
  119. * (this is OpenSSL specific for now)
  120. * @key_id: the private key's id when using engine (this is OpenSSL
  121. * specific for now)
  122. * @cert_id: the certificate's id when using engine
  123. * @ca_cert_id: the CA certificate's id when using engine
  124. * @openssl_ciphers: OpenSSL cipher configuration
  125. * @flags: Parameter options (TLS_CONN_*)
  126. * @ocsp_stapling_response: DER encoded file with cached OCSP stapling response
  127. * or %NULL if OCSP is not enabled
  128. *
  129. * TLS connection parameters to be configured with tls_connection_set_params()
  130. * and tls_global_set_params().
  131. *
  132. * Certificates and private key can be configured either as a reference name
  133. * (file path or reference to certificate store) or by providing the same data
  134. * as a pointer to the data in memory. Only one option will be used for each
  135. * field.
  136. */
  137. struct tls_connection_params {
  138. const char *ca_cert;
  139. const u8 *ca_cert_blob;
  140. size_t ca_cert_blob_len;
  141. const char *ca_path;
  142. const char *subject_match;
  143. const char *altsubject_match;
  144. const char *suffix_match;
  145. const char *domain_match;
  146. const char *client_cert;
  147. const u8 *client_cert_blob;
  148. size_t client_cert_blob_len;
  149. const char *private_key;
  150. const u8 *private_key_blob;
  151. size_t private_key_blob_len;
  152. const char *private_key_passwd;
  153. const char *dh_file;
  154. const u8 *dh_blob;
  155. size_t dh_blob_len;
  156. /* OpenSSL specific variables */
  157. int engine;
  158. const char *engine_id;
  159. const char *pin;
  160. const char *key_id;
  161. const char *cert_id;
  162. const char *ca_cert_id;
  163. const char *openssl_ciphers;
  164. unsigned int flags;
  165. const char *ocsp_stapling_response;
  166. };
  167. /**
  168. * tls_init - Initialize TLS library
  169. * @conf: Configuration data for TLS library
  170. * Returns: Context data to be used as tls_ctx in calls to other functions,
  171. * or %NULL on failure.
  172. *
  173. * Called once during program startup and once for each RSN pre-authentication
  174. * session. In other words, there can be two concurrent TLS contexts. If global
  175. * library initialization is needed (i.e., one that is shared between both
  176. * authentication types), the TLS library wrapper should maintain a reference
  177. * counter and do global initialization only when moving from 0 to 1 reference.
  178. */
  179. void * tls_init(const struct tls_config *conf);
  180. /**
  181. * tls_deinit - Deinitialize TLS library
  182. * @tls_ctx: TLS context data from tls_init()
  183. *
  184. * Called once during program shutdown and once for each RSN pre-authentication
  185. * session. If global library deinitialization is needed (i.e., one that is
  186. * shared between both authentication types), the TLS library wrapper should
  187. * maintain a reference counter and do global deinitialization only when moving
  188. * from 1 to 0 references.
  189. */
  190. void tls_deinit(void *tls_ctx);
  191. /**
  192. * tls_get_errors - Process pending errors
  193. * @tls_ctx: TLS context data from tls_init()
  194. * Returns: Number of found error, 0 if no errors detected.
  195. *
  196. * Process all pending TLS errors.
  197. */
  198. int tls_get_errors(void *tls_ctx);
  199. /**
  200. * tls_connection_init - Initialize a new TLS connection
  201. * @tls_ctx: TLS context data from tls_init()
  202. * Returns: Connection context data, conn for other function calls
  203. */
  204. struct tls_connection * tls_connection_init(void *tls_ctx);
  205. /**
  206. * tls_connection_deinit - Free TLS connection data
  207. * @tls_ctx: TLS context data from tls_init()
  208. * @conn: Connection context data from tls_connection_init()
  209. *
  210. * Release all resources allocated for TLS connection.
  211. */
  212. void tls_connection_deinit(void *tls_ctx, struct tls_connection *conn);
  213. /**
  214. * tls_connection_established - Has the TLS connection been completed?
  215. * @tls_ctx: TLS context data from tls_init()
  216. * @conn: Connection context data from tls_connection_init()
  217. * Returns: 1 if TLS connection has been completed, 0 if not.
  218. */
  219. int tls_connection_established(void *tls_ctx, struct tls_connection *conn);
  220. /**
  221. * tls_connection_shutdown - Shutdown TLS connection
  222. * @tls_ctx: TLS context data from tls_init()
  223. * @conn: Connection context data from tls_connection_init()
  224. * Returns: 0 on success, -1 on failure
  225. *
  226. * Shutdown current TLS connection without releasing all resources. New
  227. * connection can be started by using the same conn without having to call
  228. * tls_connection_init() or setting certificates etc. again. The new
  229. * connection should try to use session resumption.
  230. */
  231. int tls_connection_shutdown(void *tls_ctx, struct tls_connection *conn);
  232. enum {
  233. TLS_SET_PARAMS_ENGINE_PRV_BAD_PIN = -4,
  234. TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED = -3,
  235. TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED = -2
  236. };
  237. /**
  238. * tls_connection_set_params - Set TLS connection parameters
  239. * @tls_ctx: TLS context data from tls_init()
  240. * @conn: Connection context data from tls_connection_init()
  241. * @params: Connection parameters
  242. * Returns: 0 on success, -1 on failure,
  243. * TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED (-2) on error causing PKCS#11 engine
  244. * failure, or
  245. * TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED (-3) on failure to verify the
  246. * PKCS#11 engine private key, or
  247. * TLS_SET_PARAMS_ENGINE_PRV_BAD_PIN (-4) on PIN error causing PKCS#11 engine
  248. * failure.
  249. */
  250. int __must_check
  251. tls_connection_set_params(void *tls_ctx, struct tls_connection *conn,
  252. const struct tls_connection_params *params);
  253. /**
  254. * tls_global_set_params - Set TLS parameters for all TLS connection
  255. * @tls_ctx: TLS context data from tls_init()
  256. * @params: Global TLS parameters
  257. * Returns: 0 on success, -1 on failure,
  258. * TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED (-2) on error causing PKCS#11 engine
  259. * failure, or
  260. * TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED (-3) on failure to verify the
  261. * PKCS#11 engine private key, or
  262. * TLS_SET_PARAMS_ENGINE_PRV_BAD_PIN (-4) on PIN error causing PKCS#11 engine
  263. * failure.
  264. */
  265. int __must_check tls_global_set_params(
  266. void *tls_ctx, const struct tls_connection_params *params);
  267. /**
  268. * tls_global_set_verify - Set global certificate verification options
  269. * @tls_ctx: TLS context data from tls_init()
  270. * @check_crl: 0 = do not verify CRLs, 1 = verify CRL for the user certificate,
  271. * 2 = verify CRL for all certificates
  272. * Returns: 0 on success, -1 on failure
  273. */
  274. int __must_check tls_global_set_verify(void *tls_ctx, int check_crl);
  275. /**
  276. * tls_connection_set_verify - Set certificate verification options
  277. * @tls_ctx: TLS context data from tls_init()
  278. * @conn: Connection context data from tls_connection_init()
  279. * @verify_peer: 1 = verify peer certificate
  280. * @flags: Connection flags (TLS_CONN_*)
  281. * @session_ctx: Session caching context or %NULL to use default
  282. * @session_ctx_len: Length of @session_ctx in bytes.
  283. * Returns: 0 on success, -1 on failure
  284. */
  285. int __must_check tls_connection_set_verify(void *tls_ctx,
  286. struct tls_connection *conn,
  287. int verify_peer,
  288. unsigned int flags,
  289. const u8 *session_ctx,
  290. size_t session_ctx_len);
  291. /**
  292. * tls_connection_get_random - Get random data from TLS connection
  293. * @tls_ctx: TLS context data from tls_init()
  294. * @conn: Connection context data from tls_connection_init()
  295. * @data: Structure of client/server random data (filled on success)
  296. * Returns: 0 on success, -1 on failure
  297. */
  298. int __must_check tls_connection_get_random(void *tls_ctx,
  299. struct tls_connection *conn,
  300. struct tls_random *data);
  301. /**
  302. * tls_connection_prf - Use TLS-PRF to derive keying material
  303. * @tls_ctx: TLS context data from tls_init()
  304. * @conn: Connection context data from tls_connection_init()
  305. * @label: Label (e.g., description of the key) for PRF
  306. * @server_random_first: seed is 0 = client_random|server_random,
  307. * 1 = server_random|client_random
  308. * @skip_keyblock: Skip TLS key block from the beginning of PRF output
  309. * @out: Buffer for output data from TLS-PRF
  310. * @out_len: Length of the output buffer
  311. * Returns: 0 on success, -1 on failure
  312. *
  313. * tls_connection_prf() is required so that further keying material can be
  314. * derived from the master secret. Example implementation of this function is in
  315. * tls_prf_sha1_md5() when it is called with seed set to
  316. * client_random|server_random (or server_random|client_random). For TLSv1.2 and
  317. * newer, a different PRF is needed, though.
  318. */
  319. int __must_check tls_connection_prf(void *tls_ctx,
  320. struct tls_connection *conn,
  321. const char *label,
  322. int server_random_first,
  323. int skip_keyblock,
  324. u8 *out, size_t out_len);
  325. /**
  326. * tls_connection_handshake - Process TLS handshake (client side)
  327. * @tls_ctx: TLS context data from tls_init()
  328. * @conn: Connection context data from tls_connection_init()
  329. * @in_data: Input data from TLS server
  330. * @appl_data: Pointer to application data pointer, or %NULL if dropped
  331. * Returns: Output data, %NULL on failure
  332. *
  333. * The caller is responsible for freeing the returned output data. If the final
  334. * handshake message includes application data, this is decrypted and
  335. * appl_data (if not %NULL) is set to point this data. The caller is
  336. * responsible for freeing appl_data.
  337. *
  338. * This function is used during TLS handshake. The first call is done with
  339. * in_data == %NULL and the library is expected to return ClientHello packet.
  340. * This packet is then send to the server and a response from server is given
  341. * to TLS library by calling this function again with in_data pointing to the
  342. * TLS message from the server.
  343. *
  344. * If the TLS handshake fails, this function may return %NULL. However, if the
  345. * TLS library has a TLS alert to send out, that should be returned as the
  346. * output data. In this case, tls_connection_get_failed() must return failure
  347. * (> 0).
  348. *
  349. * tls_connection_established() should return 1 once the TLS handshake has been
  350. * completed successfully.
  351. */
  352. struct wpabuf * tls_connection_handshake(void *tls_ctx,
  353. struct tls_connection *conn,
  354. const struct wpabuf *in_data,
  355. struct wpabuf **appl_data);
  356. struct wpabuf * tls_connection_handshake2(void *tls_ctx,
  357. struct tls_connection *conn,
  358. const struct wpabuf *in_data,
  359. struct wpabuf **appl_data,
  360. int *more_data_needed);
  361. /**
  362. * tls_connection_server_handshake - Process TLS handshake (server side)
  363. * @tls_ctx: TLS context data from tls_init()
  364. * @conn: Connection context data from tls_connection_init()
  365. * @in_data: Input data from TLS peer
  366. * @appl_data: Pointer to application data pointer, or %NULL if dropped
  367. * Returns: Output data, %NULL on failure
  368. *
  369. * The caller is responsible for freeing the returned output data.
  370. */
  371. struct wpabuf * tls_connection_server_handshake(void *tls_ctx,
  372. struct tls_connection *conn,
  373. const struct wpabuf *in_data,
  374. struct wpabuf **appl_data);
  375. /**
  376. * tls_connection_encrypt - Encrypt data into TLS tunnel
  377. * @tls_ctx: TLS context data from tls_init()
  378. * @conn: Connection context data from tls_connection_init()
  379. * @in_data: Plaintext data to be encrypted
  380. * Returns: Encrypted TLS data or %NULL on failure
  381. *
  382. * This function is used after TLS handshake has been completed successfully to
  383. * send data in the encrypted tunnel. The caller is responsible for freeing the
  384. * returned output data.
  385. */
  386. struct wpabuf * tls_connection_encrypt(void *tls_ctx,
  387. struct tls_connection *conn,
  388. const struct wpabuf *in_data);
  389. /**
  390. * tls_connection_decrypt - Decrypt data from TLS tunnel
  391. * @tls_ctx: TLS context data from tls_init()
  392. * @conn: Connection context data from tls_connection_init()
  393. * @in_data: Encrypted TLS data
  394. * Returns: Decrypted TLS data or %NULL on failure
  395. *
  396. * This function is used after TLS handshake has been completed successfully to
  397. * receive data from the encrypted tunnel. The caller is responsible for
  398. * freeing the returned output data.
  399. */
  400. struct wpabuf * tls_connection_decrypt(void *tls_ctx,
  401. struct tls_connection *conn,
  402. const struct wpabuf *in_data);
  403. struct wpabuf * tls_connection_decrypt2(void *tls_ctx,
  404. struct tls_connection *conn,
  405. const struct wpabuf *in_data,
  406. int *more_data_needed);
  407. /**
  408. * tls_connection_resumed - Was session resumption used
  409. * @tls_ctx: TLS context data from tls_init()
  410. * @conn: Connection context data from tls_connection_init()
  411. * Returns: 1 if current session used session resumption, 0 if not
  412. */
  413. int tls_connection_resumed(void *tls_ctx, struct tls_connection *conn);
  414. enum {
  415. TLS_CIPHER_NONE,
  416. TLS_CIPHER_RC4_SHA /* 0x0005 */,
  417. TLS_CIPHER_AES128_SHA /* 0x002f */,
  418. TLS_CIPHER_RSA_DHE_AES128_SHA /* 0x0031 */,
  419. TLS_CIPHER_ANON_DH_AES128_SHA /* 0x0034 */
  420. };
  421. /**
  422. * tls_connection_set_cipher_list - Configure acceptable cipher suites
  423. * @tls_ctx: TLS context data from tls_init()
  424. * @conn: Connection context data from tls_connection_init()
  425. * @ciphers: Zero (TLS_CIPHER_NONE) terminated list of allowed ciphers
  426. * (TLS_CIPHER_*).
  427. * Returns: 0 on success, -1 on failure
  428. */
  429. int __must_check tls_connection_set_cipher_list(void *tls_ctx,
  430. struct tls_connection *conn,
  431. u8 *ciphers);
  432. /**
  433. * tls_get_version - Get the current TLS version number
  434. * @tls_ctx: TLS context data from tls_init()
  435. * @conn: Connection context data from tls_connection_init()
  436. * @buf: Buffer for returning the TLS version number
  437. * @buflen: buf size
  438. * Returns: 0 on success, -1 on failure
  439. *
  440. * Get the currently used TLS version number.
  441. */
  442. int __must_check tls_get_version(void *tls_ctx, struct tls_connection *conn,
  443. char *buf, size_t buflen);
  444. /**
  445. * tls_get_cipher - Get current cipher name
  446. * @tls_ctx: TLS context data from tls_init()
  447. * @conn: Connection context data from tls_connection_init()
  448. * @buf: Buffer for the cipher name
  449. * @buflen: buf size
  450. * Returns: 0 on success, -1 on failure
  451. *
  452. * Get the name of the currently used cipher.
  453. */
  454. int __must_check tls_get_cipher(void *tls_ctx, struct tls_connection *conn,
  455. char *buf, size_t buflen);
  456. /**
  457. * tls_connection_enable_workaround - Enable TLS workaround options
  458. * @tls_ctx: TLS context data from tls_init()
  459. * @conn: Connection context data from tls_connection_init()
  460. * Returns: 0 on success, -1 on failure
  461. *
  462. * This function is used to enable connection-specific workaround options for
  463. * buffer SSL/TLS implementations.
  464. */
  465. int __must_check tls_connection_enable_workaround(void *tls_ctx,
  466. struct tls_connection *conn);
  467. /**
  468. * tls_connection_client_hello_ext - Set TLS extension for ClientHello
  469. * @tls_ctx: TLS context data from tls_init()
  470. * @conn: Connection context data from tls_connection_init()
  471. * @ext_type: Extension type
  472. * @data: Extension payload (%NULL to remove extension)
  473. * @data_len: Extension payload length
  474. * Returns: 0 on success, -1 on failure
  475. */
  476. int __must_check tls_connection_client_hello_ext(void *tls_ctx,
  477. struct tls_connection *conn,
  478. int ext_type, const u8 *data,
  479. size_t data_len);
  480. /**
  481. * tls_connection_get_failed - Get connection failure status
  482. * @tls_ctx: TLS context data from tls_init()
  483. * @conn: Connection context data from tls_connection_init()
  484. *
  485. * Returns >0 if connection has failed, 0 if not.
  486. */
  487. int tls_connection_get_failed(void *tls_ctx, struct tls_connection *conn);
  488. /**
  489. * tls_connection_get_read_alerts - Get connection read alert status
  490. * @tls_ctx: TLS context data from tls_init()
  491. * @conn: Connection context data from tls_connection_init()
  492. * Returns: Number of times a fatal read (remote end reported error) has
  493. * happened during this connection.
  494. */
  495. int tls_connection_get_read_alerts(void *tls_ctx, struct tls_connection *conn);
  496. /**
  497. * tls_connection_get_write_alerts - Get connection write alert status
  498. * @tls_ctx: TLS context data from tls_init()
  499. * @conn: Connection context data from tls_connection_init()
  500. * Returns: Number of times a fatal write (locally detected error) has happened
  501. * during this connection.
  502. */
  503. int tls_connection_get_write_alerts(void *tls_ctx,
  504. struct tls_connection *conn);
  505. typedef int (*tls_session_ticket_cb)
  506. (void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
  507. const u8 *server_random, u8 *master_secret);
  508. int __must_check tls_connection_set_session_ticket_cb(
  509. void *tls_ctx, struct tls_connection *conn,
  510. tls_session_ticket_cb cb, void *ctx);
  511. void tls_connection_set_log_cb(struct tls_connection *conn,
  512. void (*log_cb)(void *ctx, const char *msg),
  513. void *ctx);
  514. #define TLS_BREAK_VERIFY_DATA BIT(0)
  515. #define TLS_BREAK_SRV_KEY_X_HASH BIT(1)
  516. #define TLS_BREAK_SRV_KEY_X_SIGNATURE BIT(2)
  517. #define TLS_DHE_PRIME_511B BIT(3)
  518. #define TLS_DHE_PRIME_767B BIT(4)
  519. #define TLS_DHE_PRIME_15 BIT(5)
  520. #define TLS_DHE_PRIME_58B BIT(6)
  521. #define TLS_DHE_NON_PRIME BIT(7)
  522. void tls_connection_set_test_flags(struct tls_connection *conn, u32 flags);
  523. int tls_get_library_version(char *buf, size_t buf_len);
  524. void tls_connection_set_success_data(struct tls_connection *conn,
  525. struct wpabuf *data);
  526. void tls_connection_set_success_data_resumed(struct tls_connection *conn);
  527. const struct wpabuf *
  528. tls_connection_get_success_data(struct tls_connection *conn);
  529. void tls_connection_remove_session(struct tls_connection *conn);
  530. #endif /* TLS_H */