openssl-quic.7ossl 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "OPENSSL-QUIC 7ossl"
  136. .TH OPENSSL-QUIC 7ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. openssl\-quic \- OpenSSL QUIC
  143. .SH "DESCRIPTION"
  144. .IX Header "DESCRIPTION"
  145. OpenSSL 3.2 and later features support for the \s-1QUIC\s0 transport protocol.
  146. Currently, only client connectivity is supported. This man page describes the
  147. usage of \s-1QUIC\s0 client functionality for both existing and new applications.
  148. .PP
  149. \&\s-1QUIC\s0 functionality uses the standard \s-1SSL API. A QUIC\s0 connection is represented
  150. by an \s-1SSL\s0 object in the same way that a \s-1TLS\s0 connection is. Only minimal changes
  151. are needed to existing applications making use of the libssl APIs to make use of
  152. \&\s-1QUIC\s0 client functionality. To make use of \s-1QUIC,\s0 use the \s-1SSL\s0 method
  153. \&\fBOSSL_QUIC_client_method\fR\|(3) or \fBOSSL_QUIC_client_thread_method\fR\|(3) with
  154. \&\fBSSL_CTX_new\fR\|(3).
  155. .PP
  156. When a \s-1QUIC\s0 connection is created, by default, it operates in default stream
  157. mode, which is intended to provide compatibility with existing non-QUIC
  158. application usage patterns. In this mode, the connection has a single
  159. stream associated with it. Calls to \fBSSL_read\fR\|(3) and
  160. \&\fBSSL_write\fR\|(3) on the \s-1QUIC\s0 connection \s-1SSL\s0 object read and write from that
  161. stream. Whether the stream is client-initiated or server-initiated from a \s-1QUIC\s0
  162. perspective depends on whether \fBSSL_read\fR\|(3) or \fBSSL_write\fR\|(3) is called
  163. first. See the \s-1MODES OF OPERATION\s0 section for more information.
  164. .PP
  165. The default stream mode is intended for compatibility with existing
  166. applications. New applications using \s-1QUIC\s0 are recommended to disable default
  167. stream mode and use the multi-stream \s-1API\s0; see the \s-1MODES OF OPERATION\s0 section and
  168. the \s-1RECOMMENDATIONS FOR NEW APPLICATIONS\s0 section for more information.
  169. .PP
  170. The remainder of this man page discusses, in order:
  171. .IP "\(bu" 4
  172. Default stream mode versus multi-stream mode;
  173. .IP "\(bu" 4
  174. The changes to existing libssl APIs which are driven by QUIC-related implementation
  175. requirements, which existing applications should bear in mind;
  176. .IP "\(bu" 4
  177. Aspects which must be considered by existing applications when adopting \s-1QUIC,\s0
  178. including potential changes which may be needed.
  179. .IP "\(bu" 4
  180. Recommended usage approaches for new applications.
  181. .IP "\(bu" 4
  182. New, QUIC-specific APIs.
  183. .SH "MODES OF OPERATION"
  184. .IX Header "MODES OF OPERATION"
  185. .SS "Default Stream Mode"
  186. .IX Subsection "Default Stream Mode"
  187. A \s-1QUIC\s0 client connection can be used in either default stream mode or
  188. multi-stream mode. By default, a newly created \s-1QUIC\s0 connection \s-1SSL\s0 object uses
  189. default stream mode.
  190. .PP
  191. In default stream mode, a stream is implicitly created and bound to the \s-1QUIC\s0
  192. connection \s-1SSL\s0 object; \fBSSL_read\fR\|(3) and \fBSSL_write\fR\|(3) calls to the \s-1QUIC\s0
  193. connection \s-1SSL\s0 object work by default and are mapped to that stream.
  194. .PP
  195. When default stream mode is used, any \s-1API\s0 function which can be called on a \s-1QUIC\s0
  196. stream \s-1SSL\s0 object can also be called on a \s-1QUIC\s0 connection \s-1SSL\s0 object, in which
  197. case it affects the default stream bound to the connection.
  198. .PP
  199. The identity of a \s-1QUIC\s0 stream, including its stream \s-1ID,\s0 varies depending on
  200. whether a stream is client-initiated or server-initiated. In default stream
  201. mode, if a client application calls \fBSSL_read\fR\|(3) first before any call to
  202. \&\fBSSL_write\fR\|(3) on the connection, it is assumed that the application protocol
  203. is using a server-initiated stream, and the \fBSSL_read\fR\|(3) call will not
  204. complete (either blocking, or failing appropriately if nonblocking mode is
  205. configured) until the server initiates a stream. Conversely, if the client
  206. application calls \fBSSL_write\fR\|(3) before any call to \fBSSL_read\fR\|(3) on the
  207. connection, it is assumed that a client-initiated stream is to be used
  208. and such a stream is created automatically.
  209. .PP
  210. Default stream mode is intended to aid compatibility with legacy applications.
  211. New applications adopting \s-1QUIC\s0 should use multi-stream mode, described below,
  212. and avoid use of the default stream functionality.
  213. .PP
  214. It is possible to use additional streams in default stream mode using
  215. \&\fBSSL_new_stream\fR\|(3) and \fBSSL_accept_stream\fR\|(3); note that the default incoming
  216. stream policy will need to be changed using \fBSSL_set_incoming_stream_policy\fR\|(3)
  217. in order to use \fBSSL_accept_stream\fR\|(3) in this case. However, applications
  218. using additional streams are strongly recommended to use multi-stream mode
  219. instead.
  220. .PP
  221. Calling \fBSSL_new_stream\fR\|(3) or \fBSSL_accept_stream\fR\|(3) before a default stream
  222. has been associated with the \s-1QUIC\s0 connection \s-1SSL\s0 object will inhibit future
  223. creation of a default stream.
  224. .SS "Multi-Stream Mode"
  225. .IX Subsection "Multi-Stream Mode"
  226. The recommended usage mode for new applications adopting \s-1QUIC\s0 is multi-stream
  227. mode, in which no default stream is attached to the \s-1QUIC\s0 connection \s-1SSL\s0 object
  228. and attempts to call \fBSSL_read\fR\|(3) and \fBSSL_write\fR\|(3) on the \s-1QUIC\s0 connection
  229. \&\s-1SSL\s0 object fail. Instead, an application calls \fBSSL_new_stream\fR\|(3) or
  230. \&\fBSSL_accept_stream\fR\|(3) to create individual stream \s-1SSL\s0 objects for sending and
  231. receiving application data using \fBSSL_read\fR\|(3) and \fBSSL_write\fR\|(3).
  232. .PP
  233. To use multi-stream mode, call \fBSSL_set_default_stream_mode\fR\|(3) with an
  234. argument of \fB\s-1SSL_DEFAULT_STREAM_MODE_NONE\s0\fR; this function must be called prior
  235. to initiating the connection. The default stream mode cannot be changed after
  236. initiating a connection.
  237. .PP
  238. When multi-stream mode is used, meaning that no default stream is associated
  239. with the connection, calls to \s-1API\s0 functions which are defined as operating on a
  240. \&\s-1QUIC\s0 stream fail if called on the \s-1QUIC\s0 connection \s-1SSL\s0 object. For example, calls
  241. such as \fBSSL_write\fR\|(3) or \fBSSL_get_stream_id\fR\|(3) will fail.
  242. .SH "CHANGES TO EXISTING APIS"
  243. .IX Header "CHANGES TO EXISTING APIS"
  244. Most \s-1SSL\s0 APIs, such as \fBSSL_read\fR\|(3) and \fBSSL_write\fR\|(3), function as they do
  245. for \s-1TLS\s0 connections and do not have changed semantics, with some exceptions. The
  246. changes to the semantics of existing APIs are as follows:
  247. .IP "\(bu" 4
  248. Since \s-1QUIC\s0 uses \s-1UDP,\s0 \fBSSL_set_bio\fR\|(3), \fBSSL_set0_rbio\fR\|(3) and
  249. \&\fBSSL_set0_wbio\fR\|(3) function as before, but must now receive a \s-1BIO\s0 with datagram
  250. semantics. There are broadly four options for applications to use as a network
  251. \&\s-1BIO:\s0
  252. .RS 4
  253. .IP "\(bu" 4
  254. \&\fBBIO_s_datagram\fR\|(3), recommended for most applications, replaces
  255. \&\fBBIO_s_socket\fR\|(3) and provides a \s-1UDP\s0 socket.
  256. .IP "\(bu" 4
  257. \&\fBBIO_s_dgram_pair\fR\|(3) provides \s-1BIO\s0 pair-like functionality but with datagram
  258. semantics, and is recommended for existing applications which use a \s-1BIO\s0 pair or
  259. memory \s-1BIO\s0 to manage libssl's communication with the network.
  260. .IP "\(bu" 4
  261. \&\fBBIO_s_dgram_mem\fR\|(3) provides a simple memory BIO-like interface but with
  262. datagram semantics. Unlike \fBBIO_s_dgram_pair\fR\|(3), it is unidirectional.
  263. .IP "\(bu" 4
  264. An application may also choose to implement a custom \s-1BIO.\s0 The new
  265. \&\fBBIO_sendmmsg\fR\|(3) and \fBBIO_recvmmsg\fR\|(3) APIs must be supported.
  266. .RE
  267. .RS 4
  268. .RE
  269. .IP "\(bu" 4
  270. \&\fBSSL_set_fd\fR\|(3), \fBSSL_set_rfd\fR\|(3) and \fBSSL_set_wfd\fR\|(3) traditionally
  271. instantiate a \fBBIO_s_socket\fR\|(3). For \s-1QUIC,\s0 these functions instead instantiate
  272. a \fBBIO_s_datagram\fR\|(3). This is equivalent to instantiating a
  273. \&\fBBIO_s_datagram\fR\|(3) and using \fBSSL_set0_rbio\fR\|(3) and \fBSSL_set0_wbio\fR\|(3).
  274. .IP "\(bu" 4
  275. Traditionally, whether the application-level I/O APIs (such as \fBSSL_read\fR\|(3)
  276. and \fBSSL_write\fR\|(3) operated in a blocking fashion was directly correlated with
  277. whether the underlying network socket was configured in a blocking fashion. This
  278. is no longer the case; applications must explicitly configure the desired
  279. application-level blocking mode using \fBSSL_set_blocking_mode\fR\|(3). See
  280. \&\fBSSL_set_blocking_mode\fR\|(3) for details.
  281. .IP "\(bu" 4
  282. Network-level I/O must always be performed in a nonblocking manner. The
  283. application can still enjoy blocking semantics for calls to application-level
  284. I/O functions such as \fBSSL_read\fR\|(3) and \fBSSL_write\fR\|(3), but the underlying
  285. network \s-1BIO\s0 provided to \s-1QUIC\s0 (such as a \fBBIO_s_datagram\fR\|(3)) must be configured
  286. in nonblocking mode. For application-level blocking functionality, see
  287. \&\fBSSL_set_blocking_mode\fR\|(3).
  288. .IP "\(bu" 4
  289. \&\fBBIO_new_ssl_connect\fR\|(3) has been changed to automatically use a
  290. \&\fBBIO_s_datagram\fR\|(3) when used with \s-1QUIC,\s0 therefore applications which use this
  291. do not need to change the \s-1BIO\s0 they use.
  292. .IP "\(bu" 4
  293. \&\fBBIO_new_buffer_ssl_connect\fR\|(3) cannot be used with \s-1QUIC\s0 and applications must
  294. change to use \fBBIO_new_ssl_connect\fR\|(3) instead.
  295. .IP "\(bu" 4
  296. \&\fBSSL_shutdown\fR\|(3) has significant changes in relation to how \s-1QUIC\s0 connections
  297. must be shut down. In particular, applications should be advised that the full
  298. RFC-conformant \s-1QUIC\s0 shutdown process may take an extended amount of time. This
  299. may not be suitable for short-lived processes which should exit immediately
  300. after their usage of a \s-1QUIC\s0 connection is completed. A rapid shutdown mode
  301. is available for such applications. For details, see \fBSSL_shutdown\fR\|(3).
  302. .IP "\(bu" 4
  303. \&\fBSSL_want\fR\|(3), \fBSSL_want_read\fR\|(3) and \fBSSL_want_write\fR\|(3) no longer reflect
  304. the I/O state of the network \s-1BIO\s0 passed to the \s-1QUIC SSL\s0 object, but instead
  305. reflect the flow control state of the \s-1QUIC\s0 stream associated with the \s-1SSL\s0
  306. object.
  307. .Sp
  308. When used in nonblocking mode, \fB\s-1SSL_ERROR_WANT_READ\s0\fR indicates that the
  309. receive part of a \s-1QUIC\s0 stream does not currently have any more data available to
  310. be read, and \fB\s-1SSL_ERROR_WANT_WRITE\s0\fR indicates that the stream's internal buffer
  311. is full.
  312. .Sp
  313. To determine if the \s-1QUIC\s0 implementation currently wishes to be informed of
  314. incoming network datagrams, use the new function \fBSSL_net_read_desired\fR\|(3);
  315. likewise, to determine if the \s-1QUIC\s0 implementation currently wishes to be
  316. informed when it is possible to transmit network datagrams, use the new function
  317. \&\fBSSL_net_write_desired\fR\|(3). Only applications which wish to manage their own event
  318. loops need to use these functions; see \fBAPPLICATION-DRIVEN \s-1EVENT LOOPS\s0\fR for
  319. further discussion.
  320. .IP "\(bu" 4
  321. The use of \s-1ALPN\s0 is mandatory when using \s-1QUIC.\s0 Attempts to connect without
  322. configuring \s-1ALPN\s0 will fail. For information on how to configure \s-1ALPN,\s0 see
  323. \&\fBSSL_set_alpn_protos\fR\|(3).
  324. .IP "\(bu" 4
  325. Whether \s-1QUIC\s0 operates in a client or server mode is determined by the
  326. \&\fB\s-1SSL_METHOD\s0\fR used, rather than by calls to \fBSSL_set_connect_state\fR\|(3) or
  327. \&\fBSSL_set_accept_state\fR\|(3). It is not necessary to call either of
  328. \&\fBSSL_set_connect_state\fR\|(3) or \fBSSL_set_accept_state\fR\|(3) before connecting, but
  329. if either of these are called, the function called must be congruent with the
  330. \&\fB\s-1SSL_METHOD\s0\fR being used. Currently, only client mode is supported.
  331. .IP "\(bu" 4
  332. The \fBSSL_set_min_proto_version\fR\|(3) and \fBSSL_set_max_proto_version\fR\|(3) APIs are
  333. not used and the values passed to them are ignored, as OpenSSL \s-1QUIC\s0 currently
  334. always uses \s-1TLS 1.3.\s0
  335. .IP "\(bu" 4
  336. The following libssl functionality is not available when used with \s-1QUIC.\s0
  337. .RS 4
  338. .IP "\(bu" 4
  339. Async functionality
  340. .IP "\(bu" 4
  341. \&\fB\s-1SSL_MODE_AUTO_RETRY\s0\fR
  342. .IP "\(bu" 4
  343. Record Padding and Fragmentation (\fBSSL_set_block_padding\fR\|(3), etc.)
  344. .IP "\(bu" 4
  345. \&\fBSSL_stateless\fR\|(3) support
  346. .IP "\(bu" 4
  347. \&\s-1SRTP\s0 functionality
  348. .IP "\(bu" 4
  349. TLSv1.3 Early Data
  350. .IP "\(bu" 4
  351. \&\s-1TLS\s0 Next Protocol Negotiation cannot be used and is superseded by \s-1ALPN,\s0 which
  352. must be used instead. The use of \s-1ALPN\s0 is mandatory with \s-1QUIC.\s0
  353. .IP "\(bu" 4
  354. Post-Handshake Client Authentication is not available as \s-1QUIC\s0 prohibits its use.
  355. .IP "\(bu" 4
  356. \&\s-1QUIC\s0 requires the use of TLSv1.3 or later, therefore functionality only relevant
  357. to older \s-1TLS\s0 versions is not available.
  358. .IP "\(bu" 4
  359. Some cipher suites which are generally available for TLSv1.3 are not available
  360. for \s-1QUIC,\s0 such as \fB\s-1TLS_AES_128_CCM_8_SHA256\s0\fR. Your application may need to
  361. adjust the list of acceptable cipher suites it passes to libssl.
  362. .IP "\(bu" 4
  363. \&\s-1CCM\s0 mode is not currently supported.
  364. .RE
  365. .RS 4
  366. .Sp
  367. The following libssl functionality is also not available when used with \s-1QUIC,\s0
  368. but calls to the relevant functions are treated as no-ops:
  369. .IP "\(bu" 4
  370. Readahead (\fBSSL_set_read_ahead\fR\|(3), etc.)
  371. .RE
  372. .RS 4
  373. .RE
  374. .SH "CONSIDERATIONS FOR EXISTING APPLICATIONS"
  375. .IX Header "CONSIDERATIONS FOR EXISTING APPLICATIONS"
  376. Existing applications seeking to adopt \s-1QUIC\s0 should apply the following list to
  377. determine what changes they will need to make:
  378. .IP "\(bu" 4
  379. An application wishing to use \s-1QUIC\s0 must use \fBOSSL_QUIC_client_method\fR\|(3) or
  380. \&\fBOSSL_QUIC_client_thread_method\fR\|(3) as its \s-1SSL\s0 method. For more information
  381. on the differences between these two methods, see \fB\s-1THREAD ASSISTED MODE\s0\fR.
  382. .IP "\(bu" 4
  383. Determine how to provide \s-1QUIC\s0 with network access. Determine which of the below
  384. apply for your application:
  385. .RS 4
  386. .IP "\(bu" 4
  387. Your application uses \fBBIO_s_socket\fR\|(3) to construct a \s-1BIO\s0 which is passed to
  388. the \s-1SSL\s0 object to provide it with network access.
  389. .Sp
  390. Changes needed: Change your application to use \fBBIO_s_datagram\fR\|(3) instead when
  391. using \s-1QUIC.\s0 The socket must be configured in nonblocking mode. You may or may
  392. not need to use \fBSSL_set1_initial_peer_addr\fR\|(3) to set the initial peer
  393. address; see the \fBQUIC-SPECIFIC \s-1APIS\s0\fR section for details.
  394. .IP "\(bu" 4
  395. Your application uses \fBBIO_new_ssl_connect\fR\|(3) to
  396. construct a \s-1BIO\s0 which is passed to the \s-1SSL\s0 object to provide it with network
  397. access.
  398. .Sp
  399. Changes needed: No changes needed. Use of \s-1QUIC\s0 is detected automatically and a
  400. datagram socket is created instead of a normal \s-1TCP\s0 socket.
  401. .IP "\(bu" 4
  402. Your application uses any other I/O strategy in this list but combines it with a
  403. \&\fBBIO_f_buffer\fR\|(3), for example using \fBBIO_push\fR\|(3).
  404. .Sp
  405. Changes needed: Disable the usage of \fBBIO_f_buffer\fR\|(3) when using \s-1QUIC.\s0 Usage
  406. of such a buffer is incompatible with \s-1QUIC\s0 as \s-1QUIC\s0 requires datagram semantics
  407. in its interaction with the network.
  408. .IP "\(bu" 4
  409. Your application uses a \s-1BIO\s0 pair to cause the \s-1SSL\s0 object to read and write
  410. network traffic to a memory buffer. Your application manages the transmission
  411. and reception of buffered data itself in a way unknown to libssl.
  412. .Sp
  413. Changes needed: Switch from using a conventional \s-1BIO\s0 pair to using
  414. \&\fBBIO_s_dgram_pair\fR\|(3) instead, which has the necessary datagram semantics. You
  415. will need to modify your application to transmit and receive using a \s-1UDP\s0 socket
  416. and to use datagram semantics when interacting with the \fBBIO_s_dgram_pair\fR\|(3)
  417. instance.
  418. .IP "\(bu" 4
  419. Your application uses a custom \s-1BIO\s0 method to provide the \s-1SSL\s0 object with network
  420. access.
  421. .Sp
  422. Changes needed: The custom \s-1BIO\s0 must be re-architected to have datagram
  423. semantics. \fBBIO_sendmmsg\fR\|(3) and \fBBIO_recvmmsg\fR\|(3) must be implemented. These
  424. calls must operate in a nonblocking fashion. Optionally, implement the
  425. \&\fBBIO_get_rpoll_descriptor\fR\|(3) and \fBBIO_get_wpoll_descriptor\fR\|(3) methods if
  426. desired. Implementing these methods is required if blocking semantics at the \s-1SSL
  427. API\s0 level are desired.
  428. .RE
  429. .RS 4
  430. .RE
  431. .IP "\(bu" 4
  432. An application must explicitly configure whether it wishes to use the \s-1SSL\s0 APIs
  433. in blocking mode or not. Traditionally, an \s-1SSL\s0 object has automatically operated
  434. in blocking or nonblocking mode based on whether the underlying network \s-1BIO\s0
  435. operates in blocking or nonblocking mode. \s-1QUIC\s0 requires the use of a
  436. nonblocking network \s-1BIO,\s0 therefore the blocking mode at the application level
  437. must be explicitly configured by the application using the new
  438. \&\fBSSL_set_blocking_mode\fR\|(3) \s-1API.\s0 The default mode is blocking. If an application
  439. wishes to use the \s-1SSL\s0 object APIs at application level in a nonblocking manner,
  440. it must add a call to \fBSSL_set_blocking_mode\fR\|(3) to disable blocking mode.
  441. .IP "\(bu" 4
  442. If your application does not choose to use thread assisted mode, it must ensure
  443. that it calls an I/O function on the \s-1SSL\s0 object (for example, \fBSSL_read\fR\|(3) or
  444. \&\fBSSL_write\fR\|(3)), or the new function \fBSSL_handle_events\fR\|(3), regularly. If the
  445. \&\s-1SSL\s0 object is used in blocking mode, an ongoing blocking call to an I/O function
  446. satisfies this requirement. This is required to ensure that timer events
  447. required by \s-1QUIC\s0 are handled in a timely fashion.
  448. .Sp
  449. Most applications will service the \s-1SSL\s0 object by calling \fBSSL_read\fR\|(3) or
  450. \&\fBSSL_write\fR\|(3) regularly. If an application does not do this, it should ensure
  451. that \fBSSL_handle_events\fR\|(3) is called regularly.
  452. .Sp
  453. \&\fBSSL_get_event_timeout\fR\|(3) can be used to determine when
  454. \&\fBSSL_handle_events\fR\|(3) must next be called.
  455. .Sp
  456. If the \s-1SSL\s0 object is being used with an underlying network \s-1BIO\s0 which is pollable
  457. (such as \fBBIO_s_datagram\fR\|(3)), the application can use
  458. \&\fBSSL_get_rpoll_descriptor\fR\|(3), \fBSSL_get_wpoll_descriptor\fR\|(3) to obtain
  459. resources which can be used to determine when \fBSSL_handle_events\fR\|(3) should be
  460. called due to network I/O.
  461. .Sp
  462. Applications which use thread assisted mode do not need to be concerned
  463. with this requirement, as the \s-1QUIC\s0 implementation ensures timeout events
  464. are handled in a timely manner. See \fB\s-1THREAD ASSISTED MODE\s0\fR for details.
  465. .IP "\(bu" 4
  466. Ensure that your usage of \fBSSL_want\fR\|(3), \fBSSL_want_read\fR\|(3) and
  467. \&\fBSSL_want_write\fR\|(3) reflects the \s-1API\s0 changes described in \fB\s-1CHANGES TO EXISTING
  468. APIS\s0\fR. In particular, you should use these APIs to determine the ability of a
  469. \&\s-1QUIC\s0 stream to receive or provide application data, not to to determine if
  470. network I/O is required.
  471. .IP "\(bu" 4
  472. Evaluate your application's use of \fBSSL_shutdown\fR\|(3) in light of the changes
  473. discussed in \fB\s-1CHANGES TO EXISTING APIS\s0\fR. Depending on whether your application
  474. wishes to prioritise \s-1RFC\s0 conformance or rapid shutdown, consider using the new
  475. \&\fBSSL_shutdown_ex\fR\|(3) \s-1API\s0 instead. See \fBQUIC-SPECIFIC \s-1APIS\s0\fR for details.
  476. .SH "RECOMMENDED USAGE IN NEW APPLICATIONS"
  477. .IX Header "RECOMMENDED USAGE IN NEW APPLICATIONS"
  478. The recommended usage in new applications varies depending on three independent
  479. design decisions:
  480. .IP "\(bu" 4
  481. Whether the application will use blocking or nonblocking I/O at the application
  482. level (configured using \fBSSL_set_blocking_mode\fR\|(3)).
  483. .Sp
  484. If the application does nonblocking I/O at the application level it can choose
  485. to manage its own polling and event loop; see \fBAPPLICATION-DRIVEN \s-1EVENT LOOPS\s0\fR.
  486. .IP "\(bu" 4
  487. Whether the application intends to give the \s-1QUIC\s0 implementation direct access to
  488. a network socket (e.g. via \fBBIO_s_datagram\fR\|(3)) or whether it intends to buffer
  489. transmitted and received datagrams via a \fBBIO_s_dgram_pair\fR\|(3) or custom \s-1BIO.\s0
  490. .Sp
  491. The former is preferred where possible as it reduces latency to the network,
  492. which enables \s-1QUIC\s0 to achieve higher performance and more accurate connection
  493. round trip time (\s-1RTT\s0) estimation.
  494. .IP "\(bu" 4
  495. Whether thread assisted mode will be used (see \fB\s-1THREAD ASSISTED MODE\s0\fR).
  496. .PP
  497. Simple demos for \s-1QUIC\s0 usage under these various scenarios can be found at
  498. <https://github.com/openssl/openssl/tree/master/doc/designs/ddd>.
  499. .PP
  500. Applications which wish to implement QUIC-specific protocols should be aware of
  501. the APIs listed under \fBQUIC-SPECIFIC \s-1APIS\s0\fR which provide access to
  502. QUIC-specific functionality. For example, \fBSSL_stream_conclude\fR\|(3) can be used
  503. to indicate the end of the sending part of a stream, and \fBSSL_shutdown_ex\fR\|(3)
  504. can be used to provide a \s-1QUIC\s0 application error code when closing a connection.
  505. .PP
  506. Regardless of the design decisions chosen above, it is recommended that new
  507. applications avoid use of the default stream mode and use the multi-stream \s-1API\s0
  508. by calling \fBSSL_set_default_stream_mode\fR\|(3); see the \s-1MODES OF OPERATION\s0 section
  509. for details.
  510. .SH "QUIC-SPECIFIC APIS"
  511. .IX Header "QUIC-SPECIFIC APIS"
  512. This section details new APIs which are directly or indirectly related to \s-1QUIC.\s0
  513. For details on the operation of each \s-1API,\s0 see the referenced man pages.
  514. .PP
  515. The following \s-1SSL\s0 APIs are new but relevant to both \s-1QUIC\s0 and \s-1DTLS:\s0
  516. .IP "\fBSSL_get_event_timeout\fR\|(3)" 4
  517. .IX Item "SSL_get_event_timeout"
  518. Determines when the \s-1QUIC\s0 implementation should next be woken up via a call to
  519. \&\fBSSL_handle_events\fR\|(3) (or another I/O function such as \fBSSL_read\fR\|(3) or
  520. \&\fBSSL_write\fR\|(3)), if ever.
  521. .Sp
  522. This can also be used with \s-1DTLS\s0 and supersedes \fBDTLSv1_get_timeout\fR\|(3) for new
  523. usage.
  524. .IP "\fBSSL_handle_events\fR\|(3)" 4
  525. .IX Item "SSL_handle_events"
  526. This is a non-specific I/O operation which makes a best effort attempt to
  527. perform any pending I/O or timeout processing. It can be used to advance the
  528. \&\s-1QUIC\s0 state machine by processing incoming network traffic, generating outgoing
  529. network traffic and handling any expired timeout events. Most other I/O
  530. functions on an \s-1SSL\s0 object, such as \fBSSL_read\fR\|(3) and \fBSSL_write\fR\|(3)
  531. implicitly perform event handling on the \s-1SSL\s0 object, so calling this function is
  532. only needed if no other I/O function is to be called.
  533. .Sp
  534. This can also be used with \s-1DTLS\s0 and supersedes \fBDTLSv1_handle_timeout\fR\|(3) for
  535. new usage.
  536. .PP
  537. The following \s-1SSL\s0 APIs are specific to \s-1QUIC:\s0
  538. .IP "\fBSSL_set_blocking_mode\fR\|(3), \fBSSL_get_blocking_mode\fR\|(3)" 4
  539. .IX Item "SSL_set_blocking_mode, SSL_get_blocking_mode"
  540. Configures whether blocking semantics are used at the application level. This
  541. determines whether calls to functions such as \fBSSL_read\fR\|(3) and \fBSSL_write\fR\|(3)
  542. will block.
  543. .IP "\fBSSL_get_rpoll_descriptor\fR\|(3), \fBSSL_get_wpoll_descriptor\fR\|(3)" 4
  544. .IX Item "SSL_get_rpoll_descriptor, SSL_get_wpoll_descriptor"
  545. These functions facilitate operation in nonblocking mode.
  546. .Sp
  547. When an \s-1SSL\s0 object is being used with an underlying network read \s-1BIO\s0 which
  548. supports polling, \fBSSL_get_rpoll_descriptor\fR\|(3) outputs an \s-1OS\s0 resource which
  549. can be used to synchronise on network readability events which should result in
  550. a call to \fBSSL_handle_events\fR\|(3). \fBSSL_get_wpoll_descriptor\fR\|(3) works in an
  551. analogous fashion for the underlying network write \s-1BIO.\s0
  552. .Sp
  553. The poll descriptors provided by these functions need only be used when
  554. \&\fBSSL_net_read_desired\fR\|(3) and \fBSSL_net_write_desired\fR\|(3) return 1, respectively.
  555. .IP "\fBSSL_net_read_desired\fR\|(3), \fBSSL_net_write_desired\fR\|(3)" 4
  556. .IX Item "SSL_net_read_desired, SSL_net_write_desired"
  557. These functions facilitate operation in nonblocking mode and are used in
  558. conjunction with \fBSSL_get_rpoll_descriptor\fR\|(3) and
  559. \&\fBSSL_get_wpoll_descriptor\fR\|(3) respectively. They determine whether the
  560. respective poll descriptor is currently relevant for the purposes of polling.
  561. .IP "\fBSSL_set1_initial_peer_addr\fR\|(3)" 4
  562. .IX Item "SSL_set1_initial_peer_addr"
  563. This function can be used to set the initial peer address for an outgoing \s-1QUIC\s0
  564. connection. This function must be used in the general case when creating an
  565. outgoing \s-1QUIC\s0 connection; however, the correct initial peer address can be
  566. autodetected in some cases. See \fBSSL_set1_initial_peer_addr\fR\|(3) for details.
  567. .IP "\fBSSL_shutdown_ex\fR\|(3)" 4
  568. .IX Item "SSL_shutdown_ex"
  569. This augments \fBSSL_shutdown\fR\|(3) by allowing an application error code to be
  570. specified. It also allows a client to decide how quickly it wants a shutdown to
  571. be performed, potentially by trading off strict \s-1RFC\s0 compliance.
  572. .IP "\fBSSL_stream_conclude\fR\|(3)" 4
  573. .IX Item "SSL_stream_conclude"
  574. This allows an application to indicate the normal end of the sending part of a
  575. \&\s-1QUIC\s0 stream. This corresponds to the \s-1FIN\s0 flag in the \s-1QUIC RFC.\s0 The receiving
  576. part of a stream remains usable.
  577. .IP "\fBSSL_stream_reset\fR\|(3)" 4
  578. .IX Item "SSL_stream_reset"
  579. This allows an application to indicate the non-normal termination of the sending
  580. part of a stream. This corresponds to the \s-1RESET_STREAM\s0 frame in the \s-1QUIC RFC.\s0
  581. .IP "\fBSSL_get_stream_write_state\fR\|(3) and \fBSSL_get_stream_read_state\fR\|(3)" 4
  582. .IX Item "SSL_get_stream_write_state and SSL_get_stream_read_state"
  583. This allows an application to determine the current stream states for the
  584. sending and receiving parts of a stream respectively.
  585. .IP "\fBSSL_get_stream_write_error_code\fR\|(3) and \fBSSL_get_stream_read_error_code\fR\|(3)" 4
  586. .IX Item "SSL_get_stream_write_error_code and SSL_get_stream_read_error_code"
  587. This allows an application to determine the application error code which was
  588. signalled by a peer which has performed a non-normal stream termination of the
  589. respective sending or receiving part of a stream, if any.
  590. .IP "\fBSSL_get_conn_close_info\fR\|(3)" 4
  591. .IX Item "SSL_get_conn_close_info"
  592. This allows an application to determine the error code which was signalled when
  593. the local or remote endpoint terminated the \s-1QUIC\s0 connection.
  594. .IP "\fBSSL_get0_connection\fR\|(3)" 4
  595. .IX Item "SSL_get0_connection"
  596. Gets the \s-1QUIC\s0 connection \s-1SSL\s0 object from a \s-1QUIC\s0 stream \s-1SSL\s0 object.
  597. .IP "\fBSSL_is_connection\fR\|(3)" 4
  598. .IX Item "SSL_is_connection"
  599. Returns 1 if a \s-1SSL\s0 object is not a \s-1QUIC\s0 stream \s-1SSL\s0 object.
  600. .IP "\fBSSL_get_stream_type\fR\|(3)" 4
  601. .IX Item "SSL_get_stream_type"
  602. Provides information on the kind of \s-1QUIC\s0 stream which is attached
  603. to the \s-1SSL\s0 object.
  604. .IP "\fBSSL_get_stream_id\fR\|(3)" 4
  605. .IX Item "SSL_get_stream_id"
  606. Returns the \s-1QUIC\s0 stream \s-1ID\s0 which the \s-1QUIC\s0 protocol has associated with a \s-1QUIC\s0
  607. stream.
  608. .IP "\fBSSL_new_stream\fR\|(3)" 4
  609. .IX Item "SSL_new_stream"
  610. Creates a new \s-1QUIC\s0 stream \s-1SSL\s0 object representing a new, locally-initiated \s-1QUIC\s0
  611. stream.
  612. .IP "\fBSSL_accept_stream\fR\|(3)" 4
  613. .IX Item "SSL_accept_stream"
  614. Potentially yields a new \s-1QUIC\s0 stream \s-1SSL\s0 object representing a new
  615. remotely-initiated \s-1QUIC\s0 stream, blocking until one is available if the
  616. connection is configured to do so.
  617. .IP "\fBSSL_get_accept_stream_queue_len\fR\|(3)" 4
  618. .IX Item "SSL_get_accept_stream_queue_len"
  619. Provides information on the number of pending remotely-initiated streams.
  620. .IP "\fBSSL_set_incoming_stream_policy\fR\|(3)" 4
  621. .IX Item "SSL_set_incoming_stream_policy"
  622. Configures how incoming, remotely-initiated streams are handled. The incoming
  623. stream policy can be used to automatically reject streams created by the peer,
  624. or allow them to be handled using \fBSSL_accept_stream\fR\|(3).
  625. .IP "\fBSSL_set_default_stream_mode\fR\|(3)" 4
  626. .IX Item "SSL_set_default_stream_mode"
  627. Used to configure or disable default stream mode; see the \s-1MODES OF OPERATION\s0
  628. section for details.
  629. .PP
  630. The following \s-1BIO\s0 APIs are not specific to \s-1QUIC\s0 but have been added to
  631. facilitate QUIC-specific requirements and are closely associated with its use:
  632. .IP "\fBBIO_s_dgram_pair\fR\|(3)" 4
  633. .IX Item "BIO_s_dgram_pair"
  634. This is a new \s-1BIO\s0 method which is similar to a conventional \s-1BIO\s0 pair but
  635. provides datagram semantics.
  636. .IP "\fBBIO_get_rpoll_descriptor\fR\|(3), \fBBIO_get_wpoll_descriptor\fR\|(3)" 4
  637. .IX Item "BIO_get_rpoll_descriptor, BIO_get_wpoll_descriptor"
  638. This is a new \s-1BIO API\s0 which allows a \s-1BIO\s0 to expose a poll descriptor. This \s-1API\s0
  639. is used to implement the corresponding \s-1SSL\s0 APIs \fBSSL_get_rpoll_descriptor\fR\|(3)
  640. and \fBSSL_get_wpoll_descriptor\fR\|(3).
  641. .IP "\fBBIO_sendmmsg\fR\|(3), \fBBIO_recvmmsg\fR\|(3)" 4
  642. .IX Item "BIO_sendmmsg, BIO_recvmmsg"
  643. This is a new \s-1BIO API\s0 which can be implemented by BIOs which implement datagram
  644. semantics. It is implemented by \fBBIO_s_datagram\fR\|(3) and \fBBIO_s_dgram_pair\fR\|(3).
  645. It is used by the \s-1QUIC\s0 implementation to send and receive \s-1UDP\s0 datagrams.
  646. .IP "\fBBIO_dgram_set_no_trunc\fR\|(3), \fBBIO_dgram_get_no_trunc\fR\|(3)" 4
  647. .IX Item "BIO_dgram_set_no_trunc, BIO_dgram_get_no_trunc"
  648. By default, \fBBIO_s_dgram_pair\fR\|(3) has semantics comparable to those of Berkeley
  649. sockets being used with datagram semantics. This allows an alternative mode
  650. to be enabled in which datagrams will not be silently truncated if they are
  651. too large.
  652. .IP "\fBBIO_dgram_set_caps\fR\|(3), \fBBIO_dgram_get_caps\fR\|(3)" 4
  653. .IX Item "BIO_dgram_set_caps, BIO_dgram_get_caps"
  654. These functions are used to allow the user of one end of a
  655. \&\fBBIO_s_dgram_pair\fR\|(3) to indicate its capabilities to the other end of a
  656. \&\fBBIO_s_dgram_pair\fR\|(3). In particular, this allows an application to inform the
  657. \&\s-1QUIC\s0 implementation of whether it is prepared to handle local and/or peer
  658. addresses in transmitted datagrams and to provide the applicable information in
  659. received datagrams.
  660. .IP "\fBBIO_dgram_get_local_addr_cap\fR\|(3), \fBBIO_dgram_set_local_addr_enable\fR\|(3), \fBBIO_dgram_get_local_addr_enable\fR\|(3)" 4
  661. .IX Item "BIO_dgram_get_local_addr_cap, BIO_dgram_set_local_addr_enable, BIO_dgram_get_local_addr_enable"
  662. Local addressing support refers to the ability of a \s-1BIO\s0 with datagram semantics
  663. to allow a source address to be specified on transmission and to report the
  664. destination address on reception. These functions can be used to determine if a
  665. \&\s-1BIO\s0 can support local addressing and to enable local addressing support if it
  666. can.
  667. .IP "\fBBIO_err_is_non_fatal\fR\|(3)" 4
  668. .IX Item "BIO_err_is_non_fatal"
  669. This is used to determine if an error while calling \fBBIO_sendmmsg\fR\|(3) or
  670. \&\fBBIO_recvmmsg\fR\|(3) is ephemeral in nature, such as \*(L"would block\*(R" errors.
  671. .SH "THREAD ASSISTED MODE"
  672. .IX Header "THREAD ASSISTED MODE"
  673. The optional thread assisted mode can be used with
  674. \&\fBOSSL_QUIC_client_thread_method\fR\|(3). In this mode, a background thread is
  675. created automatically. The OpenSSL \s-1QUIC\s0 implementation then takes responsibility
  676. for ensuring that timeout events are handled on a timely basis even if no \s-1SSL
  677. I/O\s0 function such as \fBSSL_read\fR\|(3) or \fBSSL_write\fR\|(3) is called by the
  678. application for a long time.
  679. .PP
  680. All necessary locking is handled automatically internally, but the thread safety
  681. guarantees for the public \s-1SSL API\s0 are unchanged. Therefore, an application must
  682. still do its own locking if it wishes to make concurrent use of the public \s-1SSL\s0
  683. APIs.
  684. .PP
  685. Because this method relies on threads, it is not available on platforms where
  686. threading support is not available or not supported by OpenSSL. However, it
  687. does provide the simplest mode of usage for an application.
  688. .PP
  689. The implementation may or may not use a common thread or thread pool to service
  690. multiple \s-1SSL\s0 objects in the same \fB\s-1SSL_CTX\s0\fR.
  691. .SH "APPLICATION-DRIVEN EVENT LOOPS"
  692. .IX Header "APPLICATION-DRIVEN EVENT LOOPS"
  693. OpenSSL's \s-1QUIC\s0 implementation is designed to facilitate applications which wish
  694. to use the \s-1SSL\s0 APIs in a blocking fashion, but is also designed to facilitate
  695. applications which wish to use the \s-1SSL\s0 APIs in a nonblocking fashion and manage
  696. their own event loops and polling directly. This is useful when it is desirable
  697. to host OpenSSL's \s-1QUIC\s0 implementation on top of an application's existing
  698. nonblocking I/O infrastructure.
  699. .PP
  700. This is supported via the concept of poll descriptors; see
  701. \&\fBBIO_get_rpoll_descriptor\fR\|(3) for details. Broadly, a \fB\s-1BIO_POLL_DESCRIPTOR\s0\fR is
  702. a structure which expresses some kind of \s-1OS\s0 resource which can be used to
  703. synchronise on I/O events. The \s-1QUIC\s0 implementation provides a
  704. \&\fB\s-1BIO_POLL_DESCRIPTOR\s0\fR based on the poll descriptor provided by the underlying
  705. network \s-1BIO.\s0 This is typically an \s-1OS\s0 socket handle, though custom BIOs could
  706. choose to implement their own custom poll descriptor format.
  707. .PP
  708. Broadly, an application which wishes to manage its own event loop should
  709. interact with the \s-1SSL\s0 object as follows:
  710. .IP "\(bu" 4
  711. It should provide read and write BIOs with nonblocking datagram semantics to
  712. the \s-1SSL\s0 object using \fBSSL_set0_rbio\fR\|(3) and \fBSSL_set0_wbio\fR\|(3). This could be
  713. a \s-1BIO\s0 abstracting a network socket such as \fBBIO_s_datagram\fR\|(3), or a \s-1BIO\s0
  714. abstracting some kind of memory buffer such as \fBBIO_s_dgram_pair\fR\|(3). Use of a
  715. custom \s-1BIO\s0 is also possible.
  716. .IP "\(bu" 4
  717. It should configure the \s-1SSL\s0 object into nonblocking mode by calling
  718. \&\fBSSL_set_blocking_mode\fR\|(3).
  719. .IP "\(bu" 4
  720. It should configure the \s-1SSL\s0 object as desired, set an initial peer as needed
  721. using \fBSSL_set1_initial_peer_addr\fR\|(3), and trigger the connection process by
  722. calling \fBSSL_connect\fR\|(3).
  723. .IP "\(bu" 4
  724. If the network read and write BIOs provided were pollable (for example,
  725. a \fBBIO_s_datagram\fR\|(3), or a custom \s-1BIO\s0 which implements
  726. \&\fBBIO_get_rpoll_descriptor\fR\|(3) and \fBBIO_get_wpoll_descriptor\fR\|(3)), it should
  727. perform the following steps repeatedly:
  728. .RS 4
  729. .IP "\(bu" 4
  730. The application should call \fBSSL_get_rpoll_descriptor\fR\|(3) and
  731. \&\fBSSL_get_wpoll_descriptor\fR\|(3) to identify \s-1OS\s0 resources which can be used for
  732. synchronisation.
  733. .IP "\(bu" 4
  734. It should call \fBSSL_net_read_desired\fR\|(3) and \fBSSL_net_write_desired\fR\|(3) to determine
  735. whether the \s-1QUIC\s0 implementation is currently interested in readability and
  736. writability events on the underlying network \s-1BIO\s0 which was provided, and call
  737. \&\fBSSL_get_event_timeout\fR\|(3) to determine if any timeout event will become
  738. applicable in the future.
  739. .IP "\(bu" 4
  740. It should wait until one of the following events occurs:
  741. .RS 4
  742. .IP "\(bu" 4
  743. The poll descriptor returned by \fBSSL_get_rpoll_descriptor\fR\|(3) becomes readable
  744. (if \fBSSL_net_read_desired\fR\|(3) returned 1);
  745. .IP "\(bu" 4
  746. The poll descriptor returned by \fBSSL_get_wpoll_descriptor\fR\|(3) becomes writable
  747. (if \fBSSL_net_write_desired\fR\|(3) returned 1);
  748. .IP "\(bu" 4
  749. The timeout returned by \fBSSL_get_event_timeout\fR\|(3) (if any) expires.
  750. .RE
  751. .RS 4
  752. .Sp
  753. Once any of these events occurs, \fBSSL_handle_events\fR\|(3) should be called.
  754. .RE
  755. .RE
  756. .RS 4
  757. .RE
  758. .IP "\(bu" 4
  759. If the network read and write BIOs provided were not pollable (for example, in
  760. the case of \fBBIO_s_dgram_pair\fR\|(3)), the application is responsible for managing
  761. and synchronising network I/O. It should call \fBSSL_handle_events\fR\|(3) after it
  762. writes data to a \fBBIO_s_dgram_pair\fR\|(3) or otherwise takes action so that the
  763. \&\s-1QUIC\s0 implementation can read new datagrams via a call to \fBBIO_recvmmsg\fR\|(3) on
  764. the underlying network \s-1BIO.\s0 The \s-1QUIC\s0 implementation may output datagrams via a
  765. call to \fBBIO_sendmmsg\fR\|(3) and the application is responsible for ensuring these
  766. are transmitted.
  767. .Sp
  768. The application must call \fBSSL_get_event_timeout\fR\|(3) after every call to
  769. \&\fBSSL_handle_events\fR\|(3) (or another I/O function on the \s-1SSL\s0 object), and ensure
  770. that a call to \fBSSL_handle_events\fR\|(3) is performed after the specified timeout
  771. (if any).
  772. .SH "SEE ALSO"
  773. .IX Header "SEE ALSO"
  774. \&\fBSSL_handle_events\fR\|(3), \fBSSL_get_event_timeout\fR\|(3),
  775. \&\fBSSL_net_read_desired\fR\|(3), \fBSSL_net_write_desired\fR\|(3),
  776. \&\fBSSL_get_rpoll_descriptor\fR\|(3), \fBSSL_get_wpoll_descriptor\fR\|(3),
  777. \&\fBSSL_set_blocking_mode\fR\|(3), \fBSSL_shutdown_ex\fR\|(3),
  778. \&\fBSSL_set1_initial_peer_addr\fR\|(3), \fBSSL_stream_conclude\fR\|(3),
  779. \&\fBSSL_stream_reset\fR\|(3), \fBSSL_get_stream_read_state\fR\|(3),
  780. \&\fBSSL_get_stream_read_error_code\fR\|(3), \fBSSL_get_conn_close_info\fR\|(3),
  781. \&\fBSSL_get0_connection\fR\|(3), \fBSSL_get_stream_type\fR\|(3), \fBSSL_get_stream_id\fR\|(3),
  782. \&\fBSSL_new_stream\fR\|(3), \fBSSL_accept_stream\fR\|(3),
  783. \&\fBSSL_set_incoming_stream_policy\fR\|(3), \fBSSL_set_default_stream_mode\fR\|(3)
  784. .SH "COPYRIGHT"
  785. .IX Header "COPYRIGHT"
  786. Copyright 2022\-2023 The OpenSSL Project Authors. All Rights Reserved.
  787. .PP
  788. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  789. this file except in compliance with the License. You can obtain a copy
  790. in the file \s-1LICENSE\s0 in the source distribution or at
  791. <https://www.openssl.org/source/license.html>.