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