Update early data API for writing to unauthenticated clients
[openssl.git] / doc / man3 / SSL_read_early.pod
index 5639876673fb2197a945243969374b02a7770dca..faa62d124b655360018cd90a5403552683e83115 100644 (file)
@@ -34,7 +34,9 @@ These functions are used to send and recieve early data. Early data can be sent
 by the client immediately after its initial ClientHello without having to wait
 for the server to complete the handshake. Early data can only be sent if a
 session has previously been established with the server, and the server is known
-to support it.
+to support it. Additionally these functions can be used to send data from the
+server to the client when the client has not yet completed the authentication
+stage of the handshake.
 
 Early data has weaker security properties than other data sent over an SSL/TLS
 connection. In particular the data is not forward secret and the server has no
@@ -51,10 +53,6 @@ unauthenticated at this point.
 A server or client can determine whether the full handshake has been completed
 or not by calling L<SSL_is_init_finished(3)>.
 
-[[TODO(TLS1.3): The server uses SSL_write_ex()/SSL_write() to send data to an
-unauthenticated client. Should we create a separate function for this to avoid
-accidents??]]
-
 On the client side the function SSL_SESSION_get_max_early_data() can be used to
 determine whether a session established with a server can be used to send early
 data. If the session cannot be used then this function will return 0. Otherwise
@@ -67,14 +65,15 @@ information on how to write bytes to the underlying connection, and how to
 handle any errors that may arise. This page will detail the differences between
 SSL_write_early_data() and L<SSL_write_ex(3)>.
 
-SSL_write_early_data() must be the first IO function called on a new connection,
-i.e. it must occur before any calls to L<SSL_write_ex(3)>, L<SSL_read_ex(3)>,
-L<SSL_connect(3)>, L<SSL_do_handshake(3)> or other similar functions. It may be
-called multiple times to stream data to the server, but the total number of
-bytes written must not exceed the value returned from
-SSL_SESSION_get_max_early_data(). Once the initial SSL_write_early_data() call
-has completed successfully the client may interleave calls to L<SSL_read_ex(3)>
-and L<SSL_read(3)> with calls to SSL_write_early_data() as required.
+When called by a client, SSL_write_early_data() must be the first IO function
+called on a new connection, i.e. it must occur before any calls to
+L<SSL_write_ex(3)>, L<SSL_read_ex(3)>, L<SSL_connect(3)>, L<SSL_do_handshake(3)>
+or other similar functions. It may be called multiple times to stream data to
+the server, but the total number of bytes written must not exceed the value
+returned from SSL_SESSION_get_max_early_data(). Once the initial
+SSL_write_early_data() call has completed successfully the client may interleave
+calls to L<SSL_read_ex(3)> and L<SSL_read(3)> with calls to
+SSL_write_early_data() as required.
 
 If SSL_write_early_data() fails you should call L<SSL_get_error(3)> to determine
 the correct course of action, as for L<SSL_write_ex(3)>.
@@ -85,8 +84,6 @@ L<SSL_do_handshake(3)>. Alternatively you can call a standard write function
 such as L<SSL_write_ex(3)>, which will transparently complete the connection and
 write the requested data.
 
-Only clients may call SSL_write_early_data().
-
 A server may choose to ignore early data that has been sent to it. Once the
 connection has been completed you can determine whether the server accepted or
 rejected the early data by calling SSL_get_early_data_status(). This will return
@@ -127,20 +124,26 @@ or if the early data was rejected.
 
 =back
 
-Once the initial SSL_read_early_data() call has completed successfully the
-server may interleave calls to L<SSL_write_ex(3)> and L<SSL_write(3)> with calls
-to SSL_read_early_data() as required. As noted above data sent via
-L<SSL_write_ex(3)> or L<SSL_write(3)> in this way is sent to an unauthenticated
-client.
-
-Servers must not call L<SSL_read_ex(3)> or L<SSL_read(3)> until
-SSL_read_early_data() has returned with SSL_READ_EARLY_DATA_FINISH. Once it has
-done so the connection to the client still needs to be completed. Complete the
-connection by calling a function such as L<SSL_accept(3)> or
-L<SSL_do_handshake(3)>. Alternatively you can call a standard read function such
-as L<SSL_read_ex(3)>, which will transparently complete the connection and read
-the requested data. Note that it is an error to attempt to complete the
-connection before SSL_read_early_data() has returned SSL_READ_EARLY_DATA_FINISH.
+Once the initial SSL_read_early_data() call has completed successfully (i.e. it
+has returned SSL_READ_EARLY_DATA_SUCCESS or SSL_READ_EARLY_DATA_FINISH) then the
+server may choose to write data immediately to the unauthenticated client using
+SSL_write_early_data(). If SSL_read_early_data() returned
+SSL_READ_EARLY_DATA_FINISH then in some situations (e.g. if the client only
+support TLSv1.2) the handshake may have already been completed and calls
+to SSL_write_early_data() are not allowed. Call L<SSL_is_init_finished(3)> to
+determine whether the handshake has completed or not. If the handshake is still
+in progress then the server may interleave calls to SSL_write_early_data() with
+calls to SSL_read_early_data() as required.
+
+Servers must not call L<SSL_read_ex(3)>, L<SSL_read(3)>, L<SSL_write_ex(3)> or
+L<SSL_write(3)>  until SSL_read_early_data() has returned with
+SSL_READ_EARLY_DATA_FINISH. Once it has done so the connection to the client
+still needs to be completed. Complete the connection by calling a function such
+as L<SSL_accept(3)> or L<SSL_do_handshake(3)>. Alternatively you can call a
+standard read function such as L<SSL_read_ex(3)>, which will transparently
+complete the connection and read the requested data. Note that it is an error to
+attempt to complete the connection before SSL_read_early_data() has returned
+SSL_READ_EARLY_DATA_FINISH.
 
 Only servers may call SSL_read_early_data().