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