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