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