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