Added preliminary Symbian support.
[silc.git] / doc / draft-riikonen-silc-pp-09.nroff
1 .pl 10.0i
2 .po 0
3 .ll 7.2i
4 .lt 7.2i
5 .nr LL 7.2i
6 .nr LT 7.2i
7 .ds LF Riikonen
8 .ds RF FORMFEED[Page %]
9 .ds CF
10 .ds LH Internet Draft
11 .ds RH XXX
12 .ds CH
13 .na
14 .hy 0
15 .in 0
16 .nf
17 Network Working Group                                        P. Riikonen
18 Internet-Draft
19 draft-riikonen-silc-pp-08.txt                            XXX
20 Expires: XXX
21
22 .in 3
23
24 .ce 2
25 SILC Packet Protocol
26 <draft-riikonen-silc-pp-09.txt>
27
28 .ti 0
29 Status of this Memo
30
31 This document is an Internet-Draft and is in full conformance with
32 all provisions of Section 10 of RFC 2026.  Internet-Drafts are
33 working documents of the Internet Engineering Task Force (IETF), its
34 areas, and its working groups.  Note that other groups may also
35 distribute working documents as Internet-Drafts.
36
37 Internet-Drafts are draft documents valid for a maximum of six months
38 and may be updated, replaced, or obsoleted by other documents at any
39 time.  It is inappropriate to use Internet-Drafts as reference
40 material or to cite them other than as "work in progress."
41
42 The list of current Internet-Drafts can be accessed at
43 http://www.ietf.org/ietf/1id-abstracts.txt
44
45 The list of Internet-Draft Shadow Directories can be accessed at
46 http://www.ietf.org/shadow.html
47
48 The distribution of this memo is unlimited.
49
50
51 .ti 0
52 Abstract
53
54 This memo describes a Packet Protocol used in the Secure Internet Live
55 Conferencing (SILC) protocol, specified in the Secure Internet Live
56 Conferencing, Protocol Specification [SILC1].  This protocol describes
57 the packet types and packet payloads which defines the contents of the
58 packets.  The protocol provides secure binary packet protocol that
59 assures that the contents of the packets are secured and authenticated.
60
61
62
63
64
65
66
67
68
69 .ti 0
70 Table of Contents
71
72 .nf
73 1 Introduction ..................................................  3
74   1.1 Requirements Terminology ..................................  4
75 2 SILC Packet Protocol ..........................................  4
76   2.1 SILC Packet ...............................................  4
77   2.2 SILC Packet Header ........................................  5
78   2.3 SILC Packet Types .........................................  7
79       2.3.1 SILC Packet Payloads ................................ 15
80       2.3.2 Generic payloads .................................... 15
81             2.3.2.1 ID Payload .................................. 15
82             2.3.2.2 Argument Payload ............................ 16
83             2.3.2.3 Argument List Payload ....................... 17
84             2.3.2.4 Channel Payload ............................. 18
85             2.3.2.5 Public Key Payload .......................... 19
86             2.3.2.6 Message Payload ............................. 19
87       2.3.3 Disconnect Payload .................................. 23
88       2.3.4 Success Payload ..................................... 23
89       2.3.5 Failure Payload ..................................... 24
90       2.3.6 Reject Payload ...................................... 25
91       2.3.7 Notify Payload ...................................... 25
92       2.3.8 Error Payload ....................................... 34
93       2.3.9 Channel Message Payload ............................. 35
94       2.3.10 Channel Key Payload ................................ 35
95       2.3.11 Private Message Payload ............................ 37
96       2.3.12 Private Message Key Payload ........................ 37
97       2.3.13 Command Payload .................................... 39
98       2.3.14 Command Reply Payload .............................. 40
99       2.3.15 Connection Auth Request Payload .................... 40
100       2.3.16 New ID Payload ..................................... 42
101       2.3.17 New Client Payload ................................. 42
102       2.3.18 New Server Payload ................................. 43
103       2.3.19 New Channel Payload ................................ 44
104       2.3.20 Key Agreement Payload .............................. 45
105       2.3.21 Resume Router Payload .............................. 46
106       2.3.22 File Transfer Payload .............................. 47
107       2.3.23 Resume Client Payload .............................. 48
108   2.4 SILC ID Types ............................................. 49
109   2.5 Packet Encryption And Decryption .......................... 49
110       2.5.1 Normal Packet Encryption And Decryption ............. 50
111       2.5.2 Channel Message Encryption And Decryption ........... 50
112       2.5.3 Private Message Encryption And Decryption ........... 51
113   2.6 Packet MAC Generation ..................................... 52
114   2.7 Packet Padding Generation ................................. 53
115   2.8 Packet Compression ........................................ 53
116   2.9 Packet Sending ............................................ 54
117   2.10 Packet Reception ......................................... 54
118   2.11 Packet Routing ........................................... 54
119   2.12 Packet Broadcasting ...................................... 56
120 3 Security Considerations ....................................... 56
121 4 References .................................................... 56
122 5 Author's Address .............................................. 58
123 6 Full Copyright Statement ...................................... 58
124
125 .ti 0
126 List of Figures
127
128 .nf
129 Figure 1:   Typical SILC Packet
130 Figure 2:   SILC Packet Header
131 Figure 3:   ID Payload
132 Figure 4:   Argument Payload
133 Figure 5:   Argument List Payload
134 Figure 6:   Channel Payload
135 Figure 7:   Public Key Payload
136 Figure 8:   Message Payload
137 Figure 9:   Disconnect Payload
138 Figure 10:  Success Payload
139 Figure 11:  Failure Payload
140 Figure 12:  Reject Payload
141 Figure 13:  Notify Payload
142 Figure 14:  Error Payload
143 Figure 15:  Channel Key Payload
144 Figure 16:  Private Message Key Payload
145 Figure 17:  Command Payload
146 Figure 18:  Connection Auth Request Payload
147 Figure 19:  New Client Payload
148 Figure 20:  New Server Payload
149 Figure 21:  Key Agreement Payload
150 Figure 22:  Resume Router Payload
151 Figure 23:  File Transfer Payload
152 Figure 24:  Resume Client Payload
153
154
155 .ti 0
156 1. Introduction
157
158 This document describes a Packet Protocol used in the Secure Internet
159 Live Conferencing (SILC) protocol specified in the Secure Internet Live
160 Conferencing, Protocol Specification [SILC1].  This protocol describes
161 the packet types and packet payloads which defines the contents of the
162 packets.  The protocol provides secure binary packet protocol that
163 assures that the contents of the packets are secured and authenticated.
164 The packet protocol is designed to be compact to avoid unnecessary
165 overhead as much as possible.  This makes the SILC suitable also in
166 environment of low bandwidth requirements such as mobile networks.  All
167 packet payloads can also be compressed to further reduce the size of
168 the packets.
169
170 All packets in SILC network are always encrypted and their integrity
171 is assured by computed MACs.  The protocol defines several packet types
172 and packet payloads.  Each packet type usually has a specific packet
173 payload that actually defines the contents of the packet.  Each packet
174 also includes a default SILC Packet Header that provides sufficient
175 information about the origin and the destination of the packet.
176
177
178 .ti 0
179 1.1 Requirements Terminology
180
181 The keywords MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED,
182 MAY, and OPTIONAL, when they appear in this document, are to be
183 interpreted as described in [RFC2119].
184
185
186 .ti 0
187 2 SILC Packet Protocol
188
189 .ti 0
190 2.1 SILC Packet
191
192 SILC packets deliver messages from sender to receiver securely by
193 encrypting important fields of the packet.  The packet consists of
194 default SILC Packet Header, Padding, Packet Payload data, and, packet
195 MAC.
196
197 The following diagram illustrates typical SILC packet.
198
199 .in 5
200 .nf
201  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
202 |   n bytes   | 1 - n bytes |      n bytes       |  n bytes
203 | SILC Header |   Padding   |    Data Payload    |    MAC
204  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
205 .in 3
206
207 .ce
208 Figure 1:  Typical SILC Packet
209
210
211 SILC Header is always the first part of the packet and its purpose
212 is to provide information about the packet.  It provides for example
213 the packet type, origin of the packet and the destination of the packet.
214 The header is variable in length.  See the following section for
215 description of SILC Packet header.  Packets without SILC header or
216 with malformed SILC header MUST be dropped.
217
218 Padding follows the packet header.  The purpose of the padding is to
219 make the packet multiple by eight (8) or by the block size of the
220 cipher used in the encryption, which ever is larger.  The maximum
221 length of padding is currently 128 bytes.  The padding is always
222 encrypted.  The padding is applied always, even if the packet is
223 not encrypted.  See the section 2.7 Padding Generation for more
224 detailed information.
225
226 Data payload area follows padding and it is the actual data of the
227 packet.  The packet data is the packet payloads defined in this
228 protocol.  The data payload area is always encrypted.
229
230 The last part of SILC packet is the packet MAC that assures the
231 integrity of the packet.  See the section 2.6 Packet MAC Generation
232 for more information.  If compression is used the compression is
233 always applied before encryption.
234
235 All fields in all packet payloads are always in MSB (most significant
236 byte first) order.
237
238
239 .ti 0
240 2.2 SILC Packet Header
241
242 The SILC packet header is applied to all SILC packets and it is
243 variable in length.  The purpose of SILC Packet header is to provide
244 detailed information about the packet.  The receiver of the packet
245 uses the packet header to parse the packet and gain other relevant
246 parameters of the packet.
247
248 The following diagram represents the SILC packet header.
249
250 .in 5
251 .nf
252                      1                   2                   3
253  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
254 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
255 |         Payload Length        |     Flags     |  Packet Type  |
256 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257 |   Pad Length  |    RESERVED   | Source ID Len |  Dest ID Len  |
258 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259 |  Src ID Type  |                                               |
260 +-+-+-+-+-+-+-+-+                                               +
261 |                                                               |
262 ~                           Source ID                           ~
263 |                                                               |
264 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
265 |  Dst ID Type  |                                               |
266 +-+-+-+-+-+-+-+-+                                               +
267 |                                                               |
268 ~                         Destination ID                        ~
269 |                                                               |
270 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
271 .in 3
272
273 .ce
274 Figure 2:  SILC Packet Header
275
276 .in 6
277 o Payload Length (2 bytes) - Indicates the length of the
278   packet not including the padding of the packet.
279
280 o Flags (1 byte) - Indicates flags to be used in packet
281   processing.  Several flags may be set by ORing the flags
282   together.
283
284   The following flags are reserved for this field:
285
286
287      No flags                  0x00
288
289        In this case the field is ignored.
290
291
292      Private Message Key       0x01
293
294        Indicates that the packet data MUST include private
295        message that is encrypted using private key set by
296        client.  Servers does not know this key and cannot
297        handle the packet, but passes it along.  See section
298        2.5.3 Private Message Encryption And Decryption for
299        more information.
300
301
302      List                      0x02
303
304        Indicates that the packet consists of list of
305        packet payloads indicated by the Packet Type field.
306        The payloads are added one after the other.  Note that
307        there are packet types that must not be used as
308        list.  Parsing of list packet is done by calculating
309        the length of each payload and parsing them one by
310        one.
311
312
313      Broadcast                 0x04
314
315        Marks the packet to be broadcasted.  Client and normal
316        server cannot send broadcast packets.  Only router server
317        may send broadcast packet.  The router receiving of packet
318        with this flag set MUST send (broadcast) the packet to
319        its primary route.  If router has several router connections
320        the packet may be sent only to the primary route.  See
321        section 2.12 Packet Broadcasting for description of
322        packet broadcasting.
323
324
325      Compressed                0x08
326
327        Marks that the payload of the packet is compressed.
328        The sender of the packet marks this flag when it
329        compresses the payload, and any server or router
330        en route to the recipient MUST NOT unset this flag.
331        See section 2.8 Packet Compression for description of
332        packet compressing.
333
334 .in 3
335
336 o Packet Type (1 byte) - Indicates the type of the packet.
337   Receiver uses this field to parse the packet.  See section
338   2.3 SILC Packets for list of defined packet types.
339
340 o Pad Length (1 byte) - Indicates the length of the padding
341   applied after the SILC Packet header.  Maximum length for
342   padding is 128 bytes.
343
344 o RESERVED (1 byte) - Reserved field and must include a
345   zero (0) value.
346
347 o Source ID Length (1 byte) - Indicates the length of the
348   Source ID field in the header, not including this or any
349   other fields.
350
351 o Destination ID Length (1 byte) - Indicates the length of the
352   Destination ID field in the header, not including this or
353   any other fields.
354
355 o Src ID Type (1 byte) - Indicates the type of ID in the
356   Source ID field.  See section 2.4 SILC ID Types for
357   defined ID types.
358
359 o Source ID (variable length) - The actual source ID that
360   indicates which is the original sender of the packet.
361
362 o Dst ID Type (1 byte) - Indicates the type of ID in the
363   Destination ID field.  See section 2.4 SILC ID Types for
364   defined ID types.
365
366 o Destination ID (variable length) - The actual destination
367   ID that indicates which is the end receiver of the packet.
368
369
370
371 .ti 0
372 2.3 SILC Packet Types
373
374 SILC packet types defines the contents of the packet and it is used by
375 the receiver to parse the packet.  The packet type is 8 bits in length.
376 The range for the packet types are from 0 - 255, where 0 is never sent and
377 255 is currently reserved for future extensions and MUST NOT be defined to
378 any other purpose.  Every SILC specification compliant implementation
379 SHOULD support all the following packet types.
380
381 The below list of the SILC Packet types includes reference to the packet
382 payload as well.  Packet payloads are the actual packet data area.  Each
383 packet type defines packet payload which usually may only be sent with
384 the specific packet type.
385
386 Most of the packets are packets that must be destined directly to entity
387 that is connected to the sender.  It is not allowed, for example, for a
388 router to send SILC_PACKET_DISCONNECT packet to client that is not
389 directly connected to the router.  However, there are some special packet
390 types that may be destined to some entity that the sender does not have
391 direct connection with.  These packets are for example private message
392 packets, channel message packets, command packets and some other packets
393 that may be broadcasted in the SILC network.  The following packet
394 desription list will define it separately if a packet is allowed to be
395 sent to indirectly connected entity.  Other packets MUST NOT be sent or
396 accepted, if sent, to indirectly connected entities.
397
398 Some packets MAY be sent as lists by adding the List flag to the Packet
399 Header and constructing multiple packet payloads one after the other.
400 When this is allowed it is separately defined in the following list.
401 Other packets MUST NOT be sent as list and the List flag MUST NOT be set.
402
403
404 List of SILC Packet types are defined as follows.
405
406 .in 1
407      0    SILC_PACKET_NONE
408
409           This type is reserved and it is never sent.
410
411
412      1    SILC_PACKET_DISCONNECT
413
414           This packet is sent to disconnect the remote end.  Reason of
415           the disconnection is sent inside the packet payload.
416
417           Payload of the packet:  See section 2.3.3 Disconnect Payload
418
419
420      2    SILC_PACKET_SUCCESS
421
422           This packet is sent upon successful execution of a protocol.
423           The status of the success is sent in the packet payload.
424
425           Payload of the packet:  See section 2.3.4 Success Payload
426
427
428      3    SILC_PACKET_FAILURE
429
430           This packet is sent upon failure of a protocol.  The status
431           of the failure is sent in the packet payload.
432
433           Payload of the packet:  See section 2.3.5 Failure Payload
434
435
436      4    SILC_PACKET_REJECT
437
438           This packet MAY be sent upon rejection of a protocol.  The
439           status of the rejection is sent in the packet payload.
440
441           Payload of the packet:  See section 2.3.6 Reject Payload
442
443
444      5    SILC_PACKET_NOTIFY
445
446           This packet is used to send notify message.  The packet is
447           usually sent between server and client, but also between
448           server and router.  Client MUST NOT send this packet.  Server
449           MAY destine this packet to channel as well when the packet is
450           distributed to all clients on the channel.  This packet MAY
451           be sent as list.
452
453           Payload of the packet:  See section 2.3.7 Notify Payload.
454
455
456      6    SILC_PACKET_ERROR
457
458           This packet is sent when an error occurs.  Server MAY
459           send this packet.  Client MUST NOT send this packet.  The
460           client MAY entirely ignore the packet, however, server is
461           most likely to take action anyway.  This packet MAY be sent
462           to entity that is indirectly connected to the sender.
463
464           Payload of the packet:  See section 2.3.8 Error Payload.
465
466
467      7    SILC_PACKET_CHANNEL_MESSAGE
468
469           This packet is used to send messages to channels.  The packet
470           includes Channel ID of the channel and the actual message to
471           the channel.  Messages sent to the channel are always protected
472           by channel specific keys.  This packet MAY be sent to entity
473           that is indirectly connected to the sender.
474
475           Payload of the packet:  See section 2.3.9 Channel Message
476                                   Payload
477
478
479      8    SILC_PACKET_CHANNEL_KEY
480
481           This packet is used to distribute new key for particular
482           channel when server generates it.  Each channel has their own
483           independent keys that is used to protect the traffic on the
484           channel.  It is also possible to use channel private keys that
485           are not server generated.  In this case this packet is not used.
486           Client MUST NOT send this packet.  This packet MAY be sent to
487           entity that is indirectly connected to the sender.
488
489           Payload of the packet:  See section 2.3.10 Channel Key Payload
490
491
492      9    SILC_PACKET_PRIVATE_MESSAGE
493
494           This packet is used to send private messages from client
495           to another client.  By default, private messages are protected
496           by session keys established by normal key exchange protocol.
497           However, it is possible to use specific key to protect private
498           messages.  See [SILC1] for private message key generation.
499           This packet MAY be sent to entity that is indirectly connected
500           to the sender.
501
502           Payload of the packet:  See section 2.3.11 Private Message
503                                   Payload
504
505
506      10   SILC_PACKET_PRIVATE_MESSAGE_KEY
507
508           This packet is OPTIONAL and sender of the packet can indicate
509           that a private message key should be used in private message
510           communication.  The actual key material is not sent in this
511           packet but must be either static or pre-shared key.  The
512           receiver of the packet is considered to be the responder
513           when processing the static or pre-shared key material as
514           defined in [SILC1] and [SILC3] for private message keys.
515           This packet MAY be sent to entity that is indirectly connected
516           to the sender.
517
518           Payload of the packet:  See section 2.3.12 Private Message
519                                   Key Payload
520
521
522      11   SILC_PACKET_COMMAND
523
524           This packet is used to send commands from client to server.
525           Server MAY send this packet to other servers as well.  All
526           commands are listed in their own section SILC Command Types
527           in [SILC4].  The contents of this packet is command specific.
528           This packet MAY be sent to entity that is indirectly connected
529           to the sender.
530
531           Payload of the packet:  See section 2.3.13 Command Payload
532
533
534      12   SILC_PACKET_COMMAND_REPLY
535
536           This packet is sent as reply to the SILC_PACKET_COMMAND packet.
537           The contents of this packet is command specific.  This packet
538           MAY be sent to entity that is indirectly connected to the
539           sender.  This packet MAY be sent as list.
540
541           Payload of the packet:  See section 2.3.14 Command Reply
542                                   Payload and section 2.3.13 Command
543                                   Payload
544
545
546      13   SILC_PACKET_KEY_EXCHANGE
547
548           This packet is used to start SILC Key Exchange Protocol,
549           described in detail in [SILC3].
550
551           Payload of the packet:  Payload of this packet is described
552                                   in the section SILC Key Exchange
553                                   Protocol and its sub sections in
554                                   [SILC3].
555
556
557      14   SILC_PACKET_KEY_EXCHANGE_1
558
559           This packet is used as part of the SILC Key Exchange Protocol.
560
561           Payload of the packet:  Payload of this packet is described
562                                   in the section SILC Key Exchange
563                                   Protocol and its sub sections in
564                                   [SILC3].
565
566
567      15   SILC_PACKET_KEY_EXCHANGE_2
568
569           This packet is used as part of the SILC Key Exchange Protocol.
570
571           Payload of the packet:  Payload of this packet is described
572                                   in the section SILC Key Exchange
573                                   Protocol and its sub sections in
574                                   [SILC3].
575
576
577      16   SILC_PACKET_CONNECTION_AUTH_REQUEST
578
579           This packet is used to request an authentication method to
580           be used in the SILC Connection Authentication Protocol.  If
581           initiator of the protocol does not know the mandatory
582           authentication method this packet MAY be used to determine it.
583           The party receiving this payload SHOULD respond with the same
584           packet including the mandatory authentication method.
585
586           Payload of the packet:  See section 2.3.15 Connection Auth
587                                   Request Payload
588
589
590      17   SILC_PACKET_CONNECTION_AUTH
591
592           This packet is used to start and perform the SILC Connection
593           Authentication Protocol.  This protocol is used to authenticate
594           the connecting party.  The protocol is described in detail in
595           [SILC3].
596
597           Payload of the packet:  Payload of this packet is described
598                                   in the section SILC Authentication
599                                   Protocol and it sub sections in [SILC].
600
601
602      18   SILC_PACKET_NEW_ID
603
604           This packet is used to distribute new IDs from server to
605           router and from router to all other routers in SILC network.
606           This is used when for example new client is registered to
607           SILC network.  The newly created IDs of these operations are
608           distributed by this packet.  Only server may send this packet,
609           however, client MUST be able to receive this packet.  This
610           packet MAY be sent to entity that is indirectly connected
611           to the sender.  This packet MAY be sent as list.
612
613           Payload of the packet:  See section 2.3.16 New ID Payload
614
615
616      19   SILC_PACKET_NEW_CLIENT
617
618           This packet is used by client to register itself to the
619           SILC network.  This is sent after key exchange and
620           authentication protocols has been completed.  Client sends
621           various information about itself in this packet to the server.
622
623           Payload of the packet:  See section 2.3.17 New Client Payload
624
625
626      20   SILC_PACKET_NEW_SERVER
627
628           This packet is used by server to register itself to the
629           SILC network.  This is sent after key exchange and
630           authentication protocols has been completed.  Server sends
631           this to the router it connected to, or, if router was
632           connecting, to the connected router.  Server sends its
633           Server ID and other information in this packet.  The client
634           MUST NOT send or receive this packet.
635
636           Payload of the packet:  See section 2.3.18 New Server Payload
637
638
639      21   SILC_PACKET_NEW_CHANNEL
640
641           This packet is used to notify routers about newly created
642           channel.  Channels are always created by the router and it MUST
643           notify other routers about the created channel.  Router sends
644           this packet to its primary route.  Client MUST NOT send this
645           packet.  This packet MAY be sent to entity that is indirectly
646           connected to the sender.  This packet MAY be sent as list.
647
648           Payload of the packet:  See section 2.3.19 New Channel Payload
649
650
651      22   SILC_PACKET_REKEY
652
653           This packet is used to indicate that re-key must be performed
654           for session keys.  See section Session Key Regeneration in
655           [SILC1] for more information.  This packet does not have
656           a payload.
657
658
659      23   SILC_PACKET_REKEY_DONE
660
661           This packet is used to indicate that re-key is performed and
662           new keys must be used hereafter.  This packet does not have a
663           payload.
664
665
666      24   SILC_PACKET_HEARTBEAT
667
668           This packet is used by clients, servers and routers to keep the
669           connection alive.  It is RECOMMENDED that all servers implement
670           keepalive actions and perform it to both direction in a link.
671           This packet does not have a payload.
672
673
674      25   SILC_PACKET_KEY_AGREEMENT
675
676           This packet is used by clients to request key negotiation
677           between another client in the SILC network.  If the negotiation
678           is started it is performed using the SKE protocol.  The result of
679           the negotiation, the secret key material, can be used for
680           example as private message key.  The server and router MUST NOT
681           send this packet.
682
683           Payload of the packet:  See section 2.3.20 Key Agreement Payload
684
685
686      26   SILC_PACKET_RESUME_ROUTER
687
688           This packet is used during backup router protocol when the
689           original primary router of the cell comes back online and wishes
690           to resume the position as being the primary router of the cell.
691
692           Payload of the packet:  See section 2.3.21 Resume Router Payload
693
694
695      27   SILC_PACKET_FTP
696
697           This packet is used to perform an file transfer protocol in the
698           SILC session with some entity in the network.  The packet is
699           multi purpose.  The packet is used to tell other entity in the
700           network that the sender wishes to perform an file transfer
701           protocol.  The packet is also used to actually tunnel the
702           file transfer protocol stream.  The file transfer protocol
703           stream is always protected with the SILC binary packet protocol.
704
705           Payload of the packet:  See section 2.3.22 File Transfer Payload
706
707
708      28   SILC_PACKET_RESUME_CLIENT
709
710           This packet is used to resume a client back to the network
711           after it has been detached.  A client is able to detach from
712           the network but the client is still valid client in the network.
713           The client may then later resume its session back by sending
714           this packet to a server.  Routers also use this packet to notify
715           other routers in the network that the detached client has resumed.
716
717           Payload of the packet:  See section 2.3.23 Resume Client Payload
718
719
720      29 - 199
721
722           Currently undefined commands.
723
724
725      200 - 254
726
727           These packet types are reserved for private use and they will
728           not be defined by this document.
729
730
731      255  SILC_PACKET_MAX
732
733           This type is reserved for future extensions and currently it
734           MUST NOT be sent.
735 .in 3
736
737
738 .ti 0
739 2.3.1 SILC Packet Payloads
740
741 All payloads resides in the main data area of the SILC packet.  However
742 all payloads MUST be at the start of the data area after the SILC
743 packet header and padding.  All fields in the packet payload are always
744 encrypted, as they reside in the data area of the packet which is
745 always encrypted.  Most of the payloads may only be sent with specific
746 packet type which is defined in the description of the payload.
747
748 There are some other payloads in SILC as well.  However, they are not
749 common in the sense that they could be sent at any time.  These payloads
750 are not described in this section.  These are payloads such as SILC
751 Key Exchange payloads and so on.  These are described in [SILC1],
752 [SILC3] and [SILC4].
753
754
755 .ti 0
756 2.3.2 Generic payloads
757
758 This section describes generic payloads that are not associated to any
759 specific packet type.  They can be used for example inside some other
760 packet payload.
761
762
763 .ti 0
764 2.3.2.1 ID Payload
765
766 This payload can be used to send an ID.  ID's are variable in length
767 thus this payload provides a way to send variable length ID.
768
769 The following diagram represents the ID Payload.
770
771 .in 5
772 .nf
773                      1                   2                   3
774  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
775 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
776 |             ID Type           |           ID Length           |
777 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
778 |                                                               |
779 ~                           ID Data                             ~
780 |                                                               |
781 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
782 .in 3
783
784 .ce
785 Figure 3:  ID Payload
786
787
788 .in 6
789 o ID Type (2 bytes) - Indicates the type of the ID.  See
790   section 2.4 SILC ID Types for list of defined ID types.
791
792 o ID Length (2 bytes) - Length of the ID Data area not
793   including the length of any other fields in the payload.
794
795 o ID Data (variable length) - The actual ID data.  The encoding
796   of the ID data is defined in section 2.4 SILC ID Types.
797 .in 3
798
799
800 .ti 0
801 2.3.2.2 Argument Payload
802
803 Argument Payload is used to set arguments for any packet payload that
804 need and support arguments, such as commands.  Number of arguments
805 associated with a packet MUST be indicated by the packet payload which
806 need the arguments.  Argument Payloads MUST always reside right after
807 the packet payload needing the arguments.  Incorrect amount of argument
808 payloads MUST cause rejection of the packet.
809
810 The following diagram represents the Argument Payload.
811
812 .in 5
813 .nf
814                      1                   2                   3
815  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
816 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
817 |          Data Length          | Argument Type |               |
818 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
819 |                                                               |
820 ~                        Argument Data                          ~
821 |                                                               |
822 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
823 .in 3
824
825 .ce
826 Figure 4:  Argument Payload
827
828
829 .in 6
830 o Data Length (2 bytes) - Length of the Argument Data field
831   not including the length of any other field in the payload.
832
833 o Argument Type (1 byte) - Indicates the type of the argument.
834   Every argument can have a specific type that are defined
835   by the packet payload needing the argument.  For example
836   every command specify a number for each argument that may be
837   associated with the command.  By using this number the receiver
838   of the packet knows what type of argument this is.  If there is
839   no specific argument type this field is set to zero (0) value.
840
841 o Argument Data (variable length) - Argument data.
842 .in 3
843
844
845 .ti 0
846 2.3.2.3 Argument List Payload
847
848 Argument List Payload is a list of Argument Payloads appended one
849 after the other.  The number of arguments is indicated in the
850 payload.
851
852 The following diagram represents the Argument List Payload.
853
854 .in 5
855 .nf
856                      1                   2                   3
857  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
858 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
859 |         Argument Nums         |                               |
860 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
861 |                                                               |
862 ~                        Argument Payloads                      ~
863 |                                                               |
864 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
865 .in 3
866
867 .ce
868 Figure 5:  Argument List Payload
869
870
871 .in 6
872 o Argument Nums (2 bytes) - Indicates the number of Argument
873   Payloads.  If zero (0) value is found in this field no
874   arguments are present.
875
876 o Argument Payloads (variable length) - The Argument Payloads
877   appended one after the other.  The payloads can be decoded
878   since the length of the payload is indicated in each of
879   the Argument Payload.
880 .in 3
881
882
883
884
885
886 .ti 0
887 2.3.2.4 Channel Payload
888
889 Generic Channel Payload may be used to send information about a channel,
890 its name, the Channel ID and a mode.
891
892 The following diagram represents the Channel Payload.
893
894
895 .in 5
896 .nf
897                      1                   2                   3
898  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
899 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
900 |      Channel Name Length      |                               |
901 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
902 |                                                               |
903 ~                         Channel Name                          ~
904 |                                                               |
905 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
906 |       Channel ID Length       |                               |
907 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
908 |                                                               |
909 ~                          Channel ID                           ~
910 |                                                               |
911 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
912 |                           Mode Mask                           |
913 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
914 .in 3
915
916 .ce
917 Figure 6:  New Channel Payload
918
919
920 .in 6
921 o Channel Name Length (2 bytes) - Length of the Channel Name
922   field.
923
924 o Channel Name (variable length) - The name of the channel.
925
926 o Channel ID Length (2 bytes) - Length of the Channel ID field.
927
928 o Channel ID (variable length) - The encoded Channel ID.
929
930 o Mode Mask (4 bytes) - A mode.  This can be the mode of the
931   channel but it can also be the mode of a client on the
932   channel.  The contents of this field is dependent of the
933   usage of this payload.  The usage is defined separately
934   when this payload is used.  This is a 32 bit MSB first value.
935 .in 3
936
937
938
939
940
941
942 .ti 0
943 2.3.2.5 Public Key Payload
944
945 Generic Public Key Payload may be used to send different type of
946 public keys and certificates.
947
948 The following diagram represents the Public Key Payload.
949
950 .in 5
951 .nf
952                      1                   2                   3
953  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
954 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
955 |       Public Key Length       |        Public Key Type        |
956 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
957 |                                                               |
958 ~                  Public Key (or certificate)                  ~
959 |                                                               |
960 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
961 .in 3
962
963 .ce
964 Figure 7:  Public Key Payload
965
966
967 .in 6
968 o Public Key Length (2 bytes) - The length of the Public Key
969   (or certificate) field, not including any other field.
970
971 o Public Key Type (2 bytes) - The public key (or certificate)
972   type.  This field indicates the type of the public key in
973   the packet.  See the [SILC3] for defined public key types.
974
975 o Public Key (or certificate) (variable length) - The
976   encoded public key or certificate data.
977 .in 3
978
979
980 .ti 0
981 2.3.2.6 Message Payload
982
983 Generic Message Payload can be used to send messages in SILC.  It
984 is used to send channel messages and private messages.
985
986 The following diagram represents the Message Payload.
987
988 (*) indicates that the field is not encrypted.
989
990
991
992
993
994
995
996
997
998 .in 5
999 .nf
1000                      1                   2                   3
1001  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1002 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1003 |        Message  Flags         |         Message Length        |
1004 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1005 |                                                               |
1006 ~                         Message Data                          ~
1007 |                                                               |
1008 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1009 |        Padding Length         |                               |
1010 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1011 |                                                               |
1012 ~                            Padding                            ~
1013 |                                                               |
1014 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1015 |                                                               |
1016 ~                    Initialization Vector *                    ~
1017 |                                                               |
1018 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1019 |                                                               |
1020 ~                              MAC *                            ~
1021 |                                                               |
1022 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1023 .in 3
1024
1025 .ce
1026 Figure 8:  Message Payload
1027
1028
1029 .in 6
1030 o Message Flags (2 bytes) - Includes the Message Flags of the
1031   message.  The flags can indicate a reason or a purpose for
1032   the message.  The following Message Flags are defined:
1033
1034   0x0000  SILC_MESSAGE_FLAG_NONE
1035
1036           No specific flags set.
1037
1038   0x0001  SILC_MESSAGE_FLAG_AUTOREPLY
1039
1040           This message is an automatic reply to an earlier
1041           received message.
1042
1043   0x0002  SILC_MESSAGE_FLAG_NOREPLY
1044
1045           There should not be reply messages to this
1046           message.
1047
1048   0x0004  SILC_MESSAGE_FLAG_ACTION
1049
1050           The sender is performing an action and the message
1051           is the indication of the action.
1052
1053   0x0008  SILC_MESSAGE_FLAG_NOTICE
1054
1055           The message is for example an informational notice
1056           type message.
1057
1058   0x0010  SILC_MESSAGE_FLAG_REQUEST
1059
1060           This is a generic request flag to send request
1061           messages.  A separate document should define any
1062           payloads associated to this flag.
1063
1064   0x0020  SILC_MESSAGE_FLAG_SIGNED
1065
1066           This flag indicates that the message is signed
1067           with sender's private key and thus can be verified
1068           by the receiver using the sender's public key.  A
1069           separate document should define the detailed procedure
1070           of the signing process and any associated payloads
1071           for this flag.
1072
1073   0x0040  SILC_MESSAGE_FLAG_REPLY
1074
1075           This is a generic reply flag to send a reply to
1076           previously received request.  A separate document
1077           should define any payloads associated to this flag.
1078
1079   0x0080  SILC_MESSAGE_FLAG_DATA
1080
1081           This is a generic data flag, indicating that the
1082           message includes some data which can be interpreted
1083           in a specific way.  Using this flag any kind of data
1084           can be delivered inside message payload.  A separate
1085           document should define how this flag is interpreted
1086           and define any associated payloads.
1087
1088   0x0100  SILC_MESSAGE_FLAG_UTF8
1089
1090           This flag indicates that the message is UTF-8 encoded
1091           textual message.  When sending text messages in SILC
1092           this flag SHOULD be used.  When this flag is used the
1093           text sent as message MUST be UTF-8 encoded.
1094
1095   0x0200  SILC_MESSAGE_FLAG_ACK
1096
1097           This flag indicates the sender requires the recpipient
1098           to acknowledge the received message.  This same flag
1099           is used in the acknowledgement.  A separate document
1100           should define how the acknowledgement is performed.
1101
1102   0x0400 - 0x1000 RESERVED
1103
1104           Reserved for future flags.
1105
1106   0x2000 - 0x8000 PRIVATE RANGE
1107
1108           Private range for free use.
1109
1110 o Message Length (2 bytes) - Indicates the length of the
1111   Message Data field in the payload, not including any
1112   other field.
1113
1114 o Message Data (variable length) - The actual message data.
1115
1116 o Padding Length (2 bytes) - Indicates the length of the
1117   Padding field in the payload, not including any other
1118   field.
1119
1120 o Padding (variable length) - If this payload is used as
1121   channel messages, the padding MUST be applied because
1122   this payload is encrypted separately from other parts
1123   of the packet.  If this payload is used as private
1124   messages, the padding is present only when the payload
1125   is encrypted with private message key.  If encrypted
1126   with session keys this field MUST NOT be present and the
1127   Padding Length field includes a zero (0) value.  The
1128   padding SHOULD be random data.
1129
1130 o Initialization Vector (variable length) - This field MUST
1131   be present when this payload is used as channel messages.
1132   The IV SHOULD be random data for each channel message.
1133
1134   When encrypting private messages with session keys this
1135   field MUST NOT be present.  For private messages this
1136   field is present only when encrypting with a static
1137   private message key (pre-shared key).  If randomly
1138   generated key material is used this field MUST NOT be
1139   present.  Also, If Key Agreement (SKE) was used to
1140   negotiate fresh key material for private message key
1141   this field MUST NOT be present.  See the section 4.6
1142   in [SILC1] for more information about IVs when
1143   encrypting private messages.
1144
1145   This field includes the initialization vector used in message
1146   encryption.  It need to be used in the packet decryption
1147   as well.  Contents of this field depends on the encryption
1148   algorithm and encryption mode.  This field is not encrypted,
1149   is not included in padding calculation and its length
1150   equals to cipher's block size.  This field is authenticated
1151   by the message MAC.
1152
1153 o MAC (variable length) - The MAC computed from the
1154   Message Flags, Message Length, Message Data, Padding Length,
1155   Padding and Initialization Vector fields in that order.
1156   The MAC is computed after the payload is encrypted.  This
1157   is so called Encrypt-Then-MAC order; first encrypt, then
1158   compute MAC from ciphertext.  The MAC protects the integrity
1159   of the Message Payload.  Also, when used as channel messages
1160   it is possible to have multiple private channel keys set,
1161   and receiver can use the MAC to verify which of the keys
1162   must be used in decryption.  This field is not present
1163   when encrypting private messages with session key.  This
1164   field is not encrypted. This field is authenticated by
1165   the SILC packet MAC.
1166 .in 3
1167
1168
1169 .ti 0
1170 2.3.3 Disconnect Payload
1171
1172 Disconnect payload is sent upon disconnection.  Reason of the
1173 disconnection is sent to the disconnected party in the payload.
1174
1175 The payload may only be sent with SILC_PACKET_DISCONNECT packet.  It
1176 MUST NOT be sent in any other packet type.  The following diagram
1177 represents the Disconnect Payload.
1178
1179
1180 .in 5
1181 .nf
1182                      1                   2                   3
1183  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1184 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1185 |    Status     |                                               |
1186 +-+-+-+-+-+-+-+-+                                               +
1187 |                                                               |
1188 ~                      Disconnect Message                       ~
1189 |                                                               |
1190 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1191 .in 3
1192
1193 .ce
1194 Figure 9:  Disconnect Payload
1195
1196 .in 6
1197 o Status (1 byte) - Indicates the Status Type, defined in [SILC3]
1198   for the reason of disconnection.
1199
1200 o Disconnect Message (variable length) - Human readable UTF-8
1201   encoded string indicating reason of the disconnection.  This
1202   field MAY be omitted.
1203 .in 3
1204
1205
1206 .ti 0
1207 2.3.4 Success Payload
1208
1209 Success payload is sent when some protocol execution is successfully
1210 completed.  The payload is simple; indication of the success is sent.
1211 This may be any data, including binary or human readable data, and
1212 it is protocol dependent.
1213
1214 .in 5
1215 .nf
1216                      1                   2                   3
1217  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1218 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1219 |                                                               |
1220 ~                      Success Indication                       ~
1221 |                                                               |
1222 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1223 .in 3
1224
1225 .ce
1226 Figure 10:  Success Payload
1227
1228
1229 .in 6
1230 o Success Indication (variable length) - Indication of
1231   the success.  This may be for example some flag that
1232   indicates the protocol and the success status or human
1233   readable success message.  The true length of this
1234   payload is available by calculating it from the SILC
1235   Packet Header.
1236 .in 3
1237
1238
1239 .ti 0
1240 2.3.5 Failure Payload
1241
1242 This is opposite of Success Payload.  Indication of failure of
1243 some protocol is sent in the payload.
1244
1245 .in 5
1246 .nf
1247                      1                   2                   3
1248  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1249 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1250 |                                                               |
1251 ~                      Failure Indication                       ~
1252 |                                                               |
1253 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1254 .in 3
1255
1256 .ce
1257 Figure 11:  Failure Payload
1258
1259
1260 .in 6
1261 o Failure Indication (variable length) - Indication of
1262   the failure.  This may be for example some flag that
1263   indicates the protocol and the failure status or human
1264   readable failure message.  The true length of this
1265   payload is available by calculating it from the SILC
1266   Packet Header.
1267 .in 3
1268
1269
1270 .ti 0
1271 2.3.6 Reject Payload
1272
1273 This payload is sent when some protocol is rejected to be executed.
1274 Other operations MAY send this as well that was rejected.  The
1275 indication of the rejection is sent in the payload.  The indication
1276 may be binary or human readable data and is protocol dependent.
1277
1278
1279 .in 5
1280 .nf
1281                      1                   2                   3
1282  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1283 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1284 |                                                               |
1285 ~                       Reject Indication                       ~
1286 |                                                               |
1287 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1288 .in 3
1289
1290 .ce
1291 Figure 12:  Reject Payload
1292
1293
1294 .in 6
1295 o Reject Indication (variable length) - Indication of
1296   the rejection.  This maybe for example some flag that
1297   indicates the protocol and the rejection status or human
1298   readable rejection message.  The true length of this
1299   payload is available by calculating it from the SILC
1300   Packet Header.
1301 .in 3
1302
1303
1304
1305 .ti 0
1306 2.3.7 Notify Payload
1307
1308 Notify payload is used to send notify messages.  The payload is usually
1309 sent from server to client and from server to router.  It is also used
1310 by routers to notify other routers in the network.  This payload MAY also
1311 be sent to a channel.  Client MUST NOT send this payload.  When this
1312 packet is received by client it SHOULD process it.  Servers and routers
1313 MUST process notify packets.
1314
1315 The payload may only be sent with SILC_PACKET_NOTIFY packet.  It MUST
1316 NOT be sent in any other packet type.  The following diagram represents
1317 the Notify Payload.
1318
1319
1320
1321 .in 5
1322 .nf
1323                      1                   2                   3
1324  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1325 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1326 |          Notify Type          |        Payload Length         |
1327 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1328 | Argument Nums |
1329 +-+-+-+-+-+-+-+-+
1330 .in 3
1331
1332 .ce
1333 Figure 13:  Notify Payload
1334
1335
1336 .in 6
1337 o Notify Type (2 bytes) - Indicates the type of the notify
1338   message.
1339
1340 o Payload Length (2 bytes) - Length of the entire Notify Payload
1341   including any associated Argument Payloads.
1342
1343 o Argument Nums (1 byte) - Indicates the number of Argument
1344   Payloads associated to this payload.  Notify types may define
1345   arguments to be sent along the notify message.
1346 .in 3
1347
1348 Following the list of currently defined notify types.  The format for
1349 notify arguments is same as in SILC commands described in [SILC4].
1350 Note that all IDs sent in arguments are sent inside ID Payload.  Also
1351 note that all strings sent as arguments MUST be UTF-8 [RFC3629] encoded,
1352 unless otherwise defined.  Also note that all public keys or
1353 certificates sent inside arguments are actually Public Key Payloads.
1354
1355
1356 .in 6
1357 0     SILC_NOTIFY_TYPE_NONE
1358
1359       If no specific notify type apply for the notify message this type
1360       MAY be used.
1361
1362       Max Arguments:  1
1363           Arguments:  (1) <message>
1364
1365       The <message> is implementation specific free text string.
1366       Receiver MAY ignore this message.
1367
1368
1369 1     SILC_NOTIFY_TYPE_INVITE
1370
1371       Sent when an client is invited to a channel.  This is also sent
1372       when the invite list of the channel is changed.  This notify type
1373       is sent to local servers on the channel, but MUST NOT be sent
1374       to clients on the channel.  Router MUST broadcast this to its
1375       primary router and to local servers on the channel.  When a client
1376       was directly invited to the channel this is also sent to that
1377       client.  In this case the packet is destined to the client.
1378
1379       Max Arguments:  5
1380           Arguments:  (1) <Channel ID>          (2) <channel name>
1381                       (3) [<sender Client ID>]  (4) [<add | del>]
1382                       (5) [<invite list>]
1383
1384       The <Channel ID> is the channel.  The <channel name> is the name
1385       of the channel and is provided because the client which receives
1386       this notify packet may not have a way to resolve the name of the
1387       channel from the <Channel ID>.  The <sender Client ID> is the
1388       Client ID which invited the client to the channel.  The
1389       <add | del> is an argument of size of 1 byte where 0x00 means
1390       adding a client to invite list, and 0x01 means deleting a client
1391       from invite list.  The <invite list>, if present, indicates the
1392       information to be added to or removed from the invite list.
1393       The <invite list> format is defined in [SILC4] with
1394       SILC_COMMAND_INVITE command.  When this notify is destined to
1395       a client the <add | del> and <invite list> MUST NOT be sent.
1396       When <add | del> is used  to announce information during server
1397       connecting phase the argument type MUST be 0x03.  See section
1398       4.2.1 in [SILC1] for more information.
1399
1400
1401 2     SILC_NOTIFY_TYPE_JOIN
1402
1403       Sent when client has joined to a channel.  The server MUST
1404       distribute this type to the local clients on the channel and then
1405       send it to its primary router.  Note that, when router is joining
1406       the client on behalf of normal server then router MUST send this
1407       notify type locally and globally.  The router or server receiving
1408       the packet distributes this type to the local clients on the
1409       channel and broadcast it to the network.  This notify is sent
1410       also to the client that joined the channel.
1411
1412       Max Arguments:  2
1413           Arguments:  (1) [<Client ID>]       (2) <Channel ID>
1414
1415       The <Client ID> is the client that joined to the channel
1416       indicated by the <Channel ID>.
1417
1418
1419 3     SILC_NOTIFY_TYPE_LEAVE
1420
1421       Sent when client has left a channel.  The server must distribute
1422       this type to the local clients on the channel and then send it
1423       to its primary router.  The router or server receiving the
1424       packet distributes this type to the local clients on the channel
1425       and broadcast it to the network.  This notify MUST NOT be sent to
1426       the leaving client.
1427
1428       Max Arguments:  1
1429           Arguments:  (1) <Client ID>
1430
1431       The <Client ID> is the client which left the channel.
1432
1433
1434 4     SILC_NOTIFY_TYPE_SIGNOFF
1435
1436       Sent when client signoff from SILC network.  The server MUST
1437       distribute this type to the local clients on the channel and
1438       then send it to its primary router.  The router or server
1439       receiving the packet distributes this type to the local clients
1440       on the channel and broadcast it to the network.  This notify
1441       MUST NOT be sent to the quitting client.
1442
1443       Max Arguments:  2
1444           Arguments:  (1) <Client ID>  (2) <message>
1445
1446       The <Client ID> is the client which left SILC network.  The
1447       <message> is free text string indicating the reason of the
1448       signoff.
1449
1450
1451 5     SILC_NOTIFY_TYPE_TOPIC_SET
1452
1453       Sent when topic is set/changed on a channel.  This type may be
1454       sent only to the clients which are joined on the channel which
1455       topic was just set or changed.  The packet is destined to the
1456       channel.
1457
1458       Max Arguments:  2
1459           Arguments:  (1) <ID Payload>  (2) <topic>
1460
1461       The <ID Payload> is the ID of the entity who set the topic.
1462       It usually is Client ID but it can be Server ID and Channel ID
1463       as well.
1464
1465
1466 6     SILC_NOTIFY_TYPE_NICK_CHANGE
1467
1468       Sent when client changes nick on a channel.  The server MUST
1469       distribute this type only to the local clients on the channel
1470       and then send it to its primary router.  The router or server
1471       receiving the packet distributes this type to the local clients
1472       on the channel and broadcast it to the network.  This packet is
1473       destined directly to the sent entity.  This MUST be sent to those
1474       clients that are joined on same channels as the client that
1475       changed the nickname.  This notify MUST NOT be sent multiple
1476       times to the same recipient.  This notify MUST be sent also to
1477       the client that changed the nickname.
1478
1479       Max Arguments:  3
1480           Arguments:  (1) <Old Client ID>  (2) <New Client ID>
1481                       (3) <nickname>
1482
1483       The <Old Client ID> is the old ID of the client which changed
1484       the nickname.  The <New Client ID> is the new ID generated by
1485       the change of the nickname.  The <nickname> is the new nickname.
1486       Note that it is possible to send this notify even if the
1487       nickname has not changed, but client ID was changed.
1488
1489
1490 7     SILC_NOTIFY_TYPE_CMODE_CHANGE
1491
1492       Sent when channel mode has changed.  This type MUST be sent only
1493       to the clients which are joined on the channel which mode was
1494       changed.  This packet is destined to the channel.
1495
1496       Max Arguments:  8
1497           Arguments:  (1) <ID Payload>       (2) <mode mask>
1498                       (3) [<cipher>]         (4) <[hmac>]
1499                       (5) [<passphrase>]     (6) [<founder public key>]
1500                       (7) [<channel pubkey>] (8) [<user limit>]
1501
1502       The <ID Payload> is the ID (usually Client ID but it can be
1503       Server ID as well when the router is enforcing channel mode
1504       change) of the entity which changed the mode.  The <mode mask>
1505       is the new mode mask of the channel.  The client can safely
1506       ignore the <cipher> argument since the SILC_PACKET_CHANNEL_KEY
1507       packet will force the new channel key change anyway.  The <hmac>
1508       argument is important since the client is responsible of setting
1509       the new HMAC and the hmac key into use.  The <passphrase> is
1510       the passphrase of the channel, if it was now set.  The <founder
1511       public key> argument is sent when the founder mode on the
1512       channel was set.  All routers and servers that receive the packet
1513       MUST save the founder's public key so that the founder can
1514       reclaim the channel founder rights back for the channel on any
1515       server in the network.  The <user limit> argument is present when
1516       the user limit was set or changed on the channel.
1517
1518       The <channel pubkey> is an Argument List Payload and it is used
1519       to add and/or remove channel public keys from the channel.  Also,
1520       when announcing channel information between servers and routers
1521       during connecting phase this argument includes the list of channel
1522       public keys.  To add a public key to channel public key list the
1523       SILC_CMODE_CHANNEL_AUTH mode is set and the argument type is 0x00,
1524       and the argument is the public key.  To remove a public key from
1525       the channel public key list the argument type is 0x01, and the
1526       argument is the public key to be removed.  If the mode
1527       SILC_CMODE_CHANNEL_AUTH is unset (and was set earlier) all public
1528       keys are removed at once.  Implementation MAY add and remove
1529       multiple public keys at the same time by including multiple
1530       arguments to the <channel pubkey> Argument List Payload where each
1531       argument is one Public Key Payload.  When <channel pubkey> is used
1532       to announce information during server connecting phase the
1533       argument type MUST be 0x03.  See section 4.2.1 in [SILC1] for
1534       more information.
1535
1536
1537 8     SILC_NOTIFY_TYPE_CUMODE_CHANGE
1538
1539       Sent when user mode on channel has changed.  This type MUST be
1540       sent only to the clients which are joined on the channel where
1541       the target client is on.  This packet is destined to the channel.
1542
1543       Max Arguments:  4
1544           Arguments:  (1) <ID Payload>        (2) <mode mask>
1545                       (3) <Target Client ID>  (4) [<founder pubkey>]
1546
1547       The <ID Payload> is the ID (usually Client ID but it can be
1548       Server ID as well when the router is enforcing user's mode
1549       change) of the entity which changed the mode.  The <mode mask>
1550       is the new mode mask of the channel.  The <Target Client ID>
1551       is the client which mode was changed.  The <founder pubkey>
1552       is the public key of the channel founder and may be sent only
1553       when first time setting the channel founder mode using the
1554       SILC_COMMAND_CUMODE command, and when sending this notify.
1555
1556
1557 9     SILC_NOTIFY_TYPE_MOTD
1558
1559       Sent when Message of the Day (motd) is sent to a client.
1560
1561       Max Arguments:  1
1562           Arguments:  (1) <motd>
1563
1564       The <motd> is the Message of the Day.  This notify MAY be
1565       ignored and is OPTIONAL.
1566
1567
1568 10    SILC_NOTIFY_TYPE_CHANNEL_CHANGE
1569
1570       Sent when channel's ID has changed for a reason or another.
1571       This is sent by normal server to the client.  This can also be
1572       sent by router to other server to force the Channel ID change.
1573       The Channel ID MUST be changed to use the new one.  When sent
1574       to clients, this type MUST be sent only to the clients which are
1575       joined on the channel.  This packet is destined to the sent
1576       entity.
1577
1578       Max Arguments:  2
1579           Arguments:  (1) <Old Channel ID>  (2) <New Channel ID>
1580
1581       The <Old Channel ID> is the channel's old ID and the <New
1582       Channel ID> is the new one that MUST replace the old one.
1583       Server which receives this from router MUST re-announce the
1584       channel to the router by sending SILC_PACKET_NEW_CHANNEL packet
1585       with the new Channel ID.
1586
1587
1588 11    SILC_NOTIFY_TYPE_SERVER_SIGNOFF
1589
1590       Sent when server quits SILC network.  Those clients from this
1591       server that are on channels must be removed from the channel.
1592       This packet is destined to the sent entity.
1593
1594       Max Arguments:  256
1595           Arguments:  (1) <Server ID>   (n) [<Client ID>]   [...]
1596
1597       The <Server ID> is the server's ID.  The rest of the arguments
1598       are the Client IDs of the clients which are coming from this
1599       server and are thus quitting the SILC network also.  If the
1600       maximum number of arguments are reached another
1601       SILC_NOTIFY_TYPE_SERVER_SIGNOFF notify packet MUST be sent.
1602       When this notify packet is sent between routers the Client ID's
1603       MAY be omitted.  Server receiving the Client ID's in the payload
1604       may use them directly to remove the client.
1605
1606
1607 12    SILC_NOTIFY_TYPE_KICKED
1608
1609       Sent when a client has been kicked from a channel.  This MUST
1610       also be sent to the client which was kicked from the channel.
1611       The client which was kicked from the channel MUST be removed
1612       from the channel.  The client MUST also be removed from channel's
1613       invite list if it is explicitly added in the list.  This packet
1614       is destined to the channel.  The router or server receiving the
1615       packet distributes this type to the local clients on the channel
1616       and broadcast it to the network.
1617
1618       Max Arguments:  3
1619           Arguments:  (1) <Client ID>           (2) [<comment>]
1620                       (3) <Kicker's Client ID>
1621
1622       The <Client ID> is the client which was kicked from the channel.
1623       The kicker may have set the <comment> string to indicate the
1624       reason for the kicking.  The <Kicker's Client ID> is the kicker.
1625
1626
1627 13    SILC_NOTIFY_TYPE_KILLED
1628
1629       Sent when a client has been killed from the network.  This MUST
1630       also be sent to the client which was killed from the network.
1631       This notify MUST be sent to those clients which are joined on
1632       same channels as the killed client.  The client which was killed
1633       MUST be removed from the network.  This packet is destined
1634       directly to the sent entity.  The router or server receiving
1635       the packet distributes this type to the local clients on the
1636       channel and broadcast it to the network.  The client MUST also
1637       be removed from joined channels invite list if it is explicitly
1638       added in the lists.  This notify MUST NOT be sent multiple
1639       times to same recipient.
1640
1641       Max Arguments:  3
1642           Arguments:  (1) <Client ID>           (2) [<comment>]
1643                       (3) <Killer's ID>
1644
1645       The <Client ID> is the client which was killed from the network.
1646       The killer may have set the  <comment> string to indicate the
1647       reason for the killing.  The <Killer's ID> is the killer, which
1648       may be client but also router server.
1649
1650
1651 14    SILC_NOTIFY_TYPE_UMODE_CHANGE
1652
1653       Sent when user's mode in the SILC changes.  This type is sent
1654       only between routers as broadcast packet.
1655
1656       Max Arguments:  2
1657           Arguments:  (1) <Client ID>  (2) <mode mask>
1658
1659       The <Client ID> is the client which mode was changed.  The
1660       <mode mask> is the new mode mask.
1661
1662
1663 15    SILC_NOTIFY_TYPE_BAN
1664
1665       Sent when the ban list of the channel is changed.  This notify
1666       type is sent to local servers on the channel, but MUST NOT be
1667       sent to clients on the channel.  Router MUST broadcast this to
1668       its primary router and to local servers on the channel.
1669
1670       Max Arguments:  3
1671           Arguments:  (1) <Channel ID>         (2) [<add | del>]
1672                       (3) [<ban list>]
1673
1674       The <Channel ID> is the channel which ban list was changed.
1675       The <add | del> is an argument of size of 1 byte where 0x00 means
1676       adding a client to ban list, and 0x01 means deleting a client
1677       from ban list.  The <ban list> indicates the information to be
1678       added to or removed from the ban list.  The <ban list> format
1679       format is defined in [SILC4] with SILC_COMMAND_BAN command.
1680       When <add | del> is used  to announce information during server
1681       connecting phase the argument type MUST be 0x03.  See section
1682       4.2.1 in [SILC1] for more information.
1683
1684
1685 16    SILC_NOTIFY_TYPE_ERROR
1686
1687       Sent when an error occurs during processing some SILC procedure.
1688       This is not used when error occurs during command processing, see
1689       [SILC4] for more information about commands and command replies.
1690       This type is sent directly to the sender of the packet whose
1691       packet caused the error.  See [SILC1] for definition when this
1692       type can be sent.
1693
1694       Max Arguments:  256
1695           Arguments:  (1) <Status Type>        (n) [...]
1696
1697       The <Status Type> is the error type defined in [SILC4].  Note
1698       that same types are also used with command replies to indicate
1699       the status of a command.  Both commands and this notify type
1700       share same status types.  Rest of the arguments are status type
1701       dependent and are specified with those status types that can be
1702       sent currently inside this notify type in [SILC4].  The <Status
1703       Type> is size of 1 byte.
1704
1705
1706 17    SILC_NOTIFY_TYPE_WATCH
1707
1708       Sent to indicate change in a watched user.  Client can set
1709       nicknames to be watched with SILC_COMMAND_WATCH command, and
1710       receive notifications when they login to network, signoff from
1711       the network or their user mode is changed.  This notify type
1712       is used to deliver these notifications.  The notify type is
1713       sent directly to the watching client.
1714
1715       Max Arguments:  5
1716           Arguments:  (1) <Client ID>        (2) [<nickname>]
1717                       (3) <user mode>        (4) [<Notify Type>]
1718                       (5) [<public key>]
1719
1720       The <Client ID> is the user's Client ID which is being watched,
1721       and the <nickname> is its nickname.  If the client just
1722       changed the nickname, then <nickname> is the new nickname, but
1723       the <Client ID> is the old client ID.  The <user mode> is the
1724       user's current user mode.  The <Notify Type> can be same as the
1725       Notify Payload's Notify Type, and is 16 bit MSB first order
1726       value.  If provided it may indicate the notify that occurred
1727       for the client.  If client logged in to the network the
1728       <Notify Type> MUST NOT be present.  The <public key> MAY be
1729       present, and it is the public key of the client being watched.
1730 .in 3
1731
1732 Notify types starting from 16384 are reserved for private notify
1733 message types.
1734
1735 Router server which receives SILC_NOTIFY_TYPE_SIGNOFF,
1736 SILC_NOTIFY_TYPE_SERVER_SIGNOFF, SILC_NOTIFY_TYPE_KILLED,
1737 SILC_NOTIFY_TYPE_NICK_CHANGE and SILC_NOTIFY_TYPE_UMODE_CHANGE
1738 MUST check whether someone in the local cell is watching the nickname
1739 the client has, and send the SILC_NOTIFY_TYPE_WATCH notify to the
1740 watcher, unless the watched client in case has the user mode
1741 SILC_UMODE_REJECT_WATCHING set.  If the watcher client and the client
1742 that was watched is same the notify SHOULD NOT be sent.
1743
1744
1745 .ti 0
1746 2.3.8 Error Payload
1747
1748 Error payload is sent upon error in protocol.  Error may occur in
1749 various conditions when server sends this packet.  Client MUST NOT
1750 send this payload but MUST be able to accept it.  However, client
1751 MAY ignore the contents of the packet as server is going to take
1752 action on the error anyway.  However, it is recommended that the
1753 client takes error packet seriously.
1754
1755
1756 .in 5
1757 .nf
1758                      1                   2                   3
1759  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1760 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1761 |                                                               |
1762 ~                         Error Message                         ~
1763 |                                                               |
1764 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1765 .in 3
1766
1767 .ce
1768 Figure 14:  Error Payload
1769
1770
1771 .in 6
1772 o Error Message (variable length) - Human readable error
1773   message.
1774 .in 3
1775
1776
1777 .ti 0
1778 2.3.9 Channel Message Payload
1779
1780 Channel Message Payload is used to send message to channels, a group
1781 of users.  These messages can only be sent if client has joined to
1782 some channel.  Even though this packet is very common in SILC it
1783 is still special packet.  Some special handling on sending and
1784 reception of channel message is required.
1785
1786 Padding MUST be applied into this payload since the payload is
1787 encrypted separately from other parts of the packet with the
1788 channel specific key.  Hence the requirement of the padding.
1789 The packet MUST be made multiple by eight (8) or by the block
1790 size of the cipher, which ever is larger.
1791
1792 The SILC header in this packet is encrypted with the session key
1793 of the next receiver of the packet.  Nothing else is encrypted
1794 with that key.  Thus, the actual packet and padding to be
1795 encrypted with the session key is SILC Header plus padding to it.
1796
1797 Receiver of the the channel message packet is able to determine
1798 the channel the message is destined to by checking the Destination
1799 ID from the SILC Packet header which tells the destination channel.
1800 The original sender of the packet is also determined by checking
1801 the source ID from the header which tells the client which sent
1802 the message.  The Destination ID MUST be Channel ID in the SILC
1803 Packet header.
1804
1805 This packet use generic Message Payload as Channel Message Payload.
1806 See section 2.3.2.6 for generic Message Payload.
1807
1808
1809 .ti 0
1810 2.3.10 Channel Key Payload
1811
1812 All traffic in channels are protected by channel specific keys.
1813 Channel Key Payload is used to distribute channel keys to all
1814 clients on the particular channel.  Channel keys are sent when
1815 the channel is created, when new user joins to the channel and
1816 whenever a user has left a channel.  Server creates the new
1817 channel key and distributes it to the clients by encrypting this
1818 payload with the session key shared between the server and
1819 the client.  After that, client MUST start using the key received
1820 in this payload to protect the traffic on the channel.
1821
1822 The client which is joining to the channel receives its key in the
1823 SILC_COMMAND_JOIN command reply message thus it is not necessary to
1824 send this payload to the entity which sent the SILC_COMMAND_JOIN
1825 command.
1826
1827 Channel keys are cell specific thus every router in the cell have
1828 to create a channel key and distribute it if any client in the
1829 cell has joined to a channel.  Channel traffic between cell's
1830 are not encrypted using channel keys, they are encrypted using
1831 normal session keys between two routers.  Inside a cell, all
1832 channel traffic is encrypted with the specified channel key.
1833 Channel key SHOULD expire periodically, say, in one hour, in
1834 which case new channel key is created and distributed.
1835
1836 Note that, this packet is not used if SILC_CMODE_PRIVKEY mode is set
1837 on channel.  This means that channel uses channel private keys which
1838 are not server generated.  For this reason server cannot send this
1839 packet as it does not know the key.
1840
1841 The destination ID in the packet SHOULD be the entity to whom the
1842 packet is sent.  Using Channel ID as destination ID is not
1843 necessary as the Channel ID is included in the Channel Key Payload.
1844
1845 The payload may only be sent with SILC_PACKET_CHANNEL_KEY packet.
1846 It MUST NOT be sent in any other packet type.  The following diagram
1847 represents the Channel Key Payload.
1848
1849
1850
1851 .in 5
1852 .nf
1853                      1                   2                   3
1854  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1855 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1856 |       Channel ID Length       |                               |
1857 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1858 |                                                               |
1859 ~                          Channel ID                           ~
1860 |                                                               |
1861 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1862 |      Cipher Name Length       |                               |
1863 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1864 |                                                               |
1865 ~                         Cipher Name                           ~
1866 |                                                               |
1867 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1868 |      Channel Key Length       |                               |
1869 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1870 |                                                               |
1871 ~                         Channel Key                           ~
1872 |                                                               |
1873 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1874 .in 3
1875
1876 .ce
1877 Figure 15:  Channel Key Payload
1878
1879
1880
1881 .in 6
1882 o Channel ID Length (2 bytes) - Indicates the length of the
1883   Channel ID field in the payload, not including any other
1884   field.
1885
1886 o Channel ID (variable length) - The Channel ID of the
1887   channel.
1888
1889 o Cipher Name Length (2 bytes) - Indicates the length of the
1890   Cipher name field in the payload, not including any other
1891   field.
1892
1893 o Cipher Name (variable length) - Name of the cipher used
1894   in the protection of channel traffic.  This name is
1895   initially decided by the creator of the channel but it
1896   may change during the life time of the channel as well.
1897
1898 o Channel Key Length (2 bytes) - Indicates the length of the
1899   Channel Key field in the payload, not including any other
1900   field.
1901
1902 o Channel Key (variable length) - The actual channel key
1903   material.
1904 .in 3
1905
1906
1907 .ti 0
1908 2.3.11 Private Message Payload
1909
1910 Private Message Payload is used to send private message between
1911 two clients.  The messages are sent only to the specified user
1912 and no other user inside SILC network is able to see the message.
1913
1914 The message can be protected by the session key established by the
1915 SILC Key Exchange Protocol.  However, it is also possible to agree
1916 to use a private key to protect just the private messages.  It is
1917 for example possible to perform Key Agreement between two clients.
1918 See section 2.3.20 Key Agreement Payload how to perform key
1919 agreement.  It is also possible to use static or pre-shared keys
1920 to protect private messages.  See the 2.3.12 Private Message Key
1921 Payload and [SILC1] section 4.6 for detailed description for private
1922 message key generation.
1923
1924 If normal session key is used to protect the message, every server
1925 between the sender client and the receiving client MUST decrypt the
1926 packet and always re-encrypt it with the session key of the next
1927 receiver of the packet.  See section Client To Client in [SILC1].
1928
1929 When the private message key is used, and the Private Message Key
1930 flag was set in the SILC Packet header no server or router en route
1931 is able to decrypt or re-encrypt the packet.  In this case only the
1932 SILC Packet header is processed by the servers and routers en route.
1933 Section Client To Client in [SILC1] gives example of this scheme.
1934
1935 This packet use generic Message Payload as Private Message Payload.
1936 See section 2.3.2.6 for generic Message Payload.
1937
1938
1939 .ti 0
1940 2.3.12 Private Message Key Payload
1941
1942 This payload is OPTIONAL and can be used to indicate that a static
1943 or pre-shared key should be used in the private message communication
1944 to protect the messages.  The actual key material has to be sent
1945 outside the SILC network, or it has to be a static or pre-shared key.
1946 The sender of this packet is considered to be the initiator and the
1947 receiver the responder when processing the raw key material as
1948 described in the section 4.6 in [SILC1] and in the section 2.3 in
1949 [SILC3].
1950
1951 Note that it is also possible to use static or pre-shared keys in
1952 client implementations without sending this packet.  Clients may
1953 naturally agree to use a key without sending any kind of indication
1954 to each other.  The key may be for example a long-living static key
1955 that the clients has agreed to use at all times.  Note that it is
1956 also possible to agree to use private message key by performing
1957 a Key Agreement.  See the section 2.3.20 Key Agreement Payload.
1958
1959 This payload may only be sent by client to another client.  Server
1960 MUST NOT send this payload.  After sending this payload and setting the
1961 key into use this payload the sender of private messages MUST set the
1962 Private Message Key flag into the SILC Packet Header.
1963
1964 The payload may only be sent with SILC_PACKET_PRIVATE_MESSAGE_KEY
1965 packet.  It MUST NOT be sent in any other packet type.  The following
1966 diagram represents the Private Message Key Payload.
1967
1968
1969 .in 5
1970 .nf
1971                      1                   2                   3
1972  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1973 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1974 |      Cipher Name Length       |                               |
1975 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1976 |                                                               |
1977 ~                          Cipher Name                          ~
1978 |                                                               |
1979 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1980 |       HMAC Name Length        |                               |
1981 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1982 |                                                               |
1983 ~                           HMAC Name                           ~
1984 |                                                               |
1985 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1986 .in 3
1987
1988 .ce
1989 Figure 16:  Private Message Key Payload
1990
1991
1992
1993 .in 6
1994 o Cipher Name Length (2 bytes) - Indicates the length of the
1995   Cipher Name field in the payload, not including any other
1996   field.
1997
1998 o Cipher Name (variable length) - Name of the cipher to use
1999   in the private message encryption.  If this field does not
2000   exist then the default cipher of the SILC protocol is used.
2001   See the [SILC1] for defined ciphers.
2002
2003 o HMAC Name Length (2 bytes) - Indicates the length of the
2004   HMAC Name field in the payload, not including any other
2005   field.
2006
2007 o HMAC Name (variable length) - Name of the HMAC to use
2008   in the private message MAC computation.  If this field does
2009   not exist then the default HMAC of the SILC protocol is used.
2010   See the [SILC1] for defined HMACs.
2011 .in 3
2012
2013
2014 .ti 0
2015 2.3.13 Command Payload
2016
2017 Command Payload is used to send SILC commands from client to server.
2018 Also server MAY send commands to other servers.  The following diagram
2019 represents the Command Payload.
2020
2021
2022 .in 5
2023 .nf
2024                      1                   2                   3
2025  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2026 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2027 |         Payload Length        | SILC Command  | Arguments Num |
2028 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2029 |       Command Identifier      |
2030 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2031 .in 3
2032
2033 .ce
2034 Figure 17:  Command Payload
2035
2036
2037 .in 6
2038 o Payload Length (2 bytes) - Length of the entire command
2039   payload including any command argument payloads associated
2040   with this payload.
2041
2042 o SILC Command (1 byte) - Indicates the SILC command.  This MUST
2043   be set to non-zero value.  If zero (0) value is found in this
2044   field the packet MUST be discarded.
2045
2046 o Arguments Num (1 byte) - Indicates the number of arguments
2047   associated with the command.  If there are no arguments this
2048   field is set to zero (0).  The arguments MUST follow the
2049   Command Payload.  See section 2.3.2.2 for definition of the
2050   Argument Payload.
2051
2052 o Command Identifier (2 bytes) - Identifies this command at the
2053   sender's end.  The entity which replies to this command MUST
2054   set the value found from this field into the Command Payload
2055   used to send the reply to the sender.  This way the sender
2056   can identify which command reply belongs to which originally
2057   sent command.  What this field includes is implementation
2058   issue but it is RECOMMENDED that wrapping counter value is
2059   used in the field.
2060 .in 3
2061
2062 See [SILC4] for detailed description of different SILC commands,
2063 their arguments and their reply messages.
2064
2065
2066 .ti 0
2067 2.3.14 Command Reply Payload
2068
2069 Command Reply Payload is used to send replies to the commands.  The
2070 Command Reply Payload is identical to the Command Payload thus see
2071 the 2.3.13 section for the payload specification.
2072
2073 The entity which sends the reply packet MUST set the Command Identifier
2074 field in the reply packet's Command Payload to the value it received
2075 in the original command packet.
2076
2077 See SILC Commands in [SILC4] for detailed description of different
2078 SILC commands, their arguments and their reply messages.
2079
2080
2081 .ti 0
2082 2.3.15 Connection Auth Request Payload
2083
2084 Client MAY send this payload to server to request the authentication
2085 method that must be used in authentication protocol.  If client knows
2086 this information beforehand this payload is not necessary to be sent.
2087 Server performing authentication with another server MAY also send
2088 this payload to request the authentication method.  If the connecting
2089 server already knows this information this payload is not necessary
2090 to be sent.
2091
2092 Server receiving this request SHOULD reply with same payload sending
2093 the mandatory authentication method.  Algorithms that may be required
2094 to be used by the authentication method are the ones already
2095 established by the SILC Key Exchange protocol.  See section Key
2096 Exchange Start Payload in [SILC3] for detailed information.
2097
2098 The payload may only be sent with SILC_PACKET_CONNECTION_AUTH_REQUEST
2099 packet.  It MUST NOT be sent in any other packet type.  The following
2100 diagram represents the Connection Auth Request Payload.
2101
2102
2103 .in 5
2104 .nf
2105                      1                   2                   3
2106  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2107 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2108 |        Connection Type        |     Authentication Method     |
2109 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2110 .in 3
2111
2112 .ce
2113 Figure 18:  Connection Auth Request Payload
2114
2115
2116 .in 6
2117 o Connection Type (2 bytes) - Indicates the type of the
2118   connection.  The following connection types are defined:
2119
2120
2121      1    Client connection
2122      2    Server connection
2123      3    Router connection
2124
2125   If any other type is found in this field the packet MUST be
2126   discarded and the authentication MUST be failed.
2127
2128 o Authentication Method (2 bytes) - Indicates the authentication
2129   method to be used in the authentication protocol.  The following
2130   authentication methods are defined:
2131
2132      0    NONE        (mandatory)
2133      1    password    (mandatory)
2134      2    public key  (mandatory)
2135
2136   If any other type is found in this field the packet MUST be
2137   discarded and the authentication MUST be failed.  If this
2138   payload is sent as request to receive the mandatory
2139   authentication method this field MUST be set to zero (0),
2140   indicating that receiver should send the mandatory
2141   authentication method.  The receiver sending this payload
2142   to the requesting party, MAY also set this field to zero (0)
2143   to indicate that authentication is not required.  In this
2144   case authentication protocol still MUST be started but
2145   server is most likely to respond with SILC_PACKET_SUCCESS
2146   immediately.
2147 .in 3
2148
2149
2150 .ti 0
2151 2.3.16 New ID Payload
2152
2153 New ID Payload is a multipurpose payload.  It is used to send newly
2154 created ID's from clients and servers.  When client connects to server
2155 and registers itself to the server by sending SILC_PACKET_NEW_CLIENT
2156 packet, server replies with this packet by sending the created ID for
2157 the client.  Server always creates the ID for the client.
2158
2159 This payload is also used when server tells its router that new client
2160 has registered to the SILC network.  In this case the server sends
2161 the Client ID of the client to the router.  Similarly when router
2162 distributes information to other routers about the client in the SILC
2163 network this payload is used.
2164
2165 Also, when server connects to router, router use this payload to inform
2166 other routers about new server in the SILC network.  However, every
2167 server (or router) creates their own ID's thus the ID distributed by
2168 this payload is not created by the distributor in this case.  Servers
2169 create their own ID's.  Server registers itself to the network by
2170 sending SILC_PACKET_NEW_SERVER to the router it connected to.  The case
2171 is same when router connects to another router.
2172
2173 This payload MUST NOT be used to send information about new channels.
2174 New channels are always distributed by sending the dedicated
2175 SILC_PACKET_NEW_CHANNEL packet.  Client MUST NOT send this payload.
2176 Both client and server (and router) MAY receive this payload.
2177
2178 The packet use generic ID Payload as New ID Payload.  See section
2179 2.3.2.1 for generic ID Payload.
2180
2181
2182 .ti 0
2183 2.3.17 New Client Payload
2184
2185 When client is connected to the server, keys has been exchanged and
2186 connection has been authenticated, client MUST register itself to the
2187 server.  Client's first packet after key exchange and authentication
2188 protocols MUST be SILC_PACKET_NEW_CLIENT.  This payload tells server all
2189 the relevant information about the connected user.  Server creates a new
2190 client ID for the client when received this payload and sends it to the
2191 client in New ID Payload.
2192
2193 This payload sends username and real name of the user on the remote host
2194 which is connected to the SILC server with SILC client.  The server
2195 creates the client ID according the information sent in this payload.
2196 The nickname of the user becomes the nickname sent in this payload.
2197
2198 The payload may only be sent with SILC_PACKET_NEW_CLIENT packet.  It
2199 MUST NOT be sent in any other packet type.  The following diagram
2200 represents the New Client Payload.
2201
2202
2203
2204 .in 5
2205 .nf
2206                      1                   2                   3
2207  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2208 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2209 |        Username Length        |                               |
2210 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
2211 |                                                               |
2212 ~                           Username                            ~
2213 |                                                               |
2214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2215 |       Real Name Length        |                               |
2216 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
2217 |                                                               |
2218 ~                           Real Name                           ~
2219 |                                                               |
2220 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2221 .in 3
2222
2223 .ce
2224 Figure 19:  New Client Payload
2225
2226
2227 .in 6
2228 o Username Length (2 bytes) - Length of the Username field.
2229
2230 o Username (variable length) - The username of the user on
2231   the host where connecting to the SILC server.
2232
2233 o Real Name Length (2 bytes) - Length of the Real Name field.
2234
2235 o Real Name (variable length) - The real name of the user
2236   on the host where connecting to the SILC server.
2237 .in 3
2238
2239
2240 .ti 0
2241 2.3.18 New Server Payload
2242
2243 This payload is sent by server when it has completed successfully both
2244 key exchange and connection authentication protocols.  The server
2245 MUST register itself to the SILC Network by sending this payload.
2246 The first packet after these key exchange and authentication protocols
2247 is SILC_PACKET_NEW_SERVER packet.  The payload includes the Server ID
2248 of the server that it has created by itself.  It also includes a
2249 name of the server that is associated to the Server ID.
2250
2251 The payload may only be sent with SILC_PACKET_NEW_SERVER packet.  It
2252 MUST NOT be sent in any other packet type.  The following diagram
2253 represents the New Server Payload.
2254
2255
2256
2257
2258
2259 .in 5
2260 .nf
2261                      1                   2                   3
2262  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2263 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2264 |       Server ID Length        |                               |
2265 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
2266 |                                                               |
2267 ~                        Server ID Data                         ~
2268 |                                                               |
2269 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2270 |     Server Name Length        |                               |
2271 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
2272 |                                                               |
2273 ~                          Server Name                          ~
2274 |                                                               |
2275 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2276 .in 3
2277
2278 .ce
2279 Figure 20:  New Server Payload
2280
2281
2282 .in 6
2283 o Server ID Length (2 bytes) - Length of the Server ID Data
2284   field.
2285
2286 o Server ID Data (variable length) - The encoded Server ID
2287   data.
2288
2289 o Server Name Length (2 bytes) - Length of the server name
2290   field.
2291
2292 o Server Name (variable length) - The server name string.
2293 .in 3
2294
2295
2296 .ti 0
2297 2.3.19 New Channel Payload
2298
2299 Information about newly created channel is broadcasted to all routers
2300 in the SILC network by sending this packet payload.  Channels are
2301 created by router of the cell.  Server never creates channels unless
2302 it is a standalone server and it does not have router connection,
2303 in this case server acts as router.  Normal server send JOIN command
2304 to the router (after it has received JOIN command from client) which
2305 then processes the command and creates the channel.  Client MUST NOT
2306 send this packet.  Server MAY send this packet to a router when it is
2307 announcing its existing channels to the router after it has connected
2308 to the router.
2309
2310 The packet use generic Channel Payload as New Channel Payload.  See
2311 section 2.3.2.3 for generic Channel Payload.  The Mode Mask field in the
2312 Channel Payload is the mode of the channel.
2313
2314
2315 .ti 0
2316 2.3.20 Key Agreement Payload
2317
2318 This payload is used by clients to request key negotiation between
2319 another client in the SILC Network.  The key agreement protocol used
2320 is the SKE protocol.  The result of the protocol, the secret key
2321 material, can be used for example as private message key between the
2322 two clients.  This significantly adds security as the clients agree
2323 about the key without any server interaction.  The protocol is executed
2324 peer to peer.  The server and router MUST NOT send this payload.
2325
2326 The sender MAY tell the receiver of this payload the hostname and the
2327 port where the SKE protocol is running in the sender's end.  The
2328 receiver MAY then initiate the SKE negotiation with the sender.  The
2329 sender MAY also optionally not to include the hostname and the port
2330 of its SKE protocol.  In this case the receiver MAY reply to the
2331 request by sending the same payload filled with the receiver's hostname
2332 and the port where the SKE protocol is running.  The sender MAY then
2333 initiate the SKE negotiation with the receiver.
2334
2335 This payload may be sent with SILC_PACKET_KEY_AGREEMENT and
2336 SILC_PACKET_FTP packet types.  It MUST NOT be sent in any other packet
2337 types.  The following diagram represents the Key Agreement Payload.
2338
2339
2340 .in 5
2341 .nf
2342                      1                   2                   3
2343  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2344 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2345 |        Hostname Length        |                               |
2346 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
2347 |                                                               |
2348 ~                           Hostname                            ~
2349 |                                                               |
2350 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2351 |            Protocol           |             Port              |
2352 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2353 .in 3
2354
2355 .ce
2356 Figure 21:  Key Agreement Payload
2357
2358
2359 .in 6
2360 o Hostname Length (2 bytes) - Indicates the length of the
2361   Hostname field.
2362
2363 o Hostname (variable length) - The hostname or IP address where
2364   the SKE protocol is running, as UTF-8 encoded string.  The sender
2365   MAY fill this field when sending the payload.  If the receiver
2366   sends this payload as reply to the request it MUST fill this field.
2367
2368 o Protocol (2 bytes) - The internet protocol used for the key
2369   agreement connection.  Possible values are 0 for TCP and 1 for
2370   UDP.  Other values are unsupported.  This is a 16 bit MSB first
2371   order value.  If Hostname field is not present, the value in
2372   this field is ignored.
2373
2374 o Port (2 bytes) - The port where the SKE protocol is bound.
2375   The sender MAY fill this field when sending the payload.  If
2376   the receiver sends this payload as reply to the request it
2377   MUST fill this field.  This is a 16 bit MSB first order value.
2378 .in 3
2379
2380
2381 After the key material has been received from the SKE protocol it is
2382 processed as the [SILC3] describes.  If the key material is used as
2383 channel private key then the Sending Encryption Key, as defined in
2384 [SILC3] is used as the channel private key.  Other key material must
2385 be discarded.  The [SILC1] in section 4.6 defines the way to use the
2386 key material if it is intended to be used as private message keys.
2387 Any other use for the key material is undefined.
2388
2389
2390 .ti 0
2391 2.3.21 Resume Router Payload
2392
2393 See the [SILC1] for Resume Router protocol where this payload is
2394 used.  The payload may only be sent with SILC_PACKET_RESUME_ROUTER
2395 packet.  It MUST NOT be sent in any other packet type.  The following
2396 diagram represents the Resume Router Payload.
2397
2398
2399 .in 21
2400 .nf
2401                      1
2402  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
2403 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2404 |      Type     |  Session ID   |
2405 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2406 .in 3
2407
2408 .ce
2409 Figure 22:  Resume Router Payload
2410
2411
2412 .in 6
2413 o Type (1 byte) - Indicates the type of the backup resume
2414   protocol packet.  The type values are defined in [SILC1].
2415
2416 o Session ID (1 bytes) - Indicates the session ID for the
2417   backup resume protocol.  The sender of the packet sets this
2418   value and the receiver MUST set the same value in subsequent
2419   reply packet.
2420 .in 3
2421
2422
2423
2424
2425 .ti 0
2426 2.3.22 File Transfer Payload
2427
2428 File Transfer Payload is used to perform file transfer protocol between
2429 two entities in the network.  The actual file transfer protocol is always
2430 encapsulated inside the SILC Packet.  The actual data stream is also sent
2431 peer to peer outside SILC network.
2432
2433 When an entity, usually a client wishes to perform file transfer protocol
2434 with another client in the network, they perform Key Agreement protocol
2435 as described in the section 2.3.20 Key Agreement Payload and in [SILC3],
2436 inside File Transfer Payload.  After the Key Agreement protocol has been
2437 performed the subsequent packets in the data stream will be protected
2438 using the new key material.  The actual file transfer protocol is also
2439 initialized in this stage.  All file transfer protocol packets are always
2440 encapsulated in the File Transfer Payload and protected with the
2441 negotiated key material.
2442
2443 The payload may only be sent with SILC_PACKET_FTP packet.  It MUST NOT
2444 be sent in any other packet type.  The following diagram represents the
2445 File Transfer Payload.
2446
2447
2448 .in 5
2449 .nf
2450                      1                   2                   3
2451  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2452 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2453 |     Type      |                                               |
2454 +-+-+-+-+-+-+-+-+                                               +
2455 |                                                               |
2456 ~                             Data                              ~
2457 |                                                               |
2458 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2459 .in 3
2460
2461 .ce
2462 Figure 23:  File Transfer Payload
2463
2464
2465 .in 6
2466 o Type (1 byte) - Indicates the type of the file transfer
2467   protocol.  The following file transfer protocols has been
2468   defined:
2469
2470     1    Secure File Transfer Protocol (SFTP)  (mandatory)
2471
2472   If zero (0) value or any unsupported file transfer protocol
2473   type is found in this field the packet MUST be discarded.
2474   The currently mandatory file transfer protocol is SFTP.
2475   The SFTP protocol is defined in [SFTP].
2476
2477 o Data (variable length) - Arbitrary file transfer data.  The
2478   contents and encoding of this field is dependent of the usage
2479   of this payload and the type of the file transfer protocol.
2480   When this payload is used to perform the Key Agreement
2481   protocol, this field include the Key Agreement Payload,
2482   as defined in the section 2.3.20 Key Agreement Payload.
2483   When this payload is used to send the actual file transfer
2484   protocol data, the encoding is defined in the corresponding
2485   file transfer protocol.
2486 .in 3
2487
2488
2489 .ti 0
2490 2.3.23 Resume Client Payload
2491
2492 This payload is used by client to resume its detached session in the
2493 SILC Network.  A client is able to detach itself from the network by
2494 sending SILC_COMMAND_DETACH command to its server.  The network
2495 connection to the client is lost but the client remains as valid
2496 client in the network.  The client is able to resume the session back
2497 by sending this packet and including the old Client ID, and an
2498 Authentication Payload [SILC1] which the server use to verify with
2499 the detached client's public key.  This also implies that the
2500 mandatory authentication method is public key authentication.
2501
2502 Server or router that receives this from the client also sends this,
2503 without the Authentication Payload, to routers in the network so that
2504 they know the detached client has resumed.  Refer to the [SILC1] for
2505 detailed description how the detaching and resuming procedure is
2506 performed.
2507
2508 The payload may only be sent with SILC_PACKET_RESUME CLIENT packet.  It
2509 MUST NOT be sent in any other packet type.  The following diagram
2510 represents the Resume Client Payload.
2511
2512 .in 5
2513 .nf
2514                      1                   2                   3
2515  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2516 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2517 |       Client ID Length        |                               |
2518 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
2519 |                                                               |
2520 ~                           Client ID                           ~
2521 |                                                               |
2522 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2523 |                                                               |
2524 ~                     Authentication Payload                    ~
2525 |                                                               |
2526 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2527 .in 3
2528
2529 .ce
2530 Figure 24:  Resume Client Payload
2531
2532
2533 .in 6
2534 o Client ID Length (1 byte) - The length of the Client ID
2535   field not including any other field.
2536
2537 o Client ID (variable length) - The detached client's Client
2538   ID.  The client that sends this payload must know the Client
2539   ID.
2540
2541 o Authentication Payload (variable length) - The authentication
2542   payload that the server will verify with the detached client's
2543   public key.  If the server doesn't know the public key, it must
2544   retrieve it for example with SILC_COMMAND_GETKEY command.
2545 .in 3
2546
2547
2548
2549 .ti 0
2550 2.4 SILC ID Types
2551
2552 ID's are used in the SILC network to associate different entities.
2553 The following ID's has been defined to be used in the SILC network.
2554
2555 .in 6
2556 0    No ID
2557
2558      This is used when other ID type is available at the time.
2559
2560 1    Server ID
2561
2562      Server ID to associate servers.  See the format of
2563      this ID in [SILC1].
2564
2565 2    Client ID
2566
2567      Client ID to associate clients.  See the format of
2568      this ID in [SILC1].
2569
2570 3    Channel ID
2571
2572      Channel ID to associate channels.  See the format of
2573      this ID in [SILC1].
2574 .in 3
2575
2576 When encoding different IDs into the ID Payload, all fields are always
2577 in MSB first order.  The IP address, port, and/or the random number
2578 are encoded in the MSB first order.
2579
2580
2581 .ti 0
2582 2.5 Packet Encryption And Decryption
2583
2584 SILC packets are encrypted almost entirely.  Only the MAC at the end
2585 of the packet is never encrypted.  The SILC Packet header is the first
2586 part of a packet to be encrypted and it is always encrypted with the
2587 key of the next receiver of the packet.  The data payload area of the
2588 packet is always entirely encrypted and it is usually encrypted with
2589 the next receiver's key.  However, there are some special packet types
2590 and packet payloads that require special encryption process.  These
2591 special cases are described in the next sections.  First is described
2592 the normal packet encryption process.
2593
2594
2595
2596 .ti 0
2597 2.5.1 Normal Packet Encryption And Decryption
2598
2599 Normal SILC packets are encrypted with the session key of the next
2600 receiver of the packet.  The entire SILC Packet header and the packet
2601 data payload is is encrypted with the same key.  Padding of the packet
2602 is also encrypted always with the session key, also in special cases.
2603 Computed MAC of the packet MUST NOT be encrypted.
2604
2605 Decryption process in these cases are straightforward.  The receiver
2606 of the packet MUST first decrypt the SILC Packet header, or some parts
2607 of it, usually first 16 bytes of it.  Then the receiver checks the
2608 packet type from the decrypted part of the header and can determine
2609 how the rest of the packet must be decrypted.  If the packet type is
2610 any of the special cases described in the following sections the packet
2611 decryption is special.  If the packet type is not among those special
2612 packet types rest of the packet can be decrypted with the same key.
2613 At this point the receiver is also able to determine the length of the
2614 packet.
2615
2616 With out a doubt, this sort of decryption processing causes some
2617 overhead to packet decryption, but never the less, is required.
2618
2619 The MAC of the packet is also verified at this point.  The MAC is
2620 computed from the ciphertext of the packet so it can be verified
2621 at this stage.  The length of the packet need to be known to be able
2622 to verify the MAC from the ciphertext so the first 16 bytes need to
2623 be decrypted to determine the packet length.  However, the MAC MUST
2624 be verified from the entire ciphertext.
2625
2626
2627 .ti 0
2628 2.5.2 Channel Message Encryption And Decryption
2629
2630 Channel Messages (Channel Message Payload) are always encrypted with
2631 the channel specific key.  However, the SILC Packet header is not
2632 encrypted with that key.  As in normal case, the header is encrypted
2633 with the key of the next receiver of the packet.  Note that, in this
2634 case the encrypted data area is not touched at all; it MUST NOT be
2635 re-encrypted with the session key.
2636
2637 Receiver of a channel message, who ever that is, is REQUIRED to decrypt
2638 the SILC Packet header to be able to recognize the packet to be as
2639 channel message.  This is same procedure as for normal SILC packets.
2640 As the receiver founds the packet to be channel message, rest of the
2641 packet processing is special.  Rest of the SILC Packet header is
2642 decrypted with the same session key along with the padding of the
2643 packet.  After that the packet is protected with the channel specific
2644 key and thus can be decrypted only if the receiver is the client on
2645 the channel.  See section 2.7 Packet Padding Generation for more
2646 information about padding on special packets.
2647
2648 If the receiver of the channel message is router which is routing the
2649 message to another router then it MUST decrypt the Channel Message
2650 payload too.  Between routers (that is, between cells) channel messages
2651 are protected with session keys shared between the routers.  This
2652 causes another special packet processing for channel messages.  If
2653 the channel message is received from another router then the entire
2654 packet, including Channel Message payload, MUST be encrypted with the
2655 session key shared between the routers.  In this case the packet
2656 decryption process is as with normal SILC packets.  Hence, if the
2657 router is sending channel message to another router the Channel
2658 Message payload MUST have been decrypted and MUST be re-encrypted
2659 with the session key shared between the another router.  In this
2660 case the packet encryption is as with any normal SILC packet.
2661
2662 It must be noted that this is only when the channel messages are sent
2663 from router to another router.  In all other cases the channel
2664 message encryption and decryption is as described before.  This
2665 different processing of channel messages with router to router
2666 connection is because channel keys are cell specific.  All cells have
2667 their own channel keys thus the channel message traveling from one
2668 cell to another MUST be protected as it would be any normal SILC
2669 packet.
2670
2671 If the SILC_CMODE_PRIVKEY channel mode has been set for the channel
2672 then the router cannot decrypt the packet as it does not know the
2673 private key.  In this case the entire packet MUST be encrypted with
2674 the session key and sent to the router.  The router receiving the
2675 packet MUST check the channel mode and decrypt the packet accordingly.
2676
2677
2678 .ti 0
2679 2.5.3 Private Message Encryption And Decryption
2680
2681 By default, private message in SILC are protected by session keys.
2682 In this case the private message encryption and decryption process is
2683 equivalent to normal packet encryption and decryption.
2684
2685 However, private messages MAY be protected with private message key
2686 which causes the packet to be special packet.  The procedure in this
2687 case is very much alike to channel packets.  The actual private message
2688 is encrypted with the private message key and other parts of the
2689 packet is encrypted with the session key.  See 2.7 Packet Padding
2690 Generation for more information about padding on special packets.
2691
2692 The difference from channel message processing is that server or router
2693 en route never decrypts the actual private message, as it does not
2694 have the key to do that.  Thus, when sending packets between router
2695 the processing is same as in any other case as well; the packet's header
2696 and padding is protected by the session key and the data area is not
2697 touched and is not re-encrypted.
2698
2699 The true receiver of the private message is able to decrypt the private
2700 message as it shares the key with the sender of the message.
2701
2702
2703 .ti 0
2704 2.6 Packet MAC Generation
2705
2706 Data integrity of a packet is protected by including a message
2707 authentication code (MAC) at the end of the packet.  The MAC is computed
2708 from shared secret MAC key, that is established by the SILC Key Exchange
2709 protocol, from packet sequence number, and from the encrypted packet
2710 data.  The MAC is always computed after packet is encrypted.  This is
2711 so called Encrypt-Then-MAC order; packet is first encrypted, then MAC
2712 is computed from the encrypted data.
2713
2714 The MAC is computed from entire packet.  Every bit of data in the packet,
2715 including SILC Packet Header is used in the MAC computing.  This way
2716 the entire packet becomes authenticated.
2717
2718 Hence, packet's MAC generation is as follows:
2719
2720   mac = MAC(key, sequence number | Encrypted SILC packet)
2721
2722 The MAC key is negotiated during the SKE protocol.  The sequence number
2723 is a 32 bit MSB first value starting from zero for first packet and
2724 increasing for subsequent packets, finally wrapping after 2^32 packets.
2725 The value is never reset, not even after rekey has been performed.
2726 However, rekey MUST be performed before the sequence number wraps
2727 and repeats from zero.  Note that the sequence number is incremented only
2728 when MAC is computed for a packet.  If packet is not encrypted and MAC is
2729 not computed then the sequence number is not incremented.  Hence, the
2730 sequence number is zero for the very first encrypted packet.
2731
2732 See [SILC1] for defined and allowed MAC algorithms.
2733
2734
2735 .ti 0
2736 2.7 Packet Padding Generation
2737
2738 Padding is needed in the packet because the packet is encrypted.  It
2739 always MUST be multiple by eight (8) or multiple by the block size
2740 of the cipher, which ever is larger.  The padding is always encrypted.
2741
2742 For normal packets the padding is added after the SILC Packet Header
2743 and between the Data Payload area.  The padding for normal packets
2744 may be calculated as follows:
2745
2746 .in 6
2747 padding_length = 16 - (packet_length mod block_size)
2748 if (padding_length < 8)
2749   padding_length += block_size
2750 .in 3
2751
2752 The `block_size' is the block size of the cipher.  The maximum padding
2753 length is 128 bytes, and minimum is 8 bytes.  For example, packets that
2754 include a passphrase or a password for authentication purposes SHOULD
2755 pad the packet up to the maximum padding length.  The maximum padding
2756 is calculated as follows:
2757
2758 .in 6
2759 padding_length = 128 - (packet_length mod block_size)
2760 .in 3
2761
2762 For special packets the padding calculation is different as special
2763 packets may be encrypted differently.  In these cases the encrypted
2764 data area MUST already be multiple by the block size thus in this case
2765 the padding is calculated only for SILC Packet Header, not for any
2766 other area of the packet.  The same algorithm works in this case as
2767 well, except that the `packet length' is now the SILC Packet Header
2768 length.
2769
2770 The padding MUST be random data, preferably, generated by
2771 cryptographically strong random number generator for each packet
2772 separately.
2773
2774
2775 .ti 0
2776 2.8 Packet Compression
2777
2778 SILC Packets MAY be compressed.  In this case the data payload area
2779 is compressed and all other areas of the packet MUST remain as they
2780 are.  After compression is performed for the data area, the length
2781 field of Packet Header MUST be set to the compressed length of the
2782 data.
2783
2784 The compression MUST always be applied before encryption.  When
2785 the packet is received and decrypted the data area MUST be decompressed.
2786 Note that the true sender of the packet MUST apply the compression and
2787 the true receiver of the packet MUST apply the decompression.  Any
2788 server or router en route SHOULD NOT decompress the packet.
2789
2790
2791 .ti 0
2792 2.9 Packet Sending
2793
2794 The sender of the packet MUST assemble the SILC Packet Header with
2795 correct values.  It MUST set the Source ID of the header as its own
2796 ID, unless it is forwarding the packet.  It MUST also set the Destination
2797 ID of the header to the true destination.  If the destination is client
2798 it will be Client ID, if it is server it will be Server ID and if it is
2799 channel it will be Channel ID.
2800
2801 If the sender wants to compress the packet it MUST apply the
2802 compression now.  Sender MUST also compute the padding as described
2803 in above sections.  Then sender MUST encrypt the packet as has been
2804 described in above sections according whether the packet is normal
2805 packet or special packet.  Then sender MUST compute the MAC of the
2806 packet.  The computed MAC MUST NOT be encrypted.
2807
2808
2809 .ti 0
2810 2.10 Packet Reception
2811
2812 On packet reception the receiver MUST check that all fields in the
2813 SILC Packet Header are valid.  It MUST check the flags of the
2814 header and act accordingly.  It MUST also check the MAC of the packet
2815 and if it is to be failed the packet MUST be discarded.  Also if the
2816 header of the packet includes any bad fields the packet MUST be
2817 discarded.
2818
2819 See above sections on the decryption process of the received packet.
2820
2821 The receiver MUST also check that the ID's in the header are valid
2822 ID's.  Unsupported ID types or malformed ID's MUST cause packet
2823 rejection.  The padding on the reception is always ignored.
2824
2825 The receiver MUST also check the packet type and start parsing the
2826 packet according to the type.  However, note the above sections on
2827 special packet types and their parsing.
2828
2829
2830 .ti 0
2831 2.11 Packet Routing
2832
2833 Routers are the primary entities in the SILC network that takes care
2834 of packet routing.  However, normal servers routes packets as well, for
2835 example, when they are routing channel message to the local clients.
2836 Routing is quite simple as every packet tells the true origin and the
2837 true destination of the packet.
2838
2839 It is still RECOMMENDED for routers that has several routing connections
2840 to create route cache for those destinations that has faster route than
2841 the router's primary route.  This information is available for the router
2842 when other router connects to the router.  The connecting party then
2843 sends all of its locally connected clients, servers and channels.  These
2844 informations helps to create the route cache.  Also, when new channels
2845 are created to a cell its information is broadcasted to all routers
2846 in the network.  Channel ID's are based on router's ID thus it is easy
2847 to create route cache based on these informations.  If faster route for
2848 destination does not exist in router's route cache the packet MUST be
2849 routed to the primary route (default route).
2850
2851 However, there are some issues when routing channel messages to group
2852 of users.  Routers are responsible of routing the channel message to
2853 other routers, local servers and local clients as well.  Routers MUST
2854 send the channel message to only one router in the network, preferably
2855 to the shortest route to reach the channel users.  The message can be
2856 routed into either upstream or downstream.  After the message is sent
2857 to a router in the network it MUST NOT be sent to any other router in
2858 either same route or other route.  The message MUST NOT be routed to
2859 the router it came from.
2860
2861 When routing for example private messages they should be routed to the
2862 shortest route always to reach the destination client as fast as possible.
2863
2864 For server which receives a packet to be routed to an entity that is
2865 indirectly connected to the sender, the server MUST check whether that
2866 particular packet type is allowed to be routed to that destination.  Not
2867 all packets may be sent by some odd entity to for example a local client,
2868 or to some remote server or router, that is indirectly connected to the
2869 sender.  See section 2.3 SILC Packet Types and paragraph about indirectly
2870 connected entities and sending packets to them.  That section defines the
2871 packets that may be sent to indirectly connected entities.  When a server
2872 or a router receives a packet that may be sent to indirectly connected
2873 entity and it is destined to other entity except that server, it MUST
2874 route it further either to shortest route or to the primary route to reach
2875 that destination.
2876
2877 Routers form a ring in the SILC network.  However, routers may have other
2878 direct connections to other routers in the network too.  This can cause
2879 interesting routing problems in the network.  Since the network is a ring,
2880 the packets usually should be routed into clock-wise direction, or if it
2881 cannot be used then always counter clock-wise (primary route) direction.
2882 Problems may arise when a faster direct route exists and router is routing
2883 a channel message.  Currently channel messages must be routed either
2884 in upstream or downstream, they cannot be routed to other direct routes.
2885 The SILC protocol should have a shortest path discovery protocol, and some
2886 existing routing protocol, that can handle a ring network with other
2887 direct routes inside the ring (so called hybrid ring-mesh topology),
2888 MAY be defined to be used with the SILC protocol.  Additional
2889 specifications MAY be written on the subject to permeate this
2890 specification.
2891
2892
2893 .ti 0
2894 2.12 Packet Broadcasting
2895
2896 SILC packets MAY be broadcasted in SILC network.  However, only router
2897 server may send or receive broadcast packets.  Client and normal server
2898 MUST NOT send broadcast packets and they MUST ignore broadcast packets
2899 if they receive them.  Broadcast packets are sent by setting Broadcast
2900 flag to the SILC packet header.
2901
2902 Broadcasting packets means that the packet is sent to all routers in
2903 the SILC network, except to the router that sent the packet.  The router
2904 receiving broadcast packet MUST send the packet to its primary route.
2905 The fact that SILC routers may have several router connections can
2906 cause problems, such as race conditions inside the SILC network, if
2907 care is not taken when broadcasting packets.  Router MUST NOT send
2908 the broadcast packet to any other route except to its primary route.
2909
2910 If the primary route of the router is the original sender of the packet
2911 the packet MUST NOT be sent to the primary route.  This may happen
2912 if router has several router connections and some other router uses
2913 the router as its primary route.
2914
2915 Routers use broadcast packets to broadcast for example information
2916 about newly registered clients, servers, channels etc. so that all the
2917 routers may keep these informations up to date.
2918
2919
2920 .ti 0
2921 3 Security Considerations
2922
2923 Security is central to the design of this protocol, and these security
2924 considerations permeate the specification.  Common security considerations
2925 such as keeping private keys truly private and using adequate lengths for
2926 symmetric and asymmetric keys must be followed in order to maintain the
2927 security of this protocol.
2928
2929
2930 .ti 0
2931 4 References
2932
2933 [SILC1]      Riikonen, P., "Secure Internet Live Conferencing (SILC),
2934              Protocol Specification", Internet Draft, May 2002.
2935
2936 [SILC3]      Riikonen, P., "SILC Key Exchange and Authentication
2937              Protocols", Internet Draft, May 2002.
2938
2939 [SILC4]      Riikonen, P., "SILC Commands", Internet Draft, May 2002.
2940
2941 [IRC]        Oikarinen, J., and Reed D., "Internet Relay Chat Protocol",
2942              RFC 1459, May 1993.
2943
2944 [IRC-ARCH]   Kalt, C., "Internet Relay Chat: Architecture", RFC 2810,
2945              April 2000.
2946
2947 [IRC-CHAN]   Kalt, C., "Internet Relay Chat: Channel Management", RFC
2948              2811, April 2000.
2949
2950 [IRC-CLIENT] Kalt, C., "Internet Relay Chat: Client Protocol", RFC
2951              2812, April 2000.
2952
2953 [IRC-SERVER] Kalt, C., "Internet Relay Chat: Server Protocol", RFC
2954              2813, April 2000.
2955
2956 [SSH-TRANS]  Ylonen, T., et al, "SSH Transport Layer Protocol",
2957              Internet Draft.
2958
2959 [PGP]        Callas, J., et al, "OpenPGP Message Format", RFC 2440,
2960              November 1998.
2961
2962 [SPKI]       Ellison C., et al, "SPKI Certificate Theory", RFC 2693,
2963              September 1999.
2964
2965 [PKIX-Part1] Housley, R., et al, "Internet X.509 Public Key
2966              Infrastructure, Certificate and CRL Profile", RFC 2459,
2967              January 1999.
2968
2969 [Schneier]   Schneier, B., "Applied Cryptography Second Edition",
2970              John Wiley & Sons, New York, NY, 1996.
2971
2972 [Menezes]    Menezes, A., et al, "Handbook of Applied Cryptography",
2973              CRC Press 1997.
2974
2975 [OAKLEY]     Orman, H., "The OAKLEY Key Determination Protocol",
2976              RFC 2412, November 1998.
2977
2978 [ISAKMP]     Maughan D., et al, "Internet Security Association and
2979              Key Management Protocol (ISAKMP)", RFC 2408, November
2980              1998.
2981
2982 [IKE]        Harkins D., and Carrel D., "The Internet Key Exchange
2983              (IKE)", RFC 2409, November 1998.
2984
2985 [HMAC]       Krawczyk, H., "HMAC: Keyed-Hashing for Message
2986              Authentication", RFC 2104, February 1997.
2987
2988 [PKCS1]      Kalinski, B., and Staddon, J., "PKCS #1 RSA Cryptography
2989              Specifications, Version 2.0", RFC 2437, October 1998.
2990
2991 [RFC2119]    Bradner, S., "Key Words for use in RFCs to Indicate
2992              Requirement Levels", BCP 14, RFC 2119, March 1997.
2993
2994 [SFTP]       Ylonen T., and Lehtinen S., "Secure Shell File Transfer
2995              Protocol", Internet Draft, March 2001.
2996
2997 [RFC3629]    Yergeau, F., "UTF-8, a transformation format of ISO
2998              10646", RFC 3629, November 2003.
2999
3000
3001 .ti 0
3002 5 Author's Address
3003
3004 .nf
3005 Pekka Riikonen
3006 Snellmaninkatu 34 A 15
3007 70100 Kuopio
3008 Finland
3009
3010 EMail: priikone@iki.fi
3011
3012
3013 .ti 0
3014 6 Full Copyright Statement
3015
3016 Copyright (C) The Internet Society (2003). All Rights Reserved.
3017
3018 This document and translations of it may be copied and furnished to
3019 others, and derivative works that comment on or otherwise explain it
3020 or assist in its implementation may be prepared, copied, published
3021 and distributed, in whole or in part, without restriction of any
3022 kind, provided that the above copyright notice and this paragraph are
3023 included on all such copies and derivative works. However, this
3024 document itself may not be modified in any way, such as by removing
3025 the copyright notice or references to the Internet Society or other
3026 Internet organizations, except as needed for the purpose of
3027 developing Internet standards in which case the procedures for
3028 copyrights defined in the Internet Standards process must be
3029 followed, or as required to translate it into languages other than
3030 English.
3031
3032 The limited permissions granted above are perpetual and will not be
3033 revoked by the Internet Society or its successors or assigns.
3034
3035 This document and the information contained herein is provided on an
3036 "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
3037 TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
3038 BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
3039 HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
3040 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.