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