Added SILC Thread Queue API
[runtime.git] / doc / draft-riikonen-silc-pp-01.nroff
index 7a87af28411de04c2ab7e7f8ba136389e30c4a71..da02ad4392341ae4e90dc9590774951e5f173c2b 100644 (file)
@@ -80,6 +80,7 @@ Table of Contents
       2.3.2 Generic payloads .................................... 16
             2.3.2.1 ID Payload .................................. 16
             2.3.2.2 Argument Payload ............................ 16
+            2.3.2.3 Channel Payload ............................. XXX
       2.3.3 Disconnect Payload .................................. 17
       2.3.4 Success Payload ..................................... 18
       2.3.5 Failure Payload ..................................... 18
@@ -97,6 +98,7 @@ Table of Contents
       2.3.17 New Client Payload ................................. 31
       2.3.18 New Server Payload ................................. 32
       2.3.19 New Channel Payload ................................ 33
+      2.3.20 Key Agreement Payload .............................. XXX
   2.4 SILC ID Types ............................................. 39
   2.5 Packet Encryption And Decryption .......................... 39
       2.5.1 Normal Packet Encryption And Decryption ............. 39
@@ -122,21 +124,23 @@ Figure 1:   Typical SILC Packet
 Figure 2:   SILC Packet Header
 Figure 3:   ID Payload
 Figure 4:   Argument Payload
-Figure 5:   Disconnect Payload
-Figure 6:   Success Payload
-Figure 7:   Failure Payload
-Figure 8:   Reject Payload
-Figure 9:   Notify Payload
-Figure 10:  Error Payload
-Figure 11:  Channel Message Payload
-Figure 12:  Channel Key Payload
-Figure 13:  Private Message Payload
-Figure 14:  Private Message Key Payload
-Figure 15:  Command Payload
-Figure 16:  Connection Auth Request Payload
-Figure 17:  New Client Payload
-Figure 18:  New Server Payload
-Figure 19:  New Channel Payload
+Figure 5:   Channel Payload
+Figure 6:   Disconnect Payload
+Figure 7:   Success Payload
+Figure 8:   Failure Payload
+Figure 9:   Reject Payload
+Figure 10:  Notify Payload
+Figure 11:  Error Payload
+Figure 12:  Channel Message Payload
+Figure 13:  Channel Key Payload
+Figure 14:  Private Message Payload
+Figure 15:  Private Message Key Payload
+Figure 16:  Command Payload
+Figure 17:  Connection Auth Request Payload
+Figure 18:  New Client Payload
+Figure 19:  New Server Payload
+Figure 20:  Key Agreement Payload
+Figure 21:  Cell Routers Payload
 
 
 .ti 0
@@ -195,7 +199,7 @@ the packet type, origin of the packet and the destination of the packet.
 The header is variable in length and first two (2) bytes of the
 header (thus first two bytes of the packet) are not encrypted.  The
 first two (2) bytes are the length of the packet which is not encrypted.
-See following section for description of SILC Packet header.  Packets
+See The following section for description of SILC Packet header.  Packets
 without SILC header or with malformed SILC header must be dropped.
 
 Padding follows the packet header.  The purpose of the padding is to
@@ -228,7 +232,7 @@ detailed information about the packet.  The receiver of the packet uses
 the packet header to parse the packet and gain other relevant parameters
 of the packet.
 
-Following diagram represents the default SILC header format.
+The following diagram represents the default SILC header format.
 (*) indicates that this field is never encrypted.  Other fields are
 always encrypted.
 
@@ -269,7 +273,7 @@ o Flags (1 byte) - Indicates flags to be used in packet
   processing.  Several flags may be set by ORing the flags
   together.
 
-  Following flags are reserved for this field:
+  The following flags are reserved for this field:
 
 
      No flags                  0x00
@@ -599,7 +603,7 @@ List of SILC Packet types are defined as follows.
           This packet is used to request the authentication method to
           be used in the SILC Connection Authentication Protocol.  If 
           initiator of the protocol does not know the mandatory 
-          authentication method this packet is used to determine it.
+          authentication method this packet may be used to determine it.
 
           The party receiving this payload must respond with the same
           packet including the mandatory authentication method.
@@ -648,7 +652,7 @@ List of SILC Packet types are defined as follows.
           This packet must not be sent as list and the List flag must
          not be set.
 
-          Payload of the packet:  See section 2.3.19 New Client Payload
+          Payload of the packet:  See section 2.3.17 New Client Payload
 
 
      20   SILC_PACKET_NEW_SERVER
@@ -664,7 +668,7 @@ List of SILC Packet types are defined as follows.
           This packet must not be sent as list and the List flag must
          not be set.
 
-          Payload of the packet:  See section 2.3.20 New Server Payload
+          Payload of the packet:  See section 2.3.18 New Server Payload
 
 
      21   SILC_PACKET_NEW_CHANNEL
@@ -676,7 +680,7 @@ List of SILC Packet types are defined as follows.
           packet.  This packet maybe sent to entity that is indirectly
           connected to the sender.
 
-          Payload of the packet:  See section 2.3.21 New Channel Payload
+          Payload of the packet:  See section 2.3.19 New Channel Payload
 
 
      22   SILC_PACKET_REKEY
@@ -713,7 +717,32 @@ List of SILC Packet types are defined as follows.
          not be set.
 
 
-     25 - 199
+     25   SILC_PACKET_KEY_AGREEMENT
+
+          This packet is used by clients to request key negotiation 
+          between another client in the SILC network.  If the negotiation
+          is started it is performed using the SKE protocol.  The result of
+          the negotiation, the secret key material, can be used for
+          example as private message key.  The server and router must not
+          send this packet.
+
+          Payload of the packet:  See section 2.3.20 Key Agreement Payload
+
+
+    26    SILC_PACKET_CELL_ROUTERS
+
+          This packet is used by primary router in the cell to notify its
+          primary router what other routers (backup routers) exist in the
+          cell.  In case of failure of the primary router in the cell the
+          first router in the list will act as primary router of the cell.
+          This packet may be sent at anytime after connection has been
+          registered to the primary router.  The client must not send this
+          packet.
+
+          Payload of the packet:  See section 2.3.21 Cell Routers Payload
+
+
+     27 - 199
 
          Currently undefined commands.
 
@@ -766,7 +795,7 @@ packet payloads.
 This payload can be used to send an ID.  ID's are variable length thus
 this payload provides a way to send variable length ID's.
 
-Following diagram represents the ID Payload.
+The following diagram represents the ID Payload.
 
 .in 5
 .nf
@@ -804,9 +833,10 @@ needs and supports arguments, such as commands.  Number of arguments
 associated with a packet must be indicated by the packet payload who
 needs the arguments. Argument Payloads must always reside right after
 the packet payload needing the arguments.  Incorrect amount of argument
-payloads must cause rejection of the packet.  Following diagram represents
+payloads must cause rejection of the packet.  The following diagram represents
 the Argument Payload.
 
+The following diagram represents the Argument Payload.
 
 .in 5
 .nf
@@ -842,6 +872,58 @@ o Argument Data (variable length) - Argument data.
 .in 3
 
 
+.ti 0
+2.3.2.3 Channel Payload
+
+Generic Channel Payload may be used information about channel, its name,
+the Channel ID and a mode.
+
+The following diagram represents the Channel Payload Payload.
+
+
+.in 5
+.nf
+                     1                   2                   3
+ 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
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|      Channel Name Length      |                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
+|                                                               |
+~                         Channel Name                          ~
+|                                                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|       Channel ID Length       |                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
+|                                                               |
+~                          Channel ID                           ~
+|                                                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|                           Mode Mask                           |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+.in 3
+
+.ce
+Figure 5:  New Channel Payload
+
+
+.in 6
+o Channel Name Length (2 bytes) - Length of the channel name
+  field.
+
+o Channel Name (variable length) - The name of the channel.
+
+o Channel ID Length (2 bytes) - Length of the Channel ID field.
+
+o Channel ID (variable length) - The Channel ID.
+
+o Mode Mask (4 bytes) - A mode.  This can be the mode of the
+  channel but it can also be the mode of the client on the
+  channel.  The contents of this field is dependent of the
+  usage of this payload.  The usage is defined separately
+  when this payload is used.  This is a 32 bit MSB first value.
+.in 3
+
+
 .ti 0
 2.3.3 Disconnect Payload
 
@@ -849,7 +931,7 @@ Disconnect payload is sent upon disconnection.  The payload is simple;
 reason of disconnection is sent to the disconnected party.
 
 The payload may only be sent with SILC_PACKET_DISCONNECT packet.  It
-must not be sent in any other packet type.  Following diagram represents
+must not be sent in any other packet type.  The following diagram represents
 the Disconnect Payload.
 
 
@@ -870,7 +952,7 @@ the Disconnect Payload.
 .in 3
 
 .ce
-Figure 5:  Disconnect Payload
+Figure 6:  Disconnect Payload
 
 
 
@@ -900,7 +982,7 @@ This maybe any data, including binary or human readable data.
 .in 3
 
 .ce
-Figure 6:  Success Payload
+Figure 7:  Success Payload
 
 
 .in 6
@@ -932,7 +1014,7 @@ some protocol is sent in the payload.
 .in 3
 
 .ce
-Figure 7:  Failure Payload
+Figure 8:  Failure Payload
 
 
 .in 6
@@ -966,7 +1048,7 @@ may be binary or human readable data.
 .in 3
 
 .ce
-Figure 8:  Reject Payload
+Figure 9:  Reject Payload
 
 
 .in 6
@@ -992,7 +1074,7 @@ not send this payload.  The receiver of this payload may totally ignore the
 contents of the payload, however, notify message should be audited.
 
 The payload may only be sent with SILC_PACKET_NOTIFY packet.  It must
-not be sent in any other packet type.  Following diagram represents the
+not be sent in any other packet type.  The following diagram represents the
 Notify Payload.
 
 .in 5
@@ -1007,7 +1089,7 @@ Notify Payload.
 .in 3
 
 .ce
-Figure 9:  Notify Payload
+Figure 10:  Notify Payload
 
 
 .in 6
@@ -1022,7 +1104,7 @@ o Argument Nums (2 bytes) - Indicates the number of Argument
   arguments to be send along the notify message.
 .in 3
 
-Following list of currently defined notify types.  The format for notify
+The following list of currently defined notify types.  The format for notify
 arguments is same as in SILC commands described in [SILC1].  Also, all
 ID's sent in arguments are sent inside ID Payload.
 
@@ -1041,14 +1123,28 @@ ID's sent in arguments are sent inside ID Payload.
 
 1     SILC_NOTIFY_TYPE_INVITE
 
-      Sent when receiver has been invited to a channel.  This type must be
-      sent directly to the invited client.
+      Sent when an client is invited to a channel.  This is also sent
+      when the invite list of the channel is changed.  This notify type
+      is sent between routers and if an client was invited to the 
+      client as well.  In this case the packet is destined to the client.
 
-      Max Arguments:  2
-          Arguments:  (1) <Client ID>  (2) <Channel ID>
+      Max Arguments:  5
+          Arguments:  (1) <Channel ID>          (2) <channel name>
+                      (3) [<sender Client ID>]  (4) [<adding client>]
+                      (5) [<removing client>]
 
-      The <Client ID> is the client who invites the receiver of this type 
-      to channel indicated by <Channel ID>.
+      The <Channel ID> is the channel.  The <channel name> is the name
+      of the channel and is provided because the client which receives 
+      this notify packet may not have a way to resolve the name of the
+      channel from the <Channel ID>.  The <sender Client ID> is the
+      Client ID who invited the client to the channel.  The <adding client>
+      and the <removing client> indicates the added or removed client
+      from the channel's invite list.  The format of the <adding client
+      and the <removing client> is defined in the [SILC1] with
+      SILC_COMMAND_INVITE command.
+
+      The <adding client> and <removing client> is never sent when the
+      packet is destined to a client.
 
 
 2     SILC_NOTIFY_TYPE_JOIN
@@ -1060,7 +1156,7 @@ ID's sent in arguments are sent inside ID Payload.
       broadcast it to the network.
 
       Max Arguments:  2
-          Arguments:  (1) <Client ID>  (2) <Channel ID>
+          Arguments:  (1) [<Client ID>]       (2) <Channel ID>
 
       The <Client ID> is the client that joined to the channel indicated
       by the <Channel ID>.
@@ -1128,11 +1224,17 @@ ID's sent in arguments are sent inside ID Payload.
       Sent when channel mode has changed.  This type must be sent only to
       the clients who is joined on the channel whose mode was changed.
 
-      Max Arguments:  2
-          Arguments:  (1) <Client ID>  (2) <mode mask>
+      Max Arguments:  4
+          Arguments:  (1) <ID Payload>  (2) <mode mask>
+                      (3) [<cipher>]   (4) <[hmac>]     
 
-      The <Client ID> is the client who changed the mode.  The <mode mask>
-      is the new mode mask of the channel.
+      The <ID Payload> is the ID (usually Client ID but it can be Server ID
+      as well when the router is enforcing channel mode change) of the
+      entity which changed the mode.  The <mode mask> is the new mode mask
+      of the channel.  The client can safely ignore the <cipher> argument
+      since the SILC_PACKET_CHANNEL_KEY packet will force the new channel
+      key change anyway.  The <hmac> argument is important since the client
+      is responsible of setting the new HMAC and the hmac key into use.
 
 
 8     SILC_NOTIFY_TYPE_CUMODE_CHANGE
@@ -1163,9 +1265,10 @@ ID's sent in arguments are sent inside ID Payload.
 10    SILC_NOTIFY_TYPE_CHANNEL_CHANGE
 
       Sent when channel's ID has changed for a reason or another.  This 
-      is sent by noral server to the client.  Client must change the 
-      old Channel ID to the new one.  This type must be sent only to the
-      clients who is joined on the channel.
+      is sent by normal server to the client.  This can also be sent by
+      router to other server to force the Channel ID change.  The Channel
+      ID must be changed to use the new one.  When sent to clients, this
+      type must be sent only to the clients who is joined on the channel.
 
       Max Arguments:  2
           Arguments:  (1) <Old Channel ID>  (2) <New Channel ID>
@@ -1201,6 +1304,53 @@ ID's sent in arguments are sent inside ID Payload.
       The kicker may have set the <comment> to indicate the reason for
       the kicking.
 
+
+13    SILC_NOTIFY_TYPE_KILLED
+
+      Sent when a client has been killed from the network.  This is sent 
+      also to the client who was killed from the network.  The client
+      who was killed from the network must be removed from the network.
+      This notify type is destined directly to the client who was killed
+      and to channel if the client is on any channel.  The router or
+      server receiving the packet distributes this type to the local
+      clients on the channel and broadcast it to the network.
+
+      Max Arguments:  2
+          Arguments:  (1) <Client ID>  (2) [<comment>]
+
+      The <Client ID> is the client who was killed from the network.
+      The killer may have set the <comment> to indicate the reason for
+      the killing.
+
+
+14    SILC_NOTIFY_TYPE_UMODE_CHANGE
+
+      Sent when user's mode in the SILC changes.  This type is sent only
+      between routers as broadcast packet.
+
+      Max Arguments:  2
+          Arguments:  (1) <Client ID>  (2) <mode mask>
+
+      The <Client ID> is the client which mode was changed.  The <mode mask>
+      is the new mode mask.
+
+
+15    SILC_NOTIFY_TYPE_BAN
+
+      Sent when the ban list of the channel is changed.  This type is sent
+      only between routers as broadcast packet.
+
+      Max Arguments:  3
+          Arguments:  (1) <Channel ID>         (2) [<adding client>]
+                      (3) [<removing client>]
+
+      The <Channel ID> is the channel which ban list was changed.  The
+      <adding client> is used to indicate the a ban was added and the
+      <removing client> is used to indicate that a ban was removed from
+      the ban list.  The format of the <adding client> and the 
+      <removing client> is defined in the [SILC1] with SILC_COMMAND_BAN
+      command.
+
 .in 3
 
 Notify types starting from 16384 are reserved for private notify
@@ -1230,7 +1380,7 @@ that the client takes error packet seriously.
 .in 3
 
 .ce
-Figure 10:  Error Payload
+Figure 11:  Error Payload
 
 
 .in 6
@@ -1271,7 +1421,7 @@ the source ID from the header which tells the client who sent
 the message.
 
 The payload may only be sent with SILC_PACKET_CHANNEL_MESSAGE packet.
-It  must not be sent in any other packet type.  Following diagram 
+It  must not be sent in any other packet type.  The following diagram 
 represents the Channel Message Payload.
 
 (*) indicates that the field is not encrypted.
@@ -1282,8 +1432,8 @@ represents the Channel Message Payload.
                      1                   2                   3
  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
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|         Message Length        |                               |
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
+|            Flags              |         Message Length        |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               |
 ~                         Message Data                          ~
 |                                                               |
@@ -1295,16 +1445,63 @@ represents the Channel Message Payload.
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               |
+~                              MAC                              ~
+|                                                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|                                                               |
 ~                       Initial Vector *                        ~
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 .in 3
 
 .ce
-Figure 11:  Channel Message Payload
+Figure 12:  Channel Message Payload
 
 
 .in 6
+o Flags (2 bytes) - Includes the flags of the channel
+  messages.  The flags can indicate a reason or purpose
+  for the channel message.  Note, that the Private Message
+  Payload use these same flags for the same purpose.  The
+  following flags are defined:
+
+  0x0000  SILC_MESSAGE_FLAG_NONE
+
+          No specific flags set.
+
+  0x0001  SILC_MESSAGE_FLAG_AUTREPLY
+
+          This message is an automatic reply to a earlier
+          received message.
+
+  0x0002  SILC_MESSAGE_FLAG_NOREPLY
+
+          There should not be reply messages to this
+          message.
+
+  0x0004  SILC_MESSAGE_FLAG_ACTION
+
+          The sender is performing an action and the message
+          is the indication of the action.
+
+  0x0008  SILC_MESSAGE_FLAG_NOTICE
+
+          The message is for example and informational notice
+          type message.
+
+  0x0010  SILC_MESSAGE_FLAG_REQUEST
+
+          This is a generic request flag to send request
+          messages.
+
+  0x0020 - 0x0200 RESERVED
+
+          Reserved for future flags
+
+  0x0400 - 0x8000 PRIVATE RANGE
+
+         Private range for free use.
+
 o Message Length (2 bytes) - Indicates the length of the
   the Message Data field in the payload, not including any 
   other field.
@@ -1320,6 +1517,16 @@ o Padding (variable length) - The padding that must be
   applied because this payload is encrypted separately from
   other parts of the packet.
 
+o MAC (variable legnth) - The MAC computed from the
+  Message Length, Message Data, Padding Length and Padding
+  fields.  This protects the integrity of the plaintext
+  channel message.  The receiver can verify from the MAC
+  whether the message decrypted correctly.  Also, if more than
+  one private key has been set for the channel, the receiver
+  can verify which of the keys decrypted the message 
+  correctly.  Note that, this field is encrypted and must
+  be added to the padding calculation.
+
 o Initial Vector (variable length) - The initial vector
   that has been used in packet encryption.  It needs to be
   used in the packet decryption as well.  What this field
@@ -1360,7 +1567,7 @@ Channel key should expire periodically, say, in one hour, in
 which case new channel key is created and distributed.
 
 The payload may only be sent with SILC_PACKET_CHANNEL_KEY packet.
-It must not be sent in any other packet type.  Following diagram 
+It must not be sent in any other packet type.  The following diagram 
 represents the Channel Key Payload.
 
 
@@ -1401,7 +1608,7 @@ represents the Channel Key Payload.
 .in 3
 
 .ce
-Figure 12:  Channel Key Payload
+Figure 13:  Channel Key Payload
 
 
 
@@ -1457,7 +1664,7 @@ packet.  Section 4.8.2 Client To Client in [SILC1] gives example of
 this scheme as well.
 
 The payload may only be sent with SILC_PACKET_PRIVATE_MESSAGE 
-packet.  It must not be sent in any other packet type.  Following 
+packet.  It must not be sent in any other packet type.  The following 
 diagram represents the Private Message Payload.
 
 
@@ -1466,23 +1673,36 @@ diagram represents the Private Message Payload.
                      1                   2                   3
  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
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|        Nickname Length        |                               |
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
+|            Flags              |        Nickname Length        |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               |
 ~                            Nickname                           ~
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|      Message Data Length      |                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
 |                                                               |
 ~                          Message Data                         ~
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|                                                               |
+~                             Padding                           ~
+|                                                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 .in 3
 
 .ce
-Figure 13:  Private Message Payload
+Figure 14:  Private Message Payload
 
 
 .in 6
+o Flags (2 bytes) - This field includes the flags of the
+  private message.  They can indicate a different reason or
+  purpose for the private message.  See the section 2.3.9
+  Channel Message Payload for defined flags.  Note, that
+  the Channel Message Payload use the same flags for the
+  same purpose.
+
 o Nickname Length (2 bytes) - Indicates the length of the
   Nickname field, not including any other field.
 
@@ -1494,9 +1714,19 @@ o Nickname (variable length) - Nickname of the sender of the
   to the Client ID in the SILC Packet Header.  This nickname 
   is merely provided to be displayed by the client.
 
+o Message Data Length (2 bytes) - Indicates the length of the
+  Message Data field, not includes any other field.
+
 o Message Data (variable length) - The actual message to
   the client.  Rest of the packet is reserved for the message
   data.
+
+o Padding (variable length) - This field is present only
+  when the private message payload is encrypted with private
+  message key.  In this case the padding is applied to make
+  the packet multiple by eight (8), or by the block size of
+  the cipher, which ever is larger.  When encrypted with
+  normal session keys, this field must not be included.
 .in 3
 
 
@@ -1515,7 +1745,7 @@ the sender of private messages must set the Private Message Key
 flag into SILC Packet Header.
 
 The payload may only be sent with SILC_PACKET_PRIVATE_MESSAGE_KEY 
-packet.  It must not be sent in any other packet type.  Following 
+packet.  It must not be sent in any other packet type.  The following 
 diagram represents the Private Message Key Payload.
 
 
@@ -1530,10 +1760,16 @@ diagram represents the Private Message Key Payload.
 ~                      Private Message Key                      ~
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|      Cipher Name Length       |                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
+|                                                               |
+~                          Cipher Name                          ~
+|                                                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 .in 3
 
 .ce
-Figure 14:  Private Message Key Payload
+Figure 15:  Private Message Key Payload
 
 
 
@@ -1544,16 +1780,25 @@ o Private Message Key Length (2 bytes) - Indicates the length
   any other field.
 
 o Private Message Key (variable length) - The actual private
-  message key material.  This key is used as such as key material 
-  for encryption function.
+  message key material.
+
+o Cipher Name Length (2 bytes) - Indicates the length of the
+  Cipher Name field in the payload, not including any other
+  field.
+
+o Cipher Name (variable length) - Name of the cipher to use
+  in the private message encryption.  If this field does not
+  exist then the default cipher of the SILC protocol is used.
+  See the [SILC1] for defined ciphers.
 .in 3
 
 
+
 .ti 0
 2.3.13 Command Payload
 
 Command Payload is used to send SILC commands from client to server.
-Also server may send commands to other servers.  Following diagram
+Also server may send commands to other servers.  The following diagram
 represents the Command Payload.
 
 
@@ -1569,7 +1814,7 @@ represents the Command Payload.
 .in 3
 
 .ce
-Figure 15:  Command Payload
+Figure 16:  Command Payload
 
 
 .in 6
@@ -1637,7 +1882,7 @@ established by the SILC Key Exchange protocol.  See section Key
 Exchange Start Payload in [SILC3] for detailed information.
 
 The payload may only be sent with SILC_PACKET_CONNECTION_AUTH_REQUEST
-packet.  It must not be sent in any other packet type.  Following 
+packet.  It must not be sent in any other packet type.  The following 
 diagram represents the Connection Auth Request Payload.
 
 
@@ -1651,12 +1896,12 @@ diagram represents the Connection Auth Request Payload.
 .in 3
 
 .ce
-Figure 16:  Connection Auth Request Payload
+Figure 17:  Connection Auth Request Payload
 
 
 .in 6
 o Connection Type (2 bytes) - Indicates the type of the ID.
-  Following connection types are defined:
+  The following connection types are defined:
 
      1    Client connection
      2    Server connection
@@ -1666,7 +1911,7 @@ o Connection Type (2 bytes) - Indicates the type of the ID.
   discarded and the authentication must be failed.
 
 o Authentication Method (2 bytes) - Indicates the authentication
-  method to be used in the authentication protocol.  Following
+  method to be used in the authentication protocol.  The following
   authentication methods are defined:
 
 
@@ -1725,7 +1970,7 @@ The packet uses generic ID Payload as New ID Payload.  See section
 
 
 .ti 0
-2.3.18 New Client Payload
+2.3.17 New Client Payload
 
 When client is connected to the server, keys has been exchanged and
 connection has been authenticated client must register itself to the 
@@ -1744,8 +1989,8 @@ set the real nickname of the user which is then used to create new
 client ID.
 
 The payload may only be sent with SILC_PACKET_NEW_CLIENT packet.  It
-must not be sent in any other packet type.  Following diagram represents
-the New Client Payload.
+must not be sent in any other packet type.  The following diagram
+represents the New Client Payload.
 
 
 
@@ -1769,7 +2014,7 @@ the New Client Payload.
 .in 3
 
 .ce
-Figure 17:  New Client Payload
+Figure 18:  New Client Payload
 
 
 .in 6
@@ -1786,7 +2031,7 @@ o Real Name (variable length) - The real name of the user
 
 
 .ti 0
-2.3.19 New Server Payload
+2.3.18 New Server Payload
 
 This payload is sent by server when it has completed successfully both
 key exchange and connection authentication protocols.  The server
@@ -1797,7 +2042,7 @@ of the server that it has created by itself.  It also includes a
 name of the server that is associated to the Server ID.
 
 The payload may only be sent with SILC_PACKET_NEW_SERVER packet.  It
-must not be sent in any other packet type.  Following diagram represents
+must not be sent in any other packet type.  The following diagram represents
 the New Server Payload.
 
 
@@ -1824,7 +2069,7 @@ the New Server Payload.
 .in 3
 
 .ce
-Figure 18:  New Server Payload
+Figure 19:  New Server Payload
 
 
 .in 6
@@ -1841,7 +2086,7 @@ o Server Name (variable length) - The server name.
 
 
 .ti 0
-2.3.20 New Channel Payload
+2.3.19 New Channel Payload
 
 Information about newly created channel is broadcasted to all routers
 in the SILC network by sending this packet payload.  Channels are
@@ -1852,11 +2097,34 @@ to the router (after it has received JOIN command from client) which
 then processes the command and creates the channel.  Client never sends
 this packet.
 
-The payload may only be sent with SILC_PACKET_NEW_CHANNEL packet.
-It must not be sent in any other packet type.  Following diagram
-represents the New Channel Payload.
+The packet uses generic Channel Payload as New Channel Payload.  See
+section 2.3.2.3 for generic Channel Payload.  The Mode Mask field in the
+Channel Payload is the mode of the channel.
 
 
+.ti 0
+2.3.20 Key Agreement Payload
+
+This payload is used by clients to request key negotiation between
+another client in the SILC Network.  The key agreement protocol used
+is the SKE protocol.  The result of the protocol, the secret key
+material, can be used for example as private message key between the
+two clients.  This significantly adds security as the key agreement
+is performed outside the SILC network.  The server and router must not
+send this payload.
+
+The sender may tell the receiver of this payload the hostname and the
+port where the SKE protocol is running in the sender's end.  The 
+receiver may then initiate the SKE negotiation with the sender.  The
+sender may also optionally not to include the hostname and the port
+of its SKE protocol.  In this case the receiver may reply to the
+request by sending the same payload filled with the receiver's hostname
+and the port where the SKE protocol is running.  The sender may then
+initiate the SKE negotiation with the receiver.
+
+The payload may only be sent with SILC_PACKET_KEY_AGREEMENT packet.
+It must not be sent in any other packet type.  The following diagram
+represents the Key Agreement Payload.
 
 
 .in 5
@@ -1864,34 +2132,101 @@ represents the New Channel Payload.
                      1                   2                   3
  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
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|      Channel Name Length      |                               |
+|        Hostname Length        |                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
 |                                                               |
-~                         Channel Name                          ~
+~                           Hostname                            ~
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|       Channel ID Length       |                               |
+|                             Port                              |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+.in 3
+
+.ce
+Figure 20:  Key Agreement Payload
+
+
+.in 6
+o Hostname Length (2 bytes) - Indicates the length of the Hostname
+  field.
+
+o Hostname (variable length) - The hostname or IP address where
+  the SKE protocol is running.  The sender may fill this field
+  when sending the payload.  If the receiver sends this payload
+  as reply to the request it must fill this field.
+
+o Port (4 bytes) - The port where the SKE protocol is bound.
+  The sender may fill this field when sending the payload.  If
+  the receiver sends this payload as reply to the request it 
+  must fill this field.  This is a 32 bit MSB first order value.
+.in 3
+
+
+After the key material has been received from the SKE protocol it is
+processed as the [SILC3] describes.  If the key material is used as
+channel private key then the Sending Encryption Key, as defined in
+[SILC3] is used as the channel private key.  Other key material must
+be discarded.  The [SILC1] defines the way to use the key material if
+it is intended to be used as private message keys.  Any other use for
+the key material is undefined.
+
+
+.ti 0
+2.3.21 Cell Routers Payload
+
+Cell Routers payload is used by router to notify its primary router what
+other routers exist in the cell.  The other routers are considered to be
+backup routers and one of them will come active only in the case of
+failure of the primary router.  Normal server can send this packet if it
+is acting as backup router.  Client must not send this packet.  To send
+more than one backup router set the List flag and assemble the payloads
+as list.
+
+The payload may only be sent with SILC_PACKET_CELL_ROUTERS packet.  It
+must not be sent in any other packet type.  The Following diagram
+represents the Cell Routers Payload.
+
+         
+.in 5
+.nf
+                     1                   2                   3
+ 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
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|        Hostname Length        |                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
 |                                                               |
-~                          Channel ID                           ~
+~                           Hostname                            ~
+|                                                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|                             Port                              |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+|        Server ID Length       |                               |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
+|                                                               |
+~                           Server ID                           ~
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 .in 3
 
 .ce
-Figure 19:  New Channel Payload
-
+Figure 21:  Cell Routers Payload
 
 
 .in 6
-o Channel Name Length (2 bytes) - Length of the channel name.
+o Hostname Length (2 bytes) - Indicates the length of the Hostname
+  field.
 
-o Channel Name (variable length) - The name of the created
-  channel.
+o Hostname (variable length) - The hostname or IP address of
+  the backup router.
 
-o Channel ID Length (2 bytes) - Length of the Channel ID.
+o Port (4 bytes) - The port of the backup router it currently uses.
+  This is a 32 bit MSB first order value.
 
-o Channel ID (variable length) - The created Channel ID.
+o Server ID Length (2 bytes) - Indicates the length of the Server
+  ID field.
+
+o Server ID (variable length) - Consists of the Server ID of the
+  backup router.
 .in 3
 
 
@@ -1899,7 +2234,7 @@ o Channel ID (variable length) - The created Channel ID.
 2.4 SILC ID Types
 
 ID's are extensively used in the SILC network to associate different
-entities.  Following ID's has been defined to be used in the SILC
+entities.  The following ID's has been defined to be used in the SILC
 network.
 
 .in 6
@@ -1953,7 +2288,7 @@ of the packet must first decrypt the SILC Packet header, or some parts
 of it, usually first 16 bytes of it.  Then the receiver checks the
 packet type from the decrypted part of the header and can determine
 how the rest of the packet must be decrypted.  If the packet type is
-any of the special cases described in following sections the packet
+any of the special cases described in The following sections the packet
 decryption is special.  If the packet type is not among those special
 packet types rest of the packet may be decrypted with the same key.
 
@@ -1984,7 +2319,7 @@ As the receiver founds the packet to be channel message, rest of the
 packet processing is special.  Rest of the SILC Packet header is
 decrypted with the same session key along with the padding of the
 packet.  After that the packet is protected with the channel specific
-key and hence can be decrypted only if the receiver is the client on
+key and thus can be decrypted only if the receiver is the client on
 the channel.  See section 2.7 Packet Padding Generation for more
 information about padding on special packets.
 
@@ -2011,6 +2346,12 @@ their own channel keys thus the channel message traveling from one
 cell to another must be protected as it would be any normal SILC
 packet.
 
+If the SILC_CMODE_PRIVKEY channel mode has been set for the channel
+then the router cannot decrypt the packet as it does not know the
+private key.  In this case the entire packet is encrypted with the
+session key and sent to the router.  The router receiving the packet
+must check the channel mode and decrypt the packet accordingly.
+
 
 .ti 0
 2.5.3 Private Message Encryption And Decryption