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