Subject: Re: [TLS] [DTLS1.3]About the retransmission of Handshake records

From: Benjamin Kaduk <[email-masked]>
Date: Sun, 1 Dec 2019 23:54:45 -0800

That might be an artifact from Ack having at one point (the -00) been
a handshake message.  Though, it seems that the Server's message_seq
space should also start at 0 with ServerHello, if I am understanding correctly.

-Ben

On Thu, Nov 28, 2019 at 03:15:38PM +0800, Xuan k wrote:
>  Hi Ekr,
> 
> Thanks for your help.
> 
> I have another question about the "message_seq" in section "6. Example of
> Handshake with Timeout and Retransmission".
> Could you please explain it?
> 
> In the secion 6, the Client send message_seq = 0 in Record 0 and
> message_seq = 2,3,4 in Record 2.
> 
> Why message_seq = 1 is skipped by Client?
> I think the ClientHello in the figure should begin with message_seq=1. The
> message_seq = 0 is used by the first ClientHello which is the one without
> cookies.
> 
> 
> Thanks,
> Zhai Zhaoxuan
> 
> On 11/28/19 5:37 AM, Eric Rescorla wrote:
> 
> 
> 
> On Tue, Nov 26, 2019 at 10:05 PM Xuan k <[email-masked]> wrote:
> 
> > Hi all,
> >
> > I'm trying to implement a DTLS1.3 library for embedded devices. But It
> > seems something weird about retransmissions and ACKs.
> >
> > In the section "5.2. DTLS Handshake Message Format":
> >
> >    The first message each side transmits in each association always has
> >    message_seq = 0.  Whenever a new message is generated, the
> >    message_seq value is incremented by one.  When a message is
> >    retransmitted, the old *message_seq value is re-used*, i.e., not
> >    incremented.  From the perspective of the DTLS record layer, the
> >    retransmission is a new record.  This record will have a *new*
> > *   DTLSPlaintext.sequence_number* value.
> >
> >
> > In the section "7. ACK Message", the ACK message use the record_numbers
> > (corresponds to *DTLSPlaintext.sequence_number*).
> >
> > For my understanding, the "message_seq" belongs to "Handshake" and the
> > "sequence_number" or "record_numbers" belongs to
> > record layer.
> >
> 
> Yes.
> 
> The retransmission detection is done by "Handshake" using "message_seq",
> > but the "acknowledge" is done by "record layer" using "record_numbers".
> > It is so weird.
> >
> 
> Hmm... I don't think that this is particularly weird. This is, for
> instance, how QUIC stream acknowledgement and retransmission works.
> 
> 
> The retransmission, retransmission detection and acknowledge should be done
> > in handshake process, but we need the record layer passing the
> > record_numebrs to the handshake process.
> >
> > Since a new "sequence_number" is used for retransmission, we have to
> > maintain a "record_numbers" to "message_seq" map with dynamic size.
> > Each retransmission attempt creates a new relationship between a new
> > "record_numbers" to an old "message_seq".
> >
> 
> Yes, that's how it works in NSS.
> 
> 
> Since ACK is only used with Handshake messages, is it possible that we use
> > "message_seq" in ACK messages?
> >
> Or we use *old* "sequence_number" for retransmission,
> >
> 
> Both of these give you strictly less information about the network. One of
> the cool innovations in QUIC is to label each packet separately so you can
> determine whether an ACK is an ACK of the original packet or a retransmit.
> We are trying to inherit tha there
> 
> -Ekr
> 
> so we do not need maintain the dynamic map. And if replay detection is
> > implemented, the retransmitted
> > record can be dropped by record layer (by replay detection), the
> > "Handshake Protocol" do not need to do retransmission detection.
> >
> > Thanks
> > Zhai Zhaoxuan
> > _______________________________________________
> > TLS mailing list
> > [email-masked]
> > https://www.ietf.org/mailman/listinfo/tls
> >

> _______________________________________________
> TLS mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/tls

---

From: Xuan k <[email-masked]>
Date: Mon, 2 Dec 2019 19:17:32 +0800

Hi Ben,

Thanks for your reply. But we understand may not be the same.

Since ACK messages are not retransmitted, I think they should not consume
message_seqs.
If an ACK really use a message_seq and it is lost in network, new handshake
records will
always use a larger message_seq than the peer expected (next_receive_seq).
The peer will unable to continue the handshake process.

And I think the ServerHello in the figure should start with 1, as the
figure shows.
The message_seq = 0 is used by HelloVerifyRequest, which is also been
processed by client
and been fed into its transcript hash function.

So I think the HelloVerifyRequest should be counted and new ServerHello in
the figure
should start with message_seq = 1.

Thanks,

Zhai Zhaoxuan

---

From: Xuan k <[email-masked]>
Date: Mon, 2 Dec 2019 19:20:43 +0800

Sorry for my mistake.

The HelloVerifyRequest in the previous email should be replace with
"HelloRetryRequest".

On Mon, Dec 2, 2019 at 7:17 PM Xuan k <[email-masked]> wrote:

> If an ACK really use a message_seq and it is lost in network, new
> handshake records will

---

From: Eric Rescorla <[email-masked]>
Date: Mon, 2 Dec 2019 05:34:25 -0800

U

> Why message_seq = 1 is skipped by Client?

It's a typo in the example. The Certificate should be 1.

> message_seq = 0 is used by the first ClientHello which is the one without

I agree in principle, but that's not this example, because, as you can see,
there is no HRR. Rather, this needs to remove +cookie.

-Ekr

> The retransmission, retransmission detection and acknowledge should be
>> done in handshake process, but we need the record layer passing the

---

From: Benjamin Kaduk <[email-masked]>
Date: Mon, 2 Dec 2019 10:26:12 -0800

> The peer will unable to continue the handshake process.

You are correct; they should not and do not.
But in an early version of the draft the ACK messages used the same data structure
that has an associated message_seq, and as you note, that was problematic, so it was changed.

-Ben