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