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