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