Skip to content

Commit eae0c5d

Browse files
authored
Various clarifications and cleanup (#156)
Notable changes: - The data channel id in the `exclude` list MUST be less than 65535 - Loosen strictness regarding handover - The application may decide whether or not to hand over and is no longer required to do so immediately - Handover support is no longer mandatory but recommended - Rephrase *Wrapped Data Channel* section - A wrapper/proxy is no longer recommended - Messages must still be fragmented/reassembled (encrypt-then-chunk) using unreliable/unordered mode for the handed over signalling channel. However, other wrapped data channels created by the application do not have this requirement. - Clarifies how to determine the maximum chunk size to be used for the handed over signalling channel - "Wrapped data channel" has been renamed to "Secure data channel"
1 parent 1490dc9 commit eae0c5d

File tree

1 file changed

+68
-72
lines changed

1 file changed

+68
-72
lines changed

Task-WebRTC.md

+68-72
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ makes it possible to split a message into chunks and reassemble the
3030
message on the receiver's side while allowing any combination of
3131
ordered/unordered and reliable/unreliable transport channel underneath.
3232

33-
## Wrapped Data Channel
33+
## Secure Data Channel
3434

3535
This protocol adds another security layer for WebRTC data channels as we
3636
want our protocol to sustain broken (D)TLS environments. A data channel
37-
that uses this security layer will be called *Wrapped Data Channel*.
38-
Note that the user MAY or MAY NOT choose to use wrapped data channels
37+
that uses this security layer will be called *Secure Data Channel*.
38+
Note that the user MAY or MAY NOT choose to use secure data channels
3939
for its purpose. However, the handed over signalling channel MUST use a
40-
wrapped data channel.
40+
secure data channel.
4141

4242
# Task Protocol Name
4343

@@ -59,71 +59,56 @@ MUST be validated and potentially stored.
5959
The task's data SHALL be a `Map` containing the following items:
6060

6161
* The *exclude* field MUST contain an `Array` of WebRTC data channel ids
62-
(non-negative integers) that SHALL not be used for the signalling
63-
channel. This `Array` MUST be available to be set from user
64-
applications that use specific data channel ids.
62+
(non-negative integers less than `65535`) that SHALL not be used for
63+
the signalling channel. This `Array` MUST be available to be set from
64+
user applications that use pre-negotiated data channel ids.
6565
* The *handover* field SHALL be set to `true` unless the user application
66-
explicitly requested to turn off the handover feature or the
67-
implementation has knowledge that `RTCDataChannel`s are not supported.
68-
In this case, the value SHALL be set to `false`.
66+
explicitly requested to turn off the handover feature in which case it
67+
SHALL be set to `false`.
6968

7069
## Incoming
7170

72-
A client who receives the task's data from the other peer MUST do the
71+
A client who receives the task's data from the remote peer MUST do the
7372
following checks:
7473

7574
* The *exclude* field MUST contain an `Array` of WebRTC data channel IDs
76-
(non-negative integers) that SHALL not be used for the signalling
77-
channel. The client SHALL store this list for usage during handover.
75+
(non-negative integers less than `65535`) that SHALL not be used for
76+
the signalling channel. The client SHALL store this list for usage
77+
during handover.
7878
* The *handover* field MUST be either `true` or `false`. If both
7979
client's values are `true`, the negotiated value is `true`. In any
8080
other case, the negotiated value is `false` and a handover requested
8181
by the user application SHALL be rejected (see the *Signalling Channel
8282
Handover* section for details).
8383

84-
# Wrapped Data Channel
84+
# Secure Data Channel
8585

86-
This protocol adds another security layer to WebRTC's data channels. To
87-
allow both the user's application and the handed over signalling channel
88-
to easily utilise this security layer, it is RECOMMENDED to provide a
89-
wrapper/proxy to the `RTCDataChannel` interface. Underneath, the wrapped
90-
data channel MUST use NaCl for encryption/decryption and chunk messages
91-
as specified in the
92-
[SaltyRTC chunking specification](https://github.com/saltyrtc/saltyrtc-meta/blob/master/Chunking.md)
93-
if necessary.
86+
This protocol adds another security layer to WebRTC's data channels
87+
which the handed over signalling channel SHALL use. It MUST be possible
88+
for the user application to utilise this security layer for further data
89+
channels. The secure data channel MUST use NaCl for
90+
encryption/decryption of messages.
9491

9592
Outgoing messages MUST be processed and encrypted by following the
96-
*Sending a Wrapped Data Channel Message* section. The encrypted messages
97-
SHALL be split into chunks using SaltyRTC message chunking. The maximum
98-
chunk size MUST be determined by querying the `maxMessageSize` attribute
99-
of the associated `RTCPeerConnection`'s `RTCSctpTransport`.
100-
101-
Incoming messages SHALL be stitched together using SaltyRTC message
102-
chunking. Complete messages MUST be processed and decrypted by following
103-
the *Receiving a Wrapped Data Channel Message* section. The resulting
104-
complete message SHALL raise a corresponding message event.
105-
106-
As described in the *Sending a Wrapped Data Channel Message* and the
107-
*Receiving a Wrapped Data Channel Message* section, each new wrapped
108-
data channel instance is being treated as a new peer from the nonce's
109-
perspective and independent of the underlying data channel id. To
110-
prevent nonce reuse, it is absolutely vital that each wrapped data
111-
channel instance has its own cookie, sequence number and overflow
93+
*Sending a Secure Data Channel Message* section.
94+
95+
Incoming messages MUST be processed and decrypted by following the
96+
*Receiving a Secure Data Channel Message* section.
97+
98+
As described in the *Sending a Secure Data Channel Message* and the
99+
*Receiving a Secure Data Channel Message* section, each new secure
100+
data channel instance is being treated as a distinct remote peer from
101+
the nonce's perspective and independent of the underlying data channel
102+
id. To prevent nonce reuse, it is absolutely vital that each secure
103+
data channel instance has its own cookie, sequence number and overflow
112104
number, each for incoming and outgoing messages. Both clients SHALL use
113-
cryptographically secure random numbers for the cookie and the sequence
114-
number.
105+
cryptographically secure random numbers for generating the cookie and
106+
the sequence number.
115107

116108
# Signalling Channel Handover
117109

118-
As soon as the user application has created a WebRTC `RTCPeerConnection`
119-
instance which intends to use this task for its signalling, the user
120-
application SHOULD request that the client hands over the signalling
121-
channel to a dedicated data channel before *offer* or *answer* of the
122-
`RTCPeerConnection` have been created. If the negotiated *handover*
123-
parameter from the task's data is `false` or the necessary
124-
`RTCDataChannel` instance could not be created, the user application
125-
SHALL be informed that a handover cannot take place. Otherwise, the
126-
handover process SHALL be started:
110+
If the negotiated *handover* parameter is `true`, the user application
111+
SHOULD initiate the handover process:
127112

128113
1. The client creates a new data channel on the `RTCPeerConnection`
129114
instance with the `RTCDataChannelInit` object containing only the
@@ -134,8 +119,8 @@ handover process SHALL be started:
134119
* *negotiated* MUST be set to `true`, and
135120
* *id* SHALL be set to the lowest possible number, starting from `0`,
136121
that is not excluded by both clients as negotiated.
137-
2. The newly created `RTCDataChannel` instance shall be wrapped by
138-
following the *Wrapped Data Channel* section.
122+
2. The newly created `RTCDataChannel` instance SHALL be secured by
123+
following the *Secure Data Channel* section.
139124
3. As soon as the data channel is `open`, the client SHALL send a
140125
'handover' message on the WebSocket-based signalling channel (*WS
141126
channel*) to the other client. Subsequent outgoing messages MUST be
@@ -160,7 +145,7 @@ structure as defined in the
160145
[SaltyRTC protocol specification](./Protocol.md#message-structure)
161146
SHALL be used.
162147

163-
For all messages that are being exchanged over wrapped data channels
148+
For all messages that are being exchanged over secure data channels
164149
(such as the handed over signalling channel), the nonce/header MUST be
165150
slightly changed:
166151

@@ -183,12 +168,12 @@ Contains the data channel id of the data channel that is being used for
183168
a message.
184169

185170
The cookie field remains the same as in the SaltyRTC protocol
186-
specification. Each new wrapped data channel SHALL have a new
171+
specification. Each new secure data channel SHALL have a new
187172
cryptographically secure random cookie, one for incoming messages and
188173
one for outgoing messages.
189174

190175
Overflow Number and Sequence Number SHALL remain the same as in the
191-
SaltyRTC protocol specification. Each new wrapped data channel instance
176+
SaltyRTC protocol specification. Each new secure data channel instance
192177
SHALL have its own overflow number and sequence number, each for
193178
outgoing and incoming messages.
194179

@@ -197,34 +182,45 @@ Data Channel ID field. As there can be only communication between the
197182
peers that set up the peer-to-peer connection, dedicated addresses are
198183
no longer required.
199184

200-
# Sending a Wrapped Data Channel Message
185+
# Sending a Secure Data Channel Message
201186

202187
The same procedure as described in the
203188
[SaltyRTC protocol specification](./Protocol.md#sending-a-signalling-message)
204189
SHALL be followed. However, for all messages that are being exchanged
205-
over wrapped data channels (such as the handed over signalling channel),
206-
the following changes MUST be applied:
190+
over secure data channels, the following changes MUST be applied:
207191

208192
* Each data channel instance SHALL have its own cookie, overflow number
209193
and sequence number for outgoing messages.
210194
* Source and destination addresses SHALL NOT be set, instead
211195
* The data channel id MUST be set to the id of the data channel the
212196
message will be sent on.
213197

214-
# Receiving a Wrapped Data Channel Message
198+
For the handed over
199+
signalling channel, the encrypted message MUST be fragmented into
200+
chunks using
201+
[SaltyRTC chunking](https://github.com/saltyrtc/saltyrtc-meta/blob/master/Chunking.md)
202+
in *unreliable/unordered* mode (for legacy reasons) after encryption.
203+
The chunk size MUST be less or equal to the `maxMessageSize` value of the
204+
`RTCPeerConnection`'s `RTCSctpTransport`.
205+
206+
# Receiving a Secure Data Channel Message
207+
208+
For the handed over signalling channel, the encrypted message MUST be
209+
reassembled into a complete signalling message using
210+
[SaltyRTC chunking](https://github.com/saltyrtc/saltyrtc-meta/blob/master/Chunking.md)
211+
in *unreliable/unordered* mode (for legacy reasons) before decryption.
215212

216213
The same procedure as described in the
217214
[SaltyRTC protocol specification](./Protocol.md#receiving-a-signalling-message)
218215
SHALL be followed. However, for all messages that are being exchanged
219-
over wrapped data channels (such as the handed over signalling channel),
220-
the following changes MUST be applied:
216+
over secure data channels, the following changes MUST be applied:
221217

222218
* Each data channel instance SHALL have its own cookie, overflow number
223219
and sequence number for incoming messages.
224-
* Source and destination addresses are not present in the wrapped data
220+
* Source and destination addresses are not present in the secure data
225221
channel's nonce/header.
226222
* Overflow number and sequence number SHALL NOT be validated to ensure
227-
unordered and unreliable wrapped data channels can function properly.
223+
unordered and unreliable secure data channels can function properly.
228224
However, a client SHOULD check that two consecutive incoming messages
229225
of the same data channel do not have the exact same overflow and
230226
sequence number.
@@ -235,10 +231,10 @@ the following changes MUST be applied:
235231

236232
The following messages are new messages that will be exchanged between
237233
two clients (initiator and responder) over the signalling channel. Note
238-
that the signalling channel may be handed over to a data channel anytime
239-
which is REQUIRED to be supported by the implementation. Furthermore,
240-
the handed over signalling channel MUST support all existing
241-
client-to-client message types.
234+
that the signalling channel may be handed over to a data channel any
235+
time which is RECOMMENDED to be supported by the implementation.
236+
Furthermore, the handed over signalling channel MUST support all
237+
existing client-to-client message types.
242238

243239
Other messages, general behaviour and error handling for
244240
client-to-client messages is described in the
@@ -365,11 +361,11 @@ containing the following fields:
365361
description the candidate is associated with as described in the
366362
WebRTC specification. It's value SHALL be either an unsigned integer
367363
(16 bits) or `Nil`.
368-
* The *usernameFragment* field SHALL contain the ICE user fragment as defined in
369-
the WebRTC specification in string representation or `Nil`.
364+
* The *usernameFragment* field SHALL contain the ICE user fragment as
365+
defined in the WebRTC specification in string representation or `Nil`.
370366

371367
*(Note: The naming is inconsistent with the rest of the protocol,
372-
because it uses camelCase keys instead of under_scores. The reason for
368+
since it uses camelCase keys instead of under_scores. The reason for
373369
this is ease of use in browser implementations: When using camelCase
374370
each `candidates` entry can be passed directly to the JavaScript WebRTC
375371
implementation.)*
@@ -405,7 +401,7 @@ key pair and the other client's session key pair.
405401

406402
## 'handover' Message
407403

408-
Both clients SHALL send this message once the wrapped data channel
404+
Both clients SHALL send this message once the secure data channel
409405
dedicated for the signalling is `open`. However, the message MUST be
410406
sent over the WebSocket-based signalling channel.
411407

@@ -436,10 +432,10 @@ key pair and the other client's session key pair.
436432

437433
The message itself and the client's behaviour is described in the
438434
[SaltyRTC protocol specification](./Protocol.md#close-message). Once the
439-
signalling channel has been handed over to a wrapped data channel, sent
435+
signalling channel has been handed over to a secure data channel, sent
440436
and received 'close' messages SHALL trigger closing the underlying data
441437
channel used for signalling. The user application MAY continue using the
442-
`RTCPeerConnection` instance and its data channels. However, wrapped
438+
`RTCPeerConnection` instance and its data channels. However, secure
443439
data channels MAY or MAY NOT be available once the signalling's data
444440
channel has been closed, depending on the flexibility of the client's
445441
implementation.

0 commit comments

Comments
 (0)