recmethod_local.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /*
  2. * Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <openssl/bio.h>
  10. #include <openssl/ssl.h>
  11. #include <openssl/err.h>
  12. #include "../../ssl_local.h"
  13. #include "../record_local.h"
  14. typedef struct dtls_bitmap_st {
  15. /* Track 64 packets */
  16. uint64_t map;
  17. /* Max record number seen so far, 64-bit value in big-endian encoding */
  18. unsigned char max_seq_num[SEQ_NUM_SIZE];
  19. } DTLS_BITMAP;
  20. typedef struct ssl_mac_buf_st {
  21. unsigned char *mac;
  22. int alloced;
  23. } SSL_MAC_BUF;
  24. typedef struct tls_buffer_st {
  25. /* at least SSL3_RT_MAX_PACKET_SIZE bytes */
  26. unsigned char *buf;
  27. /* default buffer size (or 0 if no default set) */
  28. size_t default_len;
  29. /* buffer size */
  30. size_t len;
  31. /* where to 'copy from' */
  32. size_t offset;
  33. /* how many bytes left */
  34. size_t left;
  35. /* 'buf' is from application for KTLS */
  36. int app_buffer;
  37. /* The type of data stored in this buffer. Only used for writing */
  38. int type;
  39. } TLS_BUFFER;
  40. typedef struct tls_rl_record_st {
  41. /* Record layer version */
  42. /* r */
  43. int rec_version;
  44. /* type of record */
  45. /* r */
  46. int type;
  47. /* How many bytes available */
  48. /* rw */
  49. size_t length;
  50. /*
  51. * How many bytes were available before padding was removed? This is used
  52. * to implement the MAC check in constant time for CBC records.
  53. */
  54. /* rw */
  55. size_t orig_len;
  56. /* read/write offset into 'buf' */
  57. /* r */
  58. size_t off;
  59. /* pointer to the record data */
  60. /* rw */
  61. unsigned char *data;
  62. /* where the decode bytes are */
  63. /* rw */
  64. unsigned char *input;
  65. /* only used with decompression - malloc()ed */
  66. /* r */
  67. unsigned char *comp;
  68. /* epoch number, needed by DTLS1 */
  69. /* r */
  70. uint16_t epoch;
  71. /* sequence number, needed by DTLS1 */
  72. /* r */
  73. unsigned char seq_num[SEQ_NUM_SIZE];
  74. } TLS_RL_RECORD;
  75. /* Macros/functions provided by the TLS_RL_RECORD component */
  76. #define TLS_RL_RECORD_set_type(r, t) ((r)->type = (t))
  77. #define TLS_RL_RECORD_set_rec_version(r, v) ((r)->rec_version = (v))
  78. #define TLS_RL_RECORD_get_length(r) ((r)->length)
  79. #define TLS_RL_RECORD_set_length(r, l) ((r)->length = (l))
  80. #define TLS_RL_RECORD_add_length(r, l) ((r)->length += (l))
  81. #define TLS_RL_RECORD_set_data(r, d) ((r)->data = (d))
  82. #define TLS_RL_RECORD_set_input(r, i) ((r)->input = (i))
  83. #define TLS_RL_RECORD_reset_input(r) ((r)->input = (r)->data)
  84. /* Protocol version specific function pointers */
  85. struct record_functions_st
  86. {
  87. /*
  88. * Returns either OSSL_RECORD_RETURN_SUCCESS, OSSL_RECORD_RETURN_FATAL or
  89. * OSSL_RECORD_RETURN_NON_FATAL_ERR if we can keep trying to find an
  90. * alternative record layer.
  91. */
  92. int (*set_crypto_state)(OSSL_RECORD_LAYER *rl, int level,
  93. unsigned char *key, size_t keylen,
  94. unsigned char *iv, size_t ivlen,
  95. unsigned char *mackey, size_t mackeylen,
  96. const EVP_CIPHER *ciph,
  97. size_t taglen,
  98. int mactype,
  99. const EVP_MD *md,
  100. COMP_METHOD *comp);
  101. /*
  102. * Returns:
  103. * 0: if the record is publicly invalid, or an internal error, or AEAD
  104. * decryption failed, or EtM decryption failed.
  105. * 1: Success or MtE decryption failed (MAC will be randomised)
  106. */
  107. int (*cipher)(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *recs, size_t n_recs,
  108. int sending, SSL_MAC_BUF *macs, size_t macsize);
  109. /* Returns 1 for success or 0 for error */
  110. int (*mac)(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *rec, unsigned char *md,
  111. int sending);
  112. /* Return 1 for success or 0 for error */
  113. int (*set_protocol_version)(OSSL_RECORD_LAYER *rl, int version);
  114. /* Read related functions */
  115. int (*read_n)(OSSL_RECORD_LAYER *rl, size_t n, size_t max, int extend,
  116. int clearold, size_t *readbytes);
  117. int (*get_more_records)(OSSL_RECORD_LAYER *rl);
  118. /* Return 1 for success or 0 for error */
  119. int (*validate_record_header)(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *rec);
  120. /* Return 1 for success or 0 for error */
  121. int (*post_process_record)(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *rec);
  122. /* Write related functions */
  123. size_t (*get_max_records)(OSSL_RECORD_LAYER *rl, uint8_t type, size_t len,
  124. size_t maxfrag, size_t *preffrag);
  125. /* Return 1 for success or 0 for error */
  126. int (*write_records)(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates,
  127. size_t numtempl);
  128. /* Allocate the rl->wbuf buffers. Return 1 for success or 0 for error */
  129. int (*allocate_write_buffers)(OSSL_RECORD_LAYER *rl,
  130. OSSL_RECORD_TEMPLATE *templates,
  131. size_t numtempl, size_t *prefix);
  132. /*
  133. * Initialise the packets in the |pkt| array using the buffers in |rl->wbuf|.
  134. * Some protocol versions may use the space in |prefixtempl| to add
  135. * an artificial template in front of the |templates| array and hence may
  136. * initialise 1 more WPACKET than there are templates. |*wpinited|
  137. * returns the number of WPACKETs in |pkt| that were successfully
  138. * initialised. This must be 0 on entry and will be filled in even on error.
  139. */
  140. int (*initialise_write_packets)(OSSL_RECORD_LAYER *rl,
  141. OSSL_RECORD_TEMPLATE *templates,
  142. size_t numtempl,
  143. OSSL_RECORD_TEMPLATE *prefixtempl,
  144. WPACKET *pkt,
  145. TLS_BUFFER *bufs,
  146. size_t *wpinited);
  147. /* Get the actual record type to be used for a given template */
  148. uint8_t (*get_record_type)(OSSL_RECORD_LAYER *rl,
  149. OSSL_RECORD_TEMPLATE *template);
  150. /* Write the record header data to the WPACKET */
  151. int (*prepare_record_header)(OSSL_RECORD_LAYER *rl, WPACKET *thispkt,
  152. OSSL_RECORD_TEMPLATE *templ,
  153. uint8_t rectype,
  154. unsigned char **recdata);
  155. int (*add_record_padding)(OSSL_RECORD_LAYER *rl,
  156. OSSL_RECORD_TEMPLATE *thistempl,
  157. WPACKET *thispkt,
  158. TLS_RL_RECORD *thiswr);
  159. /*
  160. * This applies any mac that might be necessary, ensures that we have enough
  161. * space in the WPACKET to perform the encryption and sets up the
  162. * TLS_RL_RECORD ready for that encryption.
  163. */
  164. int (*prepare_for_encryption)(OSSL_RECORD_LAYER *rl,
  165. size_t mac_size,
  166. WPACKET *thispkt,
  167. TLS_RL_RECORD *thiswr);
  168. /*
  169. * Any updates required to the record after encryption has been applied. For
  170. * example, adding a MAC if using encrypt-then-mac
  171. */
  172. int (*post_encryption_processing)(OSSL_RECORD_LAYER *rl,
  173. size_t mac_size,
  174. OSSL_RECORD_TEMPLATE *thistempl,
  175. WPACKET *thispkt,
  176. TLS_RL_RECORD *thiswr);
  177. /*
  178. * Some record layer implementations need to do some custom preparation of
  179. * the BIO before we write to it. KTLS does this to prevent coalescing of
  180. * control and data messages.
  181. */
  182. int (*prepare_write_bio)(OSSL_RECORD_LAYER *rl, int type);
  183. };
  184. struct ossl_record_layer_st
  185. {
  186. OSSL_LIB_CTX *libctx;
  187. const char *propq;
  188. int isdtls;
  189. int version;
  190. int role;
  191. int direction;
  192. int level;
  193. const EVP_MD *md;
  194. /* DTLS only */
  195. uint16_t epoch;
  196. /*
  197. * A BIO containing any data read in the previous epoch that was destined
  198. * for this epoch
  199. */
  200. BIO *prev;
  201. /* The transport BIO */
  202. BIO *bio;
  203. /*
  204. * A BIO where we will send any data read by us that is destined for the
  205. * next epoch.
  206. */
  207. BIO *next;
  208. /* Types match the equivalent fields in the SSL object */
  209. uint64_t options;
  210. uint32_t mode;
  211. /* write IO goes into here */
  212. TLS_BUFFER wbuf[SSL_MAX_PIPELINES + 1];
  213. /* Next wbuf with pending data still to write */
  214. size_t nextwbuf;
  215. /* How many pipelines can be used to write data */
  216. size_t numwpipes;
  217. /* read IO goes into here */
  218. TLS_BUFFER rbuf;
  219. /* each decoded record goes in here */
  220. TLS_RL_RECORD rrec[SSL_MAX_PIPELINES];
  221. /* How many records have we got available in the rrec buffer */
  222. size_t num_recs;
  223. /* The record number in the rrec buffer that can be read next */
  224. size_t curr_rec;
  225. /* The number of records that have been released via tls_release_record */
  226. size_t num_released;
  227. /* where we are when reading */
  228. int rstate;
  229. /* used internally to point at a raw packet */
  230. unsigned char *packet;
  231. size_t packet_length;
  232. /* Sequence number for the next record */
  233. unsigned char sequence[SEQ_NUM_SIZE];
  234. /* Alert code to be used if an error occurs */
  235. int alert;
  236. /*
  237. * Read as many input bytes as possible (for non-blocking reads)
  238. */
  239. int read_ahead;
  240. /* The number of consecutive empty records we have received */
  241. size_t empty_record_count;
  242. /*
  243. * Do we need to send a prefix empty record before application data as a
  244. * countermeasure against known-IV weakness (necessary for SSLv3 and
  245. * TLSv1.0)
  246. */
  247. int need_empty_fragments;
  248. /* cryptographic state */
  249. EVP_CIPHER_CTX *enc_ctx;
  250. /* Explicit IV length */
  251. size_t eivlen;
  252. /* used for mac generation */
  253. EVP_MD_CTX *md_ctx;
  254. /* compress/uncompress */
  255. COMP_CTX *compctx;
  256. /* Set to 1 if this is the first handshake. 0 otherwise */
  257. int is_first_handshake;
  258. /*
  259. * The smaller of the configured and negotiated maximum fragment length
  260. * or SSL3_RT_MAX_PLAIN_LENGTH if none
  261. */
  262. unsigned int max_frag_len;
  263. /* The maximum amount of early data we can receive/send */
  264. uint32_t max_early_data;
  265. /* The amount of early data that we have sent/received */
  266. size_t early_data_count;
  267. /* TLSv1.3 record padding */
  268. size_t block_padding;
  269. /* Only used by SSLv3 */
  270. unsigned char mac_secret[EVP_MAX_MD_SIZE];
  271. /* TLSv1.0/TLSv1.1/TLSv1.2 */
  272. int use_etm;
  273. /* Flags for GOST ciphers */
  274. int stream_mac;
  275. int tlstree;
  276. /* TLSv1.3 fields */
  277. /* static IV */
  278. unsigned char iv[EVP_MAX_IV_LENGTH];
  279. int allow_plain_alerts;
  280. /* TLS "any" fields */
  281. /* Set to true if this is the first record in a connection */
  282. unsigned int is_first_record;
  283. size_t taglen;
  284. /* DTLS received handshake records (processed and unprocessed) */
  285. struct pqueue_st *unprocessed_rcds;
  286. struct pqueue_st *processed_rcds;
  287. /* records being received in the current epoch */
  288. DTLS_BITMAP bitmap;
  289. /* renegotiation starts a new set of sequence numbers */
  290. DTLS_BITMAP next_bitmap;
  291. /*
  292. * Whether we are currently in a handshake or not. Only maintained for DTLS
  293. */
  294. int in_init;
  295. /* Callbacks */
  296. void *cbarg;
  297. OSSL_FUNC_rlayer_skip_early_data_fn *skip_early_data;
  298. OSSL_FUNC_rlayer_msg_callback_fn *msg_callback;
  299. OSSL_FUNC_rlayer_security_fn *security;
  300. OSSL_FUNC_rlayer_padding_fn *padding;
  301. size_t max_pipelines;
  302. /* Function pointers for version specific functions */
  303. const struct record_functions_st *funcs;
  304. };
  305. typedef struct dtls_rlayer_record_data_st {
  306. unsigned char *packet;
  307. size_t packet_length;
  308. TLS_BUFFER rbuf;
  309. TLS_RL_RECORD rrec;
  310. } DTLS_RLAYER_RECORD_DATA;
  311. extern const struct record_functions_st ssl_3_0_funcs;
  312. extern const struct record_functions_st tls_1_funcs;
  313. extern const struct record_functions_st tls_1_3_funcs;
  314. extern const struct record_functions_st tls_any_funcs;
  315. extern const struct record_functions_st dtls_1_funcs;
  316. extern const struct record_functions_st dtls_1_3_funcs;
  317. extern const struct record_functions_st dtls_any_funcs;
  318. void ossl_rlayer_fatal(OSSL_RECORD_LAYER *rl, int al, int reason,
  319. const char *fmt, ...);
  320. #define RLAYERfatal(rl, al, r) RLAYERfatal_data((rl), (al), (r), NULL)
  321. #define RLAYERfatal_data \
  322. (ERR_new(), \
  323. ERR_set_debug(OPENSSL_FILE, OPENSSL_LINE, OPENSSL_FUNC), \
  324. ossl_rlayer_fatal)
  325. #define RLAYER_USE_EXPLICIT_IV(rl) ((rl)->version == TLS1_1_VERSION \
  326. || (rl)->version == TLS1_2_VERSION \
  327. || (rl)->version == DTLS1_BAD_VER \
  328. || (rl)->version == DTLS1_VERSION \
  329. || (rl)->version == DTLS1_2_VERSION)
  330. void ossl_tls_rl_record_set_seq_num(TLS_RL_RECORD *r,
  331. const unsigned char *seq_num);
  332. int ossl_set_tls_provider_parameters(OSSL_RECORD_LAYER *rl,
  333. EVP_CIPHER_CTX *ctx,
  334. const EVP_CIPHER *ciph,
  335. const EVP_MD *md);
  336. int tls_increment_sequence_ctr(OSSL_RECORD_LAYER *rl);
  337. int tls_alloc_buffers(OSSL_RECORD_LAYER *rl);
  338. int tls_free_buffers(OSSL_RECORD_LAYER *rl);
  339. int tls_default_read_n(OSSL_RECORD_LAYER *rl, size_t n, size_t max, int extend,
  340. int clearold, size_t *readbytes);
  341. int tls_get_more_records(OSSL_RECORD_LAYER *rl);
  342. int dtls_get_more_records(OSSL_RECORD_LAYER *rl);
  343. int dtls_prepare_record_header(OSSL_RECORD_LAYER *rl,
  344. WPACKET *thispkt,
  345. OSSL_RECORD_TEMPLATE *templ,
  346. uint8_t rectype,
  347. unsigned char **recdata);
  348. int dtls_post_encryption_processing(OSSL_RECORD_LAYER *rl,
  349. size_t mac_size,
  350. OSSL_RECORD_TEMPLATE *thistempl,
  351. WPACKET *thispkt,
  352. TLS_RL_RECORD *thiswr);
  353. int tls_default_set_protocol_version(OSSL_RECORD_LAYER *rl, int version);
  354. int tls_default_validate_record_header(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *re);
  355. int tls_do_compress(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *wr);
  356. int tls_do_uncompress(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *rec);
  357. int tls_default_post_process_record(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *rec);
  358. int tls13_common_post_process_record(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *rec);
  359. int
  360. tls_int_new_record_layer(OSSL_LIB_CTX *libctx, const char *propq, int vers,
  361. int role, int direction, int level,
  362. const EVP_CIPHER *ciph, size_t taglen,
  363. const EVP_MD *md, COMP_METHOD *comp, BIO *prev,
  364. BIO *transport, BIO *next,
  365. const OSSL_PARAM *settings, const OSSL_PARAM *options,
  366. const OSSL_DISPATCH *fns, void *cbarg,
  367. OSSL_RECORD_LAYER **retrl);
  368. int tls_free(OSSL_RECORD_LAYER *rl);
  369. int tls_unprocessed_read_pending(OSSL_RECORD_LAYER *rl);
  370. int tls_processed_read_pending(OSSL_RECORD_LAYER *rl);
  371. size_t tls_app_data_pending(OSSL_RECORD_LAYER *rl);
  372. size_t tls_get_max_records(OSSL_RECORD_LAYER *rl, uint8_t type, size_t len,
  373. size_t maxfrag, size_t *preffrag);
  374. int tls_write_records(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates,
  375. size_t numtempl);
  376. int tls_retry_write_records(OSSL_RECORD_LAYER *rl);
  377. int tls_get_alert_code(OSSL_RECORD_LAYER *rl);
  378. int tls_set1_bio(OSSL_RECORD_LAYER *rl, BIO *bio);
  379. int tls_read_record(OSSL_RECORD_LAYER *rl, void **rechandle, int *rversion,
  380. uint8_t *type, const unsigned char **data, size_t *datalen,
  381. uint16_t *epoch, unsigned char *seq_num);
  382. int tls_release_record(OSSL_RECORD_LAYER *rl, void *rechandle, size_t length);
  383. int tls_default_set_protocol_version(OSSL_RECORD_LAYER *rl, int version);
  384. int tls_set_protocol_version(OSSL_RECORD_LAYER *rl, int version);
  385. void tls_set_plain_alerts(OSSL_RECORD_LAYER *rl, int allow);
  386. void tls_set_first_handshake(OSSL_RECORD_LAYER *rl, int first);
  387. void tls_set_max_pipelines(OSSL_RECORD_LAYER *rl, size_t max_pipelines);
  388. void tls_get_state(OSSL_RECORD_LAYER *rl, const char **shortstr,
  389. const char **longstr);
  390. int tls_set_options(OSSL_RECORD_LAYER *rl, const OSSL_PARAM *options);
  391. const COMP_METHOD *tls_get_compression(OSSL_RECORD_LAYER *rl);
  392. void tls_set_max_frag_len(OSSL_RECORD_LAYER *rl, size_t max_frag_len);
  393. int tls_setup_read_buffer(OSSL_RECORD_LAYER *rl);
  394. int tls_setup_write_buffer(OSSL_RECORD_LAYER *rl, size_t numwpipes,
  395. size_t firstlen, size_t nextlen);
  396. int tls_write_records_multiblock(OSSL_RECORD_LAYER *rl,
  397. OSSL_RECORD_TEMPLATE *templates,
  398. size_t numtempl);
  399. size_t tls_get_max_records_default(OSSL_RECORD_LAYER *rl, uint8_t type,
  400. size_t len,
  401. size_t maxfrag, size_t *preffrag);
  402. size_t tls_get_max_records_multiblock(OSSL_RECORD_LAYER *rl, uint8_t type,
  403. size_t len, size_t maxfrag,
  404. size_t *preffrag);
  405. int tls_allocate_write_buffers_default(OSSL_RECORD_LAYER *rl,
  406. OSSL_RECORD_TEMPLATE *templates,
  407. size_t numtempl, size_t *prefix);
  408. int tls_initialise_write_packets_default(OSSL_RECORD_LAYER *rl,
  409. OSSL_RECORD_TEMPLATE *templates,
  410. size_t numtempl,
  411. OSSL_RECORD_TEMPLATE *prefixtempl,
  412. WPACKET *pkt,
  413. TLS_BUFFER *bufs,
  414. size_t *wpinited);
  415. int tls1_allocate_write_buffers(OSSL_RECORD_LAYER *rl,
  416. OSSL_RECORD_TEMPLATE *templates,
  417. size_t numtempl, size_t *prefix);
  418. int tls1_initialise_write_packets(OSSL_RECORD_LAYER *rl,
  419. OSSL_RECORD_TEMPLATE *templates,
  420. size_t numtempl,
  421. OSSL_RECORD_TEMPLATE *prefixtempl,
  422. WPACKET *pkt,
  423. TLS_BUFFER *bufs,
  424. size_t *wpinited);
  425. int tls_prepare_record_header_default(OSSL_RECORD_LAYER *rl,
  426. WPACKET *thispkt,
  427. OSSL_RECORD_TEMPLATE *templ,
  428. uint8_t rectype,
  429. unsigned char **recdata);
  430. int tls_prepare_for_encryption_default(OSSL_RECORD_LAYER *rl,
  431. size_t mac_size,
  432. WPACKET *thispkt,
  433. TLS_RL_RECORD *thiswr);
  434. int tls_post_encryption_processing_default(OSSL_RECORD_LAYER *rl,
  435. size_t mac_size,
  436. OSSL_RECORD_TEMPLATE *thistempl,
  437. WPACKET *thispkt,
  438. TLS_RL_RECORD *thiswr);
  439. int tls_write_records_default(OSSL_RECORD_LAYER *rl,
  440. OSSL_RECORD_TEMPLATE *templates,
  441. size_t numtempl);
  442. /* Macros/functions provided by the TLS_BUFFER component */
  443. #define TLS_BUFFER_get_buf(b) ((b)->buf)
  444. #define TLS_BUFFER_set_buf(b, n) ((b)->buf = (n))
  445. #define TLS_BUFFER_get_len(b) ((b)->len)
  446. #define TLS_BUFFER_get_left(b) ((b)->left)
  447. #define TLS_BUFFER_set_left(b, l) ((b)->left = (l))
  448. #define TLS_BUFFER_sub_left(b, l) ((b)->left -= (l))
  449. #define TLS_BUFFER_get_offset(b) ((b)->offset)
  450. #define TLS_BUFFER_set_offset(b, o) ((b)->offset = (o))
  451. #define TLS_BUFFER_add_offset(b, o) ((b)->offset += (o))
  452. #define TLS_BUFFER_set_app_buffer(b, l) ((b)->app_buffer = (l))
  453. #define TLS_BUFFER_is_app_buffer(b) ((b)->app_buffer)
  454. void ossl_tls_buffer_release(TLS_BUFFER *b);