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