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