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