updates.
[silc.git] / doc / draft-riikonen-silc-spec-05.nroff
1 .pl 10.0i
2 .po 0
3 .ll 7.2i
4 .lt 7.2i
5 .nr LL 7.2i
6 .nr LT 7.2i
7 .ds LF Riikonen
8 .ds RF FORMFEED[Page %]
9 .ds CF
10 .ds LH Internet Draft
11 .ds RH XXX
12 .ds CH
13 .na
14 .hy 0
15 .in 0
16 .nf
17 Network Working Group                                        P. Riikonen
18 Internet-Draft
19 draft-riikonen-silc-spec-05.txt                        XXX
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-05.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 is IRC [IRC] like protocol, however, it is 
58 not equivalent to IRC and does not support IRC.  Strong cryptographic
59 methods are used to protect SILC packets inside the SILC network.
60 Three other Internet Drafts relates very closely to this memo;
61 SILC Packet Protocol [SILC2], SILC Key Exchange and Authentication
62 Protocols [SILC3] and SILC Commands [SILC4].
63
64
65
66
67
68
69 .ti 0
70 Table of Contents
71
72 .nf
73 1 Introduction ..................................................  3
74   1.1 Requirements Terminology ..................................  4
75 2 SILC Concepts .................................................  4
76   2.1 SILC Network Topology .....................................  4
77   2.2 Communication Inside a Cell ...............................  5
78   2.3 Communication in the Network ..............................  6
79   2.4 Channel Communication .....................................  7
80   2.5 Router Connections ........................................  7
81 3 SILC Specification ............................................  8
82   3.1 Client ....................................................  8
83       3.1.1 Client ID ...........................................  9
84   3.2 Server .................................................... 10
85       3.2.1 Server's Local ID List .............................. 10
86       3.2.2 Server ID ........................................... 11
87       3.2.3 SILC Server Ports ................................... 12
88   3.3 Router .................................................... 12
89       3.3.1 Router's Local ID List .............................. 12
90       3.3.2 Router's Global ID List ............................. 13
91       3.3.3 Router's Server ID .................................. 14
92   3.4 Channels .................................................. 14
93       3.4.1 Channel ID .......................................... 16
94   3.5 Operators ................................................. 16
95   3.6 SILC Commands ............................................. 16
96   3.7 SILC Packets .............................................. 17
97   3.8 Packet Encryption ......................................... 17
98       3.8.1 Determination of the Source and the Destination ..... 17
99       3.8.2 Client To Client .................................... 18
100       3.8.3 Client To Channel ................................... 19
101       3.8.4 Server To Server .................................... 20
102   3.9 Key Exchange And Authentication ........................... 20
103       3.9.1 Authentication Payload .............................. 20
104   3.10 Algorithms ............................................... 22
105       3.10.1 Ciphers ............................................ 22
106       3.10.2 Public Key Algorithms .............................. 23
107       3.10.3 Hash Functions ..................................... 24
108       3.10.4 MAC Algorithms ..................................... 24
109       3.10.5 Compression Algorithms ............................. 25
110   3.11 SILC Public Key .......................................... 25
111   3.12 SILC Version Detection ................................... 27
112   3.13 Backup Routers ........................................... 28
113       3.13.1 Switching to Backup Router ......................... 29
114       3.13.2 Resuming Primary Router ............................ 30
115       3.13.3 Discussion on Backup Router Scheme ................. 32
116 4 SILC Procedures ............................................... 33
117   4.1 Creating Client Connection ................................ 33
118   4.2 Creating Server Connection ................................ 34
119       4.2.1 Announcing Clients, Channels and Servers ............ 35
120   4.3 Joining to a Channel ...................................... 36
121   4.4 Channel Key Generation .................................... 37
122   4.5 Private Message Sending and Reception ..................... 38
123   4.6 Private Message Key Generation ............................ 38
124   4.7 Channel Message Sending and Reception ..................... 39
125   4.8 Session Key Regeneration .................................. 39
126   4.9 Command Sending and Reception ............................. 40
127   4.10 Closing Connection ....................................... 41
128   4.11 Detaching and Resuming a Session ......................... XXXXX
129 5 Security Considerations ....................................... 41
130 6 References .................................................... 42
131 7 Author's Address .............................................. 44
132
133
134
135 .ti 0
136 List of Figures
137
138 .nf
139 Figure 1:  SILC Network Topology
140 Figure 2:  Communication Inside cell
141 Figure 3:  Communication Between Cells
142 Figure 4:  Router Connections
143 Figure 5:  SILC Public Key
144
145
146 .ti 0
147 1. Introduction
148
149 This document describes a Secure Internet Live Conferencing (SILC)
150 protocol which provides secure conferencing services over insecure
151 network channel.  SILC is IRC [IRC] like protocol, however, it is 
152 not equivalent to IRC and does not support IRC.  Some of the SILC's
153 features are not found in IRC but in traditional Instant Message (IM)
154 protocols.  SILC combines features from both of these chat protocol
155 styles, and SILC can be implemeneted as either IRC-like system or
156 IM-like system.
157
158 Strong cryptographic methods are used to protect SILC packets inside
159 the SILC network.  Three other Internet Drafts relates very closely
160 to this memo; SILC Packet Protocol [SILC2], SILC Key Exchange and
161 Authentication Protocols [SILC3] and SILC Commands [SILC4].
162
163 The protocol uses extensively packets as conferencing protocol 
164 requires message and command sending.  The SILC Packet Protocol is
165 described in [SILC2] and should be read to fully comprehend this
166 document and protocol.  [SILC2] also describes the packet encryption
167 and decryption in detail.  The SILC Packet Protocol provides secured
168 and authenticated packets, and the protocol is designed to be compact.
169 This makes SILC also suitable in environment of low bandwith
170 requirements such as mobile networks.  All packet payloads in SILC
171 can be also compressed.
172
173 The security of SILC protocol, and for any security protocol for that
174 matter, is based on strong and secure key exchange protocol.  The SILC
175 Key Exchange protocol is described in [SILC3] along with connection
176 authentication protocol and should be read to fully comprehend this
177 document and protocol.
178
179 The SILC protocol has been developed to work on TCP/IP network
180 protocol, although it could be made to work on other network protocols
181 with only minor changes.  However, it is recommended that TCP/IP
182 protocol is used under SILC protocol.  Typical implementation would
183 be made in client-server model.
184
185
186 .ti 0
187 1.1 Requirements Terminology
188
189 The keywords MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED, 
190 MAY, and OPTIONAL, when they appear in this document, are to be
191 interpreted as described in [RFC2119].
192
193
194 .ti 0
195 2. SILC Concepts
196
197 This section describes various SILC protocol concepts that forms the 
198 actual protocol, and in the end, the actual SILC network.  The mission
199 of the protocol is to deliver messages from clients to other clients 
200 through routers and servers in secure manner.  The messages may also 
201 be delivered from one client to many clients forming a group, also 
202 known as a channel.
203
204 This section does not focus to security issues.  Instead, basic network 
205 concepts are introduced to make the topology of the SILC network 
206 clear.
207
208
209 .ti 0
210 2.1 SILC Network Topology
211
212 SILC network is a cellular network as opposed to tree style network 
213 topology.  The rationale for this is to have servers that can perform 
214 specific kind of tasks what other servers cannot perform.  This leads 
215 to two kinds of servers; normal SILC servers and SILC routers.
216
217 A difference between normal server and router server is that routers 
218 knows everything about everything in the network.  They also do the 
219 actual routing of the messages to the correct receiver.  Normal servers 
220 knows only about local information and nothing about global information.
221 This makes the network faster as there are less servers that needs to 
222 keep global information up to date at all time.
223
224 This, on the other hand, leads to cellular like network, where routers 
225 are in the center of the cell and servers are connected to the router.
226
227
228
229
230
231
232
233 The following diagram represents SILC network topology.
234
235 .in 8
236 .nf
237   ---- ---- ----         ---- ---- ----
238  | S8 | S5 | S4 |       | S7 | S5 | S6 |
239  ----- ---- -----       ----- ---- -----
240 | S7 | S/R1 | S2 | --- | S8 | S/R2 | S4 |
241  ---- ------ ----       ---- ------ ----
242  | S6 | S3 | S1 |       | S1 | S3 | S2 |         ---- ----
243   ---- ---- ----         ---- ---- ----         | S3 | S1 |
244      Cell 1.   \\             Cell 2.  | \\____  ----- -----
245                 |                     |        | S4 | S/R4 |
246     ---- ---- ----         ---- ---- ----       ---- ------
247    | S7 | S4 | S2 |       | S1 | S3 | S2 |      | S2 | S5 |
248    ----- ---- -----       ----- ---- -----       ---- ----
249   | S6 | S/R3 | S1 | --- | S4 | S/R5 | S5 | ____/ Cell 4.
250    ---- ------ ----       ---- ------ ----
251    | S8 | S5 | S3 |       | S6 | S7 | S8 |     ... etc ...
252     ---- ---- ----         ---- ---- ----
253        Cell 3.                Cell 5.
254 .in 3
255
256 .ce
257 Figure 1:  SILC Network Topology
258
259
260 A cell is formed when a server or servers connect to one router.  In
261 SILC network normal server cannot directly connect to other normal
262 server.  Normal server may only connect to SILC router which then
263 routes the messages to the other servers in the cell.  Router servers
264 on the other hand may connect to other routers to form the actual SILC 
265 network, as seen in above figure.  However, router is also normal SILC 
266 server; clients may connect to it the same way as to normal SILC 
267 server.  Normal server also cannot have active connections to more 
268 than one router.  Normal server cannot be connected to two different 
269 cells.  Router servers, on the other hand, may have as many router to 
270 router connections as needed.
271
272 There are many issues in this network topology that needs to be careful
273 about.  Issues like the size of the cells, the number of the routers in 
274 the SILC network and the capacity requirements of the routers.  These
275 issues should be discussed in the Internet Community and additional
276 documents on the issue may be written.
277
278
279 .ti 0
280 2.2 Communication Inside a Cell
281
282 It is always guaranteed that inside a cell message is delivered to the 
283 recipient with at most two server hops.  A client which is connected to
284 server in the cell and is talking on channel to other client connected 
285 to other server in the same cell, will have its messages delivered from 
286 its local server first to the router of the cell, and from the router 
287 to the other server in the cell.
288
289 The following diagram represents this scenario:
290
291
292 .in 25
293 .nf
294 1 --- S1     S4 --- 5
295          S/R
296  2 -- S2     S3
297      /        |
298     4         3
299 .in 3
300
301
302 .ce
303 Figure 2:  Communication Inside cell
304
305
306 Example:  Client 1. connected to Server 1. send message to
307           Client 4. connected to Server 2. travels from Server 1.
308           first to Router which routes the message to Server 2.
309           which then sends it to the Client 4.  All the other
310           servers in the cell will not see the routed message.
311
312
313 If the client is connected directly to the router, as router is also normal
314 SILC server, the messages inside the cell are always delivered only with 
315 one server hop.  If clients communicating with each other are connected 
316 to the same server, no router interaction is needed.  This is the optimal
317 situation of message delivery in the SILC network.
318
319
320 .ti 0
321 2.3 Communication in the Network
322
323 If the message is destined to server that does not belong to local cell 
324 the message is routed to the router server to which the destination 
325 server belongs, if the local router is connected to destination router.
326 If there is no direct connection to the destination router, the local
327 router routes the message to its primary route.  The following diagram
328 represents message sending between cells.
329
330
331 .in 16
332 .nf
333 1 --- S1     S4 --- 5            S2 --- 1
334          S/R - - - - - - - - S/R
335  2 -- S2     S3           S1
336      /        |             \\
337     4         3              2
338
339    Cell 1.               Cell 2.
340 .in 3
341
342
343 .ce
344 Figure 3:  Communication Between Cells
345
346
347 Example:  Client 5. connected to Server 4. in Cell 1. sends message
348           to Client 2. connected to Server 1. in Cell 2. travels
349           from Server 4. to Router which routes the message to
350           Router in Cell 2, which then routes the message to 
351           Server 1.  All the other servers and routers in the
352           network will not see the routed message.
353
354
355 The optimal case of message delivery from the client point of view is
356 when clients are connected directly to the routers and the messages
357 are delivered from one router to the other.
358
359
360 .ti 0 
361 2.4 Channel Communication
362
363 Messages may be sent to group of clients as well.  Sending messages to
364 many clients works the same way as sending messages point to point, from
365 message delivery point of view.  Security issues are another matter
366 which are not discussed in this section.
367
368 Router server handles the message routing to multiple recipients.  If 
369 any recipient is not in the same cell as the sender the messages are 
370 routed further.
371
372 Server distributes the channel message to its local clients which are 
373 joined to the channel.  Router also distributes the message to its 
374 local clients on the channel.
375
376
377 .ti 0
378 2.5 Router Connections
379
380 Router connections play very important role in making the SILC like
381 network topology to work.  For example, sending broadcast packets in
382 SILC network require special connections between routers; routers must
383 be connected in a specific way.
384
385 Every router has their primary route which is a connection to another
386 router in the network.  Unless there is only two routers in the network
387 must not routers use each other as their primary routes.  The router
388 connections in the network must form a ring.
389
390
391
392
393
394
395
396 Example with three routers in the network:
397
398
399 .in 16
400 .nf
401     S/R1 - < - < - < - < - < - < - S/R2
402      \\                               /
403       v                             ^
404        \\ - > -  > - S/R3 - > - > - /
405 .in 3
406
407
408 .ce
409 Figure 4:  Router Connections
410
411
412 Example:  Network with three routers.  Router 1. uses Router 2. as its
413           primary router.  Router 2. uses Router 3. as its primary router,
414           and Router 3. uses Router 1. as its primary router.  There may
415           be other direct connections between the routers but they must
416           not be used as primary routes.
417
418 The above example is applicable to any amount of routers in the network
419 except for two routers.  If there are only two routers in the network both
420 routers must be able to handle situation where they use each other as their
421 primary routes.
422
423 The issue of router connections are very important especially with SILC
424 broadcast packets.  Usually all router wide information in the network is
425 distributed by SILC broadcast packets.  This sort of ring network, with
426 ability to have other direct routes in the network cause interesting
427 routing problems.  The [SILC2] discusses the routing of packets in this
428 sort of network in more detail.
429
430
431 .ti 0
432 3. SILC Specification
433
434 This section describes the SILC protocol.  However, [SILC2] and
435 [SILC3] describes other important protocols that are part of this SILC
436 specification and must be read.
437
438
439 .ti 0
440 3.1 Client
441
442 A client is a piece of software connecting to SILC server.  SILC client 
443 cannot be SILC server.  Purpose of clients is to provide the user 
444 interface of the SILC services for end user.  Clients are distinguished
445 from other clients by unique Client ID.  Client ID is a 128 bit ID that
446 is used in the communication in the SILC network.  The client ID is 
447 based on the nickname selected by the user.  User uses logical nicknames
448 in communication which are then mapped to the corresponding Client ID.
449 Client ID's are low level identifications and must not be seen by the
450 end user.
451
452 Clients provide other information about the end user as well. Information
453 such as the nickname of the user, username and the host name of the end 
454 user and user's real name.  See section 3.2 Server for information of 
455 the requirements of keeping this information.
456
457 The nickname selected by the user is not unique in the SILC network.
458 There can be 2^8 same nicknames for one IP address.  As for comparison
459 to IRC [IRC] where nicknames are unique this is a fundamental difference
460 between SILC and IRC.  This causes the server names or client's host names
461 to be used along with the nicknames to identify specific users when sending
462 messages.  This feature of SILC makes IRC style nickname-wars obsolete as
463 no one owns their nickname; there can always be someone else with the same
464 nickname.  The maximum length of nickname is 128 bytes.
465
466
467 .ti 0
468 3.1.1 Client ID
469
470 Client ID is used to identify users in the SILC network.  The Client ID
471 is unique to the extent that there can be 2^128 different Client ID's,
472 and ID's based on IPv6 addresses extends this to 2^224 different Client
473 ID's.  Collisions are not expected to happen.  The Client ID is defined
474 as follows.
475
476
477
478 .in 6
479 128 bit Client ID based on IPv4 addresses:
480
481 32 bit  Server ID IP address (bits 1-32)
482  8 bit  Random number or counter
483 88 bit  Truncated MD5 hash value of the nickname
484
485 224 bit Client ID based on IPv6 addresses:
486
487 128 bit  Server ID IP address (bits 1-128)
488   8 bit  Random number or counter
489  88 bit  Truncated MD5 hash value of the nickname
490
491 o Server ID IP address - Indicates the server where this
492   client is coming from.  The IP address hence equals the
493   server IP address where to the client has connected.
494
495 o Random number or counter - Random number to further 
496   randomize the Client ID.  Another choice is to use
497   a counter starting from the zero (0).  This makes it
498   possible to have 2^8 same nicknames from the same
499   server IP address.
500
501 o MD5 hash - MD5 hash value of the lowercase nickname is
502   truncated taking 88 bits from the start of the hash value.
503   This hash value is used to search the user's Client ID
504   from the ID lists.  Note that the nickname MUST be in
505   lowercase format.
506
507 .in 3
508 Collisions could occur when more than 2^8 clients using same nickname
509 from the same server IP address is connected to the SILC network.  
510 Server MUST be able to handle this situation by refusing to accept 
511 anymore of that nickname.
512
513 Another possible collision may happen with the truncated hash value of
514 the nickname.  It could be possible to have same truncated hash value for
515 two different nicknames.  However, this is not expected to happen nor
516 cause any problems if it would occur.  Nicknames are usually logical and
517 it is unlikely to have two distinct logical nicknames produce same
518 truncated hash value.
519
520
521 .ti 0
522 3.2 Server
523
524 Servers are the most important parts of the SILC network.  They form the
525 basis of the SILC, providing a point to which clients may connect to.
526 There are two kinds of servers in SILC; normal servers and router servers.
527 This section focus on the normal server and router server is described
528 in the section 3.3 Router.
529
530 Normal servers MUST NOT directly connect to other normal server.  Normal
531 servers may only directly connect to router server.  If the message sent
532 by the client is destined outside the local server it is always sent to
533 the router server for further routing.  Server may only have one active
534 connection to router on same port.  Normal server MUST NOT connect to other
535 cell's router except in situations where its cell's router is unavailable.
536
537
538 .ti 0
539 3.2.1 Server's Local ID List
540
541 Normal server keeps various information about the clients and their end
542 users connected to it.  Every normal server MUST keep list of all locally
543 connected clients, Client ID's, nicknames, usernames and host names and
544 user's real name.  Normal servers only keeps local information and it
545 does not keep any global information.  Hence, normal servers knows only
546 about their locally connected clients.  This makes servers efficient as
547 they don't have to worry about global clients.  Server is also responsible
548 of creating the Client ID's for their clients.
549
550 Normal server also keeps information about locally created channels and
551 their Channel ID's.
552
553
554 Hence, local list for normal server includes:
555
556 .in 6
557 server list        - Router connection
558    o Server name
559    o Server IP address
560    o Server ID
561    o Sending key
562    o Receiving key
563    o Public key
564
565 client list        - All clients in server
566    o Nickname
567    o Username@host
568    o Real name
569    o Client ID
570    o Sending key
571    o Receiving key
572    o Public key
573
574
575 channel list       - All channels in server
576    o Channel name
577    o Channel ID
578    o Client ID's on channel
579    o Client ID modes on channel
580    o Channel key
581 .in 3
582
583
584 .ti 0
585 3.2.2 Server ID
586
587 Servers are distinguished from other servers by unique 64 bit Server ID 
588 (for IPv4) or 160 bit Server ID (for IPv6).  The Server ID is used in
589 the SILC to route messages to correct servers.  Server ID's also provide
590 information for Client ID's, see section 3.1.1 Client ID.  Server ID is
591 defined as follows.
592
593 .in 6
594 64 bit Server ID based on IPv4 addresses:
595
596 32 bit  IP address of the server
597 16 bit  Port
598 16 bit  Random number
599
600 160 bit Server ID based on IPv6 addresses:
601
602 128 bit  IP address of the server
603  16 bit  Port
604  16 bit  Random number
605
606 o IP address of the server - This is the real IP address of
607   the server.
608
609 o Port - This is the port the server is bound to.
610
611 o Random number - This is used to further randomize the Server ID.
612
613 .in 3
614 Collisions are not expected to happen in any conditions.  The Server ID
615 is always created by the server itself and server is responsible of
616 distributing it to the router.
617
618
619 .ti 0
620 3.2.3 SILC Server Ports
621
622 The following ports has been assigned by IANA for the SILC protocol:
623
624 .in 10
625 silc            706/tcp    SILC
626 silc            706/udp    SILC
627 .in 3
628
629
630 If there are needs to create new SILC networks in the future the port
631 numbers must be officially assigned by the IANA.
632
633 Server on network above privileged ports (>1023) SHOULD NOT be trusted
634 as they could have been set up by untrusted party.
635
636
637 .ti 0
638 3.3 Router
639
640 Router server in SILC network is responsible for keeping the cell together
641 and routing messages to other servers and to other routers.  Router server
642 is also a normal server thus clients may connect to it as it would be
643 just normal SILC server.
644
645 However, router servers has a lot of important tasks that normal servers
646 do not have.  Router server knows everything about everything in the SILC.
647 They know all clients currently on SILC, all servers and routers and all
648 channels in SILC.  Routers are the only servers in SILC that care about
649 global information and keeping them up to date at all time.  And, this
650 is what they must do.
651
652
653 .ti 0
654 3.3.1 Router's Local ID List
655
656 Router server as well MUST keep local list of connected clients and
657 locally created channels.  However, this list is extended to include all
658 the informations of the entire cell, not just the server itself as for
659 normal servers.
660
661 However, on router this list is a lot smaller since routers do not need
662 to keep information about user's nickname, username and host name and real
663 name since these are not needed by the router.  The router keeps only
664 information that it needs.
665
666
667 Hence, local list for router includes:
668
669 .in 6
670 server list        - All servers in the cell
671    o Server name
672    o Server ID
673    o Router's Server ID
674    o Sending key
675    o Receiving key
676
677 client list        - All clients in the cell
678    o Client ID
679
680
681 channel list       - All channels in the cell
682    o Channel ID
683    o Client ID's on channel
684    o Client ID modes on channel
685    o Channel key
686 .in 3
687
688
689 Note that locally connected clients and other information include all the
690 same information as defined in section section 3.2.1 Server's Local ID
691 List.
692
693
694 .ti 0
695 3.3.2 Router's Global ID List
696
697 Router server MUST also keep global list.  Normal servers do not have
698 global list as they know only about local information.  Global list
699 includes all the clients on SILC, their Client ID's, all created channels
700 and their Channel ID's and all servers and routers on SILC and their
701 Server ID's.  That is said, global list is for global information and the
702 list must not include the local information already on the router's local
703 list.
704
705 Note that the global list does not include information like nicknames,
706 usernames and host names or user's real names.  Router does not need to
707 keep these informations as they are not needed by the router.  This 
708 information is available from the client's server which maybe queried
709 when needed.
710
711 Hence, global list includes:
712
713 .in 6
714 server list        - All servers in SILC
715    o Server name
716    o Server ID
717    o Router's Server ID
718
719 client list        - All clients in SILC
720    o Client ID
721
722 channel list       - All channels in SILC
723    o Channel ID
724    o Client ID's on channel
725    o Client ID modes on channel
726 .in 3
727
728
729
730 .ti 0
731 3.3.3 Router's Server ID
732
733 Router's Server ID's are equivalent to normal Server ID's.  As routers
734 are normal servers as well same types of ID's applies for routers as well.
735 Thus, see section 3.2.2 Server ID.
736
737
738 .ti 0
739 3.4 Channels
740
741 A channel is a named group of one or more clients which will all receive
742 messages addressed to that channel.  The channel is created when first
743 client requests JOIN command to the channel, and the channel ceases to
744 exist when the last client has left it.  When channel exists, any client
745 can reference it using the name of the channel.  If the channel has
746 a founder mode set and last client leaves the channel the channel does
747 not cease to exist.  The founder mode can be used to make permanent
748 channels in the network.  The founder of the channel can regain the
749 channel founder privileges on the channel later when he joins the
750 channel.
751
752 Channel names are unique although the real uniqueness comes from 64 bit
753 Channel ID.  However, channel names are still unique and no two global
754 channels with same name may exist.  The channel name is a string of
755 maximum length of 256 bytes.  Channel names MUST NOT contain any
756 whitespaces (`  '), any non-printable ASCII characters, commas (`,')
757 and wildcard characters.
758
759 Channels can have operators that can administrate the channel and
760 operate all of its modes.  The following operators on channel exist on
761 the SILC network.
762
763 .in 6
764 o Channel founder - When channel is created the joining client becomes
765   channel founder.  Channel founder is channel operator with some more
766   privileges.  Basically, channel founder can fully operate the channel
767   and all of its modes.  The privileges are limited only to the
768   particular channel.  There can be only one channel founder per
769   channel. Channel founder supersedes channel operator's privileges.
770
771   Channel founder privileges cannot be removed by any other operator on
772   channel.  When channel founder leaves the channel there is no channel
773   founder on the channel.  However, it is possible to set a mode for
774   the channel which allows the original channel founder to regain the
775   founder privileges even after leaving the channel.  Channel founder
776   also cannot be removed by force from the channel.
777
778 o Channel operator - When client joins to channel that has not existed
779   previously it will become automatically channel operator (and channel
780   founder discussed above).  Channel operator is able administrate the
781   channel, set some modes on channel, remove a badly behaving client
782   from the channel and promote other clients to become channel
783   operator.  The privileges are limited only to the particular channel.
784
785   Normal channel user may be promoted (opped) to channel operator
786   gaining channel operator privileges.  Channel founder or other
787   channel operator may also demote (deop) channel operator to normal
788   channel user.
789 .in 3
790
791
792 .ti 0
793 3.4.1 Channel ID
794
795 Channels are distinguished from other channels by unique Channel ID.
796 The Channel ID is a 64 bit ID (for IPv4) or 160 bit ID (for IPv6), and
797 collisions are not expected to happen in any conditions.  Channel names
798 are just for logical use of channels.  The Channel ID is created by the
799 server where the channel is created.  The Channel ID is defined as
800 follows.
801
802 .in 6
803 64 bit Channel ID based on IPv4 addresses:
804
805 32 bit  Router's Server ID IP address (bits 1-32)
806 16 bit  Router's Server ID port (bits 33-48)
807 16 bit  Random number
808
809 160 bit Channel ID based on IPv6 addresses:
810
811 128 bit  Router's Server ID IP address (bits 1-128)
812  16 bit  Router's Server ID port (bits 129-144)
813  16 bit  Random number
814
815 o Router's Server ID IP address - Indicates the IP address of 
816   the router of the cell where this channel is created.  This is 
817   taken from the router's Server ID.  This way SILC router knows 
818   where this channel resides in the SILC network.
819
820 o Router's Server ID port - Indicates the port of the channel on 
821   the server.  This is taken from the router's Server ID.
822
823 o Random number - To further randomize the Channel ID.  This makes
824   sure that there are no collisions.  This also means that
825   in a cell there can be 2^16 channels.
826 .in 3
827
828
829 .ti 0
830 3.5 Operators
831
832 Operators are normal users with extra privileges to their server or
833 router.  Usually these people are SILC server and router administrators
834 that take care of their own server and clients on them.  The purpose of
835 operators is to administrate the SILC server or router.  However, even
836 an operator with highest privileges is not able to enter invite-only
837 channel, to gain access to the contents of a encrypted and authenticated
838 packets traveling in the SILC network or to gain channel operator
839 privileges on public channels without being promoted.  They have the
840 same privileges as everyone else except they are able to administrate
841 their server or router.
842
843
844 .ti 0
845 3.6 SILC Commands
846
847 Commands are very important part on SILC network especially for client
848 which uses commands to operate on the SILC network.  Commands are used
849 to set nickname, join to channel, change modes and many other things.
850
851 Client usually sends the commands and server replies by sending a reply
852 packet to the command.  Server MAY also send commands usually to serve
853 the original client's request.  Usually server cannot send commands to
854 clients, however there MAY be commands that allow the server to send
855 commands to client.  By default servers MAY send commands only to other
856 servers and routers.
857
858 Note that the command reply is usually sent only after client has sent
859 the command request but server is allowed to send command reply packet
860 to client even if client has not requested the command.  Client MAY
861 choose to ignore the command reply.
862
863 It is expected that some of the commands may be miss-used by clients
864 resulting various problems on the server side.  Every implementation
865 SHOULD assure that commands may not be executed more than once, say,
866 in two (2) seconds.  However, to keep response rate up, allowing for
867 example five (5) commands before limiting is allowed.  It is RECOMMENDED
868 that commands such as SILC_COMMAND_NICK, SILC_COMMAND_JOIN, 
869 SILC_COMMAND_LEAVE and SILC_COMMAND_KILL SHOULD be limited in all cases
870 as they require heavy operations.  This should be sufficient to prevent
871 the miss-use of commands.
872
873 SILC commands are described in [SILC4].
874
875
876 .ti 0
877 3.7 SILC Packets
878
879 Packets are naturally the most important part of the protocol and the
880 packets are what actually makes the protocol.  Packets in SILC network
881 are always encrypted using, usually the shared secret session key
882 or some other key, for example, channel key, when encrypting channel
883 messages.  It is not possible to send packet in SILC network without
884 encryption.  The SILC Packet Protocol is a wide protocol and is described
885 in [SILC2].  This document does not define or describe details of
886 SILC packets.
887
888
889 .ti 0
890 3.8 Packet Encryption
891
892 All packets passed in SILC network MUST be encrypted.  This section
893 defines how packets must be encrypted in the SILC network.  The detailed
894 description of the actual encryption process of the packets are
895 described in [SILC2].
896
897 Client and its server shares secret symmetric session key which is
898 established by the SILC Key Exchange Protocol, described in [SILC3]. 
899 Every packet sent from client to server, with exception of packets for
900 channels, are encrypted with this session key.
901
902 Channels has a channel key that are shared by every client on the channel.
903 However, the channel keys are cell specific thus one cell does not know
904 the channel key of the other cell, even if that key is for same channel.
905 Channel key is also known by the routers and all servers that has clients
906 on the channel.  However, channels MAY have channel private keys that
907 are entirely local setting for the client.  All clients on the channel
908 MUST know the channel private key before hand to be able to talk on the
909 channel.  In this case, no server or router know the key for channel.
910
911 Server shares secret symmetric session key with router which is
912 established by the SILC Key Exchange Protocol.  Every packet passed from
913 server to router, with exception of packets for channels, are encrypted
914 with the shared session key.  Same way, router server shares secret
915 symmetric key with its primary route.  However, every packet passed
916 from router to other router, including packets for channels, are
917 encrypted with the shared session key.  Every router connection has
918 their own session keys.
919
920
921 .ti 0
922 3.8.1 Determination of the Source and the Destination
923
924 The source and the destination of the packet needs to be determined
925 to be able to route the packets to correct receiver.  This information
926 is available in the SILC Packet Header which is included in all packets
927 sent in SILC network.  The SILC Packet Header is described in [SILC2].
928
929 The header MUST be encrypted with the session key who is next receiver
930 of the packet along the route.  The receiver of the packet, for example
931 a router along the route, is able to determine the sender and the
932 destination of the packet by decrypting the SILC Packet Header and
933 checking the ID's attached to the header.  The ID's in the header will
934 tell to where the packet needs to be sent and where it is coming from.
935
936 The header in the packet MUST NOT change during the routing of the
937 packet.  The original sender, for example client, assembles the packet
938 and the packet header and server or router between the sender and the
939 receiver MUST NOT change the packet header.  Note however, that some
940 packets such as commands may resent by a server to serve the client's
941 original command.  In this case the command packet send by the server
942 includes the server's IDs.
943
944 Note that the packet and the packet header may be encrypted with
945 different keys.  For example, packets to channels are encrypted with
946 the channel key, however, the header is encrypted with the session key
947 as described above.  However, the header and the packet may be encrypted
948 with same key.  This is the case, for example, with command packets.
949
950
951 .ti 0
952 3.8.2 Client To Client
953
954 The process of message delivery and encryption from client to another
955 client is as follows.
956
957 Example:  Private message from client to another client on different
958           servers.  Clients do not share private message delivery
959           keys; normal session keys are used.
960
961 o Client 1. sends encrypted packet to its server.  The packet is
962   encrypted with the session key shared between client and its
963   server.
964
965 o Server determines the destination of the packet and decrypts
966   the packet.  Server encrypts the packet with session key shared
967   between the server and its router, and sends the packet to the
968   router.
969
970 o Router determines the destination of the packet and decrypts
971   the packet.  Router encrypts the packet with session key 
972   shared between the router and the destination server, and sends
973   the packet to the server.
974
975 o Server determines the client to which the packet is destined
976   to and decrypts the packet.  Server encrypts the packet with
977   session key shared between the server and the destination client,
978   and sends the packet to the client.
979
980 o Client 2. decrypts the packet.
981
982
983 Example:  Private message from client to another client on different
984           servers.  Clients has established secret shared private
985           message delivery key with each other and that is used in 
986           the message encryption.
987
988 o Client 1. sends encrypted packet to its server.  The packet header
989   is encrypted with the session key shared between the client and
990   server, and the private message is encrypted with the private
991   message delivery key shared between clients.
992
993 o Server determines the destination of the packet and sends the 
994   packet to the router.
995
996 o Router determines the destination of the packet and sends the
997   packet to the server.
998
999 o Server determines the client to which the packet is destined
1000   to and sends the packet to the client.
1001
1002 o Client 2. decrypts the packet with the secret shared key.
1003
1004
1005 If clients share secret key with each other the private message
1006 delivery is much simpler since servers and routers between the
1007 clients do not need to decrypt and re-encrypt the packet.
1008
1009 The process for clients on same server is much simpler as there are
1010 no need to send the packet to the router.  The process for clients 
1011 on different cells is same as above except that the packet is routed 
1012 outside the cell.  The router of the destination cell routes the 
1013 packet to the destination same way as described above.
1014
1015
1016 .ti 0
1017 3.8.3 Client To Channel
1018
1019 Process of message delivery from client on channel to all the clients
1020 on the channel.
1021
1022 Example:  Channel of four users; two on same server, other two on
1023           different cells.  Client sends message to the channel.
1024
1025 o Client 1. encrypts the packet with channel key and sends the
1026   packet to its server.
1027
1028 o Server determines local clients on the channel and sends the
1029   packet to the Client on the same server.  Server then sends
1030   the packet to its router for further routing.
1031
1032 o Router determines local clients on the channel, if found
1033   sends packet to the local clients.  Router determines global
1034   clients on the channel and sends the packet to its primary
1035   router or fastest route.
1036
1037 o (Other router(s) do the same thing and sends the packet to
1038    the server(s))
1039
1040 o Server determines local clients on the channel and sends the
1041   packet to the client.
1042
1043 o All clients receiving the packet decrypts the packet.
1044
1045
1046 .ti 0
1047 3.8.4 Server To Server
1048
1049 Server to server packet delivery and encryption is described in above
1050 examples. Router to router packet delivery is analogous to server to
1051 server.  However, some packets, such as channel packets, are processed
1052 differently.  These cases are described later in this document and
1053 more in detail in [SILC2].
1054
1055
1056 .ti 0
1057 3.9 Key Exchange And Authentication
1058
1059 Key exchange is done always when for example client connects to server
1060 but also when server and router, and router and router connects to each
1061 other.  The purpose of key exchange protocol is to provide secure key
1062 material to be used in the communication.  The key material is used to
1063 derive various security parameters used to secure SILC packets.  The
1064 SILC Key Exchange protocol is described in detail in [SILC3].
1065
1066 Authentication is done after key exchange protocol has been successfully
1067 completed.  The purpose of authentication is to authenticate for example
1068 client connecting to the server.  However, usually clients are accepted
1069 to connect to server without explicit authentication.  Servers are
1070 required use authentication protocol when connecting.  The authentication
1071 may be based on passphrase (pre-shared-secret) or public key.  All
1072 passphrases sent in SILC protocol MUST be UTF-8 [RFC2279] encoded.
1073 The connection authentication protocol is described in detail in [SILC3].
1074
1075
1076 .ti 0
1077 3.9.1 Authentication Payload
1078
1079 Authentication payload is used separately from the SKE and the Connection
1080 Authentication protocol.  It can be used during the session to authenticate
1081 with the remote.  For example, the client can authenticate itself to the
1082 server to become server operator.  In this case, Authentication Payload is
1083 used.
1084
1085 The format of the Authentication Payload is as follows:
1086
1087
1088 .in 5
1089 .nf
1090                      1                   2                   3
1091  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
1092 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1093 |        Payload Length         |     Authentication Method     |
1094 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1095 |      Public Data Length       |                               |
1096 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1097 |                                                               |
1098 ~                           Public Data                         ~
1099 |                                                               |
1100 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1101 |   Authentication Data Length  |                               |
1102 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1103 |                                                               |
1104 ~                       Authentication Data                     ~
1105 |                                                               |
1106 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1107 .in 3
1108  
1109 .ce
1110 Figure 5:  Authentication Payload
1111
1112
1113 .in 6
1114 o Payload Length (2 bytes) - Length of the entire payload.
1115
1116 o Authentication Method (2 bytes) - The method of the
1117   authentication.  The authentication methods are defined
1118   in [SILC2] in the Connection Auth Request Payload.  The NONE 
1119   authentication method SHOULD NOT be used.
1120
1121 o Public Data Length (2 bytes) - Indicates the length of
1122   the Public Data field.
1123
1124 o Public Data (variable length) - This is defined only if
1125   the authentication method is public key.  If it is any other
1126   this field MAY include a random data for padding purposes.
1127   However, in this case the field MUST be ignored by the
1128   receiver.
1129
1130   When the authentication method is public key this includes
1131   128 to 4096 bytes of non-zero random data that is used in
1132   the signature process, described subsequently.
1133
1134 o Authentication Data Length (2 bytes) - Indicates the
1135   length of the Authentication Data field.  If zero (0)
1136   value is found in this field the payload MUST be 
1137   discarded.
1138
1139 o Authentication Data (variable length) - Authentication 
1140   method dependent authentication data.
1141 .in 3
1142
1143
1144 If the authentication method is password based, the Authentication
1145 Data field includes the plaintext UTF-8 encoded password.  It is safe
1146 to send plaintext password since the entire payload is encrypted.  In
1147 this case the Public Data Length is set to zero (0), but MAY also include
1148 random data for padding purposes.  It is also RECOMMENDED that maximum
1149 amount of padding is applied to SILC packet when using password based
1150 authentication.  This way it is not possible to approximate the length
1151 of the password from the encrypted packet.
1152
1153 If the authentication method is public key based (or certificate)
1154 the Authentication Data is computed as follows:
1155
1156   HASH = hash(random bytes | ID | public key (or certificate));
1157   Authentication Data = sign(HASH);
1158
1159 The hash() and the sign() are the hash function and the public key
1160 cryptography function selected in the SKE protocol, unless otherwise
1161 stated in the context where this payload is used.  The public key
1162 is SILC style public key unless certificates are used.  The ID is the
1163 entity's ID (Client or Server ID) which is authenticating itself.  The
1164 ID encoding is described in [SILC2].  The random bytes are non-zero
1165 random bytes of length between 128 and 4096 bytes, and will be included
1166 into the Public Data field as is.
1167
1168 The receiver will compute the signature using the random data received
1169 in the payload, the ID associated to the connection and the public key
1170 (or certificate) received in the SKE protocol.  After computing the
1171 receiver MUST verify the signature.  In case of public key authentication
1172 this payload is also encrypted.
1173
1174
1175 .ti 0
1176 3.10 Algorithms
1177
1178 This section defines all the allowed algorithms that can be used in
1179 the SILC protocol.  This includes mandatory cipher, mandatory public
1180 key algorithm and MAC algorithms.
1181
1182
1183 .ti 0
1184 3.10.1 Ciphers
1185
1186 Cipher is the encryption algorithm that is used to protect the data
1187 in the SILC packets.  See [SILC2] of the actual encryption process and
1188 definition of how it must be done.  SILC has a mandatory algorithm that
1189 must be supported in order to be compliant with this protocol.
1190
1191 The following ciphers are defined in SILC protocol:
1192
1193 .in 6
1194 aes-256-cbc         AES in CBC mode, 256 bit key       (REQUIRED)
1195 aes-192-cbc         AES in CBC mode, 192 bit key       (OPTIONAL)
1196 aes-128-cbc         AES in CBC mode, 128 bit key       (OPTIONAL)
1197 twofish-256-cbc     Twofish in CBC mode, 256 bit key   (OPTIONAL)
1198 twofish-192-cbc     Twofish in CBC mode, 192 bit key   (OPTIONAL)
1199 twofish-128-cbc     Twofish in CBC mode, 128 bit key   (OPTIONAL)
1200 blowfish-128-cbc    Blowfish in CBC mode, 128 bit key  (OPTIONAL)
1201 cast-256-cbc        CAST-256 in CBC mode, 256 bit key  (OPTIONAL)
1202 cast-192-cbc        CAST-256 in CBC mode, 192 bit key  (OPTIONAL)
1203 cast-128-cbc        CAST-256 in CBC mode, 128 bit key  (OPTIONAL)
1204 rc6-256-cbc         RC6 in CBC mode, 256 bit key       (OPTIONAL)
1205 rc6-192-cbc         RC6 in CBC mode, 192 bit key       (OPTIONAL)
1206 rc6-128-cbc         RC6 in CBC mode, 128 bit key       (OPTIONAL)
1207 mars-256-cbc        Mars in CBC mode, 256 bit key      (OPTIONAL)
1208 mars-192-cbc        Mars in CBC mode, 192 bit key      (OPTIONAL)
1209 mars-128-cbc        Mars in CBC mode, 128 bit key      (OPTIONAL)
1210 none                No encryption                      (OPTIONAL)
1211 .in 3
1212
1213
1214 Algorithm none does not perform any encryption process at all and 
1215 thus is not recommended to be used.  It is recommended that no client
1216 or server implementation would accept none algorithms except in special
1217 debugging mode.
1218
1219 Additional ciphers MAY be defined to be used in SILC by using the
1220 same name format as above.
1221
1222
1223 .ti 0
1224 3.10.2 Public Key Algorithms
1225
1226 Public keys are used in SILC to authenticate entities in SILC network
1227 and to perform other tasks related to public key cryptography.  The 
1228 public keys are also used in the SILC Key Exchange protocol [SILC3].
1229
1230 The following public key algorithms are defined in SILC protocol:
1231
1232 .in 6
1233 rsa        RSA  (REQUIRED)
1234 dss        DSS  (OPTIONAL)
1235 .in 3
1236
1237 DSS is described in [Menezes].  The RSA MUST be implemented according
1238 PKCS #1 [PKCS1].  The mandatory PKCS #1 implementation in SILC MUST be
1239 compliant to either PKCS #1 version 1.5 or newer with the following
1240 notes: The signature encoding is always in same format as the encryption
1241 encoding regardless of the PKCS #1 version.  The signature with appendix
1242 (with hash algorithm OID in the data) MUST NOT be used in the SILC.  The
1243 rationale for this is that there is no binding between the PKCS #1 OIDs
1244 and the hash algorithms used in the SILC protocol.  Hence, the encoding
1245 is always in PKCS #1 version 1.5 format.
1246
1247 Additional public key algorithms MAY be defined to be used in SILC.
1248
1249 When signatures are computed in SILC the computing of the signature is
1250 represented as sign().  The signature computing procedure is dependent
1251 of the public key algorithm, and the public key or certificate encoding.
1252 When using SILC public key the signature is computed as described in
1253 previous section for RSA and DSS keys.  When using SSH2 public keys
1254 the signature is computed as described in [SSH-TRANS].  When using
1255 X.509 version 3 certificates the signature is computed as described
1256 in [PKCS7].  When using OpenPGP certificates the signature is computed
1257 as described in [PGP].
1258
1259
1260 .ti 0
1261 3.10.3 Hash Functions
1262
1263 Hash functions are used as part of MAC algorithms defined in the next
1264 section.  They are also used in the SILC Key Exchange protocol defined
1265 in the [SILC3].
1266
1267 The following Hash algorithm are defined in SILC protocol:
1268
1269 .in 6
1270 sha1             SHA-1, length = 20      (REQUIRED)
1271 md5              MD5, length = 16        (OPTIONAL)
1272 .in 3
1273
1274
1275 .ti 0
1276 3.10.4 MAC Algorithms
1277
1278 Data integrity is protected by computing a message authentication code
1279 (MAC) of the packet data.  See [SILC2] for details how to compute the
1280 MAC.
1281
1282 The following MAC algorithms are defined in SILC protocol:
1283
1284 .in 6
1285 hmac-sha1-96     HMAC-SHA1, length = 12  (REQUIRED)
1286 hmac-md5-96      HMAC-MD5, length = 12   (OPTIONAL)
1287 hmac-sha1        HMAC-SHA1, length = 20  (OPTIONAL)
1288 hmac-md5         HMAC-MD5, length = 16   (OPTIONAL)
1289 none             No MAC                  (OPTIONAL)
1290 .in 3
1291
1292 The none MAC is not recommended to be used as the packet is not
1293 authenticated when MAC is not computed.  It is recommended that no
1294 client or server would accept none MAC except in special debugging
1295 mode.
1296
1297 The HMAC algorithm is described in [HMAC] and hash algorithms that
1298 are used as part of the HMACs are described in [Scheneir] and in
1299 [Menezes]
1300
1301 Additional MAC algorithms MAY be defined to be used in SILC.
1302
1303
1304
1305
1306 .ti 0
1307 3.10.5 Compression Algorithms
1308
1309 SILC protocol supports compression that may be applied to unencrypted
1310 data.  It is recommended to use compression on slow links as it may
1311 significantly speed up the data transmission.  By default, SILC does not
1312 use compression which is the mode that must be supported by all SILC
1313 implementations.
1314
1315 The following compression algorithms are defined:
1316
1317 .in 6
1318 none        No compression               (REQUIRED)
1319 zlib        GNU ZLIB (LZ77) compression  (OPTIONAL)
1320 .in 3
1321
1322 Additional compression algorithms MAY be defined to be used in SILC.
1323
1324
1325 .ti 0
1326 3.11 SILC Public Key
1327
1328 This section defines the type and format of the SILC public key.  All
1329 implementations MUST support this public key type.  See [SILC3] for
1330 other optional public key and certificate types allowed in the SILC
1331 protocol.  Public keys in SILC may be used to authenticate entities
1332 and to perform other tasks related to public key cryptography.
1333
1334 The format of the SILC Public Key is as follows:
1335
1336
1337 .in 5
1338 .nf
1339                      1                   2                   3
1340  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
1341 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1342 |                        Public Key Length                      |
1343 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1344 |     Algorithm Name Length     |                               |
1345 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1346 |                                                               |
1347 ~                         Algorithm Name                        ~
1348 |                                                               |
1349 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1350 |       Identifier Length       |                               |
1351 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
1352 |                                                               |
1353 ~                           Identifier                          ~
1354 |                                                               |
1355 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1356 |                                                               |
1357 ~                           Public Data                         ~
1358 |                                                               |
1359 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1360 .in 3
1361
1362 .ce
1363 Figure 5:  SILC Public Key
1364
1365
1366 .in 6
1367 o Public Key Length (4 bytes) - Indicates the full length
1368   of the public key, not including this field.
1369
1370 o Algorithm Name Length (2 bytes) - Indicates the length
1371   of the Algorithm Length field, not including this field.
1372
1373 o Algorithm name (variable length) - Indicates the name
1374   of the public key algorithm that the key is.  See the
1375   section 3.10.2 Public Key Algorithms for defined names.
1376
1377 o Identifier Length (2 bytes) - Indicates the length of
1378   the Identifier field, not including this field.
1379
1380 o Identifier (variable length) - Indicates the identifier
1381   of the public key.  This data can be used to identify
1382   the owner of the key.  The identifier is of the following
1383   format:
1384
1385      UN   User name
1386      HN   Host name or IP address
1387      RN   Real name
1388      E    EMail address
1389      O    Organization
1390      C    Country
1391
1392
1393   Examples of an identifier:
1394
1395     `UN=priikone, HN=poseidon.pspt.fi, E=priikone@poseidon.pspt.fi'
1396
1397     `UN=sam, HN=dummy.fi, RN=Sammy Sam, O=Company XYZ, C=Finland'
1398
1399   At least user name (UN) and host name (HN) MUST be provided as
1400   identifier.  The fields are separated by commas (`,').  If
1401   comma is in the identifier string it must be written as `\\,',
1402   for example, `O=Company XYZ\\, Inc.'.
1403
1404 o Public Data (variable length) - Includes the actual
1405   public data of the public key.
1406
1407   The format of this field for RSA algorithm is
1408   as follows:
1409
1410      4 bytes            Length of e
1411      variable length    e
1412      4 bytes            Length of n
1413      variable length    n
1414
1415
1416   The format of this field for DSS algorithm is
1417   as follows:
1418
1419      4 bytes            Length of p
1420      variable length    p
1421      4 bytes            Length of q
1422      variable length    q
1423      4 bytes            Length of g
1424      variable length    g
1425      4 bytes            Length of y
1426      variable length    y
1427
1428   The variable length fields are multiple precession
1429   integers encoded as strings in both examples.
1430
1431   Other algorithms must define their own type of this
1432   field if they are used.
1433 .in 3
1434
1435 All fields in the public key are in MSB (most significant byte first)
1436 order.  All strings in the public key are UTF-8 encoded.
1437
1438
1439 .ti 0
1440 3.12 SILC Version Detection
1441
1442 The version detection of both client and server is performed at the
1443 connection phase while executing the SILC Key Exchange protocol.  The
1444 version identifier is exchanged between initiator and responder.  The
1445 version identifier is of the following format:
1446
1447 .in 6
1448 SILC-<protocol version>-<software version>
1449 .in 3
1450
1451 The version strings are of the following format:
1452
1453 .in 6
1454 protocol version = <major>.<minor>
1455 software version = <major>[.<minor>[.<build or vendor string>]]
1456 .in 3
1457
1458 Protocol version MAY provide both major and minor version.  Currently
1459 implementations MUST set the protocol version and accept at least the 
1460 protocol version as SILC-1.1-<software version>.  If new protocol version 
1461 causes incompatibilities with older version the <minor> version number 
1462 MUST be incremented.  The <major> is incremented if new protocol version 
1463 is fully incompatible.
1464
1465 Software version MAY provide major, minor and build (vendor) version.
1466 The software version MAY be freely set and accepted.  The version string 
1467 MUST consist of printable US-ASCII characters.
1468
1469
1470 Thus, the version strings could be, for example:
1471
1472 .in 6
1473 SILC-1.1-2.0.2
1474 SILC-1.0-1.2
1475 SILC-1.1-1.0.VendorXYZ
1476 SILC-1.1-2.4.5 Vendor Limited
1477 .in 3
1478
1479
1480 .ti 0
1481 3.13 Backup Routers
1482
1483 Backup routers may exist in the cell in addition of the primary router.
1484 However, they must not be active routers and act as routers in the cell.
1485 Only one router may be acting as primary router in the cell.  In the case
1486 of failure of the primary router may one of the backup routers become
1487 active.  The purpose of backup routers are in case of failure of the
1488 primary router to maintain working connections inside the cell and outside
1489 the cell and to avoid netsplits.
1490
1491 Backup routers are normal servers in the cell that are prepared to take
1492 over the tasks of the primary router if needed.  They need to have at
1493 least one direct and active connection to the primary router of the cell.
1494 This communication channel is used to send the router information to
1495 the backup router.  When the backup router connects to the primary router
1496 of the cell it MUST present itself as router server in the Connection
1497 Authentication protocol, even though it is normal server as long as the
1498 primary router is available.  Reason for this is that the configuration
1499 needed in the responder end requires usually router connection level
1500 configuration.  The responder, however must understand and treat the
1501 connection as normal server (except when feeding router level data to
1502 the backup router).
1503
1504 Backup router must know everything that the primary router knows to be
1505 able to take over the tasks of the primary router.  It is the primary
1506 router's responsibility to feed the data to the backup router.  If the
1507 backup router does not know all the data in the case of failure some
1508 connections may be lost.  The primary router of the cell must consider
1509 the backup router being actual router server when it feeds the data to
1510 it.
1511
1512 In addition of having direct connection to the primary router of the
1513 cell, the backup router must also have connection to the same router
1514 the primary router of the cell is connected.  However, it must not be
1515 active router connection meaning that the backup router must not use
1516 that channel as its primary route and it must not notify the router
1517 about having connected servers, channels and clients behind it.  It
1518 merely connects to the router.  This sort of connection is later
1519 referred as being passive connection.  Some keepalive actions may be
1520 needed by the router to keep the connection alive.
1521
1522 It is required that other normal servers have passive connections to
1523 the backup router(s) in the cell.  Some keepalive actions may be needed
1524 by the server to keep the connection alive.  After they notice the
1525 failure of the primary router they must start using the connection to
1526 the first backup router as their primary route.
1527
1528 Also, if any other router in the network is using the cell's primary
1529 router as its own primary router, it must also have passive connection
1530 to the cell's backup router.  It too is prepared to switch to use the
1531 backup router as its new primary router as soon as the orignal primary
1532 router becomes unresponsive.
1533
1534 All of the parties of this protocol knows which one is the backup router
1535 of the cell from their local configuration.  Each of the entity must
1536 be configured accordingly and care must be taken when configuring the
1537 backup routers, servers and other routers in the network.
1538
1539 It must be noted that some of the channel messages and private messages
1540 may be lost during the switch to the backup router.  The announcements
1541 assures that the state of the network is not lost during the switch.
1542
1543 It is RECOMMENDED that there would be at least one backup router in
1544 the cell.  It is NOT RECOMMENDED to have all servers in the cell acting
1545 as backup routers as it requires establishing several connections to
1546 several servers in the cell.  Large cells can easily have several
1547 backup routers in the cell.
1548
1549 The order of the backup routers are decided at the configuration phase.
1550 All the parties of this protocol must be configured accordingly to 
1551 understand the order of the backup routers.  It is not required that
1552 the backup server is actually active server in the cell.  Backup router
1553 may be a spare server in the cell that does not accept normal client
1554 connections at all.  It may be reserved purely for the backup purposes.
1555 These, however, are cell management issues.
1556
1557 If also the first backup router is down as well and there is another
1558 backup router in the cell then it will start acting as the primary
1559 router as described above.
1560
1561
1562 .ti 0
1563 3.13.1 Switching to Backup Router
1564
1565 When the primary router of the cell becomes unresponsive, for example
1566 by sending EOF to the connection, all the parties of this protocol MUST
1567 replace the old connection to the primary router with first configured
1568 backup router.  The backup router usually needs to do local modifications
1569 to its database in order to update all the information needed to maintain
1570 working routes.  The backup router must understand that clients that
1571 were orignated from the primary router are now originated from some of
1572 the existing server connections and must update them accordingly.  It
1573 must also remove those clients that were owned by the primary router
1574 since those connections were lost when the primary router became
1575 unresponsive.
1576
1577 All the other parties of the protocol must also update their local
1578 database to understand that the route to the primary router will now go
1579 to the backup router.
1580
1581 The servers connected to the backup router must announce their clients,
1582 channels, channel users, channel user modes and channel modes to the
1583 backup router.  This is to assure that none of the important notify 
1584 packets were lost during the switch to the backup router.  The backup
1585 router must check which of these announced entities it already have
1586 and distribute the new ones to the primary route.
1587
1588 The backup router too must announce its servers, clients, channels
1589 and other information to the new primary router.  The primary router
1590 of the backup router too must announce its informations to the backup
1591 router.  Both must process only the ones they do not know about.  If
1592 any of the announced modes does not match then they are enforced in
1593 normal manner defined later in this specification.
1594
1595
1596 .ti 0
1597 3.13.2 Resuming Primary Router
1598
1599 Usually the primary router is unresponsive only a short period of time
1600 and it is intended that the original router of the cell will reassume
1601 its position as primary router when it comes back online.  The backup
1602 router that is now acting as primary router of the cell must constantly
1603 try to connect to the original primary router of the cell.  It is
1604 RECOMMENDED that it would try to reconnect in 30 second intervals to
1605 the primary router.
1606
1607 When the connection is established to the primary router the backup
1608 resuming protocol is executed.  The protocol is advanced as follows:
1609
1610   1. Backup router sends SILC_PACKET_RESUME_ROUTER packet with type
1611      value 1 the primary router that came back online.  The packet
1612      will indicate the primary router has been replaced by the backup
1613      router.  After sending the packet the backup router will announce
1614      all of its channels, channel users, modes etc. to the primary
1615      router.
1616
1617   2. Backup router sends SILC_PACKET_RESUME_ROUTER packet with type
1618      value 2 to its current primary router to indicate that it will
1619      resign as being primary router.  Then, backup router sends the
1620      SILC_PACKET_RESUME_ROUTER packet with type value 1 to all
1621      connected servers to also indicate that it will resign as being
1622      primary router.
1623
1624   3. Backup router also send SILC_PACKET_RESUME_ROUTER packet with
1625      type value 2 to the router that is using the backup router
1626      currently as its primary router.
1627
1628   4. Any server and router that receives the SILC_PACKET_RESUME_ROUTER
1629      with type value 1 or 2 must reconnect immediately to the
1630      primary router of the cell that came back online.  After they
1631      have created the connection they MUST NOT use that connection
1632      as active primary route but still route all packets to the
1633      backup router.  After the connection is created they MUST send
1634      SILC_PACKET_RESUME_ROUTER with type value 3 back to the
1635      backup router.  The session ID value found in the first packet
1636      MUST be set in this packet.
1637
1638   5. Backup router MUST wait for all packets with type value 3 before
1639      it continues with the protocol.  It knows from the session ID values
1640      set in the packet when it have received all packets.  The session
1641      value should be different in all packets it have send earlier.
1642      After the packets is received the backup router sends the
1643      SILC_PACKET_RESUME_ROUTER packet with type value 4 to the
1644      primary router that came back online.  This packet will indicate 
1645      that the backup router is now ready to resign as being primary
1646      router.  The session ID value in this packet MUST be the same as
1647      in first packet sent to the primary router.  During this time
1648      the backup router should still route all packets it is receiving
1649      from server connections.
1650
1651   6. The primary router receives the packet and send the
1652      SILC_PACKET_RESUME_ROUTER with type value 5 to all connected servers
1653      including the backup router.  It also sends the packet with type
1654      value 6 to its primary router, and to the router that is using
1655      it as its primary router.  The Session ID value in this packet
1656      SHOULD be zero (0).
1657
1658   7. Any server and router that receives the SILC_PACKET_RESUME_ROUTER
1659      with type value 5 or 6 must switch their primary route to the
1660      new primary router and remove the route for the backup router, since
1661      it is not anymore the primary router of the cell.  They must also
1662      update their local database to understand that the clients are
1663      not originated from the backup router but from the locally connected
1664      servers.  After that they MUST announce their channels, channel
1665      users, modes etc. to the primary router.  They must not use the
1666      backup router connection after this and the connection is considered
1667      to be passive connection.  The implementations SHOULD be able
1668      to disable the connection without closing the actual link.
1669
1670 After this protocol is executed the backup router is now again normal
1671 server in the cell that has the backup link to the primary router.  The
1672 primary router feeds the router specific data again to the backup router.
1673 All server connections in the backup router are considered passive
1674 connections.
1675
1676 When the primary router of the cell comes back online and connects
1677 to its primary router, the remote primary router must send the 
1678 SILC_PACKET_RESUME_ROUTER with type value 20 indicating that the
1679 connection is not allowed since the router has been replaced by an
1680 backup router.  The session ID value in this packet SHOULD be zero (0).
1681 When the router receives this packet it must not use the connection
1682 as active connection but to understand that it cannot act as primary
1683 router in the cell.  It must wait that the backup router connects to
1684 it, and the backup resuming protocol is executed.
1685
1686 The following type values has been defined for SILC_PACKET_RESUME_ROUTER
1687 packet:
1688
1689   1    SILC_SERVER_BACKUP_START
1690   2    SILC_SERVER_BACKUP_START_GLOBAL
1691   3    SILC_SERVER_BACKUP_START_CONNECTED
1692   4    SILC_SERVER_BACKUP_START_ENDING
1693   5    SILC_SERVER_BACKUP_START_RESUMED
1694   6    SILC_SERVER_BACKUP_START_GLOBAL
1695   20   SILC_SERVER_BACKUP_START_REPLACED
1696
1697 If any other value is found in the type field the packet must be 
1698 discarded.  The SILC_PACKET_RESUME_ROUTER packet and its payload
1699 is defined in [SILC2].
1700
1701
1702 .ti 0
1703 3.13.3 Discussion on Backup Router Scheme
1704
1705 It is clear that this backup router support is not able to handle all
1706 possible situations arrising in unreliable network environment.  This
1707 scheme for example does not handle situation when the router actually
1708 does not go offline but the network link goes down temporarily.  It would
1709 require some intelligence to figure out when it is best time to switch
1710 to the backup router.  To make it even more complicated it is possible
1711 that the backup router may have not lost the network link to the primary
1712 router.
1713
1714 Other possible situation is when the network link is lost temporarily
1715 between two primary routers in the SILC network.  Unless the routers
1716 notice the link going down they cannot perhaps find alternative routes.
1717 Worst situation is when the link goes down only for a short period of
1718 time, thus causing lag.  Should the routers or servers find alternative
1719 routes if they cannot get response from the router during the lag?
1720 When alternative routes are being found it must be careful not to
1721 mess up existing primary routes between routers in the network.
1722
1723 It is suggested that the current backup router scheme is only temporary
1724 solution and existing backup router protocols are studied further.  It
1725 is also suggested that the backup router specification will be separated
1726 from this SILC specification Internet-Draft and additional specification
1727 is written on the subject.
1728
1729
1730 .ti 0
1731 4 SILC Procedures
1732
1733 This section describes various SILC procedures such as how the 
1734 connections are created and registered, how channels are created and
1735 so on.  The section describes the procedures only generally as details
1736 are described in [SILC2] and [SILC3].
1737
1738
1739 .ti 0
1740 4.1 Creating Client Connection
1741
1742 This section describes the procedure when client connects to SILC server.
1743 When client connects to server the server MUST perform IP address lookup
1744 and reverse IP address lookup to assure that the origin host really is
1745 who it claims to be.  Client, host, connecting to server SHOULD have 
1746 both valid IP address and fully qualified domain name (FQDN).
1747
1748 After that the client and server performs SILC Key Exchange protocol
1749 which will provide the key material used later in the communication.
1750 The key exchange protocol MUST be completed successfully before the
1751 connection registration may continue.  The SILC Key Exchange protocol
1752 is described in [SILC3].
1753
1754 Typical server implementation would keep a list of connections that it
1755 allows to connect to the server.  The implementation would check, for
1756 example, the connecting client's IP address from the connection list
1757 before the SILC Key Exchange protocol has been started.  Reason for
1758 this is that if the host is not allowed to connect to the server there
1759 is no reason to perform the key exchange protocol.
1760
1761 After successful key exchange protocol the client and server performs
1762 connection authentication protocol.  The purpose of the protocol is to
1763 authenticate the client connecting to the server.  Flexible
1764 implementation could also accept the client to connect to the server
1765 without explicit authentication.  However, if authentication is
1766 desired for a specific client it may be based on passphrase or
1767 public key authentication.  If authentication fails the connection
1768 MUST be terminated.  The connection authentication protocol is described
1769 in [SILC3].
1770
1771 After successful key exchange and authentication protocol the client
1772 registers itself by sending SILC_PACKET_NEW_CLIENT packet to the
1773 server.  This packet includes various information about the client
1774 that the server uses to create the client.  Server creates the client
1775 and sends SILC_PACKET_NEW_ID to the client which includes the created
1776 Client ID that the client MUST start using after that.  After that
1777 all SILC packets from the client MUST have the Client ID as the
1778 Source ID in the SILC Packet Header, described in [SILC2].
1779
1780 Client MUST also get the server's Server ID that is to be used as
1781 Destination ID in the SILC Packet Header when communicating with
1782 the server (for example when sending commands to the server).  The
1783 ID may be resolved in two ways.  Client can take the ID from an
1784 previously received packet from server that MUST include the ID,
1785 or to send SILC_COMMAND_INFO command and receive the Server ID as
1786 command reply.
1787
1788 Server MAY choose not to use the information received in the
1789 SILC_PACKET_NEW_CLIENT packet.  For example, if public key or 
1790 certificate were used in the authentication, server MAY use those
1791 informations rather than what it received from client.  This is suitable
1792 way to get the true information about client if it is available.
1793
1794 The nickname of client is initially set to the username sent in the
1795 SILC_PACKET_NEW_CLIENT packet.  User should set the nickname to more
1796 suitable by sending SILC_COMMAND_NICK command.  However, this is not
1797 required as part of registration process.
1798
1799 Server MUST also distribute the information about newly registered
1800 client to its router (or if the server is router, to all routers in
1801 the SILC network).  More information about this in [SILC2].
1802
1803 Router server MUST also check whether some client in the local cell
1804 is watching for the nickname this new client has, and send the 
1805 SILC_NOTIFY_TYPE_WATCH to the watcher.
1806
1807
1808 .ti 0
1809 4.2 Creating Server Connection
1810
1811 This section describes the procedure when server connects to its
1812 router (or when router connects to other router, the cases are
1813 equivalent).  The procedure is very much alike when client connects
1814 to the server thus it is not repeated here.
1815
1816 One difference is that server MUST perform connection authentication
1817 protocol with proper authentication.  A proper authentication is based
1818 on passphrase or public key authentication.
1819
1820 After server and router has successfully performed the key exchange
1821 and connection authentication protocol, the server register itself
1822 to the router by sending SILC_PACKET_NEW_SERVER packet.  This packet
1823 includes the server's Server ID that it has created by itself and
1824 other relevant information about the server.
1825
1826 After router has received the SILC_PACKET_NEW_SERVER packet it
1827 distributes the information about newly registered server to all routers
1828 in the SILC network.  More information about this in [SILC2].
1829
1830 As client needed to resolve the destination ID this MUST be done by the
1831 server that connected to the router, as well.  The way to resolve it is
1832 to get the ID from previously received packet.  The server MAY also 
1833 use SILC_COMMAND_INFO command to resolve the ID.  Server MUST also start
1834 using its own Server ID as Source ID in SILC Packet Header and the
1835 router's Server ID as Destination when communicating with the router.
1836
1837
1838 .ti 0
1839 4.2.1 Announcing Clients, Channels and Servers
1840
1841 After server or router has connected to the remote router, and it already
1842 has connected clients and channels it MUST announce them to the router.
1843 If the server is router server, also all the local servers in the cell
1844 MUST be announced.
1845
1846 All clients are announced by compiling a list of ID Payloads into the
1847 SILC_PACKET_NEW_ID packet.  All channels are announced by compiling a
1848 list of Channel Payloads into the SILC_PACKET_NEW_CHANNEL packet.  Also, 
1849 the channel users on the channels must be announced by compiling a
1850 list of Notify Payloads with the SILC_NOTIFY_TYPE_JOIN notify type into
1851 the SILC_PACKET_NOTIFY packet.  The users' modes on the channel must 
1852 also be announced by compiling list of Notify Payloads with the 
1853 SILC_NOTIFY_TYPE_CUMODE_CHANGE notify type into the SILC_PACKET_NOTIFY
1854 packet.
1855
1856 The router MUST also announce the local servers by compiling list of
1857 ID Payloads into the SILC_PACKET_NEW_ID packet.
1858
1859 Also, clients' modes (user modes in SILC) MUST be announced.  This is
1860 done by compiling a list of Notify Payloads with the 
1861 SILC_NOTIFY_UMODE_CHANGE nofity type into the SILC_PACKET_NOTIFY packet.
1862
1863 Also, channel's topics MUST be announced by compiling a list of Notify
1864 Payloads with the SILC_NOTIFY_TOPIC_SET notify type into the
1865 SILC_PACKET_NOTIFY packet.
1866
1867 The router which receives these lists MUST process them and broadcast
1868 the packets to its primary route.
1869
1870 When processing the announced channels and channel users the router MUST
1871 check whether a channel exists already with the same name.  If channel
1872 exists with the same name it MUST check whether the Channel ID is
1873 different.  If the Channel ID is different the router MUST send the notify
1874 type SILC_NOTIFY_TYPE_CHANNEL_CHANGE to the server to force the channel ID
1875 change to the ID the router has.  If the mode of the channel is different
1876 the router MUST send the notify type SILC_NOTIFY_TYPE_CMODE_CHANGE to the
1877 server to force the mode change to the mode that the router has.
1878
1879 The router MUST also generate new channel key and distribute it to the
1880 channel.  The key MUST NOT be generated if the SILC_CMODE_PRIVKEY mode
1881 is set.
1882
1883 If the channel has channel founder on the router the router MUST send
1884 the notify type SILC_NOTIFY_TYPE_CUMODE_CHANGE to the server to force
1885 the mode change for the channel founder on the server.  The channel 
1886 founder privileges MUST be removed.
1887
1888 The router processing the channels MUST also compile a list of
1889 Notify Payloads with the SILC_NOTIFY_TYPE_JOIN notify type into the
1890 SILC_PACKET_NOTIFY and send the packet to the server.  This way the
1891 server (or router) will receive the clients on the channel that
1892 the router has.
1893
1894
1895 .ti 0
1896 4.3 Joining to a Channel
1897
1898 This section describes the procedure when client joins to a channel.
1899 Client joins to channel by sending command SILC_COMMAND_JOIN to the
1900 server.  If the receiver receiving join command is normal server the
1901 server MUST check its local list whether this channel already exists
1902 locally.  This would indicate that some client connected to the server
1903 has already joined to the channel.  If this is case the client is
1904 joined to the channel, new channel key is created and information about
1905 newly joined channel is sent to the router.  The router is informed
1906 by sending SILC_NOTIFY_TYPE_JOIN notify type.  The notify type MUST
1907 also be sent to the local clients on the channel.  The new channel key
1908 is also sent to the router and to local clients on the channel.
1909
1910 If the channel does not exist in the local list the client's command
1911 MUST be sent to the router which will then perform the actual joining
1912 procedure.  When server receives the reply to the command from the
1913 router it MUST be sent to the client which sent the command originally.
1914 Server will also receive the channel key from the server that it MUST
1915 send to the client which originally requested the join command.  The
1916 server MUST also save the channel key.
1917
1918 If the receiver of the join command is router it MUST first check its
1919 local list whether anyone in the cell has already joined to the channel.
1920 If this is the case the client is joined to the channel and reply is
1921 sent to the client.  If the command was sent by server the command reply
1922 is sent to the server which sent it.  Then the router MUST also create
1923 new channel key and distribute it to all clients on the channel and
1924 all servers that has clients on the channel.  Router MUST also send
1925 the SILC_NOTIFY_TYPE_JOIN notify type to local clients on the channel
1926 and to local servers that has clients on the channel.
1927
1928 If the channel does not exist on the router's local list it MUST
1929 check the global list whether the channel exists at all.  If it does
1930 the client is joined to the channel as described previously.  If
1931 the channel does not exist the channel is created and the client
1932 is joined to the channel.  The channel key is also created and
1933 distributed as previously described.  The client joining to the created
1934 channel is made automatically channel founder and both channel founder
1935 and channel operator privileges is set for the client.
1936
1937 If the router created the channel in the process, information about the
1938 new channel MUST be broadcasted to all routers.  This is done by 
1939 broadcasting SILC_PACKET_NEW_CHANNEL packet to the router's primary
1940 route.  When the router joins the client to the channel it MUST also
1941 send information about newly joined client to all routers in the SILC
1942 network.  This is done by broadcasting the SILC_NOTIFY_TYPE_JOIN notify
1943 type to the router's primary route. 
1944
1945 It is important to note that new channel key is created always when
1946 new client joins to channel, whether the channel has existed previously
1947 or not.  This way the new client on the channel is not able to decrypt
1948 any of the old traffic on the channel.  Client which receives the reply to
1949 the join command MUST start using the received Channel ID in the channel
1950 message communication thereafter.  Client also receives the key for the
1951 channel in the command reply.  Note that the channel key is never
1952 generated if the SILC_CMODE_PRIVKEY mode is set.
1953
1954
1955 .ti 0
1956 4.4 Channel Key Generation
1957
1958 Channel keys are created by router which creates the channel by taking
1959 enough randomness from cryptographically strong random number generator.
1960 The key is generated always when channel is created, when new client
1961 joins a channel and after the key has expired.  Key could expire for
1962 example in an hour.
1963
1964 The key MUST also be re-generated whenever some client leaves a channel.
1965 In this case the key is created from scratch by taking enough randomness
1966 from the random number generator.  After that the key is distributed to
1967 all clients on the channel.  However, channel keys are cell specific thus
1968 the key is created only on the cell where the client, which left the
1969 channel, exists.  While the server or router is creating the new channel
1970 key, no other client may join to the channel.  Messages that are sent
1971 while creating the new key are still processed with the old key.  After
1972 server has sent the SILC_PACKET_CHANNEL_KEY packet MUST client start
1973 using the new key.  If server creates the new key the server MUST also
1974 send the new key to its router.  See [SILC2] on more information about
1975 how channel messages must be encrypted and decrypted when router is
1976 processing them.
1977
1978 When client receives the SILC_PACKET_CHANNEL_KEY packet with the
1979 Channel Key Payload it MUST process the key data to create encryption
1980 and decryption key, and to create the HMAC key that is used to compute
1981 the MACs of the channel messages.  The processing is as follows:
1982
1983   channel_key  = raw key data
1984   HMAC key     = hash(raw key data)
1985
1986 The raw key data is the key data received in the Channel Key Payload.
1987 The hash() function is the hash function used in the HMAC of the channel.
1988 Note that the server MUST also save the channel key.
1989
1990
1991 .ti 0
1992 4.5 Private Message Sending and Reception
1993
1994 Private messages are sent point to point.  Client explicitly destines
1995 a private message to specific client that is delivered to only to that
1996 client.  No other client may receive the private message.  The receiver
1997 of the private message is destined in the SILC Packet Header as any
1998 other packet as well.
1999
2000 If the sender of a private message does not know the receiver's Client
2001 ID, it MUST resolve it from server.  There are two ways to resolve the
2002 client ID from server; it is RECOMMENDED that client implementations
2003 send SILC_COMMAND_IDENTIFY command to receive the Client ID.  Client
2004 MAY also send SILC_COMMAND_WHOIS command to receive the Client ID.
2005 If the sender has received earlier a private message from the receiver
2006 it should have cached the Client ID from the SILC Packet Header.
2007
2008 If server receives a private message packet which includes invalid
2009 destionation Client ID the server MUST send SILC_NOTIFY_TYPE_ERROR
2010 notify to the client with error status indicating that such Client ID
2011 does not exist.
2012
2013 See [SILC2] for description of private message encryption and decryption
2014 process.
2015
2016
2017 .ti 0
2018 4.6 Private Message Key Generation
2019
2020 Private message MAY be protected by the key generated by the client.
2021 The key may be generated and sent to the other client by sending packet
2022 SILC_PACKET_PRIVATE_MESSAGE_KEY which travels through the network
2023 and is secured by session keys.  After that the private message key
2024 is used in the private message communication between those clients.
2025
2026 Other choice is to entirely use keys that are not sent through
2027 the SILC network at all.  This significantly adds security.  This key
2028 would be pre-shared-key that is known by both of the clients.  Both
2029 agree about using the key and starts sending packets that indicate
2030 that the private message is secured using private message key.
2031
2032 The key material used as private message key is implementation issue.
2033 However, SILC_PACKET_KEY_AGREEMENT packet MAY be used to negotiate
2034 the key material.  If the key is normal pre-shared-key or randomly
2035 generated key, and the SILC_PACKET_KEY_AGREEMENT was not used, then
2036 the key material SHOULD be processed as defined in the [SILC3].  In
2037 the processing, however, the HASH, as defined in [SILC3] MUST be 
2038 ignored.  After processing the key material it is employed as defined
2039 in [SILC3], however, the HMAC key material MUST be discarded.
2040
2041 If the key is pre-shared-key or randomly generated the implementations
2042 SHOULD use the SILC protocol's mandatory cipher as the cipher.  If the
2043 SKE was used to negotiate key material the cipher was negotiated as well,
2044 and may be different from default cipher.
2045
2046
2047 .ti 0
2048 4.7 Channel Message Sending and Reception
2049
2050 Channel messages are delivered to group of users.  The group forms a
2051 channel and all clients on the channel receives messages sent to the
2052 channel.
2053
2054 Channel messages are destined to channel by specifying the Channel ID
2055 as Destination ID in the SILC Packet Header.  The server MUST then
2056 distribute the message to all clients on the channel by sending the
2057 channel message destined explicitly to a client on the channel.
2058
2059 If server receives a channel message packet which includes invalid
2060 destionation Channel ID the server MUST send SILC_NOTIFY_TYPE_ERROR
2061 notify to the sender with error status indicating that such Channel ID
2062 does not exist.
2063
2064 See the [SILC2] for description of channel messege routing for router
2065 servers, and channel message encryption and decryption process.
2066
2067
2068 .ti 0
2069 4.8 Session Key Regeneration
2070
2071 Session keys MUST be regenerated periodically, say, once in an hour.
2072 The re-key process is started by sending SILC_PACKET_REKEY packet to
2073 other end, to indicate that re-key must be performed.  The initiator
2074 of the connection SHOULD initiate the re-key.
2075
2076 If perfect forward secrecy (PFS) flag was selected in the SILC Key
2077 Exchange protocol [SILC3] the re-key MUST cause new key exchange with
2078 SKE protocol.  In this case the protocol is secured with the old key
2079 and the protocol results to new key material.  See [SILC3] for more
2080 information.  After the SILC_PACKET_REKEY packet is sent the sender
2081 will perform the SKE protocol.
2082
2083 If PFS flag was set the resulted key material is processed as described
2084 in the section Processing the Key Material in [SILC3].  The difference
2085 with re-key in the processing is that the initial data for the hash 
2086 function is just the resulted key material and not the HASH as it
2087 is not computed at all with re-key.  Other than that, the key processing
2088 it equivalent to normal SKE negotiation.
2089
2090 If PFS flag was not set, which is the default case, then re-key is done
2091 without executing SKE protocol.  In this case, the new key is created by
2092 providing the current sending encryption key to the SKE protocol's key
2093 processing function.  The process is described in the section Processing
2094 the Key Material in [SILC3].  The difference in the processing is that
2095 the initial data for the hash function is the current sending encryption
2096 key and not the SKE's KEY and HASH values.  Other than that, the key
2097 processing is equivalent to normal SKE negotiation.
2098
2099 After both parties has regenerated the session key, both MUST send
2100 SILC_PACKET_REKEY_DONE packet to each other.  These packets are still
2101 secured with the old key.  After these packets, the subsequent packets
2102 MUST be protected with the new key.
2103
2104
2105 .ti 0
2106 4.9 Command Sending and Reception
2107
2108 Client usually sends the commands in the SILC network.  In this case
2109 the client simply sends the command packet to server and the server
2110 processes it and replies with command reply packet.  See the [SILC3]
2111 for detailed description of all commands.
2112
2113 However, if the server is not able to process the command, it is sent 
2114 to the server's router.  This is case for example with commands such
2115 as, SILC_COMMAND_JOIN and SILC_COMMAND_WHOIS commands.  However, there
2116 are other commands as well.  For example, if client sends the WHOIS
2117 command requesting specific information about some client the server must
2118 send the WHOIS command to router so that all clients in SILC network
2119 are searched.  The router, on the other hand, sends the WHOIS command
2120 further to receive the exact information about the requested client.
2121 The WHOIS command travels all the way to the server which owns the client
2122 and it replies with command reply packet.  Finally, the server which
2123 sent the command receives the command reply and it must be able to
2124 determine which client sent the original command.  The server then
2125 sends command reply to the client.  Implementations should have some
2126 kind of cache to handle, for example, WHOIS information.  Servers
2127 and routers along the route could all cache the information for faster
2128 referencing in the future.
2129
2130 The commands sent by server may be sent hop by hop until someone is able
2131 to process the command.  However, it is preferred to destine the command
2132 as precisely as it is possible.  In this case, other routers en route
2133 MUST route the command packet by checking the true sender and true
2134 destination of the packet.  However, servers and routers MUST NOT route
2135 command reply packets to clients coming from other server.  Client
2136 MUST NOT accept command reply packet originated from anyone else but
2137 from its own server.
2138
2139
2140 .ti 0
2141 4.10 Closing Connection
2142
2143 When remote client connection is closed the server MUST send the notify
2144 type SILC_NOTIFY_TYPE_SIGNOFF to its primary router and to all channels
2145 the client was joined.  The server MUST also save the client's information
2146 for a period of time for history purposes.
2147
2148 When remote server or router connection is closed the server or router
2149 MUST also remove all the clients that was behind the server or router
2150 from the SILC Network.  The server or router MUST also send the notify
2151 type SILC_NOTIFY_TYPE_SERVER_SIGNOFF to its primary router and to all
2152 local clients that are joined on the same channels with the remote 
2153 server's or router's clients.
2154
2155 Router server MUST also check whether some client in the local cell
2156 is watching for the nickname this client has, and send the 
2157 SILC_NOTIFY_TYPE_WATCH to the watcher, unless the client which left
2158 the network has the SILC_UMODE_REJECT_WATCHING user mode set.
2159
2160
2161 .ti 0
2162 4.11 Detaching and Resuming a Session
2163
2164 SILC protocol provides a possibility for a client to detach itself from
2165 the network without actually signing off from the network.  The client
2166 connection to the server is closed but the client remains as valid client
2167 in the network.  The client may then later resume its session back from
2168 any server in the network.
2169
2170 When client wishes to detach from the network it MUST send the
2171 SILC_COMMAND_DETACH command to its server.  The server then MUST set
2172 SILC_UMODE_DETACHED mode to the client and send SILC_NOTIFY_UMODE_CHANGE
2173 notify to its primary router, which will then MUST broadcast it further
2174 to other routers in the network.  This user mode indicates that the
2175 client is detached from the network.  Implementations MUST NOT use
2176 the SILC_UMODE_DETACHED flag to determine whether a packet can be sent
2177 to the client.  All packets MUST still be sent to the client even if
2178 client is detached from the network.  Only the server that originally
2179 had the active client connection is able to make the decision after it
2180 notices that the network connection is not active.  In this case the
2181 default case is to discard the packet.
2182
2183 The SILC_UMODE_DETACHED flag cannot be set by client itself directly
2184 with SILC_COMMAND_UMODE command, but only implicitly by sending the
2185 SILC_COMMAND_DETACH command.  The flag also cannot be unset by the
2186 client, server or router with SILC_COMMAND_UMODE command, but only
2187 implicitly by sending and receiving the SILC_PACKET_RESUME_CLIENT
2188 packet.
2189
2190 When the client wishes to resume its session in the SILC Network it
2191 connects to a server in the network, which MAY also be a different
2192 from the original server, and performs normal procedures regarding
2193 creating a connection as described in section 4.1.  After the SKE
2194 and the Connection Authentication protocols has been successfully
2195 completed the client MUST NOT send SILC_PACKET_NEW_CLIENT packet, but
2196 MUST send SILC_PACKET_RESUME_CLIENT packet.  This packet is used to
2197 perform the resuming procedure.  The packet MUST include the detached
2198 client's Client ID, which the client must know.  It also includes
2199 Authentication Payload which includes signature made with the client's
2200 private key.  The signature is computed as defined in the section
2201 3.9.1.  Thus, the authentication method MUST be based in public key
2202 authentication.
2203
2204 When server receives the SILC_PACKET_RESUME_CLIENT packet it MUST
2205 do the following:  Server checks that the Client ID is valid client
2206 and that it has the SILC_UMODE_DETACHED mode set.  Then it verifies
2207 the Authentication Payload with the detached client's public key.
2208 If it does not have the public key it retrieves it by sending
2209 SILC_COMMAND_GETKEY command to the server that has the public key from
2210 the original client connection.  The server MUST NOT use the public
2211 key received in the SKE protocol for this connection.  If the
2212 signature is valid the server unsets the SILC_UMODE_DETACHED flag,
2213 and sends the SILC_PACKET_RESUME_CLIENT packet to its primary router.
2214 The routers MUST broadcast the packet and unset the SILC_UMODE_DETACHED
2215 flag when the packet is received.  If the server is router server it
2216 also MUST send the SILC_PACKET_RESUME_CLIENT packet to the original
2217 server whom owned the detached client.
2218
2219 The servers and routers that receives the SILC_PACKET_RESUME_CLIENT
2220 packet MUST know whether the packet already has been received for
2221 the client.  It is protocol error to attempt to resume the client
2222 session from more than one server.  The implementations could set
2223 internal flag that indicates that the client is resumed.  If router
2224 receive SILC_PACKET_RESUME_CLIENT packet for client that is already
2225 resumed the client MUST be killed from the network.  This would
2226 indicate that the client is attempting to resume the session more
2227 than once which is protocol error.  In this case the router sends
2228 SILC_NOTIFY_TYPE_KILLED to the client.  All routers that detect
2229 the same situation MUST also send the notify for the client.
2230
2231 The servers and routers that receive the SILC_PACKET_RESUME_CLIENT
2232 must also understand that the client may not be found behind the
2233 same server that it originally came from.  They must update their
2234 caches according this.  The server that now owns the client session
2235 MUST check whether the Client ID of the resumed client is based
2236 on the server's Server ID.  If it is not it creates a new Client
2237 ID and send SILC_NOTIFY_TYPE_NICK_CHANGE to the network.  It MUST
2238 also send the channel keys of all channels that the client is
2239 joined to the client since it does not have them.  Whether the
2240 Client ID was changed or not the server MUST send SILC_PACKET_NEW_ID
2241 packet to the client.  Only after this the client is resumed back
2242 to the network and may start sending packets and messages.
2243
2244 It is also possible that the server does not know about the channels
2245 that the client has joined.  In this case it join the client internally
2246 to the channels, generate new channel keys and distribute the keys
2247 to the channels as described in section 4.4.
2248
2249 It is implementation issue for how long servers keep detached client
2250 sessions.  It is RECOMMENDED that the detached sessions would be
2251 persistent as long as the server is running.
2252
2253
2254 .ti 0
2255 5 Security Considerations
2256
2257 Security is central to the design of this protocol, and these security
2258 considerations permeate the specification.  Common security considerations
2259 such as keeping private keys truly private and using adequate lengths for
2260 symmetric and asymmetric keys must be followed in order to maintain the
2261 security of this protocol.
2262
2263 Special attention must also be paid on the servers and routers that are
2264 running the SILC service.  The SILC protocol's security depends greatly
2265 on the security and the integrity of the servers and administrators that
2266 are running the service.  It is recommended that some form of registration
2267 is required by the server and router administrator prior acceptance to
2268 the SILC Network.  Even though, the SILC protocol is secure in a network
2269 of mutual distrust between clients, servers, routers and adminstrators
2270 of the servers, the client should be able to trust the servers they are
2271 using if they whish to do so.
2272
2273 It however must be noted that if the client requires absolute security
2274 by not trusting any of the servers or routers in the SILC Network, it can
2275 be accomplished by negotiating private keys outside the SILC Network,
2276 either using SKE or some other key exchange protocol, or to use some
2277 other external means for distributing the keys.  This applies for all 
2278 messages, private messages and channel messages.
2279
2280 It is important to note that SILC, like any other security protocol is
2281 not full proof system and cannot secure from insecure environment; the
2282 SILC servers and routers could very well be compromised.  However, to
2283 provide acceptable level of security and usability for end user the
2284 protocol use many times session keys or other keys generated by the
2285 servers to secure the messages.  This is intentional design feature to
2286 allow ease of use for end user.  This way the network is still usable,
2287 and remains encrypted even if the external means of distributing the
2288 keys is not working.  The implementation, however, may like to not
2289 follow this design feature, and always negotiate the keys outside SILC
2290 network.  This is acceptable solution and many times recommended.  The
2291 implementation still must be able to work with the server generated keys.
2292
2293 If this is unacceptable for the client or end user, the private keys
2294 negotiatied outside the SILC Network should always be used.  In the end
2295 it is always implementor's choice whether to negotiate private keys by
2296 default or whether to use the keys generated by the servers.
2297
2298 It is also recommended that router operators in the SILC Network would
2299 form a joint forum to discuss the router and SILC Network management
2300 issues.  Also, router operators along with the cell's server operators
2301 should have a forum to discuss the cell management issues.
2302
2303
2304 .ti 0
2305 6 References
2306
2307 [SILC2]      Riikonen, P., "SILC Packet Protocol", Internet Draft,
2308              April 2001.
2309
2310 [SILC3]      Riikonen, P., "SILC Key Exchange and Authentication 
2311              Protocols", Internet Draft, April 2001.
2312
2313 [SILC4]      Riikonen, P., "SILC Commands", Internet Draft, April 2001.
2314
2315 [IRC]        Oikarinen, J., and Reed D., "Internet Relay Chat Protocol",
2316              RFC 1459, May 1993.
2317
2318 [IRC-ARCH]   Kalt, C., "Internet Relay Chat: Architecture", RFC 2810,
2319              April 2000.
2320
2321 [IRC-CHAN]   Kalt, C., "Internet Relay Chat: Channel Management", RFC
2322              2811, April 2000.
2323
2324 [IRC-CLIENT] Kalt, C., "Internet Relay Chat: Client Protocol", RFC
2325              2812, April 2000.
2326
2327 [IRC-SERVER] Kalt, C., "Internet Relay Chat: Server Protocol", RFC
2328              2813, April 2000.
2329
2330 [SSH-TRANS]  Ylonen, T., et al, "SSH Transport Layer Protocol", 
2331              Internet Draft.
2332
2333 [PGP]        Callas, J., et al, "OpenPGP Message Format", RFC 2440,
2334              November 1998.
2335
2336 [SPKI]       Ellison C., et al, "SPKI Certificate Theory", RFC 2693,
2337              September 1999.
2338
2339 [PKIX-Part1] Housley, R., et al, "Internet X.509 Public Key 
2340              Infrastructure, Certificate and CRL Profile", RFC 2459,
2341              January 1999.
2342
2343 [Schneier]   Schneier, B., "Applied Cryptography Second Edition",
2344              John Wiley & Sons, New York, NY, 1996.
2345
2346 [Menezes]    Menezes, A., et al, "Handbook of Applied Cryptography",
2347              CRC Press 1997.
2348
2349 [OAKLEY]     Orman, H., "The OAKLEY Key Determination Protocol",
2350              RFC 2412, November 1998.
2351
2352 [ISAKMP]     Maughan D., et al, "Internet Security Association and
2353              Key Management Protocol (ISAKMP)", RFC 2408, November
2354              1998.
2355
2356 [IKE]        Harkins D., and Carrel D., "The Internet Key Exchange
2357              (IKE)", RFC 2409, November 1998.
2358
2359 [HMAC]       Krawczyk, H., "HMAC: Keyed-Hashing for Message
2360              Authentication", RFC 2104, February 1997.
2361
2362 [PKCS1]      Kalinski, B., and Staddon, J., "PKCS #1 RSA Cryptography
2363              Specifications, Version 2.0", RFC 2437, October 1998.
2364
2365 [RFC2119]    Bradner, S., "Key Words for use in RFCs to Indicate
2366              Requirement Levels", BCP 14, RFC 2119, March 1997.
2367
2368 [RFC2279]    Yergeau, F., "UTF-8, a transformation format of ISO
2369              10646", RFC 2279, January 1998.
2370
2371 [PKCS7]      Kalinski, B., "PKCS #7: Cryptographic Message Syntax,
2372              Version 1.5", RFC 2315, March 1998.
2373
2374
2375 .ti 0
2376 7 Author's Address
2377
2378 .nf
2379 Pekka Riikonen
2380 Snellmanninkatu 34 A 15
2381 70100 Kuopio
2382 Finland
2383
2384 EMail: priikone@iki.fi
2385
2386 This Internet-Draft expires XXX