Add documentation for SSL_key_update() and SSL_get_key_update_type()
[openssl.git] / doc / man3 / SSL_key_update.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_key_update,
6 SSL_get_key_update_type,
7 SSL_renegotiate,
8 SSL_renegotiate_abbreviated,
9 SSL_renegotiate_pending
10 - initiate and obtain information about updating connection keys
11
12 =head1 SYNOPSIS
13
14  #include <openssl/ssl.h>
15
16  /* TLSv1.3 KeyUpdate message types */
17  typedef enum {
18      /* -1 used so that this is an invalid value for the on-the-wire protocol */
19      SSL_KEY_UPDATE_NONE = -1,
20      /* Values as defined for the on-the-wire protocol */
21      SSL_KEY_UPDATE_NOT_REQUESTED = 0,
22      SSL_KEY_UPDATE_REQUESTED = 1
23  } SSL_KEY_UPDATE;
24
25  int SSL_key_update(SSL *s, SSL_KEY_UPDATE updatetype);
26  SSL_KEY_UPDATE SSL_get_key_update_type(SSL *s);
27
28  int SSL_renegotiate(SSL *s);
29  int SSL_renegotiate_abbreviated(SSL *s);
30  int SSL_renegotiate_pending(SSL *s);
31
32 =head1 DESCRIPTION
33
34 SSL_key_update() schedules an update of the keys for the current TLS connection.
35 If the B<updatetype> parameter is set to B<SSL_KEY_UPDATE_NOT_REQUESTED> then
36 the sending keys for this connection will be updated and the peer will be
37 informed of the change. If the B<updatetype> parameter is set to
38 B<SSL_KEY_UPDATE_REQUESTED> then the sending keys for this connection will be
39 updated and the peer will be informed of the change along with a request for the
40 peer to additionally update its sending keys. It is an error if B<updatetype> is
41 set to B<SSL_KEY_UPDATE_NONE>.
42
43 SSL_key_update() must only be called after the initial handshake has been
44 completed and TLSv1.3 has been negotiated. The key update will not take place
45 until the next time an IO operation such as SSL_read_ex() or SSL_write_ex()
46 takes place on the connection. Alternatively SSL_do_handshake() can be called to
47 force the update to take place immediately.
48
49 SSL_get_key_update_type() can be used to determine whether a key update
50 operation has been scheduled but not yet performed. The type of the pending key
51 update operation will be returned if there is one, or SSL_KEY_UPDATE_NONE
52 otherwise.
53
54 SSL_renegotiate() and SSL_renegotiate_abbreviated() should only be called for
55 connections that have negotiated TLSv1.2 or less. Calling them on any other
56 connection will result in an error.
57
58 When called from the client side, SSL_renegotiate() schedules a completely new
59 handshake over an existing SSL/TLS connection. The next time an IO operation
60 such as SSL_read_ex() or SSL_write_ex() takes place on the connection a check
61 will be performed to confirm that it is a suitable time to start a
62 renegotiation. If so, then it will be initiated immediately. OpenSSL will not
63 attempt to resume any session associated with the connection in the new
64 handshake.
65
66 When called from the client side, SSL_renegotiate_abbreviated() works in the
67 same was as SSL_renegotiate() except that OpenSSL will attempt to resume the
68 session associated with the current connection in the new handshake.
69
70 When called from the server side, SSL_renegotiate() and
71 SSL_renegotiate_abbreviated() behave identically. They both schedule a request
72 for a new handshake to be sent to the client. The next time an IO operation is
73 performed then the same checks as on the client side are performed and then, if
74 appropriate, the request is sent. The client may or may not respond with a new
75 handshake and it may or may not attempt to resume an existing session. If
76 a new handshake is started then this will be handled transparently by calling
77 any OpenSSL IO function.
78
79 If an OpenSSL client receives a renegotiation request from a server then again
80 this will be handled transparently through calling any OpenSSL IO function. For
81 a TLS connection the client will attempt to resume the current session in the
82 new handshake. For historical reasons, DTLS clients will not attempt to resume
83 the session in the new handshake.
84
85 The SSL_renegotiate_pending() function returns 1 if a renegotiation or
86 rengotiation request has been scheduled but not yet acted on, or 0 otherwise.
87
88 =head1 RETURN VALUES
89
90 SSL_key_update(), SSL_renegotiate() and SSL_renegotiate_abbreviated() return 1
91 on success or 0 on error.
92
93 SSL_get_key_update_type() returns the update type of the pending key update
94 operation or SSL_KEY_UPDATE_NONE if there is none.
95
96 SSL_renegotiate_pending() returns 1 if a renegotiation or rengotiation request
97 has been scheduled but not yet acted on, or 0 otherwise.
98
99 =head1 SEE ALSO
100
101 L<ssl(7)>, L<SSL_read_ex(3)>,
102 L<SSL_write_ex(3)>,
103 L<SSL_do_handshake(3)>
104
105 =head1 HISTORY
106
107 The SSL_key_update() and SSL_get_key_update_type() functions were added in
108 OpenSSL 1.1.1.
109
110 =head1 COPYRIGHT
111
112 Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
113
114 Licensed under the OpenSSL license (the "License").  You may not use
115 this file except in compliance with the License.  You can obtain a copy
116 in the file LICENSE in the source distribution or at
117 L<https://www.openssl.org/source/license.html>.
118
119 =cut