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