documented update
[gnutls.git] / doc / protocol / draft-rescorla-dtls-03.txt
blob24dfbf1dcf3994a175e2f9c1010cabe083232175
1                                                              E. Rescorla
2                                                               RTFM, Inc.
3                                                              N. Modadugu
4 INTERNET-DRAFT                                       Stanford University
5 <draft-rescorla-dtls-03.txt>         February 2004 (Expires August 2005)
7                    Datagram Transport Layer Security
9 Status of this Memo
11 By submitting this Internet-Draft, I certify that any applicable
12 patent or other IPR claims of which I am aware have been disclosed,
13 and any of which I become aware will be disclosed, in accordance with
14 RFC 3668.
16 Internet-Drafts are working documents of the Internet Engineering
17 Task Force (IETF), its areas, and its working groups. Note that other
18 groups may also distribute working documents as Internet-Drafts.
20 Internet-Drafts are draft documents valid for a maximum of six months
21 and may be updated, replaced, or obsoleted by other documents at any
22 time. It is inappropriate to use Internet-Drafts as reference
23 material or to cite them other than a "work in progress."
25 The list of current Internet-Drafts can be accessed at
26 http://www.ietf.org/1id-abstracts.html
28 The list of Internet-Draft Shadow Directories can be accessed at
29 http://www.ietf.org/shadow.html
31 Copyright Notice
33    Copyright (C) The Internet Society (1999-2004). All Rights Reserved.
41 Rescorla, Modadugu                                               [Page 1]\f
44 Abstract
46    This document specifies Version 1.0 of the Datagram Transport Layer
47    Security (DTLS) protocol. The DTLS protocol provides communications
48    privacy for datagram protocols. The protocol allows client/server
49    applications to communicate in a way that is designed to prevent
50    eavesdropping, tampering, or message forgery. The DTLS protocol is
51    based on the TLS protocol and provides equivalent security
52    guarantees. Datagram semantics of the underlying transport are
53    preserved by the DTLS protocol.
56 Contents
61 1. Introduction
63    TLS [TLS] is the most widely deployed protocol for securing network
64    traffic. It is widely used for protecting Web traffic and for e-mail
65    protocols such as IMAP [IMAP] and POP [POP]. The primary advantage of
66    TLS is that it provides a transparent connection-oriented channel.
67    Thus, it is easy to secure an application protocol by inserting TLS
68    between the application layer and the transport layer. However, TLS
69    must run over a reliable transport channel--typically TCP [TCP]. It
70    therefore cannot be used to secure unreliable datagram traffic.
72    However, over the past few years an increasing number of application
73    layer protocols have been designed which UDP transport. In particular
74    such protocols as the Session Initiation Protocol (SIP) [SIP], and
75    electronic gaming protocols are increasingly popular. (Note that SIP
76    can run over both TCP and UDP, but that there are situations in which
77    UDP is preferable). Currently, designers of these applications are
78    faced with a number of unsatisfactory choices. First, they can use
79    IPsec [RFC2401]. However, for a number of reasons detailed in
80    [WHYIPSEC], this is only suitable for some applications. Second, they
81    can design a custom application layer security protocol. SIP, for
82    instance, uses a subsert of S/MIME to secure its traffic.
83    Unfortunately, while application layer security protocols generally
84    provide superior security properties (e.g., end-to-end security in
85    the case of S/MIME) it typically require a large amount of effort to
86    design--by contrast to the relatively small amount of effort required
87    to run the protocol over TLS.
89    In many cases, the most desirable way to secure client/server
90    applications would be to use TLS; however the requirement for
91    datagram semantics automatically prohibits use of TLS. Thus, a
95 Rescorla, Modadugu                                               [Page 2]\f
98    datagram-compatible variant of TLS would be very desirable. This memo
99    describes such a protocol: Datagram Transport Layer Security (DTLS).
100    DTLS is deliberately designed to be as similar to to TLS as possible,
101    both to minimize new security invention and to maximize the amount of
102    code and infrastructure reuse.
105 1.1. Requirements Terminology
107    Keywords "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT" and
108    "MAY" that appear in this document are to be interpreted as described
109    in RFC 2119 [REQ].
111 2. Usage Model
113    The DTLS protocol is designed to secure data between communicating
114    applications. It is designed to run in application space, without
115    requiring any kernel modifications. While the design of the DTLS
116    protocol does not preclude its use in securing arbitrary datagram
117    traffic, it is primarily expected to secure communication based on
118    datagram sockets.
120    Datagram transport does not require or provide reliable or in-order
121    delivery of data. The DTLS protocol preserves this property for
122    payload data. Applications such as media streaming, Internet
123    telephony and online gaming use datagram transport for communication
124    due to the delay-sensitive nature of transported data. The behavior
125    of such applications is unchanged when the DTLS protocol is used to
126    secure communication, since the DTLS protocol does not compensate for
127    lost or re-ordered data traffic.
129 3. Overview of DTLS
131    The basic design philosophy of DTLS is to construct "TLS over
132    datagram". The reason that TLS cannot be used directly in datagram
133    environments is simply that packets may be lost or reordered. TLS has
134    no internal facilities to handle this kind of unreliability and
135    therefore TLS implementations break when rehosted on datagram
136    transport. The purpose of DTLS is to make only the minimal changes to
137    TLS required to fix this problem. To the greatest extent possible,
138    DTLS is identical to TLS. Whenever we need to invent new mechanisms,
139    we attempt to do so in such a way that it preserves the style of TLS.
141    Unreliability creates problems for TLS at two levels:
143       1. TLS's traffic encryption layer does not allow independent
144       decryption of individual records. If record N is not received,
145       then record N+1 cannot be decrypted.
149 Rescorla, Modadugu                                               [Page 3]\f
152       2. The TLS handshake layer assumes that handshake messages are
153       delivered reliably and breaks if those messages are lost.
155    The rest of this section describes the approach that DTLS uses to
156    solve these problems.
158 3.1. Loss-insensitive messaging
160    In TLS's traffic encryption layer (called the TLS Record Layer),
161    records are not independent. There are two kinds of inter-record
162    dependency:
164       1. Cryptographic context (CBC state, stream cipher key stream) is
165       chained between records.
167       2. Anti-replay and message reordering protection are provided by a
168       MAC which includes a sequence number, but the sequence numbers are
169       implicit in the records.
171    The fix for both of these problems is straightforward and well-known
172    from IPsec ESP [ESP]: add explicit state to the records. TLS 1.1
173    [TLS11] is already adding explicit CBC state to TLS records. DTLS
174    borrows that mechanism and adds explicit sequence numbers.
176 3.2. Providing Reliability for Handshake
178    The TLS handshake is a lockstep cryptographic handshake. Messages
179    must be transmitted and received in a defined order and any other
180    order is an error. Clearly, this is incompatible with reordering and
181    message loss. In addition, TLS handshake messages are potentially
182    larger than any given datagram, thus creating the problem of
183    fragmentation. DTLS must provide fixes for both these problems.
185 3.2.1. Packet Loss
187    DTLS uses a simple retransmission timer to handle packet loss. The
188    following figure demonstrates the basic concept using the first phase
189    of the DTLS handshake:
191       Client                                   Server
192       ------                                   ------
193       ClientHello           ------>
195                               X<-- HelloVerifyRequest
196                                                (lost)
198       [Timer Expires]
203 Rescorla, Modadugu                                               [Page 4]\f
206       ClientHello           ------>
207       (retransmit)
209    Once the client has transmitted the ClientHello message, it expects
210    to see a HelloVerifyRequest from the server. However, if the server's
211    message is lost the client knows that either the ClientHello or the
212    HelloVerifyRequest has been lost and retransmits. When the server
213    receives the retransmission, it knows to retransmit. The server also
214    maintains a retransmission timer and retransmits when that timer
215    expires.
217 3.2.2. Reordering
219    In DTLS, each handshake message is assigned a specific sequence
220    number within that handshake. When a peer receives a handshake
221    message, it can quickly determine whether that message is the next
222    message it expects. If it is, then it processes it. If not, it queues
223    it up for future handling once all previous messages have been
224    received.
226 3.2.3. Message Size
228    TLS and DTLS handshake messages can be quite large (in theory up to
229    2^24-1 bytes, in practice many kilobytes). By contrast, UDP datagrams
230    are often limited to <1500 bytes. In order to compensate for this
231    limitation, each DTLS handshake message may be fragmented over
232    several DTLS records. Each DTLS handshake message contains both a
233    fragment offset and a fragment length. Thus, a recipient in
234    possession of all bytes of a handshake message can reassemble the
235    original unfragmented message.
237 3.3. Replay Detection
239    DTLS optionally supports record replay detection. The technique used
240    is the same as in IPsec AH/ESP, by maintaining a bitmap window of
241    received records. Records that are too old to fit in the window and
242    records that have been previously received are silently discarded.
243    The replay detection feature is optional, since packet duplication is
244    not always malicious, but can also occur due to routing errors.
245    Applications may conceivably detect duplicate packets and accordingly
246    modify their data transmission strategy.
248 4. Differences from TLS
250    As mentioned in Section 3., DTLS is intentionally very similar to
251    TLS. Therefore, instead of presenting DTLS as a new protocol, we
252    instead present it as a series of deltas from TLS 1.1 [TLS11]. Where
253    we do not explicitly call out differences, DTLS is the same as TLS.
257 Rescorla, Modadugu                                               [Page 5]\f
260 4.1. Record Layer
262    The DTLS record layer is extremely similar to that of TLS 1.1. The
263    only change is the inclusion of an explicit sequence number in the
264    record. This sequence number allows the recipient to correctly verify
265    the TLS MAC. The DTLS record format is shown below:
267        struct {
268         ContentType type;
269         ProtocolVersion version;
270         uint16 epoch;               // New field
271         uint48 sequence_number;       // New field
272         uint16 length;
273         opaque fragment[DTLSPlaintext.length];
274        } DTLSPlaintext;
276       type
277        Equivalent to the type field in a TLS 1.1 record.
279       version
280        The version of the protocol being employed. This document
281        describes DTLS Version 1.0, which uses the version { 254, 255
282        }. The version value of 254.255 is the 1's complement of DTLS
283        Version 1.0. This maximal spacing between TLS and DTLS version
284        numbers ensures that records from the two protocols can be
285        easily distinguished.
287       epoch
288        A counter value that is incremented on every cipher state
289        change.
291       sequence_number
292        The sequence number for this record.
294       length
295        Identical to the length field in a TLS 1.1 record. As in TLS
296        1.1, the length should not exceed 2^14.
298       fragment
299        Identical to the fragment field of a TLS 1.1 record.
301    DTLS uses an explicit rather than implicit sequence number, carried
302    in the sequence_number field of the record. As with TLS, the sequence
303    number is set to zero after each ChangeCipherSpec message is sent.
305    If several handshakes are performed in close succession, there might
306    be multiple records on the wire with the same sequence number but
307    from different cipher states. The epoch field allows recipients to
311 Rescorla, Modadugu                                               [Page 6]\f
314    distinguish such packets. The epoch number is initially zero and is
315    incremented each time the ChangeCipherSpec messages is sent. In order
316    to ensure that any given sequence/epoch pair is unique,
317    implementations MUST NOT allow the same epoch value to be reused
318    within two times the maximum segment lifetime. In practice, TLS
319    implementations rehandshake rarely and we therefore do not expect
320    this to be a problem.
322 4.1.1. Transport Layer Mapping
324    Each DTLS record MUST fit within a single datagram. In order to avoid
325    IP fragmentation [MOGUL], DTLS implementations SHOULD determine the
326    MTU and send records smaller than the MTU. DTLS implementations
327    SHOULD provide a way for applications to determine the value of the
328    MTU (optimally the maximum application datagram size, which is the
329    PMTU minus the DTLS per-record overhead). If the application attempts
330    to send a record larger than the MTU, the DTLS implementation MUST
331    either generate an error or fragment the packet.
333    Multiple DTLS records may be placed in a single datagram. They are
334    simply encoded consecutively. The DTLS record framing is sufficient
335    to determine the boundaries. Note, however, that the first byte of
336    the datagram payload must be the beginning of a record. Records may
337    not span datagrams.
339 4.1.1.1. PMTU Discovery
341    The PMTU SHOULD be initialized from the interface MTU that will be
342    used to send packets.
344    To perform PMTU discovery, the DTLS sender sets the IP Don't Fragment
345    (DF) bit. As specified in [RFC 1191], when a router receives a packet
346    with DF set that is larger than the next link's MTU, it sends an ICMP
347    Destination Unreachable message to the source of the datagram with
348    the Code indicating "fragmentation needed and DF set" (also known as
349    a "Datagram Too Big" message). When a DTLS implementation receives a
350    Datagram Too Big message, it decreases its PMTU to the Next-Hop MTU
351    value given in the ICMP message. If the MTU given in the message is
352    zero, the sender chooses a value for PMTU using the algorithm
353    described in Section 7 of [RFC 1191]. If the MTU given in the message
354    is greater than the current PMTU, the Datagram Too Big message is
355    ignored, as described in [RFC 1191].
357    A DTLS implementation may allow the application to occasionally
358    request that PMTU discovery be performed again. This will reset the
359    PMTU to the outgoing interface's MTU. Such requests SHOULD be rate
360    limited, to one per two seconds, for example.
365 Rescorla, Modadugu                                               [Page 7]\f
368    Because some firewalls and routers screen out ICMP messages, it is
369    difficult to distinguish packet loss from a large PMTU estimate. In
370    order to allow connections under these circumstances, DTLS
371    implementations MAY choose to back off their PMTU estimate during the
372    retransmit backoff described in Section 4.2.4.. For instance, if a
373    large packet is being sent, after 3 retransmits a sender might choose
374    to fragment the packet.
376 4.1.2. Record payload protection
378    Like TLS, DTLS transmits data as a series of protected records. The
379    rest of this section describes the details of that format.
381 4.1.2.1. MAC
383    The DTLS MAC is the same as that of TLS 1.1. However, rather than
384    using TLS's implicit sequence number, the sequence number used to
385    compute the MAC is the 64-bit value formed by concatenating the epoch
386    and the sequence number in the order they appear on the wire. Note
387    that the DTLS epoch + sequence number is the same length as the TLS
388    sequence number.
390 4.1.2.2. Null or standard stream cipher
392    The DTLS NULL cipher is performed exactly as the TLS 1.1 NULL cipher.
394    The only stream cipher described in TLS 1.1 is RC4, which cannot be
395    randomly accessed. RC4 MUST NOT be used with DTLS.
397 4.1.2.3. Block Cipher
399    DTLS block cipher encryption and decryption are performed exactly as
400    with TLS 1.1.
402 4.1.2.4. New Cipher Suites
404    Upon registration, new TLS cipher suites MUST indicate whether they
405    are suitable for DTLS usage and what, if any, adaptations must be
406    made.
408 4.1.2.5. Anti-Replay
410    DTLS records contain a sequence number to provide replay protection.
411    Sequence number verification SHOULD be performed using the following
412    sliding, window procedure, borrowed from Section 3.4.3 of [RFC 2402]
414    The receiver packet counter for this session MUST be initialized to
415    zero when the session is established. For each received record, the
419 Rescorla, Modadugu                                               [Page 8]\f
422    receiver MUST verify that the record contains a Sequence Number that
423    does not duplicate the Sequence Number of any other record received
424    during the life of this session. This SHOULD be the first check
425    applied to a packet after it has been matched to a session, to speed
426    rejection of duplicate records.
428    Duplicates are rejected through the use of a sliding receive window.
429    (How the window is implemented is a local matter, but the following
430    text describes the functionality that the implementation must
431    exhibit.) A minimum window size of 32 MUST be supported; but a window
432    size of 64 is preferred and SHOULD be employed as the default.
433    Another window size (larger than the minimum) MAY be chosen by the
434    receiver. (The receiver does not notify the sender of the window
435    size.)
437    The "right" edge of the window represents the highest, validated
438    Sequence Number value received on this session. Records that contain
439    Sequence Numbers lower than the "left" edge of the window are
440    rejected. Packets falling within the window are checked against a
441    list of received packets within the window. An efficient means for
442    performing this check, based on the use of a bit mask, is described
443    in Appendix C of [RFC 2401].
445    If the received record falls within the window and is new, or if the
446    packet is to the right of the window, then the receiver proceeds to
447    MAC verification. If the MAC validation fails, the receiver MUST
448    discard the received record as invalid. The receive window is updated
449    only if the MAC verification succeeds.
451 4.2. The DTLS Handshake Protocol
453    DTLS uses all of the same handshake messages and flows as TLS, with
454    three principal changes:
456       1. A stateless cookie exchange has been added to prevent denial of
457       service attacks.
459       2. Modifications to the handshake header to handle message loss,
460       reordering and fragmentation.
462       3. Retransmission timers to handle message loss.
464    With these exceptions, the DTLS message formats, flows, and logic are
465    the same as those of TLS 1.1.
473 Rescorla, Modadugu                                               [Page 9]\f
476 4.2.1. Denial of Service Countermeasures
478    Datagram security protocols are extremely susceptible to a variety of
479    denial of service (DoS) attacks. Two attacks are of particular
480    concern:
482       1. An attacker can consume excessive resources on the server by
483       transmitting a series of handshake initiation requests, causing
484       the server to allocate state and potentially perform expensive
485       cryptographic operations.
487       2. An attacker can use the server as an amplifier by sending
488       connection initiation messages with a forged source of the victim.
489       The server then sends its next message (in DTLS, a Certificate
490       message, which can be quite large) to the victim machine, thus
491       flooding it.
493    In order to prevent both of these attacks, DTLS borrows the stateless
494    cookie technique used by Photuris [PHOTURIS] and IKEv2 [IKE]. When
495    the client sends its ClientHello message to the server, the server
496    MAY respond with a HelloVerifyRequest message. This message contains
497    a stateless cookie generated using the technique of [PHOTURIS]. The
498    client MUST retransmit the ClientHello with the cookie added. The
499    server then verifies the cookie and proceeds with the handshake only
500    if it is valid.
502    The exchange is shown below:
504          Client                                   Server
505          ------                                   ------
506          ClientHello           ------>
508                                <----- HelloVerifyRequest
509                                       (contains cookie)
511          ClientHello           ------>
512          (with cookie)
514          [Rest of handshake]
516    DTLS therefore modifies the ClientHello message to add the cookie
517    value.
519       struct {
520         ProtocolVersion client_version;
521         Random random;
522         SessionID session_id;
523         Cookie cookie<0..32>;                 // New field
527 Rescorla, Modadugu                                              [Page 10]\f
530         CipherSuite cipher_suites<2..2^16-1>;
531         CompressionMethod compression_methods<1..2^8-1>;
532       } ClientHello;
534    If the client does not have a cookie for a given server, it should
535    use a zero-length cookie.
537    The definition of HelloVerifyRequest is as follows:
539       struct {
540         Cookie cookie<0..32>;
541       } HelloVerifyRequest;
543    The HelloVerifyRequest message type is hello_verify_request(3).
545    When responding to a HelloVerifyRequest the client MUST use the same
546    parameter values (version, random, session_id, cipher_suites,
547    compression_method) as in the original ClientHello. The server SHOULD
548    use those values to generate its cookie and verify that they are
549    correct upon cookie receipt.
551    Although DTLS servers are not required to do a cookie exchange, they
552    SHOULD do so whenever a new handshake is performed in order to avoid
553    being used as amplifiers. If the server is being operated in an
554    environment where amplification is not a problem, the server MAY
555    choose not to perform a cookie exchange. In addition, the server MAY
556    choose not do to a cookie exchange when a session is resumed. Clients
557    MUST be prepared to do a cookie exchange with every handshake.
559 4.2.2. Handshake Message Format
561    In order to support message loss, reordering, and fragmentation DTLS
562    modifies the TLS 1.1 handshake header:
564       struct {
565         HandshakeType msg_type;
566         uint24 length;
567         uint16 message_seq;                              // New field
568         uint24 fragment_offset;                          // New field
569         uint24 fragment_length;                          // New field
570         select (HandshakeType) {
571       case hello_request: HelloRequest;
572       case client_hello:  ClientHello;
573       case hello_verify_request: HelloVerifyRequest;     // New type
574       case server_hello:  ServerHello;
575       case certificate:Certificate;
576       case server_key_exchange: ServerKeyExchange;
577       case certificate_request: CertificateRequest;
581 Rescorla, Modadugu                                              [Page 11]\f
584       case server_hello_done:ServerHelloDone;
585       case certificate_verify:  CertificateVerify;
586       case client_key_exchange: ClientKeyExchange;
587       case finished:Finished;
588         } body;
589       } Handshake;
591    The first message each side transmits in each handshake always has
592    message_seq = 0. Whenever each new message is generated, the
593    message_seq value is incremented by one. When a message is
594    retransmitted, the same message_seq value is used. For example.
596       Client                             Server
597       ------                             ------
598       ClientHello (seq=0)  ------>
600                               X<-- HelloVerifyRequest (seq=0)
601                                               (lost)
603       [Timer Expires]
605       ClientHello (seq=0)  ------>
606       (retransmit)
608                            <------ HelloVerifyRequest (seq=0)
610       ClientHello (seq=1)  ------>
611       (with cookie)
613                            <------        ServerHello (seq=1)
614                            <------        Certificate (seq=2)
615                            <------    ServerHelloDone (seq=3)
617       [Rest of handshake]
619    DTLS implementations maintain (at least notionally) a
620    next_receive_seq counter. This counter is initially set to zero. When
621    a message is received, if its sequence number matches
622    next_receive_seq, next_receive_seq is incremented and the message is
623    processed. If the sequence number is less than next_receive_seq the
624    message MUST be discarded. If the sequence number is greater than
625    next_receive_seq, the implementation SHOULD queue the message but MAY
626    discard it. (This is a simple space/bandwidth tradeoff).
628 4.2.3. Message Fragmentation and Reassembly
630    As noted in Section 4.1.1., each DTLS message MUST fit within a
631    single transport layer datagram. However, handshake messages are
635 Rescorla, Modadugu                                              [Page 12]\f
638    potentially bigger than the maximum record size. Therefore DTLS
639    provides a mechanism for fragmenting a handshake message over a
640    number of records.
642    When transmitting the handshake message, the sender divides the
643    message into a series of N contiguous data ranges. These range MUST
644    NOT be larger than the maximum handshake fragment size and MUST
645    jointly contain the entire handshake message. The ranges SHOULD NOT
646    overlap. The sender then creates N handshake messages, all with the
647    same message_seq value as the original handshake message. Each new
648    message is labelled with the fragment_offset (the number of bytes
649    contained in previous fragments) and the fragment_length (the length
650    of this fragment). The length field in all messages is the same as
651    the length field of the original message. An unfragmented message is
652    a degenerate case with fragment_offset=0 and fragment_length=length.
654    When a DTLS implementation receives a handshake message fragment, it
655    MUST buffer it until it has the entire handshake message. DTLS
656    implementations MUST be able to handle overlapping fragment ranges.
657    This allows senders to retransmit handshake messages with smaller
658    fragment sizes during path MTU discovery.
660    Note that as with TLS, multiple handshake messages may be placed in
661    the same DTLS record, provided that there is room and that they are
662    part of the same flight. Thus, there are two acceptable ways to pack
663    two DTLS messages into the same datagram: in the same record or in
664    separate records.
666 4.2.4. Timeout and Retransmission
668    DTLS messages are grouped into a series of message flights, according
669    the diagrams below. Although each flight of messages may consist of a
670    number of messages, they should be viewed as monolithic for the
671    purpose of timeout and retransmission.
689 Rescorla, Modadugu                                              [Page 13]\f
692       Client                                          Server
693       ------                                          ------
695       ClientHello             -------->                           Flight 1
697                               <-------    HelloVerifyRequest      Flight 2
699      ClientHello              -------->                           Flight 3
701                                                  ServerHello    \
702                                                 Certificate*     \
703                                           ServerKeyExchange*      Flight 4
704                                          CertificateRequest*     /
705                               <--------      ServerHelloDone    /
707       Certificate*                                              \
708       ClientKeyExchange                                          \
709       CertificateVerify*                                          Flight 5
710       [ChangeCipherSpec]                                         /
711       Finished                -------->                         /
713                                           [ChangeCipherSpec]    \ Flight 6
714                               <--------             Finished    /
715                Figure 1: Message flights for full handshake
718       Client                                           Server
719       ------                                           ------
721       ClientHello             -------->                          Flight 1
723                                                  ServerHello    \
724                                           [ChangeCipherSpec]     Flight 2
725                                <--------             Finished    /
727       [ChangeCipherSpec]                                         \Flight 3
728       Finished                 -------->                         /
729    Figure 2: Message flights for session resuming handshake (no cookie exchange)
732    DTLS uses a simple timeout and retransmission scheme with the
733    following state machine. Because DTLS clients send the first message
734    (ClientHello) they start in the PREPARING state. DTLS servers start
735    in the WAITING state, but with empty buffers and no retransmit timer.
743 Rescorla, Modadugu                                              [Page 14]\f
746                    +-----------+
747                    | PREPARING |
748              +---> |           |
749              |     |           |
750              |     +-----------+
751              |           |
752              |           |
753              |           | Buffer next flight
754              |           |
755              |          \|/
756              |     +-----------+
757              |     |           |
758              |     |  SENDING  |<------------------+
759              |     |           |                   |
760              |     +-----------+                   |
761      Receive |           |                         |
762         next |           | Send flight             |
763       flight |  +--------+                         |
764              |  |        | Set retransmit timer    |
765              |  |       \|/                        |
766              |  |  +-----------+                   |
767              |  |  |           |                   |
768              +--)--|  WAITING  |-------------------+
769              |  |  |           |   Timer expires   |
770              |  |  +-----------+                   |
771              |  |         |                        |
772              |  |         |                        |
773              |  |         +------------------------+
774              |  |                Read retransmit
775      Receive |  |
776         last |  |
777       flight |  |
778              |  |
779             \|/\|/
781          +-----------+
782          |           |
783          | FINISHED  |
784          |           |
785          +-----------+
787           Figure 3: DTLS timeout and retransmission state machine
790    The state machine has three basic states.
792    In the PREPARING state the implementation does whatever computations
793    are necessary to prepare the next flight of messages. It then buffers
797 Rescorla, Modadugu                                              [Page 15]\f
800    them up for transmission (emptying the buffer first) and enters the
801    SENDING state.
803    In the SENDING state, the implementation transmits the buffered
804    flight of messages. Once the messages have been sent, the
805    implementation then enters the FINISHED state if this is the last
806    flight in the handshake, or, if the implementation expects to receive
807    more messages, sets a retransmit timer and then enters the WAITING
808    state.
810    There are three ways to exit the WAITING state:
812       1. The retransmit timer expires: the implementation transitions to
813       the SENDING state, where it retransmits the flight, resets the
814       retransmit timer, and returns to the WAITING state.
816       2. The implementation reads a retransmitted flight from the peer:
817       the implementation transitions to the SENDING state, where it
818       retransmits the flight, resets the retransmit timer, and returns
819       to the WAITING state. The rationale here is that the receipt of a
820       duplicate message is the likely result of timer expiry on the peer
821       and therefore suggests that part of one's previous flight was
822       lost.
824       3. The implementation receives the next flight of messages: if
825       this is the final flight of messages the implementation
826       transitions to FINISHED. If the implementation needs to send a new
827       flight, it transitions to the PREPARING state. Partial reads
828       (whether partial messages or only some of the messages in the
829       flight) do not cause state transitions or timer resets.
832 4.2.4.1. Timer Values
834    Timer value choices are a local matter. We RECOMMEND that
835    implementations use an initial timer value of 500 ms and double the
836    value at each retransmission, up to twice the TCP Maximum Segment
837    Lifetime. [TCP] Implementations SHOULD start the timer value at the
838    initial value with each new flight of messages.
840 4.2.5. ChangeCipherSpec
842    As with TLS, the ChangeCipherSpec message is not technically a
843    handshake message but MUST be treated as part of the same flight as
844    the associated Finished message for the purposes of timeout and
845    retransmission.
851 Rescorla, Modadugu                                              [Page 16]\f
854 4.2.6. Finished messages
856    Finished messages have the same format as in TLS. However, in order
857    to remove sensitivity to fragmentation, the Finished MAC MUST be
858    computed as if each handshake message had been sent as a single
859    fragment. Note that in cases where the cookie exchange is used, the
860    initial ClientHello and HelloVerifyRequest MUST BE included in the
861    Finished MAC.
865 A.1\bSummary of new syntax
867    This section includes specifications for the data structures that
868    have changed between TLS 1.1 and DTLS.
870 4.2. Record Layer
871    struct {
872      ContentType type;
873      ProtocolVersion version;
874      uint16 epoch;                                   // New field
875      uint48 sequence_number;                         // New field
876      uint16 length;
877      opaque fragment[DTLSPlaintext.length];
878    } DTLSPlaintext;
880    struct {
881      ContentType type;
882      ProtocolVersion version;
883      uint16 epoch;                                   // New field
884      uint48 sequence_number;                         // New field
885      uint16 length;
886      opaque fragment[DTLSCompressed.length];
887    } DTLSCompressed;
889    struct {
890      ContentType type;
891      ProtocolVersion version;
892      uint16 epoch;                                   // New field
893      uint48 sequence_number;                         // New field
894      uint16 length;
895      select (CipherSpec.cipher_type) {
896    case block:  GenericBlockCipher;
897      } fragment;
898    } DTLSCiphertext;
905 Rescorla, Modadugu                                              [Page 17]\f
908 4.3. Handshake Protocol
910    enum {
911      hello_request(0), client_hello(1), server_hello(2),
912      hello_verify_request(3),                        // New field
913      certificate(11), server_key_exchange (12),
914      certificate_request(13), server_hello_done(14),
915      certificate_verify(15), client_key_exchange(16),
916      finished(20), (255)
917    } HandshakeType;
919    struct {
920      HandshakeType msg_type;
921      uint24 length;
922      uint16 message_seq;                             // New field
923      uint24 fragment_offset;                         // New field
924      uint24 fragment_length;                         // New field
925      select (HandshakeType) {
926    case hello_request: HelloRequest;
927    case client_hello:  ClientHello;
928    case server_hello:  ServerHello;
929    case hello_verify_request: HelloVerifyRequest;    // New field
930    case certificate:Certificate;
931    case server_key_exchange: ServerKeyExchange;
932    case certificate_request: CertificateRequest;
933    case server_hello_done:ServerHelloDone;
934    case certificate_verify:  CertificateVerify;
935    case client_key_exchange: ClientKeyExchange;
936    case finished:Finished;
937      } body;
938    } Handshake;
940    struct {
941      Cookie cookie<H0..32>;
942    } HelloVerifyRequest;
944 5. Security Considerations
946    This document describes a variant of TLS 1.1 and therefore most of
947    the security considerations are the same as those of TLS 1.1 [TLS11],
948    described in Appendices D, E, and F.
950    The primary additional security consideration raised by DTLS is that
951    of denial of service. DTLS includes a cookie exchange designed to
952    protect against denial of service. However, implementations which do
953    not use this cookie exchange are still vulnerable to DoS. In
954    particular, DTLS servers which do not use the cookie exchange may be
955    used as attack amplifiers even if they themselves are not
959 Rescorla, Modadugu                                              [Page 18]\f
962    experiencing DoS. Therefore DTLS servers SHOULD use the cookie
963    exchange unless there is good reason to believe that amplification is
964    not a threat in their environment.
966 6. IANA Considerations
968    This document uses the same identifier space as TLS [TLS11], so no
969    IANA registries are required beyond those for TLS. Identifiers MAY
970    NOT be assigned for DTLS that conflict with TLS. When new identifiers
971    are assigned for TLS, authors MUST specify whether they are suitable
972    for DTLS.
974 References
976 Normative References
978    [PHOTURIS] Karn, P., Simpson, W., "Photuris: Session-Key Management
979               Protocol", RFC 2521, March 1999.
981    [REQ]      Bradner, S., "Key words for use in RFCs to Indicate
982               Requirement Levels", BCP 14, RFC 2119, March 1997.
984    [REQ]
986    [RFC1191]  Mogul, J. C., Deering, S.E., "Path MTU Discovery",
987               RFC 1191, November 1990.
989    [RFC2401]  Kent, S., Atkinson, R., "Security Architecture for the
990               Internet Protocol", RFC2401, November 1998.
992    [TCP]      Postel, J., "Transmission Control Protocol",
993               RFC 793, September 1981.
995    [TLS]      Dierks, T., and Allen, C., "The TLS Protocol Version 1.0",
996               RFC 2246, January 1999.
998    [TLS11]    Dierks, T., Rescorla, E., "The TLS Protocol Version 1.1",
999               draft-ietf-tls-rfc2246-bis-05.txt, July 2003.
1002 Informative References
1004    [AH]       Kent, S., and Atkinson, R., "IP Authentication Header",
1005               RFC 2402, November 1998.
1007    [DCCP]     Kohler, E., Handley, M., Floyd, S., Padhye, J., "Datagram
1008               Congestion Control Protocol", draft-ietf-dccp-spec-05.txt,
1009               October 2003
1013 Rescorla, Modadugu                                              [Page 19]\f
1016    [DTLS]     Modadugu, N., Rescorla, E., "The Design and Implementation
1017               of Datagram TLS", in Proceedings of ISOC NDSS 2004,
1018               February 2004.
1020    [ESP]      Kent, S., and Atkinson, R., "IP Encapsulating Security
1021               Payload (ESP)", RFC 2406, November 1998.
1024    [IKE]      Harkins, D., Carrel, D., "The Internet Key Exchange (IKE)",
1025               RFC 2409, November 1998.
1027    [IMAP]     Crispin, M., "Internet Message Access Protocol - Version
1028               4rev1", RFC 3501, March 2003.
1030    [POP]      Myers, J., and Rose, M., "Post Office Protocol -
1031               Version 3", RFC 1939, May 1996.
1034    [SIP]      Rosenberg, J., Schulzrinne, Camarillo, G., Johnston, A.,
1035               Peterson, J., Sparks, R., Handley, M., Schooler, E.,
1036               "SIP: Session Initiation Protocol", RFC 3261,
1037               June 2002.
1039    [WHYIPSEC] Bellovin, S., "Guidelines for Mandating the Use of IPsec",
1040               draft-bellovin-useipsec-02.txt, October 2003
1042 Authors' Address
1044    Eric Rescorla <ekr@rtfm.com>
1045    RTFM, Inc.
1046    2064 Edgewood Drive
1047    Palo Alto, CA 94303
1049    Nagendra Modadugu <nagendra@cs.stanford.edu>
1050    Computer Science Department
1051    353 Serra Mall
1052    Stanford University
1053    Stanford, CA 94305
1057 Acknowledgements
1059    The authors would like to thank Dan Boneh, Eu-Jin Goh, Russ Housley,
1060    Constantine Sapuntzakis, and Hovav Shacham for discussions and
1061    comments on the design of DTLS. Thanks to the anonymous NDSS
1062    reviewers of our original NDSS paper on DTLS [DTLS] for their
1063    comments. Also, thanks to Steve Kent for feedback that helped clarify
1067 Rescorla, Modadugu                                              [Page 20]\f
1070    many points. The section on PMTU was cribbed from the DCCP
1071    specification [DCCP].
1121 Rescorla, Modadugu                                              [Page 21]\f
1124 Full Copyright Statement
1126    The IETF takes no position regarding the validity or scope of any
1127    Intellectual Property Rights or other rights that might be claimed to
1128    pertain to the implementation or use of the technology described in
1129    this document or the extent to which any license under such rights
1130    might or might not be available; nor does it represent that it has
1131    made any independent effort to identify any such rights. Information
1132    on the procedures with respect to rights in RFC documents can be
1133    found in BCP 78 and BCP 79.
1135    Copies of IPR disclosures made to the IETF Secretariat and any
1136    assurances of licenses to be made available, or the result of an
1137    attempt made to obtain a general license or permission for the use of
1138    such proprietary rights by implementers or users of this
1139    specification can be obtained from the IETF on-line IPR repository at
1140    http://www.ietf.org/ipr.
1142    The IETF invites any interested party to bring to its attention any
1143    copyrights, patents or patent applications, or other proprietary
1144    rights that may cover technology that may be required to implement
1145    this standard. Please address the information to the IETF at ietf-
1146    ipr@ietf.org.
1148 Copyright Notice
1149    Copyright (C) The Internet Society (2003). This document is subject
1150    to the rights, licenses and restrictions contained in BCP 78, and
1151    except as set forth therein, the authors retain all their rights.
1153    This document and the information contained herein are provided on an
1154    "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
1155    OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
1156    ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
1157    INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
1158    INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
1159    WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
1175 Rescorla, Modadugu                                              [Page 22]\f