Merge branch 'upstream' into tizen
[platform/upstream/gnutls.git] / doc / cha-intro-tls.texi
1 @node Introduction to TLS
2 @chapter Introduction to @acronym{TLS} and @acronym{DTLS}
3
4 @acronym{TLS} stands for ``Transport Layer Security'' and is the
5 successor of SSL, the Secure Sockets Layer protocol @xcite{SSL3}
6 designed by Netscape.  @acronym{TLS} is an Internet protocol, defined
7 by @acronym{IETF}@footnote{IETF, or Internet Engineering Task Force,
8 is a large open international community of network designers,
9 operators, vendors, and researchers concerned with the evolution of
10 the Internet architecture and the smooth operation of the Internet.
11 It is open to any interested individual.}, described in @xcite{RFC5246}.  
12 The protocol provides
13 confidentiality, and authentication layers over any reliable transport
14 layer.  The description, above, refers to @acronym{TLS} 1.0 but applies
15 to all other TLS versions as the differences between the protocols are not major.  
16
17 The @acronym{DTLS} protocol, or ``Datagram @acronym{TLS}'' @xcite{RFC4347} is a
18 protocol with identical goals as @acronym{TLS}, but can operate
19 under unreliable transport layers such as @acronym{UDP}. The
20 discussions below apply to this protocol as well, except when
21 noted otherwise.
22
23 @menu
24 * TLS layers::
25 * The transport layer::
26 * The TLS record protocol::
27 * The TLS Alert Protocol::
28 * The TLS Handshake Protocol::
29 * TLS Extensions::
30 * How to use TLS in application protocols::
31 * On SSL 2 and older protocols::
32 @end menu
33
34 @node TLS layers
35 @section TLS layers
36 @cindex TLS layers
37
38 @acronym{TLS} is a layered protocol, and consists of the record
39 protocol, the handshake protocol and the alert protocol. The record
40 protocol is to serve all other protocols and is above the transport
41 layer.  The record protocol offers symmetric encryption, data
42 authenticity, and optionally compression.
43 The alert protocol offers some signaling to the other protocols. It
44 can help informing the peer for the cause of failures and other error
45 conditions.  @xref{The Alert Protocol}, for more information.  The
46 alert protocol is above the record protocol.
47
48 The handshake protocol is responsible for the security parameters'
49 negotiation, the initial key exchange and authentication.  
50 @xref{The Handshake Protocol}, for more information about the handshake
51 protocol.  The protocol layering in TLS is shown in @ref{fig-tls-layers}.
52
53 @float Figure,fig-tls-layers
54 @image{gnutls-layers,12cm}
55 @caption{The TLS protocol layers.}
56 @end float
57
58 @node The transport layer
59 @section The transport layer
60 @cindex transport protocol
61 @cindex transport layer
62
63 @acronym{TLS} is not limited to any transport layer and can be used
64 above any transport layer, as long as it is a reliable one.  @acronym{DTLS}
65 can be used over reliable and unreliable transport layers.
66 @acronym{GnuTLS} supports TCP and UDP layers transparently using
67 the Berkeley sockets API. However, any transport layer can be used
68 by providing callbacks for @acronym{GnuTLS} to access the transport layer 
69 (for details see @ref{Setting up the transport layer}).
70
71 @node The TLS record protocol
72 @section The TLS record protocol
73 @cindex record protocol
74
75 The record protocol is the secure communications provider. Its purpose
76 is to encrypt, authenticate and ---optionally--- compress packets.
77 The record layer functions can be called at any time after
78 the handshake process is finished, when there is need to receive
79 or send data. In @acronym{DTLS} however, due to re-transmission
80 timers used in the handshake out-of-order handshake data might
81 be received for some time (maximum 60 seconds) after the handshake
82 process is finished. 
83
84 The functions to access the record protocol are limited to send
85 and receive functions, which might, given 
86 the importance of this protocol in @acronym{TLS}, seem awkward.  This is because 
87 the record protocol's parameters are all set by the handshake protocol.
88 The record protocol initially starts with NULL parameters, which means
89 no encryption, and no MAC is used. Encryption and authentication begin
90 just after the handshake protocol has finished.
91
92 @menu
93 * Encryption algorithms used in the record layer::
94 * Compression algorithms used in the record layer::
95 * Weaknesses and countermeasures::
96 * On Record Padding::
97 @end menu
98
99 @node Encryption algorithms used in the record layer
100 @subsection Encryption algorithms used in the record layer
101 @cindex symmetric encryption algorithms
102
103 Confidentiality in the record layer is achieved by using symmetric
104 block encryption algorithms like @code{3DES}, @code{AES}
105 or stream algorithms like @code{ARCFOUR_128}.
106  Ciphers are encryption algorithms that use a single, secret,
107 key to encrypt and decrypt data. Block algorithms in CBC mode also provide
108 protection against statistical analysis of the data.  Thus, if you're
109 using the @acronym{TLS} protocol, a random number of blocks will be
110 appended to data, to prevent eavesdroppers from guessing the actual
111 data size.
112
113 The supported in @acronym{GnuTLS} ciphers and MAC algorithms are shown in @ref{tab:ciphers} and
114 @ref{tab:macs}.
115
116 @float Table,tab:ciphers
117 @multitable @columnfractions .20 .70
118 @headitem Algorithm @tab Description
119 @item 3DES_@-CBC @tab
120 This is the DES block cipher algorithm used with triple
121 encryption (EDE). Has 64 bits block size and is used in CBC mode.
122
123 @item ARCFOUR_@-128 @tab
124 ARCFOUR_128 is a compatible algorithm with RSA's RC4 algorithm, which is considered to be a trade
125 secret. It is a fast cipher but considered weak today.
126
127 @item AES_@-CBC @tab
128 AES or RIJNDAEL is the block cipher algorithm that replaces the old
129 DES algorithm.  Has 128 bits block size and is used in CBC mode.
130
131 @item AES_@-GCM @tab
132 This is the AES algorithm in the authenticated encryption GCM mode.
133 This mode combines message authentication and encryption and can
134 be extremely fast on CPUs that support hardware acceleration.
135
136 @item CAMELLIA_@-CBC @tab
137 This is an 128-bit block cipher developed by Mitsubishi and NTT. It
138 is one of the approved ciphers of the European NESSIE and Japanese
139 CRYPTREC projects.
140
141 @end multitable
142 @caption{Supported ciphers.}
143 @end float
144
145
146 @float Table,tab:macs
147 @multitable @columnfractions .20 .70
148 @headitem Algorithm @tab Description
149 @item MAC_@-MD5 @tab
150 This is an HMAC based on MD5 a cryptographic hash algorithm designed 
151 by Ron Rivest. Outputs 128 bits of data.
152
153 @item MAC_@-SHA1 @tab
154 An HMAC based on the SHA1 cryptographic hash algorithm 
155 designed by NSA. Outputs 160 bits of data.
156
157 @item MAC_@-SHA256 @tab
158 An HMAC based on SHA256. Outputs 256 bits of data.
159
160 @item MAC_@-AEAD @tab
161 This indicates that an authenticated encryption algorithm, such as
162 GCM, is in use.
163
164 @end multitable
165 @caption{Supported MAC algorithms.}
166 @end float
167
168
169 @node Compression algorithms used in the record layer
170 @subsection Compression algorithms used in the record layer
171 @cindex compression algorithms
172
173 The TLS record layer also supports compression.  The algorithms
174 implemented in @acronym{GnuTLS} can be found in the table below.
175 The included algorithms perform really good when text, or other
176 compressible data are to be transferred, but offer nothing on already
177 compressed data, such as compressed images, zipped archives etc.
178 These compression algorithms, may be useful in high bandwidth TLS
179 tunnels, and in cases where network usage has to be minimized. It
180 should be noted however that compression increases latency.
181
182 The record layer compression in @acronym{GnuTLS} is implemented based
183 on @xcite{RFC3749}. The supported algorithms are shown below.
184
185 @showenumdesc{gnutls_compression_method_t,Supported compression algorithms}
186
187 Note that compression enables attacks such as traffic analysis, or even
188 plaintext recovery under certain circumstances. To avoid some of these
189 attacks GnuTLS allows each record to be compressed independently (i.e.,
190 stateless compression), by using the "%STATELESS_COMPRESSION" priority string,
191 in order to be used in cases where the attacker controlled data are
192 pt in separate records.
193
194 @node Weaknesses and countermeasures
195 @subsection Weaknesses and countermeasures
196
197 Some weaknesses that may affect the security of the record layer have
198 been found in @acronym{TLS} 1.0 protocol. These weaknesses can be
199 exploited by active attackers, and exploit the facts that
200
201 @enumerate
202
203 @item
204 @acronym{TLS} has separate alerts for ``decryption_failed'' and
205 ``bad_record_mac''
206
207 @item
208 The decryption failure reason can be detected by timing the response
209 time.
210
211 @item
212 The IV for CBC encrypted packets is the last block of the previous
213 encrypted packet.
214
215 @end enumerate
216
217 Those weaknesses were solved in @acronym{TLS} 1.1 @xcite{RFC4346}
218 which is implemented in @acronym{GnuTLS}. For this reason we suggest
219 to always negotiate the highest supported TLS version with the 
220 peer@footnote{If this is not possible then please consult @ref{Interoperability}.}.
221 For a detailed discussion of the issues see the archives of the TLS 
222 Working Group mailing list and @xcite{CBCATT}.
223
224 @node On Record Padding
225 @subsection On record padding
226 @cindex record padding
227 @cindex bad_record_mac
228
229 The TLS protocol allows for extra padding of records in CBC ciphers, to prevent
230 statistical analysis based on the length of exchanged messages (see @xcite{RFC5246} section 6.2.3.2).  
231 GnuTLS appears to be one of few implementations that take advantage of this feature: 
232 the user can provide some plaintext data with a range of lengths she wishes to hide,
233 and GnuTLS adds extra padding to make sure the attacker cannot tell the real plaintext
234 length is in a range smaller than the user-provided one.
235 Use @funcref{gnutls_record_send_range} to send length-hidden messages and
236 @funcref{gnutls_record_can_use_length_hiding} to check whether the current
237 session supports length hiding. Using the standard @funcref{gnutls_record_send}
238 will only add minimal padding.
239
240 The TLS implementation in the Symbian operating system, frequently
241 used by Nokia and Sony-Ericsson mobile phones, cannot handle
242 non-minimal record padding.  What happens when one of these clients
243 handshake with a GnuTLS server is that the client will fail to compute
244 the correct MAC for the record.  The client sends a TLS alert
245 (@code{bad_record_mac}) and disconnects.  Typically this will result
246 in error messages such as 'A TLS fatal alert has been received', 'Bad
247 record MAC', or both, on the GnuTLS server side.
248
249 If compatibility with such devices is a concern, not sending length-hidden messages
250 solves the problem by using minimal padding.
251
252 If you implement an application that has a configuration file, we
253 recommend that you make it possible for users or administrators to
254 specify a GnuTLS protocol priority string, which is used by your
255 application via @funcref{gnutls_priority_set}.  To allow the best
256 flexibility, make it possible to have a different priority string for
257 different incoming IP addresses.
258
259
260 @node The TLS Alert Protocol
261 @section The TLS alert protocol
262 @anchor{The Alert Protocol}
263 @cindex alert protocol
264
265 The alert protocol is there to allow signals to be sent between peers.
266 These signals are mostly used to inform the peer about the cause of a
267 protocol failure. Some of these signals are used internally by the
268 protocol and the application protocol does not have to cope with them
269 (e.g. @code{GNUTLS_@-A_@-CLOSE_@-NOTIFY}), and others refer to the
270 application protocol solely (e.g. @code{GNUTLS_@-A_@-USER_@-CANCELLED}).  An
271 alert signal includes a level indication which may be either fatal or
272 warning. Fatal alerts always terminate the current connection, and
273 prevent future re-negotiations using the current session ID. All alert
274 messages are summarized in the table below.
275
276 The alert messages are protected by the record protocol, thus the
277 information that is included does not leak. You must take extreme care
278 for the alert information not to leak to a possible attacker, via
279 public log files etc. 
280
281 @include alerts.texi
282
283 @node The TLS Handshake Protocol
284 @section The TLS handshake protocol
285 @anchor{The Handshake Protocol}
286 @cindex handshake protocol
287
288 The handshake protocol is responsible for the ciphersuite negotiation,
289 the initial key exchange, and the authentication of the two peers.
290 This is fully controlled by the application layer, thus your program
291 has to set up the required parameters. The main handshake function
292 is @funcref{gnutls_handshake}. In the next paragraphs we elaborate on 
293 the handshake protocol, i.e., the ciphersuite negotiation.
294
295
296 @menu
297 * TLS Cipher Suites::           TLS session parameters.
298 * Authentication::              TLS authentication.
299 * Client Authentication::       Requesting a certificate from the client.
300 * Resuming Sessions::           Reusing previously established keys.
301 @end menu
302
303
304 @node TLS Cipher Suites
305 @subsection TLS ciphersuites
306
307 The handshake protocol of @acronym{TLS} negotiates cipher suites of
308 a special form illustrated by the @code{TLS_DHE_RSA_WITH_3DES_CBC_SHA} cipher suite name.  A typical cipher
309 suite contains these parameters:
310
311 @itemize
312
313 @item The key exchange algorithm.
314 @code{DHE_RSA} in the example.
315
316 @item The Symmetric encryption algorithm and mode
317 @code{3DES_CBC} in this example.
318
319 @item The MAC@footnote{MAC stands for Message Authentication Code. It can be described as a keyed hash algorithm. See RFC2104.} algorithm used for authentication.
320 @code{MAC_SHA} is used in the above example.
321
322 @end itemize
323
324 The cipher suite negotiated in the handshake protocol will affect the
325 record protocol, by enabling encryption and data authentication.  Note
326 that you should not over rely on @acronym{TLS} to negotiate the
327 strongest available cipher suite. Do not enable ciphers and algorithms
328 that you consider weak.
329
330 All the supported ciphersuites are listed in @ref{ciphersuites}.
331
332 @node Authentication
333 @subsection Authentication
334
335 The key exchange algorithms of the @acronym{TLS} protocol offer
336 authentication, which is a prerequisite for a secure connection. 
337 The available authentication methods in @acronym{GnuTLS} follow.
338
339 @itemize
340
341 @item Certificate authentication: Authenticated key exchange using public key infrastructure and certificates (X.509 or OpenPGP).
342 @item @acronym{SRP} authentication: Authenticated key exchange using a password.
343 @item @acronym{PSK} authentication: Authenticated key exchange using a pre-shared key.
344 @item Anonymous authentication: Key exchange without peer authentication.
345
346 @end itemize
347
348 @node Client Authentication
349 @subsection Client authentication
350 @cindex client certificate authentication
351
352 In the case of ciphersuites that use certificate authentication, the
353 authentication of the client is optional in @acronym{TLS}.  A server
354 may request a certificate from the client using the
355 @funcref{gnutls_certificate_server_set_request} function. We elaborate 
356 in @ref{Certificate credentials}.
357
358 @node Resuming Sessions
359 @subsection Resuming sessions
360 @anchor{resume}
361 @cindex resuming sessions
362 @cindex session resumption
363
364 The TLS handshake process performs expensive calculations
365 and a busy server might easily be put under load. To 
366 reduce the load, session resumption may be used. This
367 is a feature of the @acronym{TLS} protocol which allows a
368 client to connect to a server after a successful handshake, without
369 the expensive calculations.  This is achieved by re-using the previously
370 established keys, meaning the server needs to store the state of established
371 connections (unless session tickets are used -- @ref{Session tickets}).
372
373 Session resumption is an integral part of @acronym{GnuTLS}, and 
374 @ref{Session resumption}, @ref{ex-resume-client} illustrate typical 
375 uses of it.
376
377 @node TLS Extensions
378 @section TLS extensions
379 @cindex TLS extensions
380
381 A number of extensions to the @acronym{TLS} protocol have been
382 proposed mainly in @xcite{TLSEXT}. The extensions supported
383 in @acronym{GnuTLS} are discussed in the subsections that follow.
384
385 @menu
386 * Maximum fragment length negotiation::
387 * Server name indication::
388 * Session tickets::
389 * HeartBeat::
390 * Safe renegotiation::
391 * OCSP status request::
392 * SRTP::
393 * Application Layer Protocol Negotiation (ALPN)::
394 @end menu
395
396 @node Maximum fragment length negotiation
397 @subsection Maximum fragment length negotiation
398 @cindex TLS extensions
399 @cindex maximum fragment length
400
401 This extension allows a @acronym{TLS} implementation to negotiate a
402 smaller value for record packet maximum length. This extension may be
403 useful to clients with constrained capabilities. The functions shown
404 below can be used to control this extension.
405
406 @showfuncB{gnutls_record_get_max_size,gnutls_record_set_max_size}
407
408 @node Server name indication
409 @subsection Server name indication
410 @anchor{serverind}
411 @cindex TLS extensions
412 @cindex server name indication
413
414 A common problem in @acronym{HTTPS} servers is the fact that the
415 @acronym{TLS} protocol is not aware of the hostname that a client
416 connects to, when the handshake procedure begins. For that reason the
417 @acronym{TLS} server has no way to know which certificate to send.
418
419 This extension solves that problem within the @acronym{TLS} protocol,
420 and allows a client to send the HTTP hostname before the handshake
421 begins within the first handshake packet.  The functions
422 @funcref{gnutls_server_name_set} and @funcref{gnutls_server_name_get} can be
423 used to enable this extension, or to retrieve the name sent by a
424 client.
425
426 @showfuncB{gnutls_server_name_set,gnutls_server_name_get}
427
428 @node Session tickets
429 @subsection Session tickets
430 @cindex TLS extensions
431 @cindex session tickets
432 @cindex tickets
433
434 To resume a TLS session, the server normally stores session parameters.  This
435 complicates deployment, and can be avoided by delegating the storage
436 to the client. Because session parameters are sensitive they are encrypted
437 and authenticated with a key only known to the server and then sent to the
438 client. The Session Tickets extension is described in RFC 5077 @xcite{TLSTKT}.
439
440 A disadvantage of session tickets is that they eliminate the effects of
441 forward secrecy when a server uses the same key for long time. That is,
442 the secrecy of all sessions on a server using tickets depends on the ticket
443 key being kept secret. For that reason server keys should be rotated and discarded
444 regularly.
445
446 Since version 3.1.3 GnuTLS clients transparently support session tickets.
447
448 @node HeartBeat
449 @subsection HeartBeat
450 @cindex TLS extensions
451 @cindex heartbeat
452
453 This is a TLS extension that allows to ping and receive confirmation from the peer,
454 and is described in @xcite{RFC6520}. The extension is disabled by default and
455 @funcref{gnutls_heartbeat_enable} can be used to enable it. A policy
456 may be negotiated to only allow sending heartbeat messages or sending and receiving.
457 The current session policy can be checked with @funcref{gnutls_heartbeat_allowed}. 
458 The requests coming from the peer result to @code{GNUTLS_@-E_@-HERTBEAT_@-PING_@-RECEIVED}
459 being returned from the receive function. Ping requests to peer can be send via
460 @funcref{gnutls_heartbeat_ping}. 
461
462 @showfuncB{gnutls_heartbeat_allowed,gnutls_heartbeat_enable}
463
464 @showfuncD{gnutls_heartbeat_ping,gnutls_heartbeat_pong,gnutls_heartbeat_set_timeouts,gnutls_heartbeat_get_timeout}
465
466 @node Safe renegotiation
467 @subsection Safe renegotiation
468 @cindex renegotiation
469 @cindex safe renegotiation
470
471 TLS gives the option to two communicating parties to renegotiate
472 and update their security parameters. One useful example of this feature
473 was for a client to initially connect using anonymous negotiation to a
474 server, and the renegotiate using some authenticated ciphersuite. This occurred
475 to avoid having the client sending its credentials in the clear.
476
477 However this renegotiation, as initially designed would not ensure that
478 the party one is renegotiating is the same as the one in the initial negotiation.
479 For example one server could forward all renegotiation traffic to an other
480 server who will see this traffic as an initial negotiation attempt.
481
482 This might be seen as a valid design decision, but it seems it was
483 not widely known or understood, thus today some application protocols use the TLS
484 renegotiation feature in a manner that enables a malicious server to insert
485 content of his choice in the beginning of a TLS session.
486
487 The most prominent vulnerability was with HTTPS. There servers request
488 a renegotiation to enforce an anonymous user to use a certificate in order
489 to access certain parts of a web site.  The
490 attack works by having the attacker simulate a client and connect to a
491 server, with server-only authentication, and send some data intended
492 to cause harm.  The server will then require renegotiation from him
493 in order to perform the request. 
494 When the proper client attempts to contact the server,
495 the attacker hijacks that connection and forwards traffic to
496 the initial server that requested renegotiation.  The
497 attacker will not be able to read the data exchanged between the
498 client and the server.  However, the server will (incorrectly) assume
499 that the initial request sent by the attacker was sent by the now authenticated
500 client.  The result is a prefix plain-text injection attack.
501
502 The above is just one example.  Other vulnerabilities exists that do
503 not rely on the TLS renegotiation to change the client's authenticated
504 status (either TLS or application layer).
505
506 While fixing these application protocols and implementations would be
507 one natural reaction, an extension to TLS has been designed that
508 cryptographically binds together any renegotiated handshakes with the
509 initial negotiation.  When the extension is used, the attack is
510 detected and the session can be terminated.  The extension is
511 specified in @xcite{RFC5746}.
512
513 GnuTLS supports the safe renegotiation extension.  The default
514 behavior is as follows.  Clients will attempt to negotiate the safe
515 renegotiation extension when talking to servers.  Servers will accept
516 the extension when presented by clients.  Clients and servers will
517 permit an initial handshake to complete even when the other side does
518 not support the safe renegotiation extension.  Clients and servers
519 will refuse renegotiation attempts when the extension has not been
520 negotiated.
521
522 Note that permitting clients to connect to servers when the safe
523 renegotiation extension is not enabled, is open up for attacks.
524 Changing this default behavior would prevent interoperability against
525 the majority of deployed servers out there.  We will reconsider this
526 default behavior in the future when more servers have been upgraded.
527 Note that it is easy to configure clients to always require the safe
528 renegotiation extension from servers.
529
530 To modify the default behavior, we have introduced some new priority
531 strings (see @ref{Priority Strings}).  
532 The @code{%UNSAFE_RENEGOTIATION} priority string permits
533 (re-)handshakes even when the safe renegotiation extension was not
534 negotiated. The default behavior is @code{%PARTIAL_RENEGOTIATION} that will
535 prevent renegotiation with clients and servers not supporting the
536 extension. This is secure for servers but leaves clients vulnerable
537 to some attacks, but this is a trade-off between security and compatibility
538 with old servers. The @code{%SAFE_RENEGOTIATION} priority string makes
539 clients and servers require the extension for every handshake. The latter
540 is the most secure option for clients, at the cost of not being able
541 to connect to legacy servers. Servers will also deny clients that
542 do not support the extension from connecting.
543
544 It is possible to disable use of the extension completely, in both
545 clients and servers, by using the @code{%DISABLE_SAFE_RENEGOTIATION}
546 priority string however we strongly recommend you to only do this for
547 debugging and test purposes.
548
549 The default values if the flags above are not specified are:
550 @table @code
551
552 @item Server:
553 %PARTIAL_RENEGOTIATION
554
555 @item Client:
556 %PARTIAL_RENEGOTIATION
557
558 @end table
559
560 For applications we have introduced a new API related to safe
561 renegotiation.  The @funcref{gnutls_safe_renegotiation_status} function is
562 used to check if the extension has been negotiated on a session, and
563 can be used both by clients and servers.
564
565 @node OCSP status request
566 @subsection OCSP status request
567 @cindex OCSP status request
568 @cindex Certificate status request
569
570 The Online Certificate Status Protocol (OCSP) is a protocol that allows the
571 client to verify the server certificate for revocation without messing with
572 certificate revocation lists. Its drawback is that it requires the client
573 to connect to the server's CA OCSP server and request the status of the
574 certificate. This extension however, enables a TLS server to include
575 its CA OCSP server response in the handshake. That is an HTTPS server
576 may periodically run @code{ocsptool} (see @ref{ocsptool Invocation}) to obtain
577 its certificate revocation status and serve it to the clients. That
578 way a client avoids an additional connection to the OCSP server.
579
580 @showfuncD{gnutls_certificate_set_ocsp_status_request_function,gnutls_certificate_set_ocsp_status_request_file,gnutls_ocsp_status_request_enable_client,gnutls_ocsp_status_request_is_checked}
581
582 A server is required to provide the OCSP server's response using the @funcref{gnutls_certificate_set_ocsp_status_request_file}.
583 The response may be obtained periodically using the following command.
584
585 @example
586 ocsptool --ask --load-cert server_cert.pem --load-issuer the_issuer.pem
587          --load-signer the_issuer.pem --outfile ocsp.response
588 @end example
589
590 Since version 3.1.3 GnuTLS clients transparently support the certificate status
591 request.
592
593 @node SRTP
594 @subsection SRTP
595 @cindex SRTP
596 @cindex Secure RTP
597
598 The TLS protocol was extended in @xcite{RFC5764} to provide keying material to the
599 Secure RTP (SRTP) protocol. The SRTP protocol provides an encapsulation of encrypted
600 data that is optimized for voice data. With the SRTP TLS extension two peers can
601 negotiate keys using TLS or DTLS and obtain keying material for use with SRTP. The
602 available SRTP profiles are listed below.
603
604 @showenumdesc{gnutls_srtp_profile_t,Supported SRTP profiles}
605
606 To enable use the following functions.
607
608 @showfuncB{gnutls_srtp_set_profile,gnutls_srtp_set_profile_direct}
609
610 To obtain the negotiated keys use the function below.
611
612 @showfuncdesc{gnutls_srtp_get_keys}
613
614 Other helper functions are listed below.
615
616 @showfuncC{gnutls_srtp_get_selected_profile,gnutls_srtp_get_profile_name,gnutls_srtp_get_profile_id}
617
618 @node Application Layer Protocol Negotiation (ALPN)
619 @subsection Application Layer Protocol Negotiation (ALPN)
620 @cindex ALPN
621 @cindex Application Layer Protocol Negotiation
622
623 The TLS protocol was extended in @code{draft-ietf-tls-applayerprotoneg-00} 
624 to provide the application layer a method of
625 negotiating the application protocol version. This allows for negotiation
626 of the application protocol during the TLS handshake, thus reducing
627 round-trips. The application protocol is described by an opaque
628 string. To enable, use the following functions.
629
630 @showfuncB{gnutls_alpn_set_protocols,gnutls_alpn_get_selected_protocol}
631
632 Note that these functions are intended to be used with protocols that are
633 registered in the Application Layer Protocol Negotiation IANA registry. While
634 you can use them for other protocols (at the risk of collisions), it is preferable
635 to register them.
636
637 @include sec-tls-app.texi
638
639 @node On SSL 2 and older protocols
640 @section On SSL 2 and older protocols
641 @cindex SSL 2
642
643 One of the initial decisions in the @acronym{GnuTLS} development was
644 to implement the known security protocols for the transport layer.
645 Initially @acronym{TLS} 1.0 was implemented since it was the latest at
646 that time, and was considered to be the most advanced in security
647 properties.  Later the @acronym{SSL} 3.0 protocol was implemented
648 since it is still the only protocol supported by several servers and
649 there are no serious security vulnerabilities known.
650
651 One question that may arise is why we didn't implement @acronym{SSL}
652 2.0 in the library.  There are several reasons, most important being
653 that it has serious security flaws, unacceptable for a modern security
654 library.  Other than that, this protocol is barely used by anyone
655 these days since it has been deprecated since 1996.  The security
656 problems in @acronym{SSL} 2.0 include:
657
658 @itemize
659
660 @item Message integrity compromised.
661 The @acronym{SSLv2} message authentication uses the MD5 function, and
662 is insecure.
663
664 @item Man-in-the-middle attack.
665 There is no protection of the handshake in @acronym{SSLv2}, which
666 permits a man-in-the-middle attack.
667
668 @item Truncation attack.
669 @acronym{SSLv2} relies on TCP FIN to close the session, so the
670 attacker can forge a TCP FIN, and the peer cannot tell if it was a
671 legitimate end of data or not.
672
673 @item Weak message integrity for export ciphers.
674 The cryptographic keys in @acronym{SSLv2} are used for both message
675 authentication and encryption, so if weak encryption schemes are
676 negotiated (say 40-bit keys) the message authentication code uses the
677 same weak key, which isn't necessary.
678
679 @end itemize
680
681 @cindex PCT
682 Other protocols such as Microsoft's @acronym{PCT} 1 and @acronym{PCT}
683 2 were not implemented because they were also abandoned and deprecated
684 by @acronym{SSL} 3.0 and later @acronym{TLS} 1.0.
685
686