Merged silc_1_0_branch to trunk.
[silc.git] / doc / draft-riikonen-silc-spec-08.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 11 February 2004
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-spec-08.txt                         11 February 2004
20 Expires: 11 August 2004
21
22 .in 3
23
24 .ce 3
25 Secure Internet Live Conferencing (SILC),
26 Protocol Specification
27 <draft-riikonen-silc-spec-08.txt>
28
29 .ti 0
30 Status of this Memo
31
32 This document is an Internet-Draft and is in full conformance with
33 all provisions of Section 10 of RFC 2026.  Internet-Drafts are
34 working documents of the Internet Engineering Task Force (IETF), its
35 areas, and its working groups.  Note that other groups may also
36 distribute working documents as Internet-Drafts.
37
38 Internet-Drafts are draft documents valid for a maximum of six months
39 and may be updated, replaced, or obsoleted by other documents at any
40 time.  It is inappropriate to use Internet-Drafts as reference
41 material or to cite them other than as "work in progress."
42
43 The list of current Internet-Drafts can be accessed at
44 http://www.ietf.org/ietf/1id-abstracts.txt
45
46 The list of Internet-Draft Shadow Directories can be accessed at
47 http://www.ietf.org/shadow.html
48
49 The distribution of this memo is unlimited.
50
51
52 .ti 0
53 Abstract
54
55 This memo describes a Secure Internet Live Conferencing (SILC)
56 protocol which provides secure conferencing services over insecure
57 network channel.  SILC provides advanced and feature rich conferencing
58 services with security as main design principal.  Strong cryptographic
59 methods are used to protect SILC packets inside the SILC network.
60 Three other specifications relates very closely to this memo;
61 SILC Packet Protocol [SILC2], SILC Key Exchange and Authentication
62 Protocols [SILC3] and SILC Commands [SILC4].
63
64
65
66
67
68
69 .ti 0
70 Table of Contents
71
72 .nf
73 1 Introduction ..................................................  3
74   1.1 Requirements Terminology ..................................  4
75 2 SILC Concepts .................................................  4
76   2.1 SILC Network Topology .....................................  5
77   2.2 Communication Inside a Cell ...............................  6
78   2.3 Communication in the Network ..............................  7
79   2.4 Channel Communication .....................................  7
80   2.5 Router Connections ........................................  8
81 3 SILC Specification ............................................  9
82   3.1 Client ....................................................  9
83       3.1.1 Client ID ...........................................  9
84   3.2 Server .................................................... 10
85       3.2.1 Server's Local ID List .............................. 11
86       3.2.2 Server ID ........................................... 12
87       3.2.3 SILC Server Ports ................................... 12
88   3.3 Router .................................................... 13
89       3.3.1 Router's Local ID List .............................. 13
90       3.3.2 Router's Global ID List ............................. 14
91       3.3.3 Router's Server ID .................................. 14
92   3.4 Channels .................................................. 15
93       3.4.1 Channel ID .......................................... 16
94   3.5 Operators ................................................. 16
95   3.6 SILC Commands ............................................. 17
96   3.7 SILC Packets .............................................. 17
97   3.8 Packet Encryption ......................................... 17
98       3.8.1 Determination of the Source and the Destination ..... 18
99       3.8.2 Client To Client .................................... 19
100       3.8.3 Client To Channel ................................... 20
101       3.8.4 Server To Server .................................... 21
102   3.9 Key Exchange And Authentication ........................... 21
103       3.9.1 Authentication Payload .............................. 21
104   3.10 Algorithms ............................................... 23
105       3.10.1 Ciphers ............................................ 23
106              3.10.1.1 CBC Mode .................................. 24
107              3.10.1.2 CTR Mode .................................. 24
108              3.10.1.3 Randomized CBC Mode ....................... 26
109       3.10.2 Public Key Algorithms .............................. 26
110              3.10.2.1 Multi-Precision Integers .................. 27
111       3.10.3 Hash Functions ..................................... 27
112       3.10.4 MAC Algorithms ..................................... 27
113       3.10.5 Compression Algorithms ............................. 28
114   3.11 SILC Public Key .......................................... 28
115   3.12 SILC Version Detection ................................... 31
116   3.13 UTF-8 Strings in SILC .................................... 31
117       3.13.1 UTF-8 Identifier Strings ........................... 32
118   3.14 Backup Routers ........................................... 33
119       3.14.1 Switching to Backup Router ......................... 35
120       3.14.2 Resuming Primary Router ............................ 36
121 4 SILC Procedures ............................................... 38
122   4.1 Creating Client Connection ................................ 38
123   4.2 Creating Server Connection ................................ 40
124       4.2.1 Announcing Clients, Channels and Servers ............ 40
125   4.3 Joining to a Channel ...................................... 42
126   4.4 Channel Key Generation .................................... 43
127   4.5 Private Message Sending and Reception ..................... 44
128   4.6 Private Message Key Generation ............................ 44
129   4.7 Channel Message Sending and Reception ..................... 45
130   4.8 Session Key Regeneration .................................. 46
131   4.9 Command Sending and Reception ............................. 46
132   4.10 Closing Connection ....................................... 47
133   4.11 Detaching and Resuming a Session ......................... 48
134 5 Security Considerations ....................................... 49
135 6 References .................................................... 50
136 7 Author's Address .............................................. 52
137 Appendix A ...................................................... 52
138 Appendix B ...................................................... 54
139 Full Copyright Statement ........................................ 54
140
141 .ti 0
142 List of Figures
143
144 .nf
145 Figure 1:  SILC Network Topology
146 Figure 2:  Communication Inside cell
147 Figure 3:  Communication Between Cells
148 Figure 4:  Router Connections
149 Figure 5:  SILC Public Key
150 Figure 6:  Counter Block
151
152
153 .ti 0
154 1. Introduction
155
156 This document describes a Secure Internet Live Conferencing (SILC)
157 protocol which provides secure conferencing services over insecure
158 network channel.  SILC can be used as a secure conferencing service
159 that provides rich conferencing features.  Some of the SILC features
160 are found in traditional chat protocols such as IRC [IRC] but many
161 of the SILC features can also be found in Instant Message (IM) style
162 protocols.  SILC combines features from both of these chat protocol
163 styles, and can be implemented as either IRC-like system or IM-like
164 system.  Some of the more advanced and secure features of the
165 protocol are new to all conferencing protocols.  SILC also supports
166 multimedia messages and can also be implemented as a video and audio
167 conferencing system.
168
169 Strong cryptographic methods are used to protect SILC packets inside
170 the SILC network.  Three other specifications relates very closely
171 to this memo; SILC Packet Protocol [SILC2], SILC Key Exchange and
172 Authentication Protocols [SILC3] and SILC Commands [SILC4].
173
174 The protocol uses extensively packets as conferencing protocol
175 requires message and command sending.  The SILC Packet Protocol is
176 described in [SILC2] and should be read to fully comprehend this
177 document and protocol.  [SILC2] also describes the packet encryption
178 and decryption in detail.  The SILC Packet Protocol provides secured
179 and authenticated packets, and the protocol is designed to be compact.
180 This makes SILC also suitable in environment of low bandwidth
181 requirements such as mobile networks.  All packet payloads in SILC
182 can be also compressed.
183
184 The security of SILC protocol sessions are based on strong and secure
185 key exchange protocol.  The SILC Key Exchange protocol is described
186 in [SILC3] along with connection authentication protocol and should
187 be read to fully comprehend this document and protocol.
188
189 The SILC protocol has been developed to work on TCP/IP network
190 protocol, although it could be made to work on other network protocols
191 with only minor changes.  However, it is recommended that TCP/IP
192 protocol is used under SILC protocol.  Typical implementation would
193 be made in client-server model.
194
195
196 .ti 0
197 1.1 Requirements Terminology
198
199 The keywords MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED,
200 MAY, and OPTIONAL, when they appear in this document, are to be
201 interpreted as described in [RFC2119].
202
203
204 .ti 0
205 2. SILC Concepts
206
207 This section describes various SILC protocol concepts that forms the
208 actual protocol, and in the end, the actual SILC network.  The mission
209 of the protocol is to deliver messages from clients to other clients
210 through routers and servers in secure manner.  The messages may also
211 be delivered from one client to many clients forming a group, also
212 known as a channel.
213
214 This section does not focus to security issues.  Instead, basic network
215 concepts are introduced to make the topology of the SILC network
216 clear.
217
218
219
220 .ti 0
221 2.1 SILC Network Topology
222
223 SILC network forms a ring as opposed to tree style network topology that
224 conferencing protocols usually have.  The network has a cells which are
225 constructed from a router and zero or more servers.  The servers are
226 connected to the router in a star like network topology.  Routers in the
227 network are connected to each other forming a ring.  The rationale for
228 this is to have servers that can perform specific kind of tasks what
229 other servers cannot perform.  This leads to two kinds of servers; normal
230 SILC servers and SILC router servers.
231
232 A difference between normal server and router server is that routers
233 knows all global information and keep the global network state up to date.
234 They also do the actual routing of the messages to the correct receiver
235 between other cells.  Normal servers knows only local information and
236 receive global information only when it is needed.  They do not need to
237 keep the global network state up to date.  This makes the network faster
238 and scalable as there are less servers that needs to maintain global
239 network state.
240
241 This, on the other hand, leads into a cellular like network, where
242 routers are in the center of the cell and servers are connected to the
243 router.
244
245 The following diagram represents SILC network topology.
246
247 .in 8
248 .nf
249   ---- ---- ----         ---- ---- ----
250  | S8 | S5 | S4 |       | S7 | S5 | S6 |
251  ----- ---- -----       ----- ---- -----
252 | S7 | S/R1 | S2 | --- | S8 | S/R2 | S4 |
253  ---- ------ ----       ---- ------ ----
254  | S6 | S3 | S1 |       | S1 | S3 | S2 |         ---- ----
255   ---- ---- ----         ---- ---- ----         | S3 | S1 |
256      Cell 1.   \\             Cell 2.  | \\____  ----- -----
257                 |                     |        | S4 | S/R4 |
258     ---- ---- ----         ---- ---- ----       ---- ------
259    | S7 | S4 | S2 |       | S1 | S3 | S2 |      | S2 | S5 |
260    ----- ---- -----       ----- ---- -----       ---- ----
261   | S6 | S/R3 | S1 | --- | S4 | S/R5 | S5 | ____/ Cell 4.
262    ---- ------ ----       ---- ------ ----
263    | S8 | S5 | S3 |       | S6 | S7 | S8 |     ... etc ...
264     ---- ---- ----         ---- ---- ----
265        Cell 3.                Cell 5.
266 .in 3
267
268 .ce
269 Figure 1:  SILC Network Topology
270
271
272 A cell is formed when a server or servers connect to one router.  In
273 SILC network normal server cannot directly connect to other normal
274 server.  Normal server may only connect to SILC router which then
275 routes the messages to the other servers in the cell.  Router servers
276 on the other hand may connect to other routers to form the actual SILC
277 network, as seen in above figure.  However, router is also able to act
278 as normal SILC server; clients may connect to it the same way as to
279 normal SILC server.  Normal server also cannot have active connections
280 to more than one router.  Normal server cannot be connected to two
281 different cells.  Router servers, on the other hand, may have as many
282 router to router connections as needed.  Other direct routes between
283 other routers is also possible in addition of the mandatory ring
284 connections.  This leads into a hybrid ring-mesh network topology.
285
286 There are many issues in this network topology that needs to be careful
287 about.  Issues like routing, the size of the cells, the number of the
288 routers in the SILC network and the capacity requirements of the
289 routers.  These issues should be discussed in the Internet Community
290 and additional documents on the issue may be written.
291
292
293 .ti 0
294 2.2 Communication Inside a Cell
295
296 It is always guaranteed that inside a cell message is delivered to the
297 recipient with at most two server hops.  A client which is connected to
298 server in the cell and is talking on channel to other client connected
299 to other server in the same cell, will have its messages delivered from
300 its local server first to the router of the cell, and from the router
301 to the other server in the cell.
302
303 The following diagram represents this scenario:
304
305
306 .in 25
307 .nf
308 1 --- S1     S4 --- 5
309          S/R
310  2 -- S2     S3
311      /        |
312     4         3
313 .in 3
314
315
316 .ce
317 Figure 2:  Communication Inside cell
318
319
320 Example:  Client 1. connected to Server 1. send message to
321           Client 4. connected to Server 2. travels from Server 1.
322           first to Router which routes the message to Server 2.
323           which then sends it to the Client 4.  All the other
324           servers in the cell will not see the routed message.
325
326
327 If the client is connected directly to the router, as router is also normal
328 SILC server, the messages inside the cell are always delivered only with
329 one server hop.  If clients communicating with each other are connected
330 to the same server, no router interaction is needed.  This is the optimal
331 situation of message delivery in the SILC network.
332
333
334 .ti 0
335 2.3 Communication in the Network
336
337 If the message is destined to client that does not belong to local cell
338 the message is routed to the router server to which the destination
339 client belongs, if the local router is connected to destination router.
340 If there is no direct connection to the destination router, the local
341 router routes the message to its primary route.  The following diagram
342 represents message sending between cells.
343
344
345
346 .in 16
347 .nf
348 1 --- S1     S4 --- 5            S2 --- 1
349          S/R - - - - - - - - S/R
350  2 -- S2     S3           S1
351      /        |             \\
352     4         3              2
353
354    Cell 1.               Cell 2.
355 .in 3
356
357
358 .ce
359 Figure 3:  Communication Between Cells
360
361
362 Example:  Client 5. connected to Server 4. in Cell 1. sends message
363           to Client 2. connected to Server 1. in Cell 2. travels
364           from Server 4. to Router which routes the message to
365           Router in Cell 2, which then routes the message to
366           Server 1.  All the other servers and routers in the
367           network will not see the routed message.
368
369
370 The optimal case of message delivery from the client point of view is
371 when clients are connected directly to the routers and the messages
372 are delivered from one router to the other.
373
374
375 .ti 0
376 2.4 Channel Communication
377
378 Messages may be sent to group of clients as well.  Sending messages to
379 many clients works the same way as sending messages point to point, from
380 message delivery point of view.  Security issues are another matter
381 which are not discussed in this section.
382
383 Router server handles the message routing to multiple recipients.  If
384 any recipient is not in the same cell as the sender the messages are
385 routed further.
386
387 Server distributes the channel message to its local clients which are
388 joined to the channel.  Router also distributes the message to its
389 local clients on the channel.
390
391
392 .ti 0
393 2.5 Router Connections
394
395 Router connections play very important role in making the SILC like
396 network topology to work.  For example, sending broadcast packets in
397 SILC network require special connections between routers; routers must
398 be connected in a specific way.
399
400 Every router has their primary route which is a connection to another
401 router in the network.  Unless there is only two routers in the network
402 must not routers use each other as their primary routes.  The router
403 connections in the network must form a ring.
404
405 Example with three routers in the network:
406
407
408 .in 16
409 .nf
410     S/R1 - < - < - < - < - < - < - S/R2
411      \\                               /
412       v                             ^
413        \\ - > -  > - S/R3 - > - > - /
414 .in 3
415
416
417 .ce
418 Figure 4:  Router Connections
419
420
421 Example:  Network with three routers.  Router 1. uses Router 2. as its
422           primary router.  Router 2. uses Router 3. as its primary router,
423           and Router 3. uses Router 1. as its primary router.  There may
424           be other direct connections between the routers but they must
425           not be used as primary routes.
426
427 The above example is applicable to any amount of routers in the network
428 except for two routers.  If there are only two routers in the network both
429 routers must be able to handle situation where they use each other as their
430 primary routes.
431
432 The issue of router connections are very important especially with SILC
433 broadcast packets.  Usually all router wide information in the network is
434 distributed by SILC broadcast packets.  This sort of ring network, with
435 ability to have other direct routes in the network can cause interesting
436 routing problems.  The [SILC2] discusses the routing of packets in this
437 sort of network in more detail.
438
439
440 .ti 0
441 3. SILC Specification
442
443 This section describes the SILC protocol.  However, [SILC2] and
444 [SILC3] describes other important protocols that are part of this SILC
445 specification and must be read.
446
447
448 .ti 0
449 3.1 Client
450
451 A client is a piece of software connecting to SILC server.  SILC client
452 cannot be SILC server.  Purpose of clients is to provide the user
453 interface of the SILC services for end user.  Clients are distinguished
454 from other clients by unique Client ID.  Client ID is a 128 bit ID that
455 is used in the communication in the SILC network.  The client ID is
456 based on the user's IP address and nickname.  User use logical nicknames
457 in communication which are then mapped to the corresponding Client ID.
458 Client IDs are low level identifications and should not be seen by the
459 end user.
460
461 Clients provide other information about the end user as well. Information
462 such as the nickname of the user, username and the host name of the end
463 user and user's real name.  See section 3.2 Server for information of
464 the requirements of keeping this information.
465
466 The nickname selected by the user is not unique in the SILC network.
467 There can be 2^8 same nicknames for one IP address.  As for comparison to
468 IRC [IRC] where nicknames are unique this is a fundamental difference
469 between SILC and IRC.  This typically causes the server names or client's
470 host names to be used along with the nicknames on user interface to
471 identify specific users when sending messages.  This feature of SILC
472 makes IRC style nickname-wars obsolete as no one owns their nickname;
473 there can always be someone else with the same nickname.  Also, any kind
474 of nickname registering service becomes obsolete.  See the section 3.13.1
475 for more information about nicknames.
476
477
478 .ti 0
479 3.1.1 Client ID
480
481 Client ID is used to identify users in the SILC network.  The Client ID
482 is unique to the extent that there can be 2^128 different Client IDs,
483 and IDs based on IPv6 addresses extends this to 2^224 different Client
484 IDs.  Collisions are not expected to happen.  The Client ID is defined
485 as follows.
486
487 .in 6
488 128 bit Client ID based on IPv4 addresses:
489
490 32 bit  Server ID IP address (bits 1-32)
491  8 bit  Random number or counter
492 88 bit  Truncated MD5 hash value of the nickname
493
494 224 bit Client ID based on IPv6 addresses:
495
496 128 bit  Server ID IP address (bits 1-128)
497   8 bit  Random number or counter
498  88 bit  Truncated MD5 hash value of the nickname
499
500 o Server ID IP address - Indicates the server where this
501   client is coming from.  The IP address hence equals the
502   server IP address where the client is connected.
503
504 o Random number or counter - Random number to further
505   randomize the Client ID.  Another choice is to use
506   a counter starting from the zero (0).  This makes it
507   possible to have 2^8 same nicknames from the same
508   server IP address.
509
510 o MD5 hash - MD5 hash value of the case folded nickname is
511   truncated taking 88 bits from the start of the hash value.
512   This hash value is used to search the user's Client ID
513   from the ID lists.  Note that the nickname MUST be prepared
514   using the stringprep [RFC3454] profile described in the
515   Appendix A before computing the MD5 hash.  See also the
516   section 3.13.1 for more information.
517
518 .in 3
519 Collisions could occur when more than 2^8 clients using same nickname
520 from the same server IP address is connected to the SILC network.
521 Server MUST be able to handle this situation by refusing to accept
522 anymore of that nickname.
523
524 Another possible collision may happen with the truncated hash value of
525 the nickname.  It could be possible to have same truncated hash value
526 for two different nicknames.  However, this is not expected to happen
527 nor cause any serious problems if it would occur.  Nicknames are usually
528 logical and it is unlikely to have two distinct logical nicknames
529 produce same truncated hash value.
530
531
532 .ti 0
533 3.2 Server
534
535 Servers are the most important parts of the SILC network.  They form the
536 basis of the SILC, providing a point to which clients may connect to.
537 There are two kinds of servers in SILC; normal servers and router servers.
538 This section focus on the normal server and router server is described
539 in the section 3.3 Router.
540
541 Normal servers MUST NOT directly connect to other normal server.  Normal
542 servers may only directly connect to router server.  If the message sent
543 by the client is destined outside the local server it is always sent to
544 the router server for further routing.  Server may only have one active
545 connection to router on same port.  Normal server MUST NOT connect to other
546 cell's router except in situations where its cell's router is unavailable.
547
548
549 .ti 0
550 3.2.1 Server's Local ID List
551
552 Normal server keeps various information about the clients and their end
553 users connected to it.  Every normal server MUST keep list of all locally
554 connected clients, Client IDs, nicknames, usernames and host names and
555 user's real name.  Normal servers only keeps local information and it
556 does not keep any global information.  Hence, normal servers knows only
557 about their locally connected clients.  This makes servers efficient as
558 they do not have to worry about global clients.  Server is also responsible
559 of creating the Client IDs for their clients.
560
561 Normal server also keeps information about locally created channels and
562 their Channel IDs.
563
564 Hence, local list for normal server includes:
565
566 .in 6
567 server list        - Router connection
568    o Server name
569    o Server IP address
570    o Server ID
571    o Sending key
572    o Receiving key
573    o Public key
574
575 client list        - All clients in server
576    o Nickname
577    o Username@host
578    o Real name
579    o Client ID
580    o Sending key
581    o Receiving key
582    o Public key
583
584 channel list       - All channels in server
585    o Channel name
586    o Channel ID
587    o Client IDs on channel
588    o Client ID modes on channel
589    o Channel key
590 .in 3
591
592
593 .ti 0
594 3.2.2 Server ID
595
596 Servers are distinguished from other servers by unique 64 bit Server ID
597 (for IPv4) or 160 bit Server ID (for IPv6).  The Server ID is used in
598 the SILC to route messages to correct servers.  Server IDs also provide
599 information for Client IDs, see section 3.1.1 Client ID.  Server ID is
600 defined as follows.
601
602 .in 6
603 64 bit Server ID based on IPv4 addresses:
604
605 32 bit  IP address of the server
606 16 bit  Port
607 16 bit  Random number
608
609 160 bit Server ID based on IPv6 addresses:
610
611 128 bit  IP address of the server
612  16 bit  Port
613  16 bit  Random number
614
615 o IP address of the server - This is the real IP address of
616   the server.
617
618 o Port - This is the port the server is bound to.
619
620 o Random number - This is used to further randomize the Server ID.
621
622 .in 3
623 Collisions are not expected to happen in any conditions.  The Server ID
624 is always created by the server itself and server is responsible of
625 distributing it to the router.
626
627
628 .ti 0
629 3.2.3 SILC Server Ports
630
631 The following ports has been assigned by IANA for the SILC protocol:
632
633 .in 10
634 silc            706/tcp    SILC
635 silc            706/udp    SILC
636 .in 3
637
638
639 If there are needs to create new SILC networks in the future the port
640 numbers must be officially assigned by the IANA.
641
642 Server on network above privileged ports (>1023) SHOULD NOT be trusted
643 as they could have been set up by untrusted party.
644
645
646 .ti 0
647 3.3 Router
648
649 Router server in SILC network is responsible for keeping the cell together
650 and routing messages to other servers and to other routers.  Router server
651 is also a normal server thus clients may connect to it as it would be
652 just normal SILC server.
653
654 However, router servers has a lot of important tasks that normal servers
655 do not have.  Router server knows everything and keeps the global state.
656 They know all clients currently on SILC, all servers and routers and all
657 channels in SILC.  Routers are the only servers in SILC that care about
658 global information and keeping them up to date at all time.
659
660
661 .ti 0
662 3.3.1 Router's Local ID List
663
664 Router server as well MUST keep local list of connected clients and
665 locally created channels.  However, this list is extended to include all
666 the informations of the entire cell, not just the server itself as for
667 normal servers.
668
669 However, on router this list is a lot smaller since routers do not need
670 to keep information about user's nickname, username and host name and real
671 name since these are not needed by the router.  The router keeps only
672 information that it needs.
673
674 Hence, local list for router includes:
675
676 .in 6
677 server list        - All servers in the cell
678    o Server name
679    o Server ID
680    o Router's Server ID
681    o Sending key
682    o Receiving key
683
684 client list        - All clients in the cell
685    o Client ID
686
687 channel list       - All channels in the cell
688    o Channel ID
689    o Client IDs on channel
690    o Client ID modes on channel
691    o Channel key
692 .in 3
693
694
695 Note that locally connected clients and other information include all the
696 same information as defined in section section 3.2.1 Server's Local ID
697 List.  Router MAY also cache same detailed information for other clients
698 if needed.
699
700
701 .ti 0
702 3.3.2 Router's Global ID List
703
704 Router server MUST also keep global list.  Normal servers do not have
705 global list as they know only about local information.  Global list
706 includes all the clients on SILC, their Client IDs, all created channels
707 and their Channel IDs and all servers and routers on SILC and their
708 Server IDs.  That is said, global list is for global information and the
709 list must not include the local information already on the router's local
710 list.
711
712 Note that the global list does not include information like nicknames,
713 usernames and host names or user's real names.  Router does not need to
714 keep these informations as they are not needed by the router.  This
715 information is available from the client's server which maybe queried
716 when needed.
717
718 Hence, global list includes:
719
720 .in 6
721 server list        - All servers in SILC
722    o Server name
723    o Server ID
724    o Router's Server ID
725
726 client list        - All clients in SILC
727    o Client ID
728
729 channel list       - All channels in SILC
730    o Channel ID
731    o Client IDs on channel
732    o Client ID modes on channel
733 .in 3
734
735
736
737 .ti 0
738 3.3.3 Router's Server ID
739
740 Router's Server ID is equivalent to normal Server ID.  As routers are
741 normal servers same types of IDs applies for routers as well.  See
742 section 3.2.2 Server ID.
743
744
745
746
747 .ti 0
748 3.4 Channels
749
750 A channel is a named group of one or more clients which will all receive
751 messages addressed to that channel.  The channel is created when first
752 client requests JOIN command to the channel, and the channel ceases to
753 exist when the last client has left it.  When channel exists, any client
754 can reference it using the Channel ID of the channel.  If the channel has
755 a founder mode set and last client leaves the channel the channel does
756 not cease to exist.  The founder mode can be used to make permanent
757 channels in the network.  The founder of the channel can regain the
758 channel founder privileges on the channel later when he joins the
759 channel.
760
761 Channel names are unique although the real uniqueness comes from 64 bit
762 Channel ID.  However, channel names are still unique and no two global
763 channels with same name may exist.  See the section 3.13.1 for more
764 information about channel names.
765
766 Channels can have operators that can administrate the channel and operate
767 all of its modes.  The following operators on channel exist on the
768 SILC network.
769
770 .in 6
771 o Channel founder - When channel is created the joining client becomes
772   channel founder.  Channel founder is channel operator with some more
773   privileges.  Basically, channel founder can fully operate the channel
774   and all of its modes.  The privileges are limited only to the
775   particular channel.  There can be only one channel founder per
776   channel.  Channel founder supersedes channel operator's privileges.
777
778   Channel founder privileges cannot be removed by any other operator on
779   channel.  When channel founder leaves the channel there is no channel
780   founder on the channel.  However, it is possible to set a mode for
781   the channel which allows the original channel founder to regain the
782   founder privileges even after leaving the channel.  Channel founder
783   also cannot be removed by force from the channel.
784
785 o Channel operator - When client joins to channel that has not existed
786   previously it will become automatically channel operator (and channel
787   founder discussed above).  Channel operator is able to administrate the
788   channel, set some modes on channel, remove a badly behaving client
789   from the channel and promote other clients to become channel
790   operator.  The privileges are limited only to the particular channel.
791
792   Normal channel user may be promoted (opped) to channel operator
793   gaining channel operator privileges.  Channel founder or other
794   channel operator may also demote (deop) channel operator to normal
795   channel user.
796 .in 3
797
798
799
800
801 .ti 0
802 3.4.1 Channel ID
803
804 Channels are distinguished from other channels by unique Channel ID.
805 The Channel ID is a 64 bit ID (for IPv4) or 160 bit ID (for IPv6), and
806 collisions are not expected to happen in any conditions.  Channel names
807 are just for logical use of channels.  The Channel ID is created by the
808 server where the channel is created.  The Channel ID is defined as
809 follows.
810
811 .in 6
812 64 bit Channel ID based on IPv4 addresses:
813
814 32 bit  Router's Server ID IP address (bits 1-32)
815 16 bit  Router's Server ID port (bits 33-48)
816 16 bit  Random number or counter
817
818 160 bit Channel ID based on IPv6 addresses:
819
820 128 bit  Router's Server ID IP address (bits 1-128)
821  16 bit  Router's Server ID port (bits 129-144)
822  16 bit  Random number or counter
823
824 o Router's Server ID IP address - Indicates the IP address of
825   the router of the cell where this channel is created.  This is
826   taken from the router's Server ID.  This way SILC router knows
827   where this channel resides in the SILC network.
828
829 o Router's Server ID port - Indicates the port of the channel on
830   the server.  This is taken from the router's Server ID.
831
832 o Random number or counter - To further randomize the Channel ID.
833   Another choice is to use a counter starting from zero (0).
834   This makes sure that there are no collisions.  This also means
835   that in a cell there can be 2^16 different channels.
836 .in 3
837
838
839 .ti 0
840 3.5 Operators
841
842 Operators are normal users with extra privileges to their server or
843 router.  Usually these people are SILC server and router administrators
844 that take care of their own server and clients on them.  The purpose of
845 operators is to administrate the SILC server or router.  However, even
846 an operator with highest privileges is not able to enter invite-only
847 channels, to gain access to the contents of encrypted and authenticated
848 packets traveling in the SILC network or to gain channel operator
849 privileges on public channels without being promoted.  They have the
850 same privileges as any normal user except they are able to administrate
851 their server or router.
852
853
854 .ti 0
855 3.6 SILC Commands
856
857 Commands are very important part on SILC network especially for client
858 which uses commands to operate on the SILC network.  Commands are used
859 to set nickname, join to channel, change modes and many other things.
860
861 Client usually sends the commands and server replies by sending a reply
862 packet to the command.  Server MAY also send commands usually to serve
863 the original client's request.  Usually server cannot send commands to
864 clients, however there MAY be commands that allow the server to send
865 commands to client.  By default servers MAY send commands only to other
866 servers and routers.
867
868 Note that the command reply is usually sent only after client has sent
869 the command request but server is allowed to send command reply packet
870 to client even if client has not requested the command.  Client MAY
871 choose to ignore the command reply.
872
873 It is expected that some of the commands may be misused by clients
874 resulting various problems on the server side.  Every implementation
875 SHOULD assure that commands may not be executed more than once, say,
876 in two (2) seconds.  However, to keep response rate up, allowing for
877 example five (5) commands before limiting is allowed.  It is RECOMMENDED
878 that commands such as SILC_COMMAND_NICK, SILC_COMMAND_JOIN,
879 SILC_COMMAND_LEAVE and SILC_COMMAND_KILL SHOULD be limited in all cases
880 as they require heavy operations.  This should be sufficient to prevent
881 the misuse of commands.
882
883 SILC commands are described in [SILC4].
884
885
886 .ti 0
887 3.7 SILC Packets
888
889 Packets are naturally the most important part of the protocol and the
890 packets are what actually makes the protocol.  Packets in SILC network
891 are always encrypted using, usually the shared secret session key
892 or some other key, for example, channel key, when encrypting channel
893 messages.  It is not possible to send a packet in SILC network without
894 encryption.  The SILC Packet Protocol is a wide protocol and is described
895 in [SILC2].  This document does not define or describe details of
896 SILC packets.
897
898
899 .ti 0
900 3.8 Packet Encryption
901
902 All packets passed in SILC network MUST be encrypted.  This section
903 gives generic description of how packets must be encrypted in the SILC
904 network.  The detailed description of the actual encryption process
905 of the packets are described in [SILC2].
906
907 Client and its server shares secret symmetric session key which is
908 established by the SILC Key Exchange Protocol, described in [SILC3].
909 Every packet sent from client to server, with exception of packets for
910 channels, are encrypted with this session key.
911
912 Channels have a channel key that are shared by every client on the channel.
913 However, the channel keys are cell specific thus one cell does not know
914 the channel key of the other cell, even if that key is for same channel.
915 Channel key is also known by the routers and all servers that have clients
916 on the channel.  However, channels MAY have channel private keys that are
917 entirely local setting for the client.  All clients on the channel MUST
918 know the channel private key beforehand to be able to talk on the
919 channel.  In this case, no server or router knows the key for the channel.
920
921 Server shares secret symmetric session key with router which is
922 established by the SILC Key Exchange Protocol.  Every packet passed from
923 server to router, with exception of packets for channels, are encrypted
924 with the shared session key.  Same way, router server shares secret
925 symmetric key with its primary router.  However, every packet passed
926 from router to other router, including packets for channels, are
927 encrypted with the shared session key.  Every router connection MUST
928 have their own session keys.
929
930
931 .ti 0
932 3.8.1 Determination of the Source and the Destination
933
934 The source and the destination of the packet needs to be determined
935 to be able to route the packets to correct receiver.  This information
936 is available in the SILC Packet Header which is included in all packets
937 sent in SILC network.  The SILC Packet Header is described in [SILC2].
938
939 The header MUST be encrypted with the session key of whom is the next
940 receiver of the packet along the route.  The receiver of the packet, for
941 example a router along the route, is able to determine the sender and the
942 destination of the packet by decrypting the SILC Packet Header and
943 checking the IDs attached to the header.  The IDs in the header will
944 tell to where the packet needs to be sent and where it is coming from.
945
946 The header in the packet MUST NOT change during the routing of the
947 packet.  The original sender, for example client, assembles the packet
948 and the packet header and server or router between the sender and the
949 receiver MUST NOT change the packet header.  Note however, that some
950 packets such as commands may be resent by a server to serve the client's
951 original command.  In this case the command packet sent by the server
952 includes the server's IDs as it is a different packet.  When server
953 or router receives a packet it MUST verify that the Source ID is
954 valid and correct ID for that sender.
955
956 Note that the packet and the packet header may be encrypted with
957 different keys.  For example, packets to channels are encrypted with
958 the channel key, however, the header is encrypted with the session key
959 as described above.  However, the header and the packet may be encrypted
960 with same key.  This is the case, for example, with command packets.
961
962
963 .ti 0
964 3.8.2 Client To Client
965
966 The process of message delivery and encryption from client to another
967 client is as follows.
968
969 Example:  Private message from client to another client on different
970           servers.  Clients do not share private message delivery
971           keys; normal session keys are used.
972
973 o Client 1 sends encrypted packet to its server.  The packet is
974   encrypted with the session key shared between client and its
975   server.
976
977 o Server determines the destination of the packet and decrypts
978   the packet.  Server encrypts the packet with session key shared
979   between the server and its router, and sends the packet to the
980   router.
981
982 o Router determines the destination of the packet and decrypts
983   the packet.  Router encrypts the packet with session key
984   shared between the router and the destination server, and sends
985   the packet to the server.
986
987 o Server determines the client to which the packet is destined
988   to and decrypts the packet.  Server encrypts the packet with
989   session key shared between the server and the destination client,
990   and sends the packet to the client.
991
992 o Client 2 decrypts the packet.
993
994
995 Example:  Private message from client to another client on different
996           servers.  Clients have established a secret shared private
997           message delivery key with each other and that is used in
998           the message encryption.
999
1000 o Client 1 sends encrypted packet to its server.  The packet header
1001   is encrypted with the session key shared between the client and
1002   server, and the private message is encrypted with the private
1003   message delivery key shared between clients.
1004
1005 o Server determines the destination of the packet and sends the
1006   packet to the router.  Header is encrypted with the session key.
1007
1008 o Router determines the destination of the packet and sends the
1009   packet to the server.  Header is encrypted with the session key.
1010
1011 o Server determines the client to which the packet is destined
1012   to and sends the packet to the client.  Header is encrypted with
1013   the session key.
1014
1015 o Client 2 decrypts the packet with the secret shared key.
1016
1017 If clients share secret key with each other the private message
1018 delivery is much simpler since servers and routers between the
1019 clients do not need to decrypt and re-encrypt the entire packet.
1020 The packet header however is always encrypted with session key and
1021 is decrypted and re-encrypted with the session key of next recipient.
1022
1023 The process for clients on same server is much simpler as there is
1024 no need to send the packet to the router.  The process for clients
1025 on different cells is same as above except that the packet is routed
1026 outside the cell.  The router of the destination cell routes the
1027 packet to the destination same way as described above.
1028
1029
1030 .ti 0
1031 3.8.3 Client To Channel
1032
1033 Process of message delivery from client on channel to all the clients
1034 on the channel.
1035
1036 Example:  Channel of four users; two on same server, other two on
1037           different cells.  Client sends message to the channel.
1038           Packet header is encrypted with the session key, message
1039           data is encrypted with channel key.
1040
1041 o Client 1 encrypts the packet with channel key and sends the
1042   packet to its server.
1043
1044 o Server determines local clients on the channel and sends the
1045   packet to the Client on the same server.  Server then sends
1046   the packet to its router for further routing.
1047
1048 o Router determines local clients on the channel, if found
1049   sends packet to the local clients.  Router determines global
1050   clients on the channel and sends the packet to its primary
1051   router or fastest route.
1052
1053 o (Other router(s) do the same thing and sends the packet to
1054    the server(s).)
1055
1056 o Server determines local clients on the channel and sends the
1057   packet to the client.
1058
1059 o All clients receiving the packet decrypts it.
1060
1061
1062 .ti 0
1063 3.8.4 Server To Server
1064
1065 Server to server packet delivery and encryption is described in above
1066 examples. Router to router packet delivery is analogous to server to
1067 server.  However, some packets, such as channel packets, are processed
1068 differently.  These cases are described later in this document and
1069 more in detail in [SILC2].
1070
1071
1072 .ti 0
1073 3.9 Key Exchange And Authentication
1074
1075 Key exchange is done always when for example client connects to server
1076 but also when server and router, and router and another router connect
1077 to each other.  The purpose of key exchange protocol is to provide secure
1078 key material to be used in the communication.  The key material is used
1079 to derive various security parameters used to secure SILC packets.  The
1080 SILC Key Exchange protocol is described in detail in [SILC3].
1081
1082 Authentication is done after key exchange protocol has been successfully
1083 completed.  The purpose of authentication is to authenticate for example
1084 client connecting to the server.  However, clients MAY be accepted
1085 to connect to server without explicit authentication.  Servers are
1086 REQUIRED to use authentication protocol when connecting.  The
1087 authentication may be based on passphrase (pre-shared secret) or public
1088 key based on digital signatures.  All passphrases sent in SILC protocol
1089 MUST be UTF-8 [RFC3629] encoded. The connection authentication protocol
1090 is described in detail in [SILC3].
1091
1092
1093 .ti 0
1094 3.9.1 Authentication Payload
1095
1096 Authentication Payload is used separately from the SKE and the Connection
1097 Authentication protocols.  It can be used during the session to
1098 authenticate with a remote.  For example, a client can authenticate
1099 itself to a server to become server operator.  In this case,
1100 Authentication Payload is used.
1101
1102 The format of the Authentication Payload is as follows:
1103
1104 .in 5
1105 .nf
1106                      1                   2                   3
1107  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
1108 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1109 |        Payload Length         |     Authentication Method     |
1110 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1111 |      Public Data Length       |                               |
1112 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1113 |                                                               |
1114 ~                           Public Data                         ~
1115 |                                                               |
1116 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1117 |   Authentication Data Length  |                               |
1118 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1119 |                                                               |
1120 ~                       Authentication Data                     ~
1121 |                                                               |
1122 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1123 .in 3
1124
1125 .ce
1126 Figure 5:  Authentication Payload
1127
1128
1129 .in 6
1130 o Payload Length (2 bytes) - Length of the entire payload.
1131
1132 o Authentication Method (2 bytes) - The method of the
1133   authentication.  The authentication methods are defined
1134   in [SILC2] in the Connection Auth Request Payload.  The NONE
1135   authentication method SHOULD NOT be used.
1136
1137 o Public Data Length (2 bytes) - Indicates the length of
1138   the Public Data field.
1139
1140 o Public Data (variable length) - This is defined only if
1141   the authentication method is public key.  If it is any other
1142   this field MAY include random data for padding purposes.
1143   However, in this case the field MUST be ignored by the
1144   receiver.
1145
1146   When the authentication method is public key this includes
1147   128 to 4096 bytes of non-zero random data that is used in
1148   the signature process, described subsequently.
1149
1150 o Authentication Data Length (2 bytes) - Indicates the
1151   length of the Authentication Data field.  If zero (0)
1152   value is found in this field the payload MUST be
1153   discarded.
1154
1155 o Authentication Data (variable length) - Authentication
1156   method dependent authentication data.
1157 .in 3
1158
1159
1160 If the authentication method is passphrase-based, the Authentication
1161 Data field includes the plaintext UTF-8 encoded passphrase.  It is safe
1162 to send plaintext passphrase since the entire payload is encrypted.  In
1163 this case the Public Data Length is set to zero (0), but MAY also include
1164 random data for padding purposes.  It is also RECOMMENDED that maximum
1165 amount of padding is applied to SILC packet when using passphrase-based
1166 authentication.  This way it is not possible to approximate the length
1167 of the passphrase from the encrypted packet.
1168
1169 If the authentication method is public key based (or certificate)
1170 the Authentication Data is computed as follows:
1171
1172   HASH = hash(random bytes | ID | public key (or certificate));
1173   Authentication Data = sign(HASH);
1174
1175 The hash() and the sign() are the hash function and the public key
1176 cryptography function selected in the SKE protocol, unless otherwise
1177 stated in the context where this payload is used.  The public key
1178 is SILC style public key unless certificates are used.  The ID is the
1179 entity's ID (Client or Server ID) which is authenticating itself.  The
1180 ID encoding is described in [SILC2].  The random bytes are non-zero
1181 random bytes of length between 128 and 4096 bytes, and will be included
1182 into the Public Data field as is.
1183
1184 The receiver will compute the signature using the random data received
1185 in the payload, the ID associated to the connection and the public key
1186 (or certificate) received in the SKE protocol.  After computing the
1187 receiver MUST verify the signature.  Also in case of public key
1188 authentication this payload is encrypted.
1189
1190
1191 .ti 0
1192 3.10 Algorithms
1193
1194 This section defines all the allowed algorithms that can be used in
1195 the SILC protocol.  This includes mandatory cipher, mandatory public
1196 key algorithm and MAC algorithms.
1197
1198
1199 .ti 0
1200 3.10.1 Ciphers
1201
1202 Cipher is the encryption algorithm that is used to protect the data
1203 in the SILC packets.  See [SILC2] for the actual encryption process and
1204 definition of how it must be done.  SILC has a mandatory algorithm that
1205 must be supported in order to be compliant with this protocol.
1206
1207 The following ciphers are defined in SILC protocol:
1208
1209 aes-256-cbc          AES in CBC mode, 256 bit key            (REQUIRED)
1210 aes-256-ctr          AES in CTR mode, 256 bit key            (RECOMMENDED)
1211 aes-256-rcbc         AES in randomized CBC mode, 256 bit key (OPTIONAL)
1212 aes-192-<mode>       AES in <mode> mode, 192 bit key         (OPTIONAL)
1213 aes-128-<mode>       AES in <mode> mode, 128 bit key         (RECOMMENDED)
1214 twofish-256-<mode>   Twofish in <mode> mode, 256 bit key     (OPTIONAL)
1215 twofish-192-<mode>   Twofish in <mode> mode, 192 bit key     (OPTIONAL)
1216 twofish-128-<mode>   Twofish in <mode> mode, 128 bit key     (OPTIONAL)
1217 cast-256-<mode>      CAST-256 in <mode> mode, 256 bit key    (OPTIONAL)
1218 cast-192-<mode>      CAST-256 in <mode> mode, 192 bit key    (OPTIONAL)
1219 cast-128-<mode>      CAST-256 in <mode> mode, 128 bit key    (OPTIONAL)
1220 serpent-<len>-<mode> Serpent in <mode> mode, <len> bit key   (OPTIONAL)
1221 rc6-<len>-<mode>     RC6 in <mode> mode, <len> bit key       (OPTIONAL)
1222 mars-<len>-<mode>    MARS in <mode> mode, <len> bit key      (OPTIONAL)
1223 none                 No encryption                           (OPTIONAL)
1224
1225 The <mode> is either "cbc", "ctr" or "rcbc".  Other encryption modes MAY
1226 be defined to be used in SILC using the same name format.  The <len> is
1227 either 256, 192 or 128 bit key length.  Also, additional ciphers MAY be
1228 defined to be used in SILC by using the same name format as above.
1229
1230 Algorithm "none" does not perform any encryption process at all and
1231 thus is not recommended to be used.  It is recommended that no client
1232 or server implementation would accept none algorithm except in special
1233 debugging mode.
1234
1235
1236 .ti 0
1237 3.10.1.1 CBC Mode
1238
1239 The "cbc" encryption mode is CBC mode with inter-packet chaining.  This
1240 means that the Initialization Vector (IV) for the next encryption block
1241 is the previous ciphertext block.  The very first IV MUST be random and
1242 is generated as described in [SILC3].
1243
1244
1245 .ti 0
1246 3.10.1.2 CTR Mode
1247
1248 The "ctr" encryption mode is Counter Mode (CTR).  The CTR mode in SILC is
1249 stateful in encryption and decryption.  Both sender and receiver maintain
1250 the counter for the CTR mode and thus can precompute the key stream for
1251 encryption and decryption.  By default, CTR mode does not require
1252 plaintext padding, however implementations MAY apply padding to the
1253 packets.  If the last key block is larger than the last plaintext block
1254 the resulted value is truncated to the size of the plaintext block and
1255 the most significant bits are used.  When sending authentication data
1256 inside packets the maximum amount of padding SHOULD be applied with
1257 CTR mode as well.
1258
1259 In CTR mode only the encryption operation of the cipher is used.  The
1260 decryption operation is not needed since both encryption and decryption
1261 process is simple XOR with the plaintext block and the key stream block.
1262
1263 The counter block is used to create the key for the CTR mode.  When
1264 SILC specifications refer to Initialization Vector (IV) in general cases,
1265 in case of CTR mode it refers to the counter block.  The format of the
1266 128 bit counter block is as follows:
1267
1268 .in 5
1269 .nf
1270                      1                   2                   3
1271  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
1272 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1273 |                   Truncated HASH from SKE                     |
1274 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1275 |                Sending/Receiving IV from SKE                  |
1276 |                                                               |
1277 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1278 |                        Block Counter                          |
1279 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1280 .in 3
1281
1282 .ce
1283 Figure 6:  Counter Block
1284
1285 .in 6
1286 o Truncated HASH from SKE (4 bytes) - This value is the first 4
1287   bytes from the HASH value that was computed as a result of SKE
1288   protocol.  This acts as session identifier and each rekey MUST
1289   produce a new HASH value.
1290
1291 o Sending/Receiving IV from SKE (8 bytes) - This value is the
1292   first 8 bytes from the Sending IV or Receiving IV generated in
1293   the SKE protocol.  When this mode is used to encrypt sending
1294   traffic the Sending IV is used, when used to decrypt receiving
1295   traffic the Receiving IV is used.  This assures that two parties
1296   of the protocol use different IV for sending traffic.  Each rekey
1297   MUST produce a new value.
1298
1299 o Block Counter (4 bytes) - This is the counter value for the
1300   counter block and is MSB ordered number starting from one (1)
1301   value for first block and incrementing for subsequent blocks.
1302   The same value MUST NOT be used twice.  The rekey MUST be
1303   performed before this counter value wraps.
1304 .in 3
1305
1306 CTR mode MUST NOT be used with "none" MAC.  Implementations also MUST
1307 assure that the same counter block is not used to encrypt more than
1308 one block.  Also, the key material used with CTR mode MUST be fresh
1309 key material.  Static keys (pre-shared keys) MUST NOT be used with
1310 CTR mode.  For this reason using CTR mode to encrypt for example
1311 channel messages or private messages with a pre-shared key is
1312 inappropriate.  For private messages, the Key Agreement could be
1313 performed to produce fresh key material.
1314
1315 If the IV Included flag was negotiated in SKE, or CTR mode is used to
1316 protect channel messages where the counter block will be included in the
1317 Message Payload, implementations SHOULD still use the same counter block
1318 format as defined above.  However, implementations are RECOMMENDED to
1319 replace the Truncated HASH field with a 32 bit random value for each IV
1320 (counter block) per encrypted SILC packet.  Also note, that in this case
1321 the decryption process is not stateful and receiver cannot precompute the
1322 key stream.
1323
1324
1325 .ti 0
1326 3.10.1.3 Randomized CBC Mode
1327
1328 The "rcbc" encryption mode is CBC mode with randomized IV.  This means
1329 that each IV for each packet MUST be chosen randomly.  When encrypting
1330 more than one block the normal inter-packet chaining is used, but for
1331 the first block new random IV is selected in each packet.  In this mode
1332 the IV is appended at the end of the last ciphertext block and thus
1333 delivered to the recipient.  This mode increases the ciphertext size by
1334 one ciphertext block.  Note also that some data payloads in SILC are
1335 capable of delivering the IV to the recipient.  When explicitly
1336 encrypting these payloads with randomized CBC the IV MUST NOT be appended
1337 at the end of the ciphertext, but is placed at the specified location
1338 in the payload.  However, Message Payload for example has the IV at
1339 the location which is equivalent to placing it after the last ciphertext
1340 block.  When using CBC mode with such payloads it is actually equivalent
1341 to using randomized CBC since the IV is selected in random and included
1342 in the ciphertext.
1343
1344
1345 .ti 0
1346 3.10.2 Public Key Algorithms
1347
1348 Public keys are used in SILC to authenticate entities in SILC network
1349 and to perform other tasks related to public key cryptography.  The
1350 public keys are also used in the SILC Key Exchange protocol [SILC3].
1351
1352 The following public key algorithms are defined in SILC protocol:
1353
1354 .in 6
1355 rsa        RSA  (REQUIRED)
1356 dss        DSS  (OPTIONAL)
1357 .in 3
1358
1359 DSS is described in [Menezes].  The RSA MUST be implemented according
1360 PKCS #1 [PKCS1].  The mandatory PKCS #1 implementation in SILC MUST be
1361 compliant to either PKCS #1 version 1.5 or newer with the following
1362 notes: The signature encoding is always in same format as the encryption
1363 encoding regardless of the PKCS #1 version.  The signature with appendix
1364 (with hash algorithm OID in the data) MUST NOT be used in the SILC.  The
1365 rationale for this is that there is no binding between the PKCS #1 OIDs
1366 and the hash algorithms used in the SILC protocol.  Hence, the encoding
1367 is always in PKCS #1 version 1.5 format.
1368
1369 Additional public key algorithms MAY be defined to be used in SILC.
1370
1371 When signatures are computed in SILC the computing of the signature is
1372 represented as sign().  The signature computing procedure is dependent
1373 of the public key algorithm, and the public key or certificate encoding.
1374 When using SILC public key the signature is computed as described in
1375 previous paragraph for RSA and DSS keys.  If the hash function is not
1376 specified separately for signing process SHA-1 MUST be used.  When using
1377 SSH2 public keys the signature is computed as described in [SSH-TRANS].
1378 When using X.509 version 3 certificates the signature is computed as
1379 described in [PKCS7].  When using OpenPGP certificates the signature is
1380 computed as described in [PGP].
1381
1382
1383 .ti 0
1384 3.10.2.1 Multi-Precision Integers
1385
1386 Multi-Precision (MP) integers in SILC are encoded and decoded as defined
1387 in PKCS #1 [PKCS1].  MP integers are unsigned, encoded with desired octet
1388 length.  This means that if the octet length is more than the actual
1389 length of the integer one or more leading zero octets will appear at the
1390 start of the encoding.  The actual length of the integer is the bit size
1391 of the integer not counting any leading zero bits.
1392
1393
1394 .ti 0
1395 3.10.3 Hash Functions
1396
1397 Hash functions are used as part of MAC algorithms defined in the next
1398 section.  They are also used in the SILC Key Exchange protocol defined
1399 in the [SILC3].
1400
1401 The following Hash algorithm are defined in SILC protocol:
1402
1403 .in 6
1404 sha1             SHA-1, length = 20      (REQUIRED)
1405 md5              MD5, length = 16        (RECOMMENDED)
1406 .in 3
1407
1408
1409 .ti 0
1410 3.10.4 MAC Algorithms
1411
1412 Data integrity is protected by computing a message authentication code
1413 (MAC) of the packet data.  See [SILC2] for details how to compute the
1414 MAC for a packet.
1415
1416 The following MAC algorithms are defined in SILC protocol:
1417
1418 .in 6
1419 hmac-sha1-96     HMAC-SHA1, length = 12 bytes  (REQUIRED)
1420 hmac-md5-96      HMAC-MD5, length = 12 bytes   (OPTIONAL)
1421 hmac-sha1        HMAC-SHA1, length = 20 bytes  (OPTIONAL)
1422 hmac-md5         HMAC-MD5, length = 16 bytes   (OPTIONAL)
1423 none             No MAC                        (OPTIONAL)
1424 .in 3
1425
1426 The "none" MAC is not recommended to be used as the packet is not
1427 authenticated when MAC is not computed.  It is recommended that no
1428 client or server would accept none MAC except in special debugging
1429 mode.
1430
1431 The HMAC algorithm is described in [HMAC].  The hash algorithms used
1432 in HMACs, the SHA-1 is described in [RFC3174] and MD5 is described
1433 in [RFC1321].
1434
1435 Additional MAC algorithms MAY be defined to be used in SILC.
1436
1437
1438 .ti 0
1439 3.10.5 Compression Algorithms
1440
1441 SILC protocol supports compression that may be applied to unencrypted
1442 data.  It is recommended to use compression on slow links as it may
1443 significantly speed up the data transmission.  By default, SILC does not
1444 use compression which is the mode that must be supported by all SILC
1445 implementations.
1446
1447 The following compression algorithms are defined:
1448
1449 .in 6
1450 none        No compression               (REQUIRED)
1451 zlib        GNU ZLIB (LZ77) compression  (OPTIONAL)
1452 .in 3
1453
1454 Additional compression algorithms MAY be defined to be used in SILC.
1455
1456
1457 .ti 0
1458 3.11 SILC Public Key
1459
1460 This section defines the type and format of the SILC public key.  All
1461 implementations MUST support this public key type.  See [SILC3] for
1462 other optional public key and certificate types allowed in the SILC
1463 protocol.  Public keys in SILC may be used to authenticate entities
1464 and to perform other tasks related to public key cryptography.
1465
1466 The format of the SILC Public Key is as follows:
1467
1468
1469
1470
1471
1472
1473
1474
1475 .in 5
1476 .nf
1477                      1                   2                   3
1478  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
1479 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1480 |                        Public Key Length                      |
1481 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1482 |     Algorithm Name Length     |                               |
1483 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1484 |                                                               |
1485 ~                         Algorithm Name                        ~
1486 |                                                               |
1487 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1488 |       Identifier Length       |                               |
1489 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1490 |                                                               |
1491 ~                           Identifier                          ~
1492 |                                                               |
1493 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1494 |                                                               |
1495 ~                           Public Data                         ~
1496 |                                                               |
1497 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1498 .in 3
1499
1500 .ce
1501 Figure 5:  SILC Public Key
1502
1503
1504 .in 6
1505 o Public Key Length (4 bytes) - Indicates the full length
1506   of the SILC Public Key, not including this field.
1507
1508 o Algorithm Name Length (2 bytes) - Indicates the length
1509   of the Algorithm Length field, not including this field.
1510
1511 o Algorithm name (variable length) - Indicates the name
1512   of the public key algorithm that the key is.  See the
1513   section 3.10.2 Public Key Algorithms for defined names.
1514
1515 o Identifier Length (2 bytes) - Indicates the length of
1516   the Identifier field, not including this field.
1517
1518 o Identifier (variable length) - Indicates the identifier
1519   of the public key.  This data can be used to identify
1520   the owner of the key.  The identifier is of the following
1521   format:
1522
1523      UN   User name
1524      HN   Host name or IP address
1525      RN   Real name
1526      E    EMail address
1527      O    Organization
1528      C    Country
1529
1530
1531   Examples of an identifier:
1532
1533     `UN=priikone, HN=poseidon.pspt.fi, E=priikone@poseidon.pspt.fi'
1534
1535     `UN=sam, HN=dummy.fi, RN=Sammy Sam, O=Company XYZ, C=Finland'
1536
1537   At least user name (UN) and host name (HN) MUST be provided as
1538   identifier.  The fields are separated by commas (`,').  If
1539   comma is in the identifier string it must be escaped as `\\,',
1540   for example, `O=Company XYZ\\, Inc.'.  Other characters that
1541   require escaping are listed in [RFC2253] and are to be escaped
1542   as defined therein.
1543
1544 o Public Data (variable length) - Includes the actual
1545   public data of the public key.
1546
1547   The format of this field for RSA algorithm is
1548   as follows:
1549
1550      4 bytes            Length of e
1551      variable length    e
1552      4 bytes            Length of n
1553      variable length    n
1554
1555
1556   The format of this field for DSS algorithm is
1557   as follows:
1558
1559      4 bytes            Length of p
1560      variable length    p
1561      4 bytes            Length of q
1562      variable length    q
1563      4 bytes            Length of g
1564      variable length    g
1565      4 bytes            Length of y
1566      variable length    y
1567
1568   The variable length fields are multiple precession
1569   integers encoded as strings in both examples.
1570
1571   Other algorithms must define their own type of this
1572   field if they are used.
1573 .in 3
1574
1575 All fields in the public key are in MSB (most significant byte first)
1576 order.  All strings in the public key MUST be UTF-8 encoded.
1577
1578 If an external protocol needs to refer to SILC Public Key by name, the
1579 names "silc-rsa" and "silc-dss" for SILC Public Key based on RSA algorithm
1580 and SILC Public Key based on DSS algorithm, respectively, are to be used.
1581 However, this SILC specification does not use these names directly, and
1582 they are defined here for external protocols (protocols that may like
1583 to use SILC Public Key).
1584
1585
1586 .ti 0
1587 3.12 SILC Version Detection
1588
1589 The version detection of both client and server is performed at the
1590 connection phase while executing the SILC Key Exchange protocol.  The
1591 version identifier is exchanged between initiator and responder.  The
1592 version identifier is of the following format:
1593
1594 .in 6
1595 SILC-<protocol version>-<software version>
1596 .in 3
1597
1598 The version strings are of the following format:
1599
1600 .in 6
1601 protocol version = <major>.<minor>
1602 software version = <major>[.<minor>[.<build or vendor string>]]
1603 .in 3
1604
1605 Protocol version MUST provide both major and minor version.  Currently
1606 implementations MUST set the protocol version and accept at least the
1607 protocol version as SILC-1.2-<software version>.  If new protocol version
1608 causes incompatibilities with older version the <minor> version number
1609 MUST be incremented.  The <major> is incremented if new protocol version
1610 is fully incompatible.
1611
1612 Software version MAY provide major, minor and build (vendor) version.
1613 The software version MAY be freely set and accepted.  The version string
1614 MUST consist of printable US-ASCII characters.
1615
1616 Thus, the version strings could be, for example:
1617
1618 .in 6
1619 SILC-1.1-2.0.2
1620 SILC-1.0-1.2
1621 SILC-1.2-1.0.VendorXYZ
1622 SILC-1.2-2.4.5 Vendor Limited
1623 .in 3
1624
1625
1626 .ti 0
1627 3.13 UTF-8 Strings in SILC
1628
1629 By default all strings that are sent in SILC protocol MUST be UTF-8
1630 [RFC3269] encoded, unless otherwise defined.  This means that any string
1631 sent inside for example, command, command reply, notify or any packet
1632 payload is UTF-8 encoded.  Also nicknames, channel names, server names,
1633 and hostnames are UTF-8 encoded.  This definition does not affect
1634 messages sent in SILC, as the Message Payload provides its own mechanism
1635 to indicate whether a message is UTF-8 text message, data message, which
1636 may use its own character encoding, or pure binary message [SILC2].
1637
1638 Certain limitations are imposed on the UTF-8 encoded strings in SILC.
1639 The UTF-8 encoded strings MUST NOT include any characters that are
1640 marked in the Unicode standard as control codes, noncharacters,
1641 reserved or private range characters, or any other illegal Unicode
1642 characters.  Also the BOM (Byte-Order Mark) MUST NOT be used as byte
1643 order signature in UTF-8 encoded strings.  A string containing these
1644 characters MUST be treated as malformed UTF-8 encoding.
1645
1646 The Unicode standard defines that malformed sequences shall be signalled
1647 by replacing the sequence with a replacement character.  Even though,
1648 in case of SILC these strings may not be malformed UTF-8 encodings
1649 they MUST be treated as malformed strings.  Implementation MAY use
1650 a replacement character, however, the character Unicode standard defines
1651 MUST NOT be used, but another character must be chosen.  It is, however,
1652 RECOMMENDED that an error is returned instead of using replacement
1653 character if it is possible.  For example, when setting a nickname
1654 with SILC_COMMAND_NICK command, implementation is able to send error
1655 indication back to the command sender.  It must be noted that on server
1656 implementation if a character sequence is merely outside of current
1657 character subset, but is otherwise valid character, it MUST NOT be
1658 replaced by a replacement character.
1659
1660 On user interface where UTF-8 strings are displayed the implementation
1661 is RECOMMENDED to escape any character that it is unable to render
1662 properly.  The escaping may be done for example as described in
1663 [RFC2253].  The escaping makes it possible to retrieve the original
1664 UTF-8 encoding.  Alternatively, a replacement character may be used
1665 if it does not cause practical problems to the implementation.
1666
1667
1668 .ti 0
1669 3.13.1 UTF-8 Identifier Strings
1670
1671 Identifier strings are special strings in SILC protocol that require
1672 more careful processing, than the general UTF-8 strings described in the
1673 previous section.  These strings include the nicknames, channel names,
1674 server names, hostnames and some other identifier strings.  These strings
1675 are prepared using the stringprep [RFC3454] standard.  The Appendix A
1676 defines the stringprep profile for SILC identifier strings and conforming
1677 implementation MUST use the profile to prepare any identifier string.
1678
1679 The stringprep profile describes how identifier strings are prepared,
1680 what characters they may include, and which characters are prohibited.
1681 Identifier strings with prohibited characters MUST be treated as
1682 malformed strings.
1683
1684 Because of the profile the identifier strings in SILC may generally
1685 include only letters, numbers, most punctuation characters, and some
1686 other characters.  For practical reasons most symbol characters and
1687 many other special characters are prohibited.  All identifier strings
1688 are case folded and comparing the identifier strings MUST be done as
1689 caseless matching.  Also, identifier strings may not include any
1690 commas (','), '@', '!' or any wildcard characters, as defined in the
1691 stringprep profile in Appendix A.
1692
1693 In general, the identifier strings does not have a maximum length.
1694 However, the length of a nickname string MUST NOT exceed 128 bytes, and
1695 the length of a channel name string MUST NOT exceed 256 bytes.  Since
1696 these strings are UTF-8 encoded the length of one character may be
1697 longer than one byte.  This means that the character length of these
1698 strings may be shorter than the maximum length of the string in bytes.
1699 The minimum length of an identifier string MUST be at least one character,
1700 which may be one byte or more in length.  Implementation MAY limit the
1701 maximum length of an identifier string, with exception of the nickname
1702 and channel name strings which has the explicit length definition.
1703
1704
1705 .ti 0
1706 3.14 Backup Routers
1707
1708 Backup routers may exist in the cell in addition to the primary router.
1709 However, they must not be active routers or act as routers in the cell.
1710 Only one router may be acting as primary router in the cell.  In the case
1711 of failure of the primary router one of the backup routers becomes active.
1712 The purpose of backup routers are in case of failure of the primary router
1713 to maintain working connections inside the cell and outside the cell and
1714 to avoid netsplits.
1715
1716 Backup routers are normal servers in the cell that are prepared to take
1717 over the tasks of the primary router if needed.  They need to have at
1718 least one direct and active connection to the primary router of the cell.
1719 This communication channel is used to send the router information to
1720 the backup router.  When the backup router connects to the primary router
1721 of the cell it MUST present itself as router server in the Connection
1722 Authentication protocol, even though it is normal server as long as the
1723 primary router is available.  Reason for this is that the configuration
1724 needed in the responder end requires usually router connection level
1725 configuration.  The responder, however must understand and treat the
1726 connection as normal server (except when feeding router level data to
1727 the backup router).
1728
1729 Backup router must know everything that the primary router knows to be
1730 able to take over the tasks of the primary router.  It is the primary
1731 router's responsibility to feed the data to the backup router.  If the
1732 backup router does not know all the data in the case of failure some
1733 connections may be lost.  The primary router of the cell must consider
1734 the backup router being an actual router server when it feeds the data
1735 to it.
1736
1737 In addition to having direct connection to the primary router of the
1738 cell, the backup router must also have connection to the same router
1739 to which the primary router of the cell is connected.  However, it must
1740 not be the active router connection meaning that the backup router must
1741 not use that channel as its primary route and it must not notify the
1742 router about having connected servers, channels and clients behind it.
1743 It merely connects to the router.  This sort of connection is later
1744 referred to as being a passive connection.  Some keepalive actions may
1745 be needed by the router to keep the connection alive.
1746
1747 It is required that other normal servers have passive connections to
1748 the backup router(s) in the cell.  Some keepalive actions may be needed
1749 by the server to keep the connection alive.  After they notice the
1750 failure of the primary router they must start using the connection to
1751 the first backup router as their primary route.
1752
1753 Also, if any other router in the network is using the cell's primary
1754 router as its own primary router, it must also have passive connection
1755 to the cell's backup router.  It too is prepared to switch to use the
1756 backup router as its new primary router as soon as the original primary
1757 router becomes unresponsive.
1758
1759 All of the parties of this protocol know which one is the backup router
1760 of the cell from their local configuration.  Each of the entities must
1761 be configured accordingly and care must be taken when configuring the
1762 backup routers, servers and other routers in the network.
1763
1764 It must be noted that some of the channel messages and private messages
1765 may be lost during the switch to the backup router.  The announcements
1766 assure that the state of the network is not lost during the switch.
1767
1768 It is RECOMMENDED that there would be at least one backup router in
1769 the cell.  It is NOT RECOMMENDED to have all servers in the cell acting
1770 as backup routers as it requires establishing several connections to
1771 several servers in the cell.  Large cells can easily have several
1772 backup routers in the cell.
1773
1774 The order of the backup routers are decided at the local configuration
1775 phase.  All the parties of this protocol must be configured accordingly to
1776 understand the order of the backup routers.  It is not required that the
1777 backup server is actually an active server in the cell.  The backup router
1778 may be a redundant server in the cell that does not accept normal client
1779 connections at all.  It may be reserved purely for the backup purposes.
1780
1781 If also the first backup router is down as well and there is another
1782 backup router in the cell then it will start acting as the primary
1783 router as described above.
1784
1785
1786 .ti 0
1787 3.14.1 Switching to Backup Router
1788
1789 When the primary router of the cell becomes unresponsive, for example
1790 by sending EOF to the connection, all the parties of this protocol MUST
1791 replace the old connection to the primary router with first configured
1792 backup router.  The backup router usually needs to do local modifications
1793 to its database in order to update all the information needed to maintain
1794 working routes.  The backup router must understand that clients that
1795 were originated from the primary router are now originated from some of
1796 the existing server connections and must update them accordingly.  It
1797 must also remove those clients that were owned by the primary router
1798 since those connections were lost when the primary router became
1799 unresponsive.
1800
1801 All the other parties of the protocol must also update their local
1802 database to understand that the route to the primary router will now go
1803 to the backup router.
1804
1805 Servers connected to the backup router MUST send SILC_PACKET_RESUME_ROUTER
1806 packet with type value 21, to indicate that the server will start using
1807 the backup router as primary router.  The backup router MUST NOT allow
1808 this action if it detects that primary is still up and running.  If
1809 backup router knows that primary is up and running it MUST send
1810 SILC_PACKET_FAILURE with type value 21 (4 bytes, MSB first order) back
1811 to the server.  The server then MUST NOT use the backup as primary
1812 router, but must try to establish connection back to the primary router.
1813 If the action is allowed type value 21 is sent back to the server from
1814 the backup router.  It is RECOMMENDED that implementations use the
1815 SILC_COMMAND_PING command to detect whether primary router is responsive.
1816
1817 The servers connected to the backup router must then announce their
1818 clients, channels, channel users, channel user modes, channel modes,
1819 topics and other information to the backup router.  This is to assure
1820 that none of the important notify packets were lost during the switch
1821 to the backup router.  The backup router must check which of these
1822 announced entities it already has and distribute the new ones to the
1823 primary router.
1824
1825 The backup router too must announce its servers, clients, channels
1826 and other information to the new primary router.  The primary router
1827 of the backup router too must announce its information to the backup
1828 router.  Both must process only the ones they do not know about.  If
1829 any of the announced modes do not match then they are enforced in
1830 normal manner as defined in section 4.2.1 Announcing Clients, Channels
1831 and Servers.
1832
1833
1834 .ti 0
1835 3.14.2 Resuming Primary Router
1836
1837 Usually the primary router is unresponsive only a short period of time
1838 and it is intended that the original router of the cell will resume
1839 its position as primary router when it comes back online.  The backup
1840 router that is now acting as primary router of the cell must constantly
1841 try to connect to the original primary router of the cell.  It is
1842 RECOMMENDED that it would try to reconnect in 30 second intervals to
1843 the primary router.
1844
1845 When the connection is established to the primary router the backup
1846 resuming protocol is executed.  The protocol is advanced as follows:
1847
1848   1. Backup router sends SILC_PACKET_RESUME_ROUTER packet with type
1849      value 1 to the primary router that came back online.  The packet
1850      will indicate the primary router has been replaced by the backup
1851      router.  After sending the packet the backup router will announce
1852      all of its channels, channel users, modes etc. to the primary
1853      router.
1854
1855      If the primary knows that it has not been replaced (for example
1856      the backup itself disconnected from the primary router and thinks
1857      that it is now primary in the cell) the primary router send
1858      SILC_PACKET_FAILURE with the type value 1 (4 bytes, MSB first
1859      order) back to the backup router.  If backup receives this it
1860      MUST NOT continue with the backup resuming protocol.
1861
1862   2. Backup router sends SILC_PACKET_RESUME_ROUTER packet with type
1863      value 1 to its current primary router to indicate that it will
1864      resign as being primary router.  Then, backup router sends the
1865      SILC_PACKET_RESUME_ROUTER packet with type value 1 to all
1866      connected servers to also indicate that it will resign as being
1867      primary router.
1868
1869   3. Backup router also send SILC_PACKET_RESUME_ROUTER packet with
1870      type value 1 to the router that is using the backup router
1871      currently as its primary router.
1872
1873   4. Any server and router that receives the SILC_PACKET_RESUME_ROUTER
1874      with type value 1 must reconnect immediately to the primary
1875      router of the cell that came back online.  After they have created
1876      the connection they MUST NOT use that connection as active primary
1877      route but still route all packets to the backup router.  After
1878      the connection is created they MUST send SILC_PACKET_RESUME_ROUTER
1879      with type value 2 back to the backup router.  The session ID value
1880      found in the first packet MUST be set in this packet.
1881
1882   5. Backup router MUST wait for all packets with type value 2 before
1883      it continues with the protocol.  It knows from the session ID values
1884      set in the packet when it has received all packets.  The session
1885      value should be different in all packets it has sent earlier.
1886      After the packets are received the backup router sends the
1887      SILC_PACKET_RESUME_ROUTER packet with type value 3 to the
1888      primary router that came back online.  This packet will indicate
1889      that the backup router is now ready to resign as being primary
1890      router.  The session ID value in this packet MUST be the same as
1891      in the first packet sent to the primary router.  During this time
1892      the backup router must still route all packets it is receiving
1893      from server connections.
1894
1895   6. The primary router receives the packet and send the packet
1896      SILC_PACKET_RESUME_ROUTER with type value 4 to all connected servers
1897      including the backup router.  It also sends the packet with type
1898      value 4 to its primary router, and to the router that is using
1899      it as its primary router.  The Session ID value in these packets
1900      SHOULD be zero (0).
1901
1902   7. Any server and router that receives the SILC_PACKET_RESUME_ROUTER
1903      packet with type value 4 must switch their primary route to the new
1904      primary router and remove the route for the backup router, since
1905      it is no longer the primary router of the cell.  They must also
1906      update their local database to understand that the clients are
1907      not originated from the backup router but from the locally connected
1908      servers.  After that they MUST announce their channels, channel
1909      users, modes etc. to the primary router.  They MUST NOT use the
1910      backup router connection after this and the connection is considered
1911      to be a passive connection.  The implementation SHOULD be able
1912      to disable the connection without closing the actual link.
1913
1914 After this protocol is executed the backup router is now again a normal
1915 server in the cell that has the backup link to the primary router.  The
1916 primary router feeds the router specific data again to the backup router.
1917 All server connections to the backup router are considered passive
1918 connections.
1919
1920 When the primary router of the cell comes back online and connects
1921 to its remote primary router, the remote primary router MUST send the
1922 SILC_PACKET_RESUME_ROUTER packet with type value 20 indicating that the
1923 connection is not allowed since the router has been replaced by an
1924 backup router in the cell.  The session ID value in this packet SHOULD be
1925 zero (0).  When the primary router receives this packet it MUST NOT use
1926 the connection as active connection but must understand that it cannot
1927 act as primary router in the cell, until the backup resuming protocol has
1928 been executed.
1929
1930 The following type values has been defined for SILC_PACKET_RESUME_ROUTER
1931 packet:
1932
1933   1    SILC_SERVER_BACKUP_START
1934   2    SILC_SERVER_BACKUP_START_CONNECTED
1935   3    SILC_SERVER_BACKUP_START_ENDING
1936   4    SILC_SERVER_BACKUP_START_RESUMED
1937   20   SILC_SERVER_BACKUP_START_REPLACED
1938   21   SILC_SERVER_BACKUP_START_USE
1939
1940 If any other value is found in the type field the packet MUST be
1941 discarded.  The SILC_PACKET_RESUME_ROUTER packet and its payload
1942 is defined in [SILC2].
1943
1944
1945 .ti 0
1946 4 SILC Procedures
1947
1948 This section describes various SILC procedures such as how the
1949 connections are created and registered, how channels are created and
1950 so on.  The references [SILC2], [SILC3] and [SILC4] permeate this
1951 section's definitions.
1952
1953
1954 .ti 0
1955 4.1 Creating Client Connection
1956
1957 This section describes the procedure when a client connects to SILC
1958 server.  When client connects to server the server MUST perform IP
1959 address lookup and reverse IP address lookup to assure that the origin
1960 host really is who it claims to be.  Client, a host, connecting to server
1961 SHOULD have both valid IP address and fully qualified domain name (FQDN).
1962
1963 After that the client and server performs SILC Key Exchange protocol
1964 which will provide the key material used later in the communication.
1965 The key exchange protocol MUST be completed successfully before the
1966 connection registration may continue.  The SILC Key Exchange protocol
1967 is described in [SILC3].
1968
1969 Typical server implementation would keep a list of connections that it
1970 allows to connect to the server.  The implementation would check, for
1971 example, the connecting client's IP address from the connection list
1972 before the SILC Key Exchange protocol has been started.  The reason for
1973 this is that if the host is not allowed to connect to the server there
1974 is no reason to perform the key exchange protocol.
1975
1976 After successful key exchange protocol the client and server perform
1977 connection authentication protocol.  The purpose of the protocol is to
1978 authenticate the client connecting to the server.  Flexible
1979 implementation could also accept the client to connect to the server
1980 without explicit authentication.  However, if authentication is
1981 desired for a specific client it may be based on passphrase or
1982 public key authentication.  If authentication fails the connection
1983 MUST be terminated.  The connection authentication protocol is described
1984 in [SILC3].
1985
1986 After successful key exchange and authentication protocol the client
1987 MUST register itself by sending SILC_PACKET_NEW_CLIENT packet to the
1988 server.  This packet includes various information about the client
1989 that the server uses to register the client.  Server registers the
1990 client and sends SILC_PACKET_NEW_ID to the client which includes the
1991 created Client ID that the client MUST start using after that.  After
1992 that all SILC packets from the client MUST have the Client ID as the
1993 Source ID in the SILC Packet Header, described in [SILC2].
1994
1995 Client MUST also get the server's Server ID that is to be used as
1996 Destination ID in the SILC Packet Header when communicating with
1997 the server (for example when sending commands to the server).  The
1998 ID may be resolved in two ways.  Client can take the ID from an
1999 previously received packet from server that MUST include the ID,
2000 or to send SILC_COMMAND_INFO command and receive the Server ID as
2001 command reply.
2002
2003 Server MAY choose not to use the information received in the
2004 SILC_PACKET_NEW_CLIENT packet.  For example, if public key or
2005 certificate were used in the authentication, server MAY use that
2006 information rather than what it received from client.  This is a suitable
2007 way to get the true information about client if it is available.
2008
2009 The nickname of client is initially set to the username sent in the
2010 SILC_PACKET_NEW_CLIENT packet.  User may set the nickname to something
2011 more desirable by sending SILC_COMMAND_NICK command.  However, this is
2012 not required as part of registration process.
2013
2014 Server MUST also distribute the information about newly registered
2015 client to its router (or if the server is router, to all routers in
2016 the SILC network).  More information about this in [SILC2].
2017
2018 Router server MUST also check whether some client in the local cell
2019 is watching for the nickname this new client has, and send the
2020 SILC_NOTIFY_TYPE_WATCH to the watcher.
2021
2022
2023
2024
2025 .ti 0
2026 4.2 Creating Server Connection
2027
2028 This section describes the procedure when server connects to its
2029 router (or when router connects to other router, the cases are
2030 equivalent).  The procedure is very much alike to when a client
2031 connects to the server thus it is not repeated here.
2032
2033 One difference is that server MUST perform connection authentication
2034 protocol with proper authentication.  A proper authentication is based
2035 on passphrase authentication or public key authentication based on
2036 digital signatures.
2037
2038 After server and router have successfully performed the key exchange
2039 and connection authentication protocol, the server MUST register itself
2040 to the router by sending SILC_PACKET_NEW_SERVER packet.  This packet
2041 includes the server's Server ID that it has created by itself and
2042 other relevant information about the server.  The router receiving the
2043 ID MUST verify that the IP address in the Server ID is same as the
2044 server's real IP address.
2045
2046 After router has received the SILC_PACKET_NEW_SERVER packet it
2047 distributes the information about newly registered server to all routers
2048 in the SILC network.  More information about this is in [SILC2].
2049
2050 As the client needed to resolve the destination ID this MUST be done by
2051 the server that connected to the router, as well.  The way to resolve it
2052 is to get the ID from previously received packet.  The server MAY also
2053 use SILC_COMMAND_INFO command to resolve the ID.  Server MUST also start
2054 using its own Server ID as Source ID in SILC Packet Header and the
2055 router's Server ID as Destination when communicating with the router.
2056
2057
2058 .ti 0
2059 4.2.1 Announcing Clients, Channels and Servers
2060
2061 After server or router has connected to the remote router, and it already
2062 has connected clients and channels it MUST announce them to the router.
2063 If the server is router server, also all the local servers in the cell
2064 MUST be announced.
2065
2066 All clients are announced by compiling a list of ID Payloads into the
2067 SILC_PACKET_NEW_ID packet.  All channels are announced by compiling a
2068 list of Channel Payloads into the SILC_PACKET_NEW_CHANNEL packet.
2069 Channels' mode, founder public key, channel public keys, and other
2070 channel mode specific data is announced by sending the
2071 SILC_NOTIFY_TYPE_CMODE_CHANGE notify list.
2072
2073 The channel public keys that are announced are compiled in Argument
2074 List Payload where the argument type is 0x03, and each argument is
2075 Public Key Payload containing one public key or certificate.
2076
2077 Also, the channel users on the channels must be announced by compiling
2078 a list of Notify Payloads with the SILC_NOTIFY_TYPE_JOIN notify type
2079 into the SILC_PACKET_NOTIFY packet.  The users' modes on the channel
2080 must also be announced by compiling list of Notify Payloads with the
2081 SILC_NOTIFY_TYPE_CUMODE_CHANGE notify type into the SILC_PACKET_NOTIFY
2082 packet.
2083
2084 The router MUST also announce the local servers by compiling list of
2085 ID Payloads into the SILC_PACKET_NEW_ID packet.
2086
2087 Also, clients' modes (user modes in SILC) MUST be announced.  This is
2088 done by compiling a list of Notify Payloads with SILC_NOTIFY_UMODE_CHANGE
2089 notify type into the SILC_PACKET_NOTIFY packet.  Also, channels' topics
2090 MUST be announced by compiling a list of Notify Payloads with the
2091 SILC_NOTIFY_TOPIC_SET notify type into the SILC_PACKET_NOTIFY packet.
2092 Also, channel's invite and ban lists MUST be announced by compiling list
2093 of Notify Payloads with the SILC_NOTIFY_TYPE_INVITE and
2094 SILC_NOTIFY_TYPE_BAN notify types, respectively, into the
2095 SILC_PACKET_NOTIFY packet.
2096
2097 The router which receives these lists MUST process them and broadcast
2098 the packets to its primary router.  When processing the announced channels
2099 and channel users the router MUST check whether a channel exists already
2100 with the same name.  If channel exists with the same name it MUST check
2101 whether the Channel ID is different.  If the Channel ID is different the
2102 router MUST send the notify type SILC_NOTIFY_TYPE_CHANNEL_CHANGE to the
2103 server to force the channel ID change to the ID the router has.  If the
2104 mode of the channel is different the router MUST send the notify type
2105 SILC_NOTIFY_TYPE_CMODE_CHANGE to the server to force the mode change
2106 to the mode that the router has.
2107
2108 The router MUST also generate new channel key and distribute it to the
2109 channel.  The key MUST NOT be generated if the SILC_CMODE_PRIVKEY mode
2110 is set.
2111
2112 If the channel has a channel founder already on the router, the router
2113 MUST send the notify type SILC_NOTIFY_TYPE_CUMODE_CHANGE to the server
2114 to force the mode change for the channel founder on the server.  The
2115 channel founder privileges MUST be removed on the server.
2116
2117 If the channel public keys are already set on the on router, the router
2118 MUST ignore the received channel public key list and send the notify
2119 type SILC_NOTIFY_TYPE_CUMODE_CHANGE to the server which includes the
2120 channel public key list that is on router.  The server MUST change the
2121 list to the one it receives from router.
2122
2123 The router processing the channels MUST also compile a list of
2124 Notify Payloads with the SILC_NOTIFY_TYPE_JOIN notify type into the
2125 SILC_PACKET_NOTIFY and send the packet to the server.  This way the
2126 server (or router) will receive the clients on the channel that
2127 the router has.
2128
2129
2130 .ti 0
2131 4.3 Joining to a Channel
2132
2133 This section describes the procedure when client joins to a channel.
2134 Client joins to channel by sending command SILC_COMMAND_JOIN to the
2135 server.  If the receiver receiving join command is normal server the
2136 server MUST check its local list whether this channel already exists
2137 locally.  This would indicate that some client connected to the server
2138 has already joined to the channel.  If this is the case, the client is
2139 joined to the channel, new channel key is created and information about
2140 newly joined channel is sent to the router.  The router is informed
2141 by sending SILC_NOTIFY_TYPE_JOIN notify type.  The notify type MUST
2142 also be sent to the local clients on the channel.  The new channel key
2143 is also sent to the router and to local clients on the channel.
2144
2145 If the channel does not exist in the local list the client's command
2146 MUST be sent to the router which will then perform the actual joining
2147 procedure.  When server receives the reply to the command from the
2148 router it MUST be sent to the client which sent the command originally.
2149 Server will also receive the channel key from the server that it MUST
2150 send to the client which originally requested the join command.  The
2151 server MUST also save the channel key.
2152
2153 If the receiver of the join command is router it MUST first check its
2154 local list whether anyone in the cell has already joined to the channel.
2155 If this is the case, the client is joined to the channel and reply is
2156 sent to the client.  If the command was sent by server the command reply
2157 is sent to the server which sent it.  Then the router MUST also create
2158 new channel key and distribute it to all clients on the channel and
2159 all servers that have clients on the channel.  Router MUST also send
2160 the SILC_NOTIFY_TYPE_JOIN notify type to local clients on the channel
2161 and to local servers that have clients on the channel.
2162
2163 If the channel does not exist on the router's local list it MUST
2164 check the global list whether the channel exists at all.  If it does
2165 the client is joined to the channel as described previously.  If
2166 the channel does not exist the channel is created and the client
2167 is joined to the channel.  The channel key is also created and
2168 distributed as previously described.  The client joining to the created
2169 channel is made automatically channel founder and both channel founder
2170 and channel operator privileges are set for the client.
2171
2172 If the router created the channel in the process, information about the
2173 new channel MUST be broadcast to all routers.  This is done by
2174 broadcasting SILC_PACKET_NEW_CHANNEL packet to the router's primary
2175 route.  When the router joins the client to the channel it MUST also
2176 send information about newly joined client to all routers in the SILC
2177 network.  This is done by broadcasting the SILC_NOTIFY_TYPE_JOIN notify
2178 type to the router's primary route.
2179
2180 It is important to note that new channel key is created always when
2181 new client joins to channel, whether the channel has existed previously
2182 or not.  This way the new client on the channel is not able to decrypt
2183 any of the old traffic on the channel.  Client which receives the reply to
2184 the join command MUST start using the received Channel ID in the channel
2185 message communication thereafter.  Client also receives the key for the
2186 channel in the command reply.  Note that the channel key is never
2187 generated or distributed if the SILC_CMODE_PRIVKEY mode is set.
2188
2189
2190 .ti 0
2191 4.4 Channel Key Generation
2192
2193 Channel keys are created by router which creates the channel by taking
2194 enough randomness from cryptographically strong random number generator.
2195 The key is generated always when channel is created, when new client
2196 joins a channel and after the key has expired.  Key could expire for
2197 example in an hour.
2198
2199 The key MUST also be re-generated whenever some client leaves a channel.
2200 In this case the key is created from scratch by taking enough randomness
2201 from the random number generator.  After that the key is distributed to
2202 all clients on the channel.  However, channel keys are cell specific thus
2203 the key is created only on the cell where the client, which left the
2204 channel, exists.  While the server or router is creating the new channel
2205 key, no other client may join to the channel.  Messages that are sent
2206 while creating the new key are still processed with the old key.  After
2207 server has sent the SILC_PACKET_CHANNEL_KEY packet client MUST start
2208 using the new key.  If server creates the new key the server MUST also
2209 send the new key to its router.  See [SILC2] for more information about
2210 how channel messages must be encrypted and decrypted when router is
2211 processing them.
2212
2213 If the key changes very often due to joining traffic on the channel it
2214 is RECOMMENDED that client implementation would cache some of the old
2215 channel keys for short period of time so that it is able to decrypt all
2216 channel messages it receives.  It is possible that on a heavy traffic
2217 channel a message encrypted with channel key that was just changed
2218 is received by client after the new key was set into use.  This is
2219 possible because not all clients may receive the new key at the same
2220 time, and may still be sending messages encrypted with the old key.
2221
2222 When client receives the SILC_PACKET_CHANNEL_KEY packet with the
2223 Channel Key Payload it MUST process the key data to create encryption
2224 and decryption key, and to create the HMAC key that is used to compute
2225 the MACs of the channel messages.  The processing is as follows:
2226
2227   channel_key  = raw key data
2228   HMAC key     = hash(raw key data)
2229
2230 The raw key data is the key data received in the Channel Key Payload.
2231 The hash() function is the hash function used in the HMAC of the channel.
2232 Note that the server also MUST save the channel key.
2233
2234
2235 .ti 0
2236 4.5 Private Message Sending and Reception
2237
2238 Private messages are sent point to point.  Client explicitly destine
2239 a private message to specific client that is delivered to only to that
2240 client.  No other client may receive the private message.  The receiver
2241 of the private message is destined in the SILC Packet Header as in any
2242 other packet as well.  The Source ID in the SILC Packet Header MUST be
2243 the ID of the sender of the message.
2244
2245 If the sender of a private message does not know the receiver's Client
2246 ID, it MUST resolve it from server.  There are two ways to resolve the
2247 client ID from server; it is RECOMMENDED that client implementations
2248 send SILC_COMMAND_IDENTIFY command to receive the Client ID.  Client
2249 MAY also send SILC_COMMAND_WHOIS command to receive the Client ID.
2250 If the sender has received earlier a private message from the receiver
2251 it should have cached the Client ID from the SILC Packet Header.
2252
2253 If server receives a private message packet which includes invalid
2254 destination Client ID the server MUST send SILC_NOTIFY_TYPE_ERROR
2255 notify to the client with error status indicating that such Client ID
2256 does not exist.
2257
2258 See [SILC2] for description of private message encryption and decryption
2259 process.
2260
2261
2262 .ti 0
2263 4.6 Private Message Key Generation
2264
2265 Private message MAY be protected with a key generated by the client.
2266 One way to generate private message key is to use static or pre-shared
2267 keys in the client implementation.  Client that wants to indicate other
2268 client on the network that a private message key should be set, the
2269 client MAY send SILC_PACKET_PRIVATE_MESSAGE_KEY packet to indicate this.
2270 The actual key material has to be transferred outside the SILC network,
2271 or it has to be pre-shared key.  The client receiving this packet knows
2272 that the sender wishes to use private message key in private message
2273 communication.  In case of static or pre-shared keys the IV used in
2274 the encryption SHOULD be chosen randomly.  Sending the
2275 SILC_PACKET_PRIVATE_MESSAGE_KEY is not mandatory, and clients may
2276 naturally agree to use a key without sending the packet.
2277
2278 Another choice to use private message keys is to negotiate fresh key
2279 material by performing the Key Agreement.  The SILC_PACKET_KEY_AGREEMENT
2280 packet MAY be used to negotiate the fresh key material.  In this case
2281 the resulting key material is used to secure the private messages.
2282 Also, the IV used in encryption is used as defined in [SILC3], unless
2283 otherwise stated by the encryption mode used.  By performing Key
2284 Agreement the clients can also negotiate the cipher and HMAC to be used
2285 in the private message encryption and to negotiate additional security
2286 parameters.  The actual Key Agreement [SILC2] is performed by executing
2287 the SILC Key Exchange protocol [SILC3], peer to peer.  Because of NAT
2288 devices in the network, it might be impossible to perform the Key
2289 Agreement.  In this case using static or pre-shared key and sending the
2290 SILC_PACKET_PRIVATE_MESSAGE_KEY to indicate the use of a private message
2291 key is a working alternative.
2292
2293 If the key is pre-shared key or other key material not generated by
2294 Key Agreement, then the key material SHOULD be processed as defined
2295 in [SILC3].  In the processing, however, the HASH, as defined in [SILC3]
2296 MUST be ignored.  After processing the key material it is employed as
2297 defined in [SILC3].  If the SILC_PACKET_PRIVATE_MESSAGE_KEY was sent,
2298 then it defines the cipher and HMAC to be used.  The hash algorithm to be
2299 used in the key material processing is the one that HMAC algorithm is
2300 defined to use.  If the SILC_PACKET_PRIVATE_MESSAGE_KEY was not sent at
2301 all, then the hash algorithm to be used SHOULD be SHA1.  In this case
2302 also, implementations SHOULD use the SILC protocol's mandatory cipher
2303 and HMAC in private message encryption.
2304
2305
2306 .ti 0
2307 4.7 Channel Message Sending and Reception
2308
2309 Channel messages are delivered to a group of users.  The group forms a
2310 channel and all clients on the channel receives messages sent to the
2311 channel.  The Source ID in the SILC Packet Header MUST be the ID
2312 of the sender of the message.
2313
2314 Channel messages are destined to a channel by specifying the Channel ID
2315 as Destination ID in the SILC Packet Header.  The server MUST then
2316 distribute the message to all clients, except to the original sender,
2317 on the channel by sending the channel message destined explicitly to a
2318 client on the channel.  However, the Destination ID MUST still remain
2319 as the Channel ID.
2320
2321 If server receives a channel message packet which includes invalid
2322 destination Channel ID the server MUST send SILC_NOTIFY_TYPE_ERROR
2323 notify to the sender with error status indicating that such Channel ID
2324 does not exist.
2325
2326 See the [SILC2] for description of channel message routing for router
2327 servers, and channel message encryption and decryption process.
2328
2329
2330 .ti 0
2331 4.8 Session Key Regeneration
2332
2333 Session keys MUST be regenerated periodically, say, once in an hour.
2334 The re-key process is started by sending SILC_PACKET_REKEY packet to
2335 other end, to indicate that re-key must be performed.  The initiator
2336 of the connection SHOULD initiate the re-key.
2337
2338 If perfect forward secrecy (PFS) flag was selected in the SILC Key
2339 Exchange protocol [SILC3] the re-key MUST cause new key exchange with
2340 SKE protocol.  In this case the protocol is secured with the old key
2341 and the protocol results to new key material.  See [SILC3] for more
2342 information.  After the SILC_PACKET_REKEY packet is sent the sender
2343 will perform the SKE protocol.
2344
2345 If PFS flag was set the resulted key material is processed as described
2346 in the section Processing the Key Material in [SILC3].  The difference
2347 with re-key in the processing is that the initial data for the hash
2348 function is just the resulted key material and not the HASH as it
2349 is not computed at all with re-key.  Other than that, the key processing
2350 it equivalent to normal SKE negotiation.
2351
2352 If PFS flag was not set, which is the default case, then re-key is done
2353 without executing SKE protocol.  In this case, the new key is created by
2354 providing the current sending encryption key to the SKE protocol's key
2355 processing function.  The process is described in the section Processing
2356 the Key Material in [SILC3].  The difference in the processing is that
2357 the initial data for the hash function is the current sending encryption
2358 key and not the SKE's KEY and HASH values.  Other than that, the key
2359 processing is equivalent to normal SKE negotiation.
2360
2361 After both parties have regenerated the session key, both MUST send
2362 SILC_PACKET_REKEY_DONE packet to each other.  These packets are still
2363 secured with the old key.  After these packets, the subsequent packets
2364 MUST be protected with the new key.
2365
2366
2367 .ti 0
2368 4.9 Command Sending and Reception
2369
2370 Client usually sends the commands in the SILC network.  In this case
2371 the client simply sends the command packet to server and the server
2372 processes it and replies with command reply packet.  See the [SILC4]
2373 for detailed description of all commands.
2374
2375 However, if the server is not able to process the command, it is sent to
2376 the server's router.  This is case for example with commands such as
2377 SILC_COMMAND_JOIN and SILC_COMMAND_WHOIS commands.  However, there are
2378 other commands as well [SILC4].  For example, if client sends the WHOIS
2379 command requesting specific information about some client the server must
2380 send the WHOIS command to router so that all clients in SILC network are
2381 searched.  The router, on the other hand, sends the WHOIS command further
2382 to receive the exact information about the requested client.  The WHOIS
2383 command travels all the way to the server which owns the client and it
2384 replies with command reply packet.  Finally, the server which sent the
2385 command receives the command reply and it must be able to determine which
2386 client sent the original command.  The server then sends command reply to
2387 the client.  Implementations should have some kind of cache to handle, for
2388 example, WHOIS information.  Servers and routers along the route could all
2389 cache the information for faster referencing in the future.
2390
2391 The commands sent by server may be sent hop by hop until someone is able
2392 to process the command.  However, it is preferred to destine the command
2393 as precisely as it is possible.  In this case, other routers en route
2394 MUST route the command packet by checking the true sender and true
2395 destination of the packet.  However, servers and routers MUST NOT route
2396 command reply packets to clients coming from other servers.  Client
2397 MUST NOT accept command reply packet originated from anyone else but
2398 from its own server.
2399
2400
2401 .ti 0
2402 4.10 Closing Connection
2403
2404 When remote client connection is closed the server MUST send the notify
2405 type SILC_NOTIFY_TYPE_SIGNOFF to its primary router and to all channels
2406 the client was joined.  The server MUST also save the client's information
2407 for a period of time for history purposes.
2408
2409 When remote server or router connection is closed the server or router
2410 MUST also remove all the clients that was behind the server or router
2411 from the SILC Network.  The server or router MUST also send the notify
2412 type SILC_NOTIFY_TYPE_SERVER_SIGNOFF to its primary router and to all
2413 local clients that are joined on the same channels with the remote
2414 server's or router's clients.
2415
2416 Router server MUST also check whether some client in the local cell
2417 is watching for the nickname this client has, and send the
2418 SILC_NOTIFY_TYPE_WATCH to the watcher, unless the client which left
2419 the network has the SILC_UMODE_REJECT_WATCHING user mode set.
2420
2421
2422 .ti 0
2423 4.11 Detaching and Resuming a Session
2424
2425 SILC protocol provides a possibility for a client to detach itself from
2426 the network without actually signing off from the network.  The client
2427 connection to the server is closed but the client remains as valid client
2428 in the network.  The client may then later resume its session back from
2429 any server in the network.
2430
2431 When client wishes to detach from the network it MUST send the
2432 SILC_COMMAND_DETACH command to its server.  The server then MUST set
2433 SILC_UMODE_DETACHED mode to the client and send SILC_NOTIFY_UMODE_CHANGE
2434 notify to its primary router, which then MUST broadcast it further
2435 to other routers in the network.  This user mode indicates that the
2436 client is detached from the network.  Implementations MUST NOT use
2437 the SILC_UMODE_DETACHED flag to determine whether a packet can be sent
2438 to the client.  All packets MUST still be sent to the client even if
2439 client is detached from the network.  Only the server that originally
2440 had the active client connection is able to make the decision after it
2441 notices that the network connection is not active.  In this case the
2442 default case is to discard the packet.
2443
2444 The SILC_UMODE_DETACHED flag cannot be set by client itself directly
2445 with SILC_COMMAND_UMODE command, but only implicitly by sending the
2446 SILC_COMMAND_DETACH command.  The flag also cannot be unset by the
2447 client, server or router with SILC_COMMAND_UMODE command, but only
2448 implicitly by sending and receiving the SILC_PACKET_RESUME_CLIENT
2449 packet.
2450
2451 When the client wishes to resume its session in the SILC Network it
2452 connects to a server in the network, which MAY also be a different
2453 from the original server, and performs normal procedures regarding
2454 creating a connection as described in section 4.1.  After the SKE
2455 and the Connection Authentication protocols has been successfully
2456 completed the client MUST NOT send SILC_PACKET_NEW_CLIENT packet, but
2457 MUST send SILC_PACKET_RESUME_CLIENT packet.  This packet is used to
2458 perform the resuming procedure.  The packet MUST include the detached
2459 client's Client ID, which the client must know.  It also includes
2460 Authentication Payload which includes signature computed with the
2461 client's private key.  The signature is computed as defined in the
2462 section 3.9.1.  Thus, the authentication method MUST be based in
2463 public key authentication.
2464
2465 When server receive the SILC_PACKET_RESUME_CLIENT packet it MUST
2466 do the following:  Server checks that the Client ID is valid client
2467 and that it has the SILC_UMODE_DETACHED mode set.  Then it verifies
2468 the Authentication Payload with the detached client's public key.
2469 If it does not have the public key it retrieves it by sending
2470 SILC_COMMAND_GETKEY command to the server that has the public key from
2471 the original client connection.  The server MUST NOT use the public
2472 key received in the SKE protocol for this connection.  If the
2473 signature is valid the server unsets the SILC_UMODE_DETACHED flag,
2474 and sends the SILC_PACKET_RESUME_CLIENT packet to its primary router.
2475 The routers MUST broadcast the packet and unset the SILC_UMODE_DETACHED
2476 flag when the packet is received.  If the server is router server it
2477 also MUST send the SILC_PACKET_RESUME_CLIENT packet to the original
2478 server whom owned the detached client.
2479
2480 The servers and routers that receives the SILC_PACKET_RESUME_CLIENT
2481 packet MUST know whether the packet already has been received for
2482 the client.  It is a protocol error to attempt to resume the client
2483 session from more than one server.  The implementations could set
2484 internal flag that indicates that the client is resumed.  If router
2485 receive SILC_PACKET_RESUME_CLIENT packet for client that is already
2486 resumed the client MUST be killed from the network.  This would
2487 indicate that the client is attempting to resume the session more
2488 than once which is a protocol error.  In this case the router sends
2489 SILC_NOTIFY_TYPE_KILLED to the client.  All routers that detect
2490 the same situation MUST also send the notify for the client.
2491
2492 The servers and routers that receive the SILC_PACKET_RESUME_CLIENT
2493 must also understand that the client may not be found behind the
2494 same server that it originally came from.  They must update their
2495 caches according to this.  The server that now owns the client session
2496 MUST check whether the Client ID of the resumed client is based
2497 on the server's Server ID.  If it is not it creates a new Client
2498 ID and send SILC_NOTIFY_TYPE_NICK_CHANGE to the network.  It MUST
2499 also send the channel keys of all channels that the client has
2500 joined to the client since it does not have them.  Whether the
2501 Client ID was changed or not the server MUST send SILC_PACKET_NEW_ID
2502 packet to the client.  Only after this is the client resumed back
2503 to the network and may start sending packets and messages.
2504
2505 It is also possible that the server did not know about the global
2506 channels before the client resumed.  In this case it joins the client
2507 to the channels, generates new channel keys and distributes the keys
2508 to the channels as described in section 4.4.
2509
2510 It is an implementation issue for how long servers keep detached client
2511 sessions.  It is RECOMMENDED that the detached sessions would be
2512 persistent as long as the server is running.
2513
2514
2515 .ti 0
2516 5 Security Considerations
2517
2518 Security is central to the design of this protocol, and these security
2519 considerations permeate the specification.  Common security considerations
2520 such as keeping private keys truly private and using adequate lengths for
2521 symmetric and asymmetric keys must be followed in order to maintain the
2522 security of this protocol.
2523
2524 Special attention must also be paid to the servers and routers that are
2525 running the SILC service.  The SILC protocol's security depends greatly
2526 on the security and the integrity of the servers and administrators that
2527 are running the service.  It is recommended that some form of registration
2528 is required by the server and router administrator prior to acceptance to
2529 the SILC Network.  Even though the SILC protocol is secure in a network
2530 of mutual distrust between clients, servers, routers and administrators
2531 of the servers, the client should be able to trust the servers they are
2532 using if they wish to do so.
2533
2534 It however must be noted that if the client requires absolute security
2535 by not trusting any of the servers or routers in the SILC Network, it can
2536 be accomplished by negotiating private keys outside the SILC Network,
2537 either using SKE or some other key exchange protocol, or to use some
2538 other external means for distributing the keys.  This applies for all
2539 messages, private messages and channel messages.
2540
2541 It is important to note that SILC, like any other security protocol, is
2542 not a foolproof system; the SILC servers and routers could very well be
2543 compromised.  However, to provide an acceptable level of security and
2544 usability for end users, the protocol uses many times session keys or
2545 other keys generated by the servers to secure the messages.  This is an
2546 intentional design feature to allow ease of use for end users.  This way
2547 the network is still usable, and remains encrypted even if the external
2548 means of distributing the keys is not working.  The implementation,
2549 however, may like to not follow this design feature, and may always
2550 negotiate the keys outside SILC network.  This is an acceptable solution
2551 and many times recommended.  The implementation still must be able to
2552 work with the server generated keys.
2553
2554 If this is unacceptable for the client or end user, the private keys
2555 negotiated outside the SILC Network should always be used.  In the end
2556 it is the implementor's choice whether to negotiate private keys by
2557 default or whether to use the keys generated by the servers.
2558
2559 It is also recommended that router operators in the SILC Network would
2560 form a joint forum to discuss the router and SILC Network management
2561 issues.  Also, router operators along with the cell's server operators
2562 should have a forum to discuss the cell management issues.
2563
2564
2565 .ti 0
2566 6 References
2567
2568 [SILC2]      Riikonen, P., "SILC Packet Protocol", Internet Draft,
2569              May 2002.
2570
2571 [SILC3]      Riikonen, P., "SILC Key Exchange and Authentication
2572              Protocols", Internet Draft, May 2002.
2573
2574 [SILC4]      Riikonen, P., "SILC Commands", Internet Draft, May 2002.
2575
2576 [IRC]        Oikarinen, J., and Reed D., "Internet Relay Chat Protocol",
2577              RFC 1459, May 1993.
2578
2579 [IRC-ARCH]   Kalt, C., "Internet Relay Chat: Architecture", RFC 2810,
2580              April 2000.
2581
2582 [IRC-CHAN]   Kalt, C., "Internet Relay Chat: Channel Management", RFC
2583              2811, April 2000.
2584
2585 [IRC-CLIENT] Kalt, C., "Internet Relay Chat: Client Protocol", RFC
2586              2812, April 2000.
2587
2588 [IRC-SERVER] Kalt, C., "Internet Relay Chat: Server Protocol", RFC
2589              2813, April 2000.
2590
2591 [SSH-TRANS]  Ylonen, T., et al, "SSH Transport Layer Protocol",
2592              Internet Draft.
2593
2594 [PGP]        Callas, J., et al, "OpenPGP Message Format", RFC 2440,
2595              November 1998.
2596
2597 [SPKI]       Ellison C., et al, "SPKI Certificate Theory", RFC 2693,
2598              September 1999.
2599
2600 [PKIX-Part1] Housley, R., et al, "Internet X.509 Public Key
2601              Infrastructure, Certificate and CRL Profile", RFC 2459,
2602              January 1999.
2603
2604 [Schneier]   Schneier, B., "Applied Cryptography Second Edition",
2605              John Wiley & Sons, New York, NY, 1996.
2606
2607 [Menezes]    Menezes, A., et al, "Handbook of Applied Cryptography",
2608              CRC Press 1997.
2609
2610 [OAKLEY]     Orman, H., "The OAKLEY Key Determination Protocol",
2611              RFC 2412, November 1998.
2612
2613 [ISAKMP]     Maughan D., et al, "Internet Security Association and
2614              Key Management Protocol (ISAKMP)", RFC 2408, November
2615              1998.
2616
2617 [IKE]        Harkins D., and Carrel D., "The Internet Key Exchange
2618              (IKE)", RFC 2409, November 1998.
2619
2620 [HMAC]       Krawczyk, H., "HMAC: Keyed-Hashing for Message
2621              Authentication", RFC 2104, February 1997.
2622
2623 [PKCS1]      Kalinski, B., and Staddon, J., "PKCS #1 RSA Cryptography
2624              Specifications, Version 2.0", RFC 2437, October 1998.
2625
2626 [RFC2119]    Bradner, S., "Key Words for use in RFCs to Indicate
2627              Requirement Levels", BCP 14, RFC 2119, March 1997.
2628
2629 [RFC3629]    Yergeau, F., "UTF-8, a transformation format of ISO
2630              10646", RFC 3629, November 2003.
2631
2632 [RFC1321]    Rivest R., "The MD5 Message-Digest Algorithm", RFC 1321,
2633              April 1992.
2634
2635 [RFC3174]    Eastlake, F., et al., "US Secure Hash Algorithm 1 (SHA1)",
2636              RFC 3174, September 2001.
2637
2638 [PKCS7]      Kalinski, B., "PKCS #7: Cryptographic Message Syntax,
2639              Version 1.5", RFC 2315, March 1998.
2640
2641 [RFC2253]    Wahl, M., et al., "Lightweight Directory Access Protocol
2642              (v3): UTF-8 String Representation of Distinguished Names",
2643              RFC 2253, December 1997.
2644
2645 [RFC3454]    Hoffman, P., et al., "Preparation of Internationalized
2646              Strings ("stringprep")", RFC 3454, December 2002.
2647
2648
2649 .ti 0
2650 7 Author's Address
2651
2652 .nf
2653 Pekka Riikonen
2654 Snellmaninkatu 34 A 15
2655 70100 Kuopio
2656 Finland
2657
2658 EMail: priikone@iki.fi
2659
2660
2661 .ti 0
2662 Appendix A
2663
2664 This appendix defines the stringprep [RFC3454] profile for string
2665 identifiers in SILC protocol.  Compliant implementation MUST use this
2666 profile to prepare the identifier strings in the SILC protocol.  The
2667 profile defines the following as required by [RFC3454].
2668
2669 - Intended applicability of the profile:  the following identifiers in
2670   the SILC Protocol;  nicknames, channel names, usernames, server names,
2671   hostnames, service names, algorithm names and other security property
2672   names [SILC3], and SILC Public Key name.
2673
2674 - The character repertoire that is the input and output to
2675   stringprep:  Unicode 3.2 with the list of unassigned code points
2676   being the Table A.1, as defined in [RFC3454].
2677
2678 - The mapping tables used:  the following tables are used, in order,
2679   as defined in [RFC3454].
2680
2681     Table B.1
2682     Table B.2
2683
2684   The mandatory case folding is done using the Table B.2 which includes
2685   the characters for the normalization form KC.
2686
2687 - The Unicode normalization used:  the Unicode normalization form
2688   KC is used, as defined in [RFC3454].
2689
2690 - The prohibited characters as output:  the following tables are used
2691   to prohibit characters, as defined in [RFC3454];
2692
2693     Table C.1.1
2694     Table C.1.2
2695     Table C.2.1
2696     Table C.2.2
2697     Table C.3
2698     Table C.4
2699     Table C.5
2700     Table C.6
2701     Table C.7
2702     Table C.8
2703     Table C.9
2704
2705 - Additional prohibited characters as output:  in addition, the following
2706   tables are used to prohibit characters, as defined in this document;
2707
2708     Appendix B
2709
2710 - The bidirectional string testing used:  bidirectional string testing
2711   is ignored in this profile.
2712
2713 This profile is to be maintained in the IANA registry for stringprep
2714 profiles.  The name of this profile is "silc-identifier-prep" and this
2715 document defines the profile.  This document defines the first version of
2716 this profile.
2717
2718
2719 .ti 0
2720 Appendix B
2721
2722 This appendix defines additional prohibited characters in the identifier
2723 strings as defined in the stringprep profile in Appendix A.  Note that
2724 the prohibited character tables listed in the Appendix A may include some
2725 of the same characters listed in this appendix as well.
2726
2727 Reserved US-ASCII characters
2728 0021 002A 002C 003F 0040
2729
2730 Symbol characters and other symbol like characters
2731 00A2-00A9 00AC 00AE 00AF 00B0 00B1 00B4 00B6 00B8 00D7 00F7
2732 02C2-02C5 02D2-02FF 0374 0375 0384 0385 03F6 0482 060E 060F
2733 06E9 06FD 06FE 09F2 09F3 09FA 0AF1 0B70 0BF3-0BFA 0E3F
2734 0F01-0F03 0F13-0F17 0F1A-0F1F 0F34 0F36 0F38 0FBE 0FBF
2735 0FC0-0FC5 0FC7-0FCF 17DB 1940 19E0-19FF 1FBD 1FBF-1FC1
2736 1FCD-1FCF 1FDD-1FDF 1FED-1FEF 1FFD 1FFE 2044 2052 207A-207C
2737 208A-208C 20A0-20B1 2100-214F 2150-218F 2190-21FF 2200-22FF
2738 2300-23FF 2400-243F 2440-245F 2460-24FF 2500-257F 2580-259F
2739 25A0-25FF 2600-26FF 2700-27BF 27C0-27EF 27F0-27FF 2800-28FF
2740 2900-297F 2980-29FF 2A00-2AFF 2B00-2BFF 2E9A 2EF4-2EFF
2741 2FF0-2FFF 303B-303D 3040 3095-3098 309F-30A0 30FF-3104
2742 312D-3130 318F 31B8-31FF 321D-321F 3244-325F 327C-327E
2743 32B1-32BF 32CC-32CF 32FF 3377-337A 33DE-33DF 33FF 4DB6-4DFF
2744 9FA6-9FFF A48D-A48F A4A2-A4A3 A4B4 A4C1 A4C5 A4C7-ABFF
2745 D7A4-D7FF FA2E-FAFF FFE0-FFEE FFFC 10000-1007F 10080-100FF
2746 10100-1013F 1D000-1D0FF 1D100-1D1FF 1D300-1D35F 1D400-1D7FF
2747
2748 Other characters
2749 E0100-E01EF
2750
2751
2752 .ti 0
2753 Full Copyright Statement
2754
2755 Copyright (C) The Internet Society (2003). All Rights Reserved.
2756
2757 This document and translations of it may be copied and furnished to
2758 others, and derivative works that comment on or otherwise explain it
2759 or assist in its implementation may be prepared, copied, published
2760 and distributed, in whole or in part, without restriction of any
2761 kind, provided that the above copyright notice and this paragraph are
2762 included on all such copies and derivative works. However, this
2763 document itself may not be modified in any way, such as by removing
2764 the copyright notice or references to the Internet Society or other
2765 Internet organizations, except as needed for the purpose of
2766 developing Internet standards in which case the procedures for
2767 copyrights defined in the Internet Standards process must be
2768 followed, or as required to translate it into languages other than
2769 English.
2770
2771 The limited permissions granted above are perpetual and will not be
2772 revoked by the Internet Society or its successors or assigns.
2773
2774 This document and the information contained herein is provided on an
2775 "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
2776 TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
2777 BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
2778 HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
2779 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.