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