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