Makefile.defines_int.in
acconfig.h
aclocal.m4
+autom4te.cache
+autom4te-*.cache
config.cache
config.guess
config.h
libtool
libtool-shared
ltconfig
+ltmain.sh
stamp-h
stamp-h.in
+Thu Dec 26 14:19:29 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added some sanity checks in server for correctness of the
+ server configuration. Affected file silcd/serverconfig.c.
+
+Fri Dec 20 10:47:59 CET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Prevent endless resolving of user informations in USERS
+ command by checking the command reply status correctly.
+ Affected file lib/silcclient/command_reply.c.
+
+Tue Dec 17 10:05:00 CET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed file writing on WIN32 to use O_BINARY flag. Affected
+ file is lib/silcutil/silcfileutil.c. A patch by Matthew
+ Aldous <Matthew@Aldous.com>.
+
+ * Added better implementation using CriticalSection of
+ SilcMutex on WIN32. A patch by Mikko Lähteenmäki
+ <mikko.lahteenmaki@pikabaana.net>.
+
+ * Added some Winsock WIN32 compatiblity defines into
+ includes/silcwin32.h.
+
+Mon Dec 16 19:33:05 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed double free in async host lookup code. Affected file
+ lib/silcutil/silcsockconn.c.
+
+ * On backup router handle now the SERVER_SIGNOFF from router
+ for local connected servers too, and close the connections.
+
+ Do not process them as normally signing off servers when they
+ really signoff by sending EOF fe, but always assume that
+ router sends the SERVER_SIGNOFF.
+
+ Affected files silcd/server.c and silcd/packet_receive.c.
+
+ * Fixed socket unsetting when closing connections. Affected
+ files silcd/server.c and silcd/packet_send.c.
+
+ * Do not print the nickname in SERVER_SIGNOFF if we do not
+ have it. Prevents asserts in Irssi core. It is possible we
+ don't have the nick if it was just being resolved when server
+ signoff. Affected file irssi/src/silc/core/client_ops.c.
+
+Thu Dec 12 23:22:50 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed autonick crashbug in client library. Affected file
+ lib/silcclient/client.c.
+
+ * Fixed Unix implementation of SilcMutex to really assert if
+ the mutex is locked/unlcoked already. Affected file
+ lib/silcutil/unix/silcunixmutex.c.
+
+ * Fixed locking in silc_schedule_uninit. It didn't lock
+ when dispatching timeout tasks. Affected file is
+ lib/silcutil/silcschedule.c.
+
+ * Changed Win32 implementation of SilcThread to use modern
+ Win32 interface. Affected file is
+ lib/silcutil/win32/silcwin32thread.c A patch by Mikko L.
+
+Thu Dec 12 12:06:59 CET 2002 Jochen Eisinger <c0ffee@penguin-breeder.org>
+
+ * Don't print signed messages when sending failed. Affected files
+ irssi/src/silc/core/silc-[servers.c/commands.h]
+
+ * Send adquate signal when founding a channel by joing it. Affect
+ file irssi/src/silc/core/client_ops.c
+
+Wed Dec 11 21:46:19 CET 2002 Jochen Eisinger <c0ffee@penguin-breeder.org>
+
+ * Fix theme abstracts parsing. Affected files irssi/default.theme,
+ irssi/src/fe-common/core/themes.c
+
+Wed Dec 11 20:20:07 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed close command to use the port correctly when closing
+ server connections. Affected file silcd/idlist.c.
+
+ * Check for NULL outbuf in silc_socket_write. It is possible
+ that it is NULL is some odd case. Affected files are
+ lib/silcutil/[unix/win32]/silc[unix/win32]sockconn.c.
+
+ * Do not call final protocol callback for backup router
+ resuming protocol when closing connection. It is closed
+ by timeout in case of error. Affected file silcd/server.c.
+
+ * Backup reconnect to router if backup resuming protocol
+ failed. Affected file silcd/server_backup.c.
+
+Wed Dec 11 10:01:26 CET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed double free in SKE library error hadling when signature
+ error occurred. Affected file lib/silcske/silcske.c.
+
+ * Save the fingerprint to new SilcClientEntry after changing
+ nickname. Affected file lib/silcclient/client_notify.c.
+
+ * Print SIGNOFF in Irssi SILC client only if the nickname is
+ known. Prevents asserts in Irssi core. It is possible we
+ don't have the nick if it was just being resolved when it
+ quit. Affected file irssi/src/silc/core/client_ops.c.
+
+Tue Dec 10 21:47:56 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed double free in invite list adding code when adding
+ invite strings. Affected file silcd/server_util.c.
+
+Fri Dec 6 17:40:24 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * More log printing during backup router protocol. Affected
+ file silcd/server_backup.c.
+
+ * Removed backwards support for old private key file format.
+ Affected file lib/silccrypt/silcpkcs.c.
+
+ * Removed backwards support for not-so-strict decryption length
+ check, it's strict now. Affected lib/silccrypt/silccipher.c.
+
+ * GETKEY to update the client entrys fingerprint too.
+ Affected file lib/silcclient/command_reply.c.
+
+ * Added --without-libtoolfix for package builders using weird
+ wrappers around libtool (BSD at least).
+
+Thu Dec 5 22:29:46 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed backup router bugs: When backup resumes router and
+ receives a CHANNEL_MESSAGE packet the backup must not act
+ as router since the packet header decryption would be
+ different. Also, when relaying packets to channel, do
+ not re-encrypt packets on backup that came from the primary
+ since the connection isn't really router-router connection.
+ Affected files silcd/server.c, silcd/packet_send.c.
+
+ * Added checks in encryption/decryption that encryption/decryption
+ length sent as argument really is multiple by block size. Helps
+ catching really weird bugs like the above backup router bugs
+ when packets are being decrypted in wrong way. Affected files
+ lib/silccore/silcpacket.c, and lib/silccrypt/silccipher.c.
+
+ * Fixed padding generation in private key file encryption.
+ Affected file lib/silccrypt/silcpkcs.c.
+
+Thu Dec 5 16:35:23 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added ignore_message_signatures setting which can be used
+ to ignore signatures in messages. Affected files are
+ irssi/src/silc/core/client_ops.c, silc-core.c.
+
+ * Fixed the libtoolfix to use command line options instead of
+ environment variables. They didn't work as expected. Now,
+ the libtool is fully run-time configurable.
+
+Wed Dec 4 21:08:52 CET 2002 Jochen Eisinger <c0ffee@penguin-breeder.org>
+
+ * Verify signature payload for signed messages. Affected files
+ irssi/src/silc/core/client_ops.h, irssi/src/silc/core/silc-servers.c,
+ irssi/src/silc/core/silc-core.h
+
+ * Display signature verification result in public and private
+ messages using theme abstracts. See irssi/default.theme for
+ examples on their usage. Affected files
+ irssi/default.theme, irssi/src/fe-common/silc/fe-messages.h,
+ irssi/src/fe-common/silc/module-formats.[ch],
+ irssi/src/fe-common/silc/fe-common-silc.c,
+ irssi/src/fe-common/silc/Makefile.am
+ irssi/src/fe-common/core/fe-messages.[ch]
+
+ * Fixed bugs in Irssi's theme parsing. Affected files
+ irssi/src/fe-common/core/themes.c
+
+Wed Dec 4 18:29:13 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Calculate the correct length for signed messages before
+ encrypting, it must be multiple by block size. Affected
+ file lib/silccore/silcmessage.c.
+
+ * silc_message_signed_get_public_key returns now both
+ decoded and encoded public key. Affected files are
+ lib/silccore/silcmessage.[ch].
+
+ * Added libtoolfix script that makes the libtool more generic
+ and configurable in run-time. Now we can specify in run-time
+ if what kind of libraries we want to create, regardless of
+ configuration. SIMs are now creates even if --disable-shared
+ was explicitly given.
+
+Tue Dec 3 23:26:55 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed founder key sending in CMODE command in client.
+ Affected file lib/silcclient/command.c.
+
+ * Fixed CUMODE founder authentication in server to not check
+ for client's public key since it's not supposed to do that.
+ Affected file silcd/command.c.
+
+Tue Dec 3 12:02:41 CET 2002 Jochen Eisinger <c0ffee@penguin-breeder.org>
+
+ * Set realname and hostname in NICK_REC records. Affected file
+ irssi/src/silc/core/silc-nicklist.c
+
+Mon Dec 2 20:50:20 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Remove 1.0 protocol backwards compat code from client
+ library.
+
+ * Added more reliable check for whether nickname did change
+ or not, or whether only Client ID changed in NICK_CHANGE
+ notify. Affected file lib/silcclient/client_notify.c.
+ Fixes bug in '@' character handling in a nickname.
+
+ * Added support for automatically parsing signature from
+ the message payload. Added new function
+ silc_message_get_signature to return the payload to
+ application. Affected files lib/silccore/silcmessage.[ch].
+
+ * Changed the private_message and channel_message client
+ operations to deliver the SilcMessagePayload to the
+ application too. Application can use it fe. to get the
+ signature from the message for verification. Affected
+ file lib/silcclient/silcclient.h, client_channel.c and
+ client_prvmsg.c.
+
+ * Redefined the signed payload for message payloads.
+ Updated protocol specs and implemented.
+
+Mon Dec 2 16:28:29 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed wrong invite and ban list handling in server command
+ reply. Affected files are silcd/command_reply.c,
+ silcd/server_util.[ch].
+
+Sun Dec 1 20:48:17 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed CMODE setting in server when founder mode was set.
+ Affected file silcd/command.c. Bug #95.
+
+ * Added support to setting specific public key in CMODE in
+ Irssi SILC client. Affected file lib/silcclient/command.c.
+
+ * Added support to use specific public key in CUMODE in
+ Irssi SILC Client. Affected file lib/silcclient/command.c.
+
+ * Added support for inviting and banning by public key in
+ Irssi SILC client. Affected file lib/silcclient/command.c.
+
+ * Fixed fingerprint/babbleprint showing in invite and ban
+ list command replys. Affected file is
+ irssi/src/silc/core/client_ops.c.
+
+Sun Dec 1 16:32:03 CET 2002 Jochen Eisinger <c0ffee@penguin-breeder.org>
+
+ * Format CMODE +c and +h to display both the mode and the argument
+
+Sun Dec 1 18:17:22 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added test vectors and test programs for SHA-1, MD5,
+ HMAC-SHA1 and HMAC-MD5. New tests are located in
+ lib/silccrypt/tests/. Fixed also argument decoding bug in
+ MD5 implementation. Affected file lib/silccrypt/md5.c.
+
+ * Changed the channel private key and private message key
+ generation (with static keys) to use SHA1 instead of MD5,
+ as SHA1 is the mandatory hash function in SILC. Affected
+ file lib/silcclient/client_[channel/prvmsg].c.
+
+ * Changed the private key file encryption to use SHA1 instead
+ of MD5. Added support for the old generation and added
+ automatic change of the key (to be removed later). Affected
+ files lib/silccrypt/silcpkcs.c.
+
+Sat Nov 30 19:07:52 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Load only files with .pub suffix in PublicKeyDir. Affected
+ file silcd/serverconfig.c.
+
+Sat Nov 30 14:29:34 CET 2002 Johnny Mnemonic <johnny@themnemonic.org>
+
+ * Extended the SILC_SERVER_LOG_ERROR macro to all available logging
+ channels. Affected files silcd/silcd.c, silcd/server.h.
+
+ * Added the config directive PublicKeyDir for the client block.
+ Affected files doc/exampe_silcd.conf.in, silcd/serverconfig.[ch].
+
+Sat Nov 30 09:30:55 CET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Merged Toni's irssi/silc.conf patch.
+
+ * ROBODoc cleanup patch to lib/silccrypt/silcpkcs.h by johnny.
+
+ * Max alloc tests in allocation routines. Affected file
+ lib/silcutil/silcmemory.c.
+
+Fri Nov 29 23:44:29 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Fixed a typo in resuming code that fixed detach/resume code
+ in server. Bug #93. Affected file silcd/packet_receive.c.
+
+Thu Nov 28 17:17:11 CET 2002 Jochen Eisinger <c0ffee@penguin-breeder.org>
+
+ * Do reverse lookups for server when /connecting. Affected files
+ irssi/silc.conf, irssi/src/core/servers.c, irssi/src/core/network.c,
+ irssi/src/core/net-nonblock.*
+
+Thu Nov 28 16:19:18 CET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added library versioning for shared libraries. Affected
+ files configure.in.pre and lib/Makefile.am.pre.
+
Wed Nov 27 21:51:52 CET 2002 Jochen Eisinger <c0ffee@penguin-breeder.org>
* Display INVITE and BAN lists as specified by SILC 1.2
option to the `configure' script. This will assure that assembler
optimized code is not compiled in.
+`--enabled-shared'
+
+ If you wish to compile and install shared libraries then enable this
+option. By default all libraries are compiled as static libraries.
+
`--enable-debug'
If you would like to enable the debugging for the compiled programs
-rm -rf $(distdir)
SILC_EXTRA_DIST = SILC_DISTRIBUTION_EXTRA
-EXTRA_DIST = CHANGES CREDITS $(SILC_EXTRA_DIST)
+EXTRA_DIST = libtoolfix CHANGES CREDITS $(SILC_EXTRA_DIST)
#
# Installing of SILC into the system
TODO for Irssi SILC Client 1.0
==============================
- o Support to set arbitrary pulic key in CMODE.
-
- o INVITE/BAN by public key file.
-
- o Signed message payload handling on UI
-
- o bugs parsing nicknames with @ in NICK_CHANGE
-
o Testing - See test plan:
http://silcnet.org/docs/silc-client-1.0-test.pdf
http://silcnet.org/docs/silc-client-1.0-test.ps
TODO for SILC Server 1.0
========================
+ o Fix CUMODE_CHANGE and CMODE_CHANGE for founder key things.
+
o 1.2 backup router support
o Testing
TODO/bugs In SILC Libraries
===========================
- o WIN32 silc_net_create_connection_async does not work the same way
- than on Unix. Do it with threads on WIN32. The function works but
- is not actually async currently (Fix this to 0.9.x).
+ o Test cases for all cryptographic primitive in lib/silccrypt/
+
+ o Test cases for all payload encoding and decoding routins in lib/silccore/
+
+ o Test cases for math library routines in lib/silcmath/
TODO in Toolkit Documentation
#confdir = $(sysconfdir)
confdir = $(silc_etcdir)
-conf_DATA = silc.conf
+conffile = silc.conf
themedir = $(datadir)/silc/themes
theme_DATA = default.theme
file2header.sh \
irssi.spec \
irssi.spec.in \
- $(conf_DATA) \
+ $(conffile) \
$(theme_DATA) \
irssi-config.in \
irssi-icon.png \
sb_act_hilight = "%M$*";
# hilight with specified color, $0 = color, $1 = text
sb_act_hilight_color = "$0$1-%n";
+
+ # signed messages
+ # the following formats fit the Irssi default theme:
+ #
+ # flag_signed = "%GS%n";
+ # flag_unknown = "%Y?%n";
+ # flag_failed = "%RF%n";
+ #
+ # pubmsghinick_signed = "{msgnick {flag_signed} $0$2-%n}";
+ # pubmsghinick_unknown = "{msgnick {flag_unknown} $0$2-%n}";
+ # pubmsghinick_failed = "{msgnick {flag_failed} $0$2-%n}";
+ #
+ # pubmsgmenick_signed = "{msgnick {flag_signed} $1-}";
+ # pubmsgmenick_unknown = "{msgnick {flag_unknown} $1-}";
+ # pubmsgmenick_failed = "{msgnick {flag_failed} $1-}";
+ #
+ # pubmsgnick_signed = "{msgnick {flag_signed} $1-}";
+ # pubmsgnick_unknown = "{msgnick {flag_unknown} $1-}";
+ # pubmsgnick_failed = "{msgnick {flag_failed} $1-}";
+ #
+ # privmsg_signed = "{privmsg {flag_signed}$0 $1}";
+ # privmsg_unknown = "{privmsg {flag_unknown}$0 $1}";
+ # privmsg_failed = "{privmsg {flag_failed}$0 $1}";
+ #
+ # privmsgnick_signed = "{msgnick {flag_signed} %R$*%n}";
+ # privmsgnick_unknown = "{msgnick {flag_unknown} %R$*%n}";
+ # privmsgnick_failed = "{msgnick {flag_failed} %R$*%n}";
+ #
+ # ownmsgnick_signed = "{msgnick {flag_signed} $1-}";
+ # ownprivmsgnick_signed = "{msgnick {flag_signed} $*}";
+ #
+ flag_signed = "[%cS%n]";
+ flag_unknown = "[%Y?%n]";
+ flag_failed = "[%RF%n]";
+
+ pubmsghinick_signed = "{msgnick {flag_signed} $0$2-%n}";
+ pubmsghinick_unknown = "{msgnick {flag_unknown} $0$2-%n}";
+ pubmsghinick_failed = "{msgnick {flag_failed} $0$2-%n}";
+
+ pubmsgmenick_signed = "%g<{flag_signed}$1->%n %|";
+ pubmsgmenick_unknown = "%g<{flag_unknown}$1->%n %|";
+ pubmsgmenick_failed = "%g<{flag_failed}$1->%n %|";
+
+ pubmsgnick_signed = "{msgnick {flag_signed}$0 $1-}";
+ pubmsgnick_unknown = "{msgnick {flag_unknown}$0 $1-}";
+ pubmsgnick_failed = "{msgnick {flag_failed}$0 $1-}";
+
+ privmsg_signed = "{privmsg {flag_signed}$0 $1}";
+ privmsg_unknown = "{privmsg {flag_unknown}$0 $1}";
+ privmsg_failed = "{privmsg {flag_failed}$0 $1}";
+
+ privmsgnick_signed = "{privmsgnick {flag_signed}$0}";
+ privmsgnick_unknown = "{privmsgnick {flag_unknown}$0}";
+ privmsgnick_failed = "{privmsgnick {flag_failed}$0}";
+
+ ownmsgnick_signed = "{msgnick {flag_signed} $1-}%g";
+ ownprivmsg_signed = "->*%c{flag_signed}$1-%n* %g";
+ ownprivmsgnick_signed = "->*%c{flag_signed}$0%n* %g$1-";
};
#
@SYNTAX:action@
-Same as ME, but gets channel as an additional parameter.
-Example: /ACTION #irssi yawns
-(This outputs the following to #irssi: * Nick yawns)
+Same as ME, but gets channel as an additional parameter. Example: /ACTION silc yawns (This outputs the following to channel silc: * Nick yawns)
See also: ME
-
no server is specified, the server you are connected to is
used.
-This command may be an alias.
-
-See also: INFO
+This command is an alias of INFO.
+See also: INFO, STATS
You must be channel operator to be able to use this command.
Wildcards may be used with this command.
+In ban list it is possible to add nicknames, server name, username,
+hostname or netmask (IP/MASK), and public keys.
+
Examples:
/BAN #mychannel +foobar!mr.bar@foo.bar.com
Adds nickname `foobar' with username `mr.bar' from host
Adds foo* nicknames from any server with any username from
*.foobar.com hosts to the ban list on current channel.
+ /BAN * +/path/to/public_key.pub
+ Adds the public key from file /path/to/public_key.pub to
+ ban list of the current channel.
+
/BAN * -looser
Removes the nickname `looser' from the ban list on current
channel.
/BAN *
Shows the ban list of the current channel.
-See also: KNOCKOUT, KICKBAN
+See also: KICK
Outputs the contents of the specified file. Equivalent to
UNIX 'cat' command.
-See also: CD
+See also: EXEC
Changes the current working directory. Equivalent to UNIX
'cd' command.
-See also: DCC GET
+See also: EXEC
Operator command. Makes the server to close connection to another server
or router.
-See also: OPER, SILCOPER
+You need to use same name of the server as configured in silcd.conf.
+
+Example: /CLOSE sauna.silcnet.org
+
+See also: SCONNECT, OPER, SILCOPER
+
be provided when joining to the channel.
c <cipher> Set/unset channel's cipher
h <hmac> Set/unset channel's hmac
- f Set/unset channel founder authentication.
+ f [<pubkeyfile> <privkeyfile> [<privkey passphrase>]]
+ Set/unset channel founder authentication.
Channel founder may set this mode so that
if the client leaves the channel it can
claim the founder rights when it returns
be permanent channel. You can claim the
founder rights using CUMODE or JOIN commands.
+ If the <pubkeyfile> and <privkeyfile> is
+ provided then the <pubkeyfile> will the used
+ as founder public key, and the private key
+ is used to compute a signature for the SILC
+ server. If these are omitted then the default
+ SILC keypair is used. Normally you do not need
+ to provide these arguments.
+
Multiple modes can be set/unset at once if the modes does not
require any arguments. If mode requires an argument then only
one mode can be set at once.
only to remove both modes at once).
f <nickname>[@<server>]
+ [<pubkeyfile> <privkeyfile> [<privkey passphrase>]]
Set/Unset channel founder. If you are channel
founder you can set the channel founder authentication
using CMODEc command.
+ If the <pubkeyfile> and <privkeyfile> is
+ provided then the <pubkeyfile> will the used
+ as founder public key, and the private key
+ is used to compute a signature for the SILC
+ server. If these are omitted then the default
+ SILC keypair is used. Normally you do not need
+ to provide these arguments.
+
o <nickname>[@<server>]
Set/unset channel operator. Requires that
@SYNTAX:dehilight@
-Makes irssi not to highlight items containing the text.
-If parameter is a number, deletes the specified hilight
-entry from the list.
-
-See also: HILIGHT
+Remove given highlight. If parameter is a number, deletes the specified hilight entry from the list.
+See also: HILIGHT, SET HILIGHT
kill the process. It is meant to remove the processes that don't die
even with SIGKILL. This option just closes the pipes used to
communicate with the process and frees all memory it used.
+
+See also: CAT, CD
+
prompted to verify and accept the fetched public key. The public key
is saved into your local key directory (~/.silc/clientkeys/).
+See also: WHOIS, KEY
no server is specified, the server you are connected to is
used.
+See also: STATS
This command is used to invite an client to a channel and to manage
the channel's invite list. Wildcards may be used with this command.
+In invite list it is possible to add nicknames, server name, username,
+hostname or netmask (IP/MASK), and public keys.
+
Examples:
/INVITE silc joe
Invites nickname `joe' to channel 'silc', and adds the client
Adds nicknames foo* from silcnet.org server from *.foobar.com
hosts to the invite list of the current channel.
+ /INVITE * +/path/to/public_key.pub
+ Adds the public key from file /path/to/public_key.pub to
+ invite list of the current channel.
+
/INVITE * -joe
Removes nickname `joe' from the invite list of the current
channel.
/KEY MSG nick set secretkey -responder
/KEY MSG foo agreement 10.2.1.7 5000
/KEY MSG bar negotiate 10.2.1.7 5000
+
+See also: WHOIS, CHANNEL, GETKEY
The default alias for /KICK is /K.
-See also: KNOCKOUT
+See also: BAN
Shows the given number of lines of log from the current window.
-See also:
+See also: LOG, SET LOG, WINDOW LOG
windows where they were when you called /LAYOUT SAVE.
Channels aren't actually joined in those windows immediately, they're
-just marked "next time you join to '#channel' in server that has tag
-'ircnet' place it to this window".
+just marked "next time you join to 'channel' in server that has tag
+'silcnet' place it to this window".
/LAYOUT RESET removes the saved layout.
+
+See also: SAVE
@SYNTAX:list@
-Lists the channel names. Trying to list all the channel
-names usually causes you to be disconnected from the
-server with the reason "Excess flood", as usually all
-40000 channels form together and server naively attempts
-to send you them.
+Lists all channel names and number of people on them. Channel topics
+are also shown.
-Thus, on IRCNet, you should rather use service ALIS
-(Advanced Listing Service), which will allow you to query
-for channel with specific name, topic, mode or usercount.
-Type /SQUERY ALIS HELP to get more info about it.
-
-See also: SQUERY
+Your server only knows number of people on channels if it has local
+clients joined onto those. This is why you'll see N/A for some channels.
Load a plugin. If full path isn't given, irssi searches the
plugin from directories:
- ~/.irssi/modules/
- <install dir, /usr/local or /usr maybe>/lib/irssi/modules/
-
-See plugins page of http://irssi.org/ to see if there's any plugins
-you'd want to use.
+~/.silc/modules/
+/path/to/silc/modules/ (by default /usr/local/silc/modules)
See also: UNLOAD
/SET log_close_string <text> - Text written to log when it's closed
/SET log_day_changed <text> - Text written to log when day changes
-NOTE: Log files are locked after opened, so two Irssis can't
+NOTE: Log files are locked after opened, so two clients can't
accidentally try to write to the same log file.
Examples:
-/LOG OPEN -targets cras ~/irclogs/cras.log MSGS
- - Logs all messages from/to nick `cras'
+/LOG OPEN -targets Toni ~/silclogs/Toni.log MSGS
+ - Logs all messages from/to nick `Toni'
-/LOG OPEN -targets #linux ~/irclogs/linux/linux-%%Y-%%m-%%d
- - Logs all messages in channel #linux. Log is rotated daily, so
- logs in 1. May 2000 goes to file "linux-2000-05-01", when the
- day is changed, Irssi closes the log and starts logging to
- "linux-2000-05-02" etc.
+/LOG OPEN -targets silc ~/silclogs/silc/silc-%%Y-%%m-%%d
+ - Logs all messages in channel silc. Log is rotated daily, so
+ logs in 1. May 2000 goes to file "silc-2000-05-01", when the
+ day is changed the log is closed and new log is opened as
+ "silc-2000-05-02".
-See also: SET LOG, WINDOW LOG
+See also: LASTLOG, SET LOG, WINDOW LOG
@SYNTAX:motd@
-Shows the motd of the current server. This contains
-usually some useful info on the server, administrator and
-the rules.
+Shows the motd of the current or given server. This contains usually some useful info on the server, administrator and the rules.
+See also: INFO, ADMIN, STATS
@SYNTAX:msg@
-Sends a message to a remote client. Usually this
-is used for sending private messages to other persons.
+Sends a private message to other user in the network.
-Examples:
+It is possible to digitally sign your messages. The receiver
+may then verify the message with your public key. By default
+messages are not signed. If you want your private messages
+to be signed you SMSG command instead of this MSG command.
-/MSG friend Hi, what's up?
+If -channel option is provided then this command actually
+send channel message to the specified channel. The message
+IS NOT private message, it is normal channel message. It is
+also possible to digitally sign channel messages by using
+SMSG command or by doing /set sign_channel_messages on, in
+which case _all_ channel messages will be signed.
+
+Example:
+
+/MSG Toni Hi, what's up?
+
+See also: QUERY SMSG
-voices: show voiced people in list
-normal: show rest of the people in list
-Shows the names (nicks) in the specified channels. /NAMES **
-shows all nicks in all channels, you probably don't want
-to do this.
+Shows users of specified channels. /NAMES ** shows all nicks in all channels, you probably don't want to do this.
Examples:
/NAMES
- shows nicks in the current channel.
-/NAMES -ops #c1,#c2
- - shows operators in channels #c1 and #c2
+/NAMES -ops silc,beginners
+ - shows operators in channels silc and beginners
-See also: WHO, CHANNEL
+See also: USERS, WHO, WHOIS, WHOWAS, CHANNEL
@SYNTAX:part@
-Parts from the current or specified channel. Depending
-on your settings, closes the corresponding window, too.
+Parts from the current or specified channel. Depending on your settings it closes the corresponding window also.
-See also: LEAVE, JOIN
+See also: JOIN
@SYNTAX:query@
-Starts a private conversation with the nick. All text you
-type that would normally be sent to your channel now goes to
-the specified nick in the form of MSGs.
+Starts a private conversation with given person.
-Usually this command opens up a new window, too.
-
-The query is ended by giving command UNQUERY
+The query session is ended by giving command UNQUERY
See also: UNQUERY, WINDOW, MSG, SET QUERY
@SYNTAX:quit@
-This ends your session. If a quit message is supplied, it
-will be displayed to anyone else on any channel you were on
-before quitting. If one isn't specified, the text "Leaving" is
-used.
+This ends your session.
-/EXIT does the same.
+If a quit message is supplied, it will be displayed to everyone on all channels you were on before quitting. If quit message isn't specified, the text "leaving" is used.
+See also: EXIT
@SYNTAX:save@
-Saves the current Irssi configuration into the configuration
-file.
-
-See also: RELOAD
+Saves the current configuration.
+See also: RELOAD, LAYOUT
server or router. The <server> is the hostname or IP
addres of the server.
-Example: /SCONNECT silc.silcnet.org 706
+You need to use same name of the server as configured in silcd.conf.
-See also: OPER, SILCOPER, CLOSE, SHUTDOWN
+Example: /SCONNECT sauna.silcnet.org
+See also: CLOSE, OPER, SILCOPER
/SCRIPT RESET unloads all loaded scripts and resets the perl interpreter.
-See also: LOAD, UNLOAD
+See also: LOAD, UNLOAD, RUN
-4, -6: specify explicitly whether to use IPv4 or IPv6 address
-auto: Automatically connect to server at startup (default)
-noauto: Don't connect to server at startup
- -silcnet: Specify what network this server belongs to
- -host: Specify what host name to use, if you have multiple
+ -silcnet: Specify the network this server belongs to
+ -host: Specify what host name to bind to, if you have multiple interfaces
-!: don't autojoin channels
- -cmdspeed: Same as /SET cmd_queue_speed, see section 3.1
- -cmdmax: Same as /SET cmd_max_at_once, see section 3.1
-port: This is pretty much like the port argument later,
except this can be used to modify existing server's
port.
/SERVER REMOVE <address> [<port>]
-/SERVER LIST
-
-See also: RMRECONNS, DISCONNECT, RECONNECT
-
+See also: RMRECONNS, DISCONNECT, RECONNECT, CONNECT
@SYNTAX:shutdown@
-Operator command. Shutdowns the server.
+Operator command. Shuts the server down.
See also: OPER, SILCOPER, CLOSE
-
--- /dev/null
+
+@SYNTAX:smsg@
+
+Sends a signed private message to other user in the network.
+The message will be digitally signed and the receiver may verify
+the message by using your public key.
+
+If -channel option is provided then this command actually
+send channel message to the specified channel. The message
+IS NOT private message, it is normal channel message. Also this
+message will be signed and can be verified by using your public
+key.
+
+The default theme of Irssi SILC Client shows the digital signed
+messages with [S] at start of the nickname who sent the message, when
+the message was successfully verified, [?] if the message could not
+be verified since the public key of the sender isn't cached locally,
+or [F] if the signature verificationn failed. If you do not have
+the sender's public key you can fetch it with GETKEY command.
+
+If you don't want to verify the signatures from received messages
+you may do /SET ignore_message_signatures on. In this case
+signatures in messages are ignored and they appear as normal
+non-signed messages. By default, all message signatures are
+verified.
+
+Examples:
+
+/SMSG Foobar Very authenticated message
+/SMSG -channel silc Another signed message
+/SMSG * I truly said this
+
+See also: MSG QUERY GETKEY
@SYNTAX:stats@
Shows various server and network statistics.
+
+See also: INFO, ADMIN
+++ /dev/null
-
-@SYNTAX:upgrade@
-
-Upgrade irssi to new version on-the-fly without disconnecting from
-server, so other people won't even notice you quit from network. This ONLY
-executes the new binary, it does NOT download/compile/whatever irssi.
-
-NOTE: THIS COMMAND DOES NOT WORK WITH Irssi-SILC CLIENT!
-
@SYNTAX:users@
-Shows users of the specified channel. The channel must be either joined or it
-needs to be a public channel (without secret or private flags set).
+Lists users of given channel. The channel must be either joined or it needs to be a public channel (without secret or private flags set).
Alias WHO is by default USERS * command.
-See also: WHOIS, WHOWAS
-
-
+See also: NAMES, WHOIS, WHOWAS
If you want to send your information in WHOIS you can set the
information with ATTR command. See HELP ATTR.
-See also: WHOWAS, CHANNEL, ATTR
+See also: WHOIS, CHANNEL, ATTR, NAMES, WHO
#
# Configured servers
#
+# silc.silcnet.org is DNS round robin for all (currently) known public SILCNet servers.
+#
servers = (
- { address = "silc.silcnet.org"; chatnet = SILCNet; port = 706; },
- { address = "silc.ytti.fi"; chatnet = SILCNet; port = 706; },
- { address = "silc.peelo.com"; chatnet = SILCNet; port = 706; },
+ { address = "silc.silcnet.org"; chatnet = SILCNet; port = 706; autoconnect = "yes"; }
);
#
EXIT = "quit";
SIGNOFF = "quit";
DESCRIBE = "action";
- DATE = "time";
- HOST = "userhost";
LAST = "lastlog";
SAY = "msg *";
WHO = "users *";
KN = "knockout";
BANS = "ban";
B = "ban";
- MUB = "unban *";
- UB = "unban";
IG = "ignore";
UNIG = "unignore";
SB = "scrollback";
WC = "window close";
WN = "window new hide";
GOTO = "sb goto";
- CHAT = "dcc chat";
ADMIN = "info";
RUN = "SCRIPT LOAD";
UPTIME = "eval exec - expr `date +%s` - \\$F | awk '{print \"Irssi uptime: \"int(\\\\\\$1/3600/24)\"d \"int(\\\\\\$1/3600%24)\"h \"int(\\\\\\$1/60%60)\"m \"int(\\\\\\$1%60)\"s\" }'";
Q = "QUERY";
MOOD = "ATTR status_mood";
OP = "CUMODE $C +o";
+ DEOP = "CUMODE $C -o";
};
#
placement = "top";
position = "1";
visible = "always";
- disabled = "yes";
+ disabled = "no";
items = {
barstart = { priority = "100"; };
topic = { };
# aes-256-cbc, aes-192-cbc, aes-128-cbc,
# twofish-256-cbc, twofish-192-cbc, twofish-128-cbc,
# rc6-256-cbc, rc6-192-cbc, rc6-128-cbc,
-# mars-256-cbc, mars-192-cbc, mars-128-cbc,
# cast-256-cbc, cast-192-cbc and cast-128-cbc
#
# Available hash functions are (default: sha1):
crypto_default_hmac = "hmac-sha1-96";
};
"fe-common/core" = {
- autocreate_own_query = "no";
+ autocreate_own_query = "yes";
use_status_window = "no";
autoclose_windows = "no";
use_msgs_window = "no";
- autocreate_windows = "no";
- autocreate_query_level = "none";
+ autocreate_windows = "yes";
+ autocreate_query_level = "MSG";
+ reuse_unused_windows = "yes";
};
core = {
server_reconnect_time = "10000";
+ resolve_reverse_lookup = "yes";
};
"fe-text" = { indent = "8"; };
};
return conn;
}
-/* SYNTAX: CONNECT [-4 | -6] [-ssl] [-noproxy] [-ircnet <ircnet>]
+/* SYNTAX: CONNECT [-4 | -6] [-ssl] [-noproxy] [-silcnet <silcnet>]
[-host <hostname>] [-rawlog <file>]
<address>|<chatnet> [<port> [<password> [<nick>]]] */
static void cmd_connect(const char *data)
signal_emit("command server connect", 3, data, server, item);
}
-/* SYNTAX: SERVER [-4 | -6] [-ssl] [-noproxy] [-ircnet <ircnet>]
+/* SYNTAX: SERVER [-4 | -6] [-ssl] [-noproxy] [-silcnet <silcnet>]
[-host <hostname>] [-rawlog <file>]
[+]<address>|<chatnet> [<port> [<password> [<nick>]]] */
static void cmd_server_connect(const char *data, SERVER_REC *server)
signal_emit("gui exit", 0);
}
-/* SYNTAX: JOIN [-invite] [-<server tag>] <channels> [<keys>] */
static void cmd_join(const char *data, SERVER_REC *server)
{
GHashTable *optlist;
cmd_params_free(free_arg);
}
-/* SYNTAX: MSG [-<server tag>] [-channel | -nick] <targets> <message> */
+/* SYNTAX: MSG [-channel] <target> <message> */
static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
GHashTable *optlist;
void core_init_paths(int argc, char *argv[])
{
static struct poptOption options[] = {
- { "config", 0, POPT_ARG_STRING, NULL, 0, "Configuration file location (~/.irssi/config)", "PATH" },
- { "home", 0, POPT_ARG_STRING, NULL, 0, "Irssi home dir location (~/.irssi)", "PATH" },
+ { "config", 0, POPT_ARG_STRING, NULL, 0, "Configuration file location (~/.silc/config)", "PATH" },
+ { "home", 0, POPT_ARG_STRING, NULL, 0, "Irssi home dir location (~/.silc)", "PATH" },
{ NULL, '\0', 0, NULL }
};
const char *home;
/* nonblocking gethostbyname(), ip (IPADDR) + error (int, 0 = not error) is
written to pipe when found PID of the resolver child is returned */
-int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe)
+int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
+ int reverse_lookup)
{
RESOLVED_IP_REC rec;
const char *errorstr;
#ifndef WIN32
int pid;
#endif
+ int len;
g_return_val_if_fail(addr != NULL, FALSE);
rec.error = net_gethostbyname(addr, &rec.ip4, &rec.ip6);
if (rec.error == 0) {
errorstr = NULL;
+ if (reverse_lookup) {
+ /* reverse lookup the IP, ignore any error */
+ if (rec.ip4.family != 0)
+ net_gethostbyaddr(&rec.ip4, &rec.host4);
+ if (rec.ip6.family != 0)
+ net_gethostbyaddr(&rec.ip6, &rec.host6);
+ }
} else {
errorstr = net_gethosterror(rec.error);
rec.errlen = errorstr == NULL ? 0 : strlen(errorstr)+1;
g_io_channel_write_block(pipe, &rec, sizeof(rec));
if (rec.errlen != 0)
g_io_channel_write_block(pipe, (void *) errorstr, rec.errlen);
+ else {
+ if (rec.host4) {
+ len = strlen(rec.host4) + 1;
+ g_io_channel_write_block(pipe, (void *) &len,
+ sizeof(int));
+ g_io_channel_write_block(pipe, (void *) rec.host4,
+ len);
+ }
+ if (rec.host6) {
+ len = strlen(rec.host6) + 1;
+ g_io_channel_write_block(pipe, (void *) &len,
+ sizeof(int));
+ g_io_channel_write_block(pipe, (void *) rec.host6,
+ len);
+ }
+ }
#ifndef WIN32
if (pid == 0)
/* get the resolved IP address */
int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec)
{
+ int len;
+
rec->error = -1;
rec->errorstr = NULL;
+ rec->host4 = NULL;
+ rec->host6 = NULL;
#ifndef WIN32
fcntl(g_io_channel_unix_get_fd(pipe), F_SETFL, O_NONBLOCK);
reason, just ignore it. */
rec->errorstr = g_malloc0(rec->errlen+1);
g_io_channel_read_block(pipe, rec->errorstr, rec->errlen);
+ } else {
+ if (rec->host4) {
+ g_io_channel_read_block(pipe, &len, sizeof(int));
+ rec->host4 = g_malloc0(len);
+ g_io_channel_read_block(pipe, rec->host4, len);
+ }
+ if (rec->host6) {
+ g_io_channel_read_block(pipe, &len, sizeof(int));
+ rec->host6 = g_malloc0(len);
+ g_io_channel_read_block(pipe, rec->host6, len);
+ }
}
return 0;
rec->pipes[1] = g_io_channel_unix_new(fd[1]);
/* start nonblocking host name lookup */
- net_gethostbyname_nonblock(server, rec->pipes[1]);
+ net_gethostbyname_nonblock(server, rec->pipes[1], 0);
rec->tag = g_input_add(rec->pipes[0], G_INPUT_READ,
(GInputFunction) simple_readpipe, rec);
int errlen; /* error text length */
char *errorstr; /* error string - dynamically allocated, you'll
need to free() it yourself unless it's NULL */
+ char *host4, *host6; /* dito */
} RESOLVED_IP_REC;
typedef struct {
typedef void (*NET_HOST_CALLBACK) (RESOLVED_NAME_REC *, void *);
/* nonblocking gethostbyname(), PID of the resolver child is returned. */
-int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe);
+int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
+ int reverse_lookup);
/* Get host's name, call func when finished */
int net_gethostbyaddr_nonblock(IPADDR *ip, NET_HOST_CALLBACK func, void *data);
/* get the resolved IP address. returns -1 if some error occured with read() */
#ifdef HAVE_IPV6
struct addrinfo req, *ai;
int host_error;
+ char hostname[NI_MAXHOST];
+ char ipname[MAX_IP_LEN];
#else
struct hostent *hp;
#endif
- char ipname[MAX_IP_LEN];
g_return_val_if_fail(ip != NULL, -1);
g_return_val_if_fail(name != NULL, -1);
- net_ip2host(ip, ipname);
-
*name = NULL;
#ifdef HAVE_IPV6
+ net_ip2host(ip, ipname);
+
memset(&req, 0, sizeof(struct addrinfo));
req.ai_socktype = SOCK_STREAM;
req.ai_flags = AI_CANONNAME;
host_error = getaddrinfo(ipname, NULL, &req, &ai);
if (host_error != 0)
return host_error;
- *name = g_strdup(ai->ai_canonname);
+ host_error = getnameinfo(ai->ai_addr, ai->ai_addrlen,
+ hostname, NI_MAXHOST, NULL, 0, 0);
+ if (host_error != 0) {
+ freeaddrinfo(ai);
+ return host_error;
+ }
+
+ *name = g_strdup(hostname);
freeaddrinfo(ai);
#else
- hp = gethostbyaddr(ipname, strlen(ipname), AF_INET);
+ if (ip->family != AF_INET) return -1;
+ hp = gethostbyaddr(&ip->ip, 4, AF_INET);
if (hp == NULL) return -1;
*name = g_strdup(hp->h_name);
RESOLVED_IP_REC iprec;
IPADDR *ip;
const char *errormsg;
+ char *servername = NULL;
g_source_remove(server->connect_tag);
server->connect_tag = -1;
} else if (server->connrec->family == AF_INET) {
/* force IPv4 connection */
ip = iprec.ip4.family == 0 ? NULL : &iprec.ip4;
+ servername = iprec.host4;
} else if (server->connrec->family == AF_INET6) {
/* force IPv6 connection */
ip = iprec.ip6.family == 0 ? NULL : &iprec.ip6;
+ servername = iprec.host6;
} else {
/* pick the one that was found, or if both do it like
/SET resolve_prefer_ipv6 says. */
- ip = iprec.ip4.family == 0 ||
- (iprec.ip6.family != 0 &&
- settings_get_bool("resolve_prefer_ipv6")) ?
- &iprec.ip6 : &iprec.ip4;
+ if (iprec.ip4.family == 0 ||
+ (iprec.ip6.family != 0 &&
+ settings_get_bool("resolve_prefer_ipv6"))) {
+ ip = &iprec.ip6;
+ servername = iprec.host6;
+ } else {
+ ip = &iprec.ip4;
+ servername = iprec.host4;
+ }
}
if (ip != NULL) {
/* host lookup ok */
+ if (servername) {
+ g_free(server->connrec->address);
+ server->connrec->address = g_strdup(servername);
+ }
server_real_connect(server, ip, NULL);
errormsg = NULL;
} else {
}
g_free(iprec.errorstr);
+ g_free(iprec.host4);
+ g_free(iprec.host6);
}
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn)
server->connrec->proxy : server->connrec->address;
server->connect_pid =
net_gethostbyname_nonblock(connect_address,
- server->connect_pipe[1]);
+ server->connect_pipe[1],
+ settings_get_bool("resolve_reverse_lookup"));
server->connect_tag =
g_input_add(server->connect_pipe[0], G_INPUT_READ,
(GInputFunction)
void servers_init(void)
{
settings_add_bool("server", "resolve_prefer_ipv6", FALSE);
+ settings_add_bool("server", "resolve_reverse_lookup", FALSE);
lookup_servers = servers = NULL;
signal_add("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
session_file = NULL;
args_register(options);
- command_bind("upgrade", NULL, (SIGNAL_FUNC) cmd_upgrade);
+ /*command_bind("upgrade", NULL, (SIGNAL_FUNC) cmd_upgrade);*/
signal_add("session save", (SIGNAL_FUNC) sig_session_save);
signal_add("session restore", (SIGNAL_FUNC) sig_session_restore);
{
g_free_not_null(irssi_binary);
- command_unbind("upgrade", (SIGNAL_FUNC) cmd_upgrade);
+ /*command_unbind("upgrade", (SIGNAL_FUNC) cmd_upgrade);*/
signal_remove("session save", (SIGNAL_FUNC) sig_session_save);
signal_remove("session restore", (SIGNAL_FUNC) sig_session_restore);
#define ishighalnum(c) ((unsigned char) (c) >= 128 || i_isalnum(c))
-static GHashTable *printnicks;
+GHashTable *printnicks;
/* convert _underlined_ and *bold* words (and phrases) to use real
underlining or bolding */
char *channel_get_nickmode(CHANNEL_REC *channel, const char *nick);
+extern GHashTable *printnicks;
+
#endif
return FALSE;
}
+/* return "data" from {abstract data} string */
+char *theme_format_expand_get(THEME_REC *theme, const char **format)
+{
+ GString *str;
+ char *ret, dummy;
+ int braces = 1; /* we start with one brace opened */
+
+ str = g_string_new(NULL);
+ while ((**format != '\0') && (braces)) {
+ if (**format == '{')
+ braces++;
+ else if (**format == '}')
+ braces--;
+ else if ((braces > 1) && (**format == ' ')) {
+ g_string_append(str, "\\x20");
+ (*format)++;
+ continue;
+ } else {
+ theme_format_append_next(theme, str, format,
+ 'n', 'n',
+ &dummy, &dummy, 0);
+ continue;
+ }
+
+ if (!braces) {
+ (*format)++;
+ break;
+ }
+
+ g_string_append_c(str, **format);
+ (*format)++;
+ }
+
+ ret = str->str;
+ g_string_free(str, FALSE);
+ return ret;
+}
+
/* expand a single {abstract ...data... } */
static char *theme_format_expand_abstract(THEME_REC *theme,
const char **formatp,
char default_fg, char default_bg,
int flags)
{
+ GString *str;
const char *p, *format;
char *abstract, *data, *ret;
int len;
abstract = g_strdup(data);
/* we'll need to get the data part. it may contain
- more abstracts, they are automatically expanded. */
- data = theme_format_expand_data(theme, formatp, default_fg, default_bg,
- NULL, NULL, flags);
+ more abstracts, they are _NOT_ expanded. */
+ data = theme_format_expand_get(theme, formatp);
len = strlen(data);
if (len > 1 && i_isdigit(data[len-1]) && data[len-2] == '$') {
PARSE_FLAG_ONLY_ARGS);
g_free(abstract);
g_free(data);
- abstract = ret;
+ str = g_string_new(NULL);
+ p = ret;
+ while (*p != '\0') {
+ if (*p == '\\') {
+ int chr;
+ p++;
+ chr = expand_escape(&p);
+ g_string_append_c(str, chr != -1 ? chr : *p);
+ } else
+ g_string_append_c(str, *p);
+ p++;
+ }
+ g_free(ret);
+ abstract = str->str;
+ g_string_free(str, FALSE);
/* abstract may itself contain abstracts or replaces */
p = abstract;
fe-channels.c \
fe-common-silc.c \
module-formats.c \
- silc-modules.c
+ silc-modules.c \
+ fe-messages.c
noinst_HEADERS = \
module-formats.h \
void fe_silc_modules_init(void);
void fe_silc_modules_deinit(void);
+void fe_silc_messages_init(void);
+void fe_silc_messages_deinit(void);
+
void fe_silc_init(void)
{
theme_register(fecommon_silc_formats);
fe_silc_channels_init();
fe_silc_modules_init();
+ fe_silc_messages_init();
module_register("silc", "fe");
}
void fe_silc_deinit(void)
{
+ fe_silc_messages_deinit();
fe_silc_modules_deinit();
fe_silc_channels_deinit();
--- /dev/null
+/*
+
+ fe-messages.c
+
+ Author: Jochen Eisinger <c0ffee@penguin-breeder.org>
+
+ Copyright (C) 2002 Jochen Eisinger
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+*/
+
+#include "module.h"
+#include "modules.h"
+#include "signals.h"
+#include "themes.h"
+#include "levels.h"
+#include "misc.h"
+#include "special-vars.h"
+#include "settings.h"
+
+#include "servers.h"
+#include "channels.h"
+#include "nicklist.h"
+#include "ignore.h"
+
+#include "window-items.h"
+#include "fe-queries.h"
+#include "fe-messages.h"
+#include "hilight-text.h"
+#include "printtext.h"
+#include "module-formats.h"
+
+#define VERIFIED_MSG(v,msg) (v == SILC_MSG_SIGNED_VERIFIED ? \
+ msg##_SIGNED : (v == SILC_MSG_SIGNED_UNKNOWN ? \
+ msg##_UNKNOWN : msg##_FAILED))
+
+static void sig_signed_message_public(SERVER_REC * server, const char *msg,
+ const char *nick,
+ const char *address,
+ const char *target,
+ int verified)
+{
+ CHANNEL_REC *chanrec;
+ NICK_REC *nickrec = NULL; /* we cheat here a little to keep the limit of
+ 6 parameters to a signal handler ... */
+ const char *nickmode, *printnick;
+ int for_me, print_channel, level;
+ char *color, *freemsg = NULL;
+
+ /* NOTE: this may return NULL if some channel is just closed with
+ /WINDOW CLOSE and server still sends the few last messages */
+ chanrec = channel_find(server, target);
+ if (nickrec == NULL && chanrec != NULL)
+ nickrec = nicklist_find(chanrec, nick);
+
+ for_me = !settings_get_bool("hilight_nick_matches") ? FALSE :
+ nick_match_msg(chanrec, msg, server->nick);
+ color = for_me ? NULL :
+ hilight_match_nick(server, target, nick, address, MSGLEVEL_PUBLIC,
+ msg);
+
+ print_channel = chanrec == NULL ||
+ !window_item_is_active((WI_ITEM_REC *) chanrec);
+ if (!print_channel && settings_get_bool("print_active_channel") &&
+ window_item_window((WI_ITEM_REC *) chanrec)->items->next != NULL)
+ print_channel = TRUE;
+
+ level = MSGLEVEL_PUBLIC;
+ if (for_me || color != NULL)
+ level |= MSGLEVEL_HILIGHT;
+
+ if (settings_get_bool("emphasis"))
+ msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg);
+
+ /* get nick mode & nick what to print the msg with
+ (in case there's multiple identical nicks) */
+ nickmode = channel_get_nickmode(chanrec, nick);
+ printnick = nickrec == NULL ? nick :
+ g_hash_table_lookup(printnicks, nickrec);
+ if (printnick == NULL)
+ printnick = nick;
+
+ if (!print_channel) {
+ /* message to active channel in window */
+ if (color != NULL) {
+ /* highlighted nick */
+ printformat_module("fe-common/silc", server, target,
+ level, VERIFIED_MSG(verified, SILCTXT_PUBMSG_HILIGHT),
+ color, printnick, msg, nickmode);
+ } else {
+ printformat_module("fe-common/silc", server, target, level,
+ for_me ? VERIFIED_MSG(verified, SILCTXT_PUBMSG_ME) :
+ VERIFIED_MSG(verified,SILCTXT_PUBMSG),
+ printnick, msg, nickmode);
+ }
+ } else {
+ /* message to not existing/active channel */
+ if (color != NULL) {
+ /* highlighted nick */
+ printformat_module("fe-common/silc", server, target, level,
+ VERIFIED_MSG(verified, SILCTXT_PUBMSG_HILIGHT_CHANNEL),
+ color, printnick, target, msg, nickmode);
+ } else {
+ printformat_module("fe-common/silc", server, target, level,
+ for_me ? VERIFIED_MSG(verified, SILCTXT_PUBMSG_ME_CHANNEL) :
+ VERIFIED_MSG(verified, SILCTXT_PUBMSG_CHANNEL),
+ printnick, target, msg, nickmode);
+ }
+ }
+
+ g_free_not_null(freemsg);
+ g_free_not_null(color);
+}
+
+static void sig_signed_message_private(SERVER_REC * server,
+ const char *msg, const char *nick,
+ const char *address, int verified)
+{
+ QUERY_REC *query;
+ char *freemsg = NULL;
+
+ query = query_find(server, nick);
+
+ if (settings_get_bool("emphasis"))
+ msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
+
+ printformat_module("fe-common/silc", server, nick, MSGLEVEL_MSGS,
+ query == NULL ? VERIFIED_MSG(verified, SILCTXT_MSG_PRIVATE) :
+ VERIFIED_MSG(verified, SILCTXT_MSG_PRIVATE_QUERY), nick, address, msg);
+
+ g_free_not_null(freemsg);
+}
+
+static void sig_signed_message_own_public(SERVER_REC * server,
+ const char *msg,
+ const char *target)
+{
+ WINDOW_REC *window;
+ CHANNEL_REC *channel;
+ const char *nickmode;
+ char *freemsg = NULL;
+ int print_channel;
+
+ channel = channel_find(server, target);
+ if (channel != NULL)
+ target = channel->visible_name;
+
+ nickmode = channel_get_nickmode(channel, server->nick);
+
+ window = channel == NULL ? NULL :
+ window_item_window((WI_ITEM_REC *) channel);
+
+ print_channel = window == NULL ||
+ window->active != (WI_ITEM_REC *) channel;
+
+ if (!print_channel && settings_get_bool("print_active_channel") &&
+ window != NULL && g_slist_length(window->items) > 1)
+ print_channel = TRUE;
+
+ if (settings_get_bool("emphasis"))
+ msg = freemsg = expand_emphasis((WI_ITEM_REC *) channel, msg);
+
+ if (!print_channel) {
+ printformat_module("fe-common/silc", server, target,
+ MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
+ MSGLEVEL_NO_ACT, SILCTXT_OWN_MSG_SIGNED, server->nick, msg,
+ nickmode);
+ } else {
+ printformat_module("fe-common/silc", server, target,
+ MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
+ MSGLEVEL_NO_ACT, SILCTXT_OWN_MSG_CHANNEL_SIGNED,
+ server->nick, target, msg, nickmode);
+ }
+
+ g_free_not_null(freemsg);
+}
+
+static void sig_signed_message_own_private(SERVER_REC * server,
+ const char *msg,
+ const char *target,
+ const char *origtarget)
+{
+ QUERY_REC *query;
+ char *freemsg = NULL;
+
+ g_return_if_fail(server != NULL);
+ g_return_if_fail(msg != NULL);
+
+ if (target == NULL) {
+ /* this should only happen if some special target failed and
+ we should display some error message. currently the special
+ targets are only ',' and '.'. */
+ g_return_if_fail(strcmp(origtarget, ",") == 0 ||
+ strcmp(origtarget, ".") == 0);
+
+ printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CLIENTNOTICE,
+ *origtarget == ',' ? SILCTXT_NO_MSGS_GOT :
+ SILCTXT_NO_MSGS_SENT);
+ signal_stop();
+ return;
+ }
+
+ query = privmsg_get_query(server, target, TRUE, MSGLEVEL_MSGS);
+
+ if (settings_get_bool("emphasis"))
+ msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
+
+ printformat_module("fe-common/silc", server, target,
+ MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
+ query == NULL ? SILCTXT_OWN_MSG_PRIVATE_SIGNED :
+ SILCTXT_OWN_MSG_PRIVATE_QUERY_SIGNED, target, msg,
+ server->nick);
+
+ g_free_not_null(freemsg);
+}
+
+void fe_silc_messages_init(void)
+{
+ signal_add_last("message signed_public",
+ (SIGNAL_FUNC) sig_signed_message_public);
+ signal_add_last("message signed_private",
+ (SIGNAL_FUNC) sig_signed_message_private);
+ signal_add_last("message signed_own_public",
+ (SIGNAL_FUNC) sig_signed_message_own_public);
+ signal_add_last("message signed_own_private",
+ (SIGNAL_FUNC) sig_signed_message_own_private);
+}
+
+void fe_silc_messages_deinit(void)
+{
+ signal_remove("message signed_public",
+ (SIGNAL_FUNC) sig_signed_message_public);
+ signal_remove("message signed_private",
+ (SIGNAL_FUNC) sig_signed_message_private);
+ signal_remove("message signed_own_public",
+ (SIGNAL_FUNC) sig_signed_message_own_public);
+ signal_remove("message signed_own_private",
+ (SIGNAL_FUNC) sig_signed_message_own_private);
+}
{ "killed", "{nick $0} has been killed from the SILC Network by {nick $1} ($2)", 3, { 0, 0, 0 } },
{ "quieted", "You have been queited and cannot talk on {channel $0}", 1, { 0 } },
{ "appears", "{channick $0} now appears as {channick_hilight $1}", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_hilight_signed", "{pubmsghinick_signed $0 $3 $1}$2", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_hilight_unknown", "{pubmsghinick_unknown $0 $3 $1}$2", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_hilight_failed", "{pubmsghinick_failed $0 $3 $1}$2", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_me_signed", "{pubmsgmenick_signed $2 {menick $0}}$1", 3, { 0, 0, 0 } },
+ { "pubmsg_me_unknown", "{pubmsgmenick_unknown $2 {menick $0}}$1", 3, { 0, 0, 0 } },
+ { "pubmsg_me_failed", "{pubmsgmenick_failed $2 {menick $0}}$1", 3, { 0, 0, 0 } },
+ { "pubmsg_signed", "{pubmsgnick_signed $2 {pubnick $0}}$1", 3, { 0, 0, 0 } },
+ { "pubmsg_unknown", "{pubmsgnick_unknown $2 {pubnick $0}}$1", 3, { 0, 0, 0 } },
+ { "pubmsg_failed", "{pubmsgnick_failed $2 {pubnick $0}}$1", 3, { 0, 0, 0 } },
+ { "pubmsg_hilight_channel_signed", "{pubmsghinick_signed $0 $4 $1{msgchannel $2}}$3", 5, { 0, 0, 0, 0, 0 } },
+ { "pubmsg_hilight_channel_unknown", "{pubmsghinick_unknown $0 $4 $1{msgchannel $2}}$3", 5, { 0, 0, 0, 0, 0 } },
+ { "pubmsg_hilight_channel_failed", "{pubmsghinick_failed $0 $4 $1{msgchannel $2}}$3", 5, { 0, 0, 0, 0, 0 } },
+ { "pubmsg_me_channel_signed", "{pubmsgmenick_signed $3 {menick $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_me_channel_unknown", "{pubmsgmenick_unknown $3 {menick $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_me_channel_failed", "{pubmsgmenick_failed $3 {menick $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_channel_signed", "{pubmsgnick_signed $3 {pubnick $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_channel_unknown", "{pubmsgnick_unknown $3 {pubnick $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } },
+ { "pubmsg_channel_failed", "{pubmsgnick_failed $3 {pubnick $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } },
+ { "msg_private_signed", "{privmsg_signed $0 $1}$2", 3, { 0, 0, 0 } },
+ { "msg_private_unknown", "{privmsg_unknown $0 $1}$2", 3, { 0, 0, 0 } },
+ { "msg_private_failed", "{privmsg_failed $0 $1}$2", 3, { 0, 0, 0 } },
+ { "msg_private_query_signed", "{privmsgnick_signed $0}$2", 3, { 0, 0, 0 } },
+ { "msg_private_query_unknown", "{privmsgnick_unknown $0}$2", 3, { 0, 0, 0 } },
+ { "msg_private_query_failed", "{privmsgnick_failed $0}$2", 3, { 0, 0, 0 } },
+ { "own_msg_signed", "{ownmsgnick_signed $2 {ownnick $0}}$1", 3, { 0, 0, 0 } },
+ { "own_msg_channel_signed", "{ownmsgnick_signed $3 {ownnick $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } },
+ { "no_msgs_got", "You have not received a message from anyone yet", 0 },
+ { "no_msgs_sent", "You have not sent a message to anyone yet", 0 },
+ { "own_msg_private_signed", "{ownprivmsg_signed msg $0}$1", 2, { 0, 0 } },
+ { "own_msg_private_query_signed", "{ownprivmsgnick_signed {ownprivnick $2}}$1", 3, { 0, 0, 0 } },
/* WHOIS, WHOWAS and USERS (alias WHO) messages */
{ NULL, "Who Queries", 0 },
SILCTXT_CHANNEL_KILLED,
SILCTXT_CHANNEL_QUIETED,
SILCTXT_CHANNEL_APPEARS,
+ SILCTXT_PUBMSG_HILIGHT_SIGNED,
+ SILCTXT_PUBMSG_HILIGHT_UNKNOWN,
+ SILCTXT_PUBMSG_HILIGHT_FAILED,
+ SILCTXT_PUBMSG_ME_SIGNED,
+ SILCTXT_PUBMSG_ME_UNKNOWN,
+ SILCTXT_PUBMSG_ME_FAILED,
+ SILCTXT_PUBMSG_SIGNED,
+ SILCTXT_PUBMSG_UNKNOWN,
+ SILCTXT_PUBMSG_FAILED,
+ SILCTXT_PUBMSG_HILIGHT_CHANNEL_SIGNED,
+ SILCTXT_PUBMSG_HILIGHT_CHANNEL_UNKNOWN,
+ SILCTXT_PUBMSG_HILIGHT_CHANNEL_FAILED,
+ SILCTXT_PUBMSG_ME_CHANNEL_SIGNED,
+ SILCTXT_PUBMSG_ME_CHANNEL_UNKNOWN,
+ SILCTXT_PUBMSG_ME_CHANNEL_FAILED,
+ SILCTXT_PUBMSG_CHANNEL_SIGNED,
+ SILCTXT_PUBMSG_CHANNEL_UNKNOWN,
+ SILCTXT_PUBMSG_CHANNEL_FAILED,
+ SILCTXT_MSG_PRIVATE_SIGNED,
+ SILCTXT_MSG_PRIVATE_UNKNOWN,
+ SILCTXT_MSG_PRIVATE_FAILED,
+ SILCTXT_MSG_PRIVATE_QUERY_SIGNED,
+ SILCTXT_MSG_PRIVATE_QUERY_UNKNOWN,
+ SILCTXT_MSG_PRIVATE_QUERY_FAILED,
+ SILCTXT_OWN_MSG_SIGNED,
+ SILCTXT_OWN_MSG_CHANNEL_SIGNED,
+ SILCTXT_NO_MSGS_GOT,
+ SILCTXT_NO_MSGS_SENT,
+ SILCTXT_OWN_MSG_PRIVATE_SIGNED,
+ SILCTXT_OWN_MSG_PRIVATE_QUERY_SIGNED,
SILCTXT_FILL_2,
LIBS = $(SILC_COMMON_LIBS)
silc_LDADD = \
@COMMON_LIBS@ \
+ -L../../../lib -lsilcclient \
@PERL_LINK_LIBS@ \
@PERL_FE_LINK_LIBS@ \
@PERL_LINK_FLAGS@ \
@PROG_LIBS@ \
- @TEXTUI_LIBS@ \
- -L../../../lib -lsilcclient
+ @TEXTUI_LIBS@
silc_LDFLAGS = -export-dynamic
tparm_sources = \
va_end(va);
}
+/* try to verify a message using locally stored public key data */
+int verify_message_signature(SilcClientEntry sender,
+ SilcMessageSignedPayload sig,
+ SilcMessagePayload message)
+{
+ SilcPublicKey pk;
+ char file[256], filename[256];
+ char *fingerprint, *fingerprint2;
+ unsigned char *pk_data;
+ SilcUInt32 pk_datalen;
+ struct stat st;
+ int ret = SILC_MSG_SIGNED_VERIFIED, i;
+
+ if (sig == NULL)
+ return SILC_MSG_SIGNED_UNKNOWN;
+
+ /* get public key from the signature payload and compare it with the
+ one stored in the client entry */
+ pk = silc_message_signed_get_public_key(sig, &pk_data, &pk_datalen);
+
+ if (pk != NULL) {
+ fingerprint = silc_hash_fingerprint(NULL, pk_data, pk_datalen);
+
+ if (sender->fingerprint) {
+ fingerprint2 = silc_fingerprint(sender->fingerprint,
+ sender->fingerprint_len);
+ if (strcmp(fingerprint, fingerprint2)) {
+ /* since the public key differs from the senders public key, the
+ verification _failed_ */
+ silc_pkcs_public_key_free(pk);
+ silc_free(fingerprint);
+ ret = SILC_MSG_SIGNED_UNKNOWN;
+ }
+ silc_free(fingerprint2);
+ }
+ } else if (sender->fingerprint)
+ fingerprint = silc_fingerprint(sender->fingerprint,
+ sender->fingerprint_len);
+ else
+ /* no idea, who or what signed that message ... */
+ return SILC_MSG_SIGNED_UNKNOWN;
+
+ /* search our local client key cache */
+ for (i = 0; i < strlen(fingerprint); i++)
+ if (fingerprint[i] == ' ')
+ fingerprint[i] = '_';
+
+ snprintf(file, sizeof(file) - 1, "clientkey_%s.pub", fingerprint);
+ snprintf(filename, sizeof(filename) - 1, "%s/clientkeys/%s",
+ get_irssi_dir(), file);
+ silc_free(fingerprint);
+
+ if (stat(filename, &st) < 0)
+ /* we don't have the public key cached ... use the one from the sig */
+ ret = SILC_MSG_SIGNED_UNKNOWN;
+ else {
+ SilcPublicKey cached_pk=NULL;
+
+ /* try to load the file */
+ if (!silc_pkcs_load_public_key(filename, &cached_pk, SILC_PKCS_FILE_PEM) &&
+ !silc_pkcs_load_public_key(filename, &cached_pk,
+ SILC_PKCS_FILE_BIN)) {
+ printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+ SILCTXT_PUBKEY_COULD_NOT_LOAD, "client");
+ if (pk == NULL)
+ return SILC_MSG_SIGNED_UNKNOWN;
+ else
+ ret = SILC_MSG_SIGNED_UNKNOWN;
+ }
+
+ if (cached_pk) {
+ if (pk)
+ silc_pkcs_public_key_free(pk);
+ pk = cached_pk;
+ }
+ }
+
+ /* the public key is now in pk, our "level of trust" in ret */
+ if ((pk) && silc_message_signed_verify(sig, message, pk,
+ silc_client->sha1hash)!= SILC_AUTH_OK)
+ ret = SILC_MSG_SIGNED_FAILED;
+
+ if (pk)
+ silc_pkcs_public_key_free(pk);
+
+ return ret;
+}
+
/* Message for a channel. The `sender' is the nickname of the sender
received in the packet. The `channel_name' is the name of the channel. */
void silc_channel_message(SilcClient client, SilcClientConnection conn,
SilcClientEntry sender, SilcChannelEntry channel,
+ SilcMessagePayload payload,
SilcMessageFlags flags, const unsigned char *message,
SilcUInt32 message_len)
{
SILC_SERVER_REC *server;
SILC_NICK_REC *nick;
SILC_CHANNEL_REC *chanrec;
+ int verified = 0;
SILC_LOG_DEBUG(("Start"));
nick = silc_nicklist_insert(chanrec, chu, FALSE);
}
+ /* If the messages is digitally signed, verify it, if possible. */
+ if (flags & SILC_MESSAGE_FLAG_SIGNED) {
+ if (!settings_get_bool("ignore_message_signatures")) {
+ SilcMessageSignedPayload sig = silc_message_get_signature(payload);
+ verified = verify_message_signature(sender, sig, payload);
+ } else {
+ flags &= ~SILC_MESSAGE_FLAG_SIGNED;
+ }
+ }
+
if (flags & SILC_MESSAGE_FLAG_DATA) {
/* MIME object received, try to display it as well as we can */
char type[128], enc[128];
if (!message)
return;
+ /* FIXME: replace those printformat calls with signals and add signature
+ information to them (if present) */
if (flags & SILC_MESSAGE_FLAG_ACTION)
printformat_module("fe-common/silc", server, channel->channel_name,
MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_ACTION,
silc_utf8_decode(message, message_len, SILC_STRING_LANGUAGE,
cp, message_len);
- signal_emit("message public", 6, server, cp,
- nick == NULL ? "[<unknown>]" : nick->nick,
- nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
- chanrec->name, nick);
+ if (flags & SILC_MESSAGE_FLAG_SIGNED)
+ signal_emit("message signed_public", 6, server, cp,
+ nick == NULL ? "[<unknown>]" : nick->nick,
+ nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
+ chanrec->name, verified);
+ else
+ signal_emit("message public", 6, server, cp,
+ nick == NULL ? "[<unknown>]" : nick->nick,
+ nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
+ chanrec->name, nick);
silc_free(dm);
return;
}
- signal_emit("message public", 6, server, message,
- nick == NULL ? "[<unknown>]" : nick->nick,
- nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
- chanrec->name, nick);
+ if (flags & SILC_MESSAGE_FLAG_SIGNED)
+ signal_emit("message signed_public", 6, server, message,
+ nick == NULL ? "[<unknown>]" : nick->nick,
+ nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
+ chanrec->name, verified);
+ else
+ signal_emit("message public", 6, server, message,
+ nick == NULL ? "[<unknown>]" : nick->nick,
+ nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
+ chanrec->name, nick);
}
}
sender received in the packet. */
void silc_private_message(SilcClient client, SilcClientConnection conn,
- SilcClientEntry sender, SilcMessageFlags flags,
+ SilcClientEntry sender, SilcMessagePayload payload,
+ SilcMessageFlags flags,
const unsigned char *message,
SilcUInt32 message_len)
{
SILC_SERVER_REC *server;
char userhost[256];
+ int verified = 0;
SILC_LOG_DEBUG(("Start"));
snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
sender->username, sender->hostname);
+ /* If the messages is digitally signed, verify it, if possible. */
+ if (flags & SILC_MESSAGE_FLAG_SIGNED) {
+ if (!settings_get_bool("ignore_message_signatures")) {
+ SilcMessageSignedPayload sig = silc_message_get_signature(payload);
+ verified = verify_message_signature(sender, sig, payload);
+ } else {
+ flags &= ~SILC_MESSAGE_FLAG_SIGNED;
+ }
+ }
+
if (flags & SILC_MESSAGE_FLAG_DATA) {
/* MIME object received, try to display it as well as we can */
char type[128], enc[128];
silc_utf8_decode(message, message_len, SILC_STRING_LANGUAGE,
cp, message_len);
- signal_emit("message private", 4, server, cp,
- sender->nickname ? sender->nickname : "[<unknown>]",
- sender->username ? userhost : NULL);
+ if (flags & SILC_MESSAGE_FLAG_SIGNED)
+ signal_emit("message signed_private", 5, server, cp,
+ sender->nickname ? sender->nickname : "[<unknown>]",
+ sender->username ? userhost : NULL, verified);
+ else
+ signal_emit("message private", 4, server, cp,
+ sender->nickname ? sender->nickname : "[<unknown>]",
+ sender->username ? userhost : NULL);
silc_free(dm);
return;
}
- signal_emit("message private", 4, server, message,
- sender->nickname ? sender->nickname : "[<unknown>]",
- sender->username ? userhost : NULL);
+ if (flags & SILC_MESSAGE_FLAG_SIGNED)
+ signal_emit("message signed_private", 5, server, message,
+ sender->nickname ? sender->nickname : "[<unknown>]",
+ sender->username ? userhost : NULL, verified);
+ else
+ signal_emit("message private", 4, server, message,
+ sender->nickname ? sender->nickname : "[<unknown>]",
+ sender->username ? userhost : NULL);
}
/* Notify message to the client. The notify arguments are sent in the
snprintf(buf, sizeof(buf) - 1, "%s@%s",
client_entry->username, client_entry->hostname);
signal_emit("message part", 5, server, channel->channel_name,
- client_entry->nickname, client_entry->username ?
+ client_entry->nickname, client_entry->username ?
buf : "", client_entry->nickname);
-
+
chanrec = silc_channel_find_entry(server, channel);
if (chanrec != NULL) {
nickrec = silc_nicklist_find(chanrec, client_entry);
tmp = va_arg(va, char *);
silc_server_free_ftp(server, client_entry);
-
- memset(buf, 0, sizeof(buf));
- if (client_entry->username)
- snprintf(buf, sizeof(buf) - 1, "%s@%s",
- client_entry->username, client_entry->hostname);
- signal_emit("message quit", 4, server, client_entry->nickname,
- client_entry->username ? buf : "",
- tmp ? tmp : "");
-
+
+ /* Print only if we have the nickname. If this cliente has just quit
+ when we were only resolving it, it is possible we don't have the
+ nickname. */
+ if (client_entry->nickname) {
+ memset(buf, 0, sizeof(buf));
+ if (client_entry->username)
+ snprintf(buf, sizeof(buf) - 1, "%s@%s",
+ client_entry->username, client_entry->hostname);
+ signal_emit("message quit", 4, server, client_entry->nickname,
+ client_entry->username ? buf : "",
+ tmp ? tmp : "");
+ }
+
list1 = nicklist_get_same_unique(SERVER(server), client_entry);
for (list_tmp = list1; list_tmp != NULL; list_tmp =
list_tmp->next->next) {
for (i = 0; i < clients_count; i++) {
memset(buf, 0, sizeof(buf));
- if (clients[i]->username)
- snprintf(buf, sizeof(buf) - 1, "%s@%s",
- clients[i]->username, clients[i]->hostname);
- signal_emit("message quit", 4, server, clients[i]->nickname,
- clients[i]->username ? buf : "",
- "server signoff");
+
+ /* Print only if we have the nickname. If this client has just quit
+ when we were only resolving it, it is possible we don't have the
+ nickname. */
+ if (clients[i]->nickname) {
+ if (clients[i]->username)
+ snprintf(buf, sizeof(buf) - 1, "%s@%s",
+ clients[i]->username, clients[i]->hostname);
+ signal_emit("message quit", 4, server, clients[i]->nickname,
+ clients[i]->username ? buf : "",
+ "server signoff");
+ }
silc_server_free_ftp(server, clients[i]);
channel->channel_name, chanrec->topic);
if (founder) {
- if (founder == conn->local_entry)
+ if (founder == conn->local_entry) {
printformat_module("fe-common/silc",
server, channel->channel_name, MSGLEVEL_CRAP,
SILCTXT_CHANNEL_FOUNDER_YOU,
channel->channel_name);
- else
+ signal_emit("nick mode changed", 2, chanrec, ownnick);
+ } else
printformat_module("fe-common/silc",
server, channel->channel_name, MSGLEVEL_CRAP,
SILCTXT_CHANNEL_FOUNDER,
/* a public key */
char *fingerprint, *babbleprint;
- fingerprint = silc_hash_fingerprint(NULL, tmp, len);
- babbleprint = silc_hash_fingerprint(NULL, tmp, len);
-
+ /* tmp is Public Key Payload, take public key from it. */
+ fingerprint = silc_hash_fingerprint(NULL, tmp + 4, len - 4);
+ babbleprint = silc_hash_babbleprint(NULL, tmp + 4, len - 4);
+
printformat_module("fe-common/silc", server,
(chanrec ? chanrec->visible_name : NULL),
MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITEBAN_PUBKEY,
void silc_channel_message(SilcClient client, SilcClientConnection conn,
SilcClientEntry sender,
SilcChannelEntry channel,
+ SilcMessagePayload payload,
SilcMessageFlags flags,
const unsigned char *message,
SilcUInt32 message_len);
void silc_private_message(SilcClient client, SilcClientConnection conn,
SilcClientEntry sender,
+ SilcMessagePayload payload,
SilcMessageFlags flags,
const unsigned char *message,
SilcUInt32 message_len);
cmd_return_error(CMDERR_NOT_CONNECTED); \
} G_STMT_END
+/* Returning from command function with error */
+#define cmd_return_error_value(a,v) \
+ G_STMT_START { \
+ signal_emit("error command", 1, GINT_TO_POINTER(a)); \
+ signal_stop(); \
+ return (v); \
+ } G_STMT_END
+
#endif
settings_add_int("server", "key_exchange_rekey_secs", 3600);
settings_add_int("server", "connauth_request_secs", 2);
settings_add_int("server", "heartbeat", 300);
+ settings_add_bool("server", "ignore_message_signatures", FALSE);
/* Requested Attributes settings */
settings_add_bool("silc", "attr_allow", TRUE);
#define IS_SILC_ITEM(rec) (IS_SILC_CHANNEL(rec) || IS_SILC_QUERY(rec))
+#define SILC_MSG_SIGNED_VERIFIED 0
+#define SILC_MSG_SIGNED_UNKNOWN 1
+#define SILC_MSG_SIGNED_FAILED 2
+
#endif
rec = g_new0(SILC_NICK_REC, 1);
rec->nick = g_strdup(user->client->nickname);
- rec->host = g_strdup(user->client->username);
+ rec->host = g_strdup_printf("%s@%s", user->client->username,
+ user->client->hostname);
+ rec->realname = g_strdup(user->client->realname);
rec->silc_user = user;
rec->unique_id = user->client;
void silc_servers_reconnect_init(void);
void silc_servers_reconnect_deinit(void);
-static void silc_send_channel(SILC_SERVER_REC *server,
- char *channel, char *msg)
+static int silc_send_channel(SILC_SERVER_REC *server,
+ char *channel, char *msg,
+ SilcMessageFlags flags)
{
SILC_CHANNEL_REC *rec;
rec = silc_channel_find(server, channel);
if (rec == NULL || rec->entry == NULL) {
- cmd_return_error(CMDERR_NOT_JOINED);
- return;
+ cmd_return_error_value(CMDERR_NOT_JOINED, FALSE);
}
silc_client_send_channel_message(silc_client, server->conn, rec->entry,
- NULL, SILC_MESSAGE_FLAG_UTF8,
- msg, strlen(msg), TRUE);
+ NULL, flags, msg, strlen(msg), TRUE);
+ return TRUE;
}
typedef struct {
g_free(rec);
}
-static void silc_send_msg(SILC_SERVER_REC *server, char *nick, char *msg,
- int msg_len, SilcMessageFlags flags)
+static int silc_send_msg(SILC_SERVER_REC *server, char *nick, char *msg,
+ int msg_len, SilcMessageFlags flags)
{
PRIVMSG_REC *rec;
SilcClientEntry *clients;
if (!silc_parse_userfqdn(nick, &nickname, NULL)) {
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_BAD_NICK, nick);
- return;
+ return FALSE;
}
/* Find client entry */
silc_client_get_clients(silc_client, server->conn,
nickname, NULL, silc_send_msg_clients, rec);
silc_free(nickname);
- return;
+ return FALSE;
}
/* Send the private message directly */
silc_client_send_private_message(silc_client, server->conn,
clients[0], flags,
msg, msg_len, TRUE);
+ return TRUE;
}
void silc_send_mime(SILC_SERVER_REC *server, WI_ITEM_REC *to,
}
if (target_type == SEND_TARGET_CHANNEL)
- silc_send_channel(server, target, message ? message : msg);
+ silc_send_channel(server, target, message ? message : msg,
+ SILC_MESSAGE_FLAG_UTF8);
else
silc_send_msg(server, target, message ? message : msg,
message ? strlen(message) : strlen(msg),
/* SYNTAX: WATCH [<-add | -del> <nickname>] */
/* SYNTAX: STATS */
/* SYNTAX: ATTR [<-del> <option> [{ <value>}]] */
+/* SYNTAX: SMSG [<-channel>] <target> <message> */
void silc_command_exec(SILC_SERVER_REC *server,
const char *command, const char *args)
signal_stop();
}
+/* SMSG command, to send digitally signed messages */
+
+static void command_smsg(const char *data, SILC_SERVER_REC *server,
+ WI_ITEM_REC *item)
+{
+ GHashTable *optlist;
+ char *target, *origtarget, *msg;
+ void *free_arg;
+ int free_ret, target_type;
+
+ g_return_if_fail(data != NULL);
+ if (server == NULL || !server->connected)
+ cmd_param_error(CMDERR_NOT_CONNECTED);
+
+ if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
+ PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
+ "msg", &optlist, &target, &msg))
+ return;
+ if (*target == '\0' || *msg == '\0')
+ cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
+
+ origtarget = target;
+ free_ret = FALSE;
+
+ if (strcmp(target, "*") == 0) {
+ if (item == NULL)
+ cmd_param_error(CMDERR_NOT_JOINED);
+
+ target_type = IS_CHANNEL(item) ?
+ SEND_TARGET_CHANNEL : SEND_TARGET_NICK;
+ target = (char *) window_item_get_target(item);
+ } else if (g_hash_table_lookup(optlist, "channel") != NULL) {
+ target_type = SEND_TARGET_CHANNEL;
+ } else {
+ target_type = server_ischannel(SERVER(server), target) ?
+ SEND_TARGET_CHANNEL : SEND_TARGET_NICK;
+ }
+
+ if (target != NULL) {
+ char *message = NULL;
+ int len, result;
+
+ if (!silc_term_utf8()) {
+ len = silc_utf8_encoded_len(msg, strlen(msg), SILC_STRING_LANGUAGE);
+ message = silc_calloc(len + 1, sizeof(*message));
+ g_return_if_fail(message != NULL);
+ silc_utf8_encode(msg, strlen(msg), SILC_STRING_LANGUAGE, message, len);
+ }
+
+ if (target_type == SEND_TARGET_CHANNEL)
+ result = silc_send_channel(server, target, message ? message : msg,
+ SILC_MESSAGE_FLAG_UTF8 |
+ SILC_MESSAGE_FLAG_SIGNED);
+ else
+ result = silc_send_msg(server, target, message ? message : msg,
+ message ? strlen(message) : strlen(msg),
+ SILC_MESSAGE_FLAG_UTF8 |
+ SILC_MESSAGE_FLAG_SIGNED);
+ silc_free(message);
+ if (!result)
+ goto out;
+ }
+
+ signal_emit(target != NULL && target_type == SEND_TARGET_CHANNEL ?
+ "message signed_own_public" : "message signed_own_private", 4,
+ server, msg, target, origtarget);
+out:
+ if (free_ret && target != NULL) g_free(target);
+ cmd_params_free(free_arg);
+}
+
/* FILE command */
SILC_TASK_CALLBACK(silc_client_file_close_later)
command_bind_silc("watch", MODULE_NAME, (SIGNAL_FUNC) command_self);
command_bind_silc("stats", MODULE_NAME, (SIGNAL_FUNC) command_self);
command_bind_silc("attr", MODULE_NAME, (SIGNAL_FUNC) command_attr);
+ command_bind_silc("smsg", MODULE_NAME, (SIGNAL_FUNC) command_smsg);
command_set_options("connect", "+silcnet");
}
command_unbind("watch", (SIGNAL_FUNC) command_self);
command_unbind("stats", (SIGNAL_FUNC) command_self);
command_unbind("attr", (SIGNAL_FUNC) command_attr);
+ command_unbind("smsg", (SIGNAL_FUNC) command_smsg);
}
void silc_server_free_ftp(SILC_SERVER_REC *server,
/* Allocate hash table for invite list if it doesn't exist yet */
if (!channel->invite_list)
- channel->invite_list = silc_hash_table_alloc(0, silc_hash_ptr,
- NULL, NULL, NULL,
- NULL, NULL, TRUE);
+ channel->invite_list =
+ silc_hash_table_alloc(0, silc_hash_ptr,
+ NULL, NULL, NULL,
+ silc_server_inviteban_destruct, channel, TRUE);
/* Check if the ID is in the list already */
silc_hash_table_list(channel->invite_list, &htl);
if (tmp[0] == 0x00) {
/* Allocate hash table for invite list if it doesn't exist yet */
if (!channel->invite_list)
- channel->invite_list = silc_hash_table_alloc(0, silc_hash_ptr,
- NULL, NULL, NULL,
- NULL, NULL, TRUE);
+ channel->invite_list =
+ silc_hash_table_alloc(0, silc_hash_ptr,
+ NULL, NULL, NULL,
+ silc_server_inviteban_destruct, channel,
+ TRUE);
/* Check for resource limit */
if (silc_hash_table_count(channel->invite_list) > 64) {
0);
goto out;
}
+ } else {
+ /* If key was not sent and the channel mode has already founder
+ then the key was not to be changed. */
+ if (channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH)
+ goto has_founder;
}
/* Set the founder authentication */
channel->founder_key = NULL;
goto out;
}
+ has_founder:
}
} else {
if (chl->mode & SILC_CHANNEL_UMODE_CHANFO) {
SilcServerCommandContext cmd = (SilcServerCommandContext)context;
SilcServer server = cmd->server;
SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
- SilcIDListData idata = (SilcIDListData)client;
SilcChannelID *channel_id = NULL;
SilcClientID *client_id = NULL;
SilcChannelEntry channel;
SilcHashTableList htl;
if (!(channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) ||
- !channel->founder_key || !idata->public_key ||
- !silc_pkcs_public_key_compare(channel->founder_key,
- idata->public_key)) {
+ !channel->founder_key) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_CUMODE,
SILC_STATUS_ERR_AUTH_FAILED, 0);
goto out;
if (tmp[0] == 0x00) {
/* Allocate hash table for ban list if it doesn't exist yet */
if (!channel->ban_list)
- channel->ban_list = silc_hash_table_alloc(0, silc_hash_ptr,
- NULL, NULL, NULL,
- NULL, NULL, TRUE);
+ channel->ban_list =
+ silc_hash_table_alloc(0, silc_hash_ptr,
+ NULL, NULL, NULL,
+ silc_server_inviteban_destruct, channel,
+ TRUE);
/* Check for resource limit */
if (silc_hash_table_count(channel->ban_list) > 64) {
/* Get the ban list */
tmp = silc_argument_get_arg_type(cmd->args, 8, &len);
- if (tmp) {
- silc_free(entry->ban_list);
- entry->ban_list = silc_memdup(tmp, len);
+ if (tmp && len > 2) {
+ SilcArgumentPayload iargs;
+ SilcUInt16 iargc;
+ SILC_GET16_MSB(iargc, tmp);
+ iargs = silc_argument_payload_parse(tmp + 2, len - 2, iargc);
+ if (iargs) {
+ /* Delete old ban list */
+ if (entry->ban_list)
+ silc_hash_table_free(entry->ban_list);
+ entry->ban_list =
+ silc_hash_table_alloc(0, silc_hash_ptr,
+ NULL, NULL, NULL,
+ silc_server_inviteban_destruct, entry, TRUE);
+
+ /* Add new ban list */
+ silc_server_inviteban_process(server, entry->ban_list, 0, iargs);
+ silc_argument_payload_free(iargs);
+ }
}
/* Get the invite list */
tmp = silc_argument_get_arg_type(cmd->args, 9, &len);
- if (tmp) {
- silc_free(entry->invite_list);
- entry->invite_list = silc_memdup(tmp, len);
+ if (tmp && len > 2) {
+ SilcArgumentPayload iargs;
+ SilcUInt16 iargc;
+ SILC_GET16_MSB(iargc, tmp);
+ iargs = silc_argument_payload_parse(tmp + 2, len - 2, iargc);
+ if (iargs) {
+ /* Delete old invite list */
+ if (entry->invite_list)
+ silc_hash_table_free(entry->invite_list);
+ entry->invite_list =
+ silc_hash_table_alloc(0, silc_hash_ptr,
+ NULL, NULL, NULL,
+ silc_server_inviteban_destruct, entry, TRUE);
+
+ /* Add new invite list */
+ silc_server_inviteban_process(server, entry->invite_list, 0, iargs);
+ silc_argument_payload_free(iargs);
+ }
}
/* Get the topic */
if (sock && ((sock->hostname && !strcasecmp(sock->hostname, hostname)) ||
(sock->ip && !strcasecmp(sock->ip, hostname)))
- && sock->port == port)
+ && server->id->port == htons(port))
break;
id_cache = NULL;
if (!silc_idcache_del_by_context(id_list->servers, entry))
return FALSE;
- SILC_LOG_DEBUG(("Deleting server %s", entry->server_name ?
- entry->server_name : ""));
+ SILC_LOG_DEBUG(("Deleting server %s id %s", entry->server_name ?
+ entry->server_name : "",
+ entry->id ?
+ silc_id_render(entry->id, SILC_ID_SERVER) : ""));
/* Free data */
silc_free(entry->server_name);
int silc_idlist_del_channel(SilcIDList id_list, SilcChannelEntry entry)
{
if (entry) {
- SilcHashTableList htl;
- SilcBuffer tmp;
- SilcUInt32 type;
-
/* Remove from cache */
if (!silc_idcache_del_by_context(id_list->channels, entry))
return FALSE;
silc_free(entry->id);
silc_free(entry->topic);
- if (entry->invite_list) {
- silc_hash_table_list(entry->invite_list, &htl);
- while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp)) {
- if (type == 1) {
- silc_free((char *)tmp);
- continue;
- }
- silc_buffer_free(tmp);
- }
- silc_hash_table_list_reset(&htl);
+ if (entry->invite_list)
silc_hash_table_free(entry->invite_list);
- }
-
- if (entry->ban_list) {
- silc_hash_table_list(entry->ban_list, &htl);
- while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp)) {
- if (type == 1) {
- silc_free((char *)tmp);
- continue;
- }
- silc_buffer_free(tmp);
- }
- silc_hash_table_list_reset(&htl);
+ if (entry->ban_list)
silc_hash_table_free(entry->ban_list);
- }
if (entry->channel_key)
silc_cipher_free(entry->channel_key);
goto out;
if (action == 0 && !channel->invite_list)
- channel->invite_list = silc_hash_table_alloc(0, silc_hash_ptr,
- NULL, NULL, NULL,
- NULL, NULL, TRUE);
+ channel->invite_list =
+ silc_hash_table_alloc(0, silc_hash_ptr,
+ NULL, NULL, NULL,
+ silc_server_inviteban_destruct, channel, TRUE);
/* Proces the invite action */
silc_server_inviteban_process(server, channel->invite_list, action,
}
silc_free(server_id);
- /* Sending SERVER_SIGNOFF is not right way to signoff local connection */
- if (SILC_IS_LOCAL(server_entry))
+ /* For local entrys SERVER_SIGNOFF is processed only on backup router.
+ It is possible that router sends server signoff for a server. If
+ backup router has it as local connection it will be closed. */
+ if (SILC_IS_LOCAL(server_entry)) {
+ if (server->server_type == SILC_BACKUP_ROUTER) {
+ sock = server_entry->connection;
+ SILC_LOG_DEBUG(("Closing connection %s after SERVER_SIGNOFF",
+ sock->hostname));
+ SILC_SET_DISCONNECTING(sock);
+ if (sock->user_data)
+ silc_server_free_sock_user_data(server, sock, NULL);
+ silc_server_close_connection(server, sock);
+ }
+
break;
+ }
/* Remove all servers that are originated from this server, and
remove the clients of those servers too. */
goto out;
if (action == 0 && !channel->ban_list)
- channel->ban_list = silc_hash_table_alloc(0, silc_hash_ptr,
- NULL, NULL, NULL,
- NULL, NULL, TRUE);
+ channel->ban_list =
+ silc_hash_table_alloc(0, silc_hash_ptr,
+ NULL, NULL, NULL,
+ silc_server_inviteban_destruct, channel, TRUE);
/* Proces the ban action */
silc_server_inviteban_process(server, channel->ban_list, action,
/* Save the channel key */
channel = silc_server_save_channel_key(server, buffer, NULL);
- if (!channel)
+ if (!channel) {
+ SILC_LOG_ERROR(("Bad channel key from %s (%s)",
+ sock->hostname, sock->ip));
return;
-
+ }
+
/* Distribute the key to everybody who is on the channel. If we are router
we will also send it to locally connected servers. */
silc_server_send_channel_key(server, sock, channel, FALSE);
}
silc_free(client_id);
- silc_idlist_del_data(detached_client);
}
if (SILC_IS_DISCONNECTING(sock))
return -1;
- /* If rekey protocol is active we must assure that all packets are
- sent through packet queue. */
- if (SILC_SERVER_IS_REKEY(sock))
- force_send = FALSE;
-
- /* If outbound data is already pending do not force send */
- if (SILC_IS_OUTBUF_PENDING(sock))
- force_send = FALSE;
-
/* Send the packet */
- ret = silc_packet_send(sock, force_send);
+ ret = silc_packet_send(sock, FALSE);
if (ret != -2) {
+ if (ret == -1) {
+ SILC_LOG_ERROR(("Error sending packet to connection "
+ "%s:%d [%s]", sock->hostname, sock->port,
+ (sock->type == SILC_SOCKET_TYPE_UNKNOWN ? "Unknown" :
+ sock->type == SILC_SOCKET_TYPE_CLIENT ? "Client" :
+ sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" :
+ "Router")));
+
+ SILC_SET_DISCONNECTING(sock);
+ if (sock->user_data)
+ silc_server_free_sock_user_data(server, sock, NULL);
+ silc_server_close_connection(server, sock);
+ return ret;
+ }
+
server->stat.packets_sent++;
return ret;
}
unsigned char *data,
unsigned int data_len)
{
+ SilcUInt32 mac_len, iv_len;
+ unsigned char iv[SILC_CIPHER_MAX_IV_SIZE];
+
/* If we are router and the packet came from router and private key
has not been set for the channel then we must encrypt the packet
as it was decrypted with the session key shared between us and the
same channel key. */
if (server->server_type == SILC_ROUTER &&
sock->type == SILC_SOCKET_TYPE_ROUTER &&
- !(channel->mode & SILC_CHANNEL_MODE_PRIVKEY) &&
- channel->channel_key) {
- SilcUInt32 mac_len = silc_hmac_len(channel->hmac);
- SilcUInt32 iv_len = silc_cipher_get_block_len(channel->channel_key);
- unsigned char iv[SILC_CIPHER_MAX_IV_SIZE];
+ !(channel->mode & SILC_CHANNEL_MODE_PRIVKEY) && channel->key) {
+
+ /* If we are backup router and remote is our primary router and
+ we are currently doing backup resuming protocol we must not
+ re-encrypt message with session key. */
+ if (server->backup_router && SILC_SERVER_IS_BACKUP(sock) &&
+ SILC_PRIMARY_ROUTE(server) == sock)
+ return TRUE;
+
+ mac_len = silc_hmac_len(channel->hmac);
+ iv_len = silc_cipher_get_block_len(channel->channel_key);
if (data_len <= mac_len + iv_len) {
SILC_LOG_WARNING(("Corrupted channel message, cannot relay it"));
}
memcpy(iv, data + (data_len - iv_len - mac_len), iv_len);
- silc_message_payload_encrypt(data, data_len - iv_len, iv, iv_len,
- channel->channel_key, channel->hmac);
+ silc_message_payload_encrypt(data, data_len - iv_len, data_len,
+ iv, iv_len, channel->channel_key,
+ channel->hmac);
}
return TRUE;
(SILC_IS_DISCONNECTED(sock) == FALSE)) {
server->stat.packets_sent++;
silc_packet_send(sock, TRUE);
- SILC_SET_CONNECTION_FOR_INPUT(server->schedule, sock->sock);
SILC_UNSET_OUTBUF_PENDING(sock);
silc_buffer_clear(sock->outbuf);
}
SILC_TASK_CALLBACK(silc_server_rehash_close_connection);
SILC_TASK_CALLBACK(silc_server_connect_to_router_retry);
SILC_TASK_CALLBACK(silc_server_connect_router);
-SILC_TASK_CALLBACK(silc_server_connect_to_router);
SILC_TASK_CALLBACK(silc_server_connect_to_router_second);
SILC_TASK_CALLBACK(silc_server_connect_to_router_final);
SILC_TASK_CALLBACK(silc_server_accept_new_connection);
SILC_TASK_CALLBACK(silc_server_free_client_data_timeout);
SILC_TASK_CALLBACK(silc_server_timeout_remote);
SILC_TASK_CALLBACK(silc_server_channel_key_rekey);
-SILC_TASK_CALLBACK(silc_server_failure_callback);
SILC_TASK_CALLBACK(silc_server_get_stats);
/* Allocates a new SILC server object. This has to be done before the server
server to do authentication and key exchange with our router - called
from schedule. */
-SILC_TASK_CALLBACK(silc_server_connect_to_router)
+SILC_TASK_CALLBACK_GLOBAL(silc_server_connect_to_router)
{
SilcServer server = (SilcServer)context;
SilcServerConnection sconn;
silc_ske_free(ctx->ske);
silc_free(ctx->dest_id);
silc_free(ctx);
- silc_schedule_task_del_by_callback(server->schedule,
- silc_server_failure_callback);
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_KEY_EXCHANGE_FAILED, NULL);
silc_ske_free(ctx->ske);
silc_free(ctx->dest_id);
silc_free(ctx);
- silc_schedule_task_del_by_callback(server->schedule,
- silc_server_failure_callback);
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_KEY_EXCHANGE_FAILED, NULL);
silc_free(sconn->remote_host);
silc_free(sconn->backup_replace_ip);
silc_free(sconn);
- silc_schedule_task_del_by_callback(server->schedule,
- silc_server_failure_callback);
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_KEY_EXCHANGE_FAILED, NULL);
return;
silc_server_config_unref(&ctx->sconfig);
silc_server_config_unref(&ctx->rconfig);
silc_free(ctx);
- silc_schedule_task_del_by_callback(server->schedule,
- silc_server_failure_callback);
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_KEY_EXCHANGE_FAILED,
NULL);
silc_server_config_unref(&ctx->sconfig);
silc_server_config_unref(&ctx->rconfig);
silc_free(ctx);
- silc_schedule_task_del_by_callback(server->schedule,
- silc_server_failure_callback);
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_KEY_EXCHANGE_FAILED, NULL);
server->stat.auth_failures++;
silc_server_config_unref(&ctx->sconfig);
silc_server_config_unref(&ctx->rconfig);
silc_free(ctx);
- silc_schedule_task_del_by_callback(server->schedule,
- silc_server_failure_callback);
silc_server_disconnect_remote(server, sock, SILC_STATUS_ERR_AUTH_FAILED,
NULL);
server->stat.auth_failures++;
server->schedule);
out:
- silc_schedule_task_del_by_callback(server->schedule,
- silc_server_failure_callback);
silc_protocol_free(protocol);
if (ctx->packet)
silc_packet_context_free(ctx->packet);
SilcCipher cipher = NULL;
SilcHmac hmac = NULL;
SilcUInt32 sequence = 0;
+ bool local_is_router;
int ret;
if (!sock) {
else
silc_server_free_sock_user_data(server, sock, NULL);
} else if (server->router_conn && server->router_conn->sock == sock &&
- !server->router && server->standalone)
+ !server->router && server->standalone)
silc_schedule_task_add(server->schedule, 0,
silc_server_connect_to_router,
server, 1, 0,
sequence = idata->psn_receive;
}
- /* Process the packet. This will call the parser that will then
+ /* Then, process the packet. This will call the parser that will then
decrypt and parse the packet. */
- ret = silc_packet_receive_process(sock, server->server_type == SILC_ROUTER ?
- TRUE : FALSE, cipher, hmac, sequence,
+
+ local_is_router = (server->server_type == SILC_ROUTER);
+
+ /* If socket connection is our primary, we are backup and we are doing
+ backup resuming, we won't process the packet as being a router
+ (affects channel message decryption). */
+ if (server->backup_router && SILC_SERVER_IS_BACKUP(sock) &&
+ SILC_PRIMARY_ROUTE(server) == sock)
+ local_is_router = FALSE;
+
+ ret = silc_packet_receive_process(sock, local_is_router,
+ cipher, hmac, sequence,
silc_server_packet_parse, server);
/* If processing failed the connection is closed. */
and we want to call this processor with valid cipher. */
if (idata)
ret = silc_packet_receive_process(
- sock, server->server_type == SILC_ROUTER ?
- TRUE : FALSE, idata->receive_key,
+ sock, server->server_type == SILC_ROUTER,
+ idata->receive_key,
idata->hmac_receive, idata->psn_receive,
silc_server_packet_parse, server);
else
ret = silc_packet_receive_process(
- sock, server->server_type == SILC_ROUTER ?
- TRUE : FALSE, NULL, NULL, 0,
+ sock, server->server_type == SILC_ROUTER,
+ NULL, NULL, 0,
silc_server_packet_parse, server);
if (!ret) {
if (packet->flags & SILC_PACKET_FLAG_LIST)
break;
if (sock->protocol) {
- SilcServerFailureContext f;
- f = silc_calloc(1, sizeof(*f));
- f->sock = silc_socket_dup(sock);
-
- /* We will wait 5 seconds to process this failure packet */
- silc_schedule_task_add(server->schedule, sock->sock,
- silc_server_failure_callback, (void *)f, 5, 0,
- SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+ sock->protocol->state = SILC_PROTOCOL_STATE_FAILURE;
+ silc_protocol_execute(sock->protocol, server->schedule, 0, 0);
}
break;
char tmp[128];
if (!server->sockets[sock->sock] && SILC_IS_DISCONNECTED(sock)) {
- silc_schedule_task_add(server->schedule, 0,
+ silc_schedule_unset_listen_fd(server->schedule, sock->sock);
+ silc_schedule_task_del_by_fd(server->schedule, sock->sock);
+ silc_schedule_task_add(server->schedule, sock->sock,
silc_server_close_connection_final,
(void *)sock, 0, 1, SILC_TASK_TIMEOUT,
SILC_TASK_PRI_NORMAL);
sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" :
"Router"), tmp[0] ? tmp : ""));
- /* We won't listen for this connection anymore */
- silc_schedule_unset_listen_fd(server->schedule, sock->sock);
-
/* Unregister all tasks */
silc_schedule_task_del_by_fd(server->schedule, sock->sock);
if (!sock->user_data) {
/* If any protocol is active cancel its execution. It will call
the final callback which will finalize the disconnection. */
- if (sock->protocol) {
+ if (sock->protocol && sock->protocol->protocol &&
+ sock->protocol->protocol->type != SILC_PROTOCOL_SERVER_BACKUP) {
SILC_LOG_DEBUG(("Cancelling protocol, calling final callback"));
silc_protocol_cancel(sock->protocol, server->schedule);
sock->protocol->state = SILC_PROTOCOL_STATE_ERROR;
}
}
- silc_schedule_task_add(server->schedule, 0,
+ /* We won't listen for this connection anymore */
+ silc_schedule_unset_listen_fd(server->schedule, sock->sock);
+
+ silc_schedule_task_add(server->schedule, sock->sock,
silc_server_close_connection_final,
(void *)sock, 0, 1, SILC_TASK_TIMEOUT,
SILC_TASK_PRI_NORMAL);
server->id_entry->router = NULL;
server->router = NULL;
server->standalone = TRUE;
+ server->backup_primary = FALSE;
backup_router = NULL;
} else {
if (server->id_entry != backup_router) {
SILC_TASK_PRI_NORMAL);
}
+ SILC_SERVER_SEND_OPERS(server, FALSE, TRUE, SILC_NOTIFY_TYPE_NONE,
+ ("Server %s signoff", user_data->server_name));
+
if (!backup_router) {
/* Remove all servers that are originated from this server, and
remove the clients of those servers too. */
silc_server_remove_servers_by_server(server, user_data, TRUE);
+#if 0
/* Remove the clients that this server owns as they will become
invalid now too. For backup router the server is actually
coming from the primary router, so mark that as the owner
silc_server_remove_clients_by_server(server, server->router,
user_data, TRUE);
else
+#endif
silc_server_remove_clients_by_server(server, user_data,
user_data, TRUE);
}
/* If any protocol is active cancel its execution */
- if (sock->protocol) {
+ if (sock->protocol && sock->protocol->protocol &&
+ sock->protocol->protocol->type != SILC_PROTOCOL_SERVER_BACKUP) {
SILC_LOG_DEBUG(("Cancelling protocol, calling final callback"));
silc_protocol_cancel(sock->protocol, server->schedule);
sock->protocol->state = SILC_PROTOCOL_STATE_ERROR;
/* If we have protocol active we must assure that we call the protocol's
final callback so that all the memory is freed. */
- if (sock->protocol) {
+ if (sock->protocol && sock->protocol->protocol &&
+ sock->protocol->protocol->type != SILC_PROTOCOL_SERVER_BACKUP) {
protocol = sock->protocol->protocol->type;
silc_protocol_cancel(sock->protocol, server->schedule);
sock->protocol->state = SILC_PROTOCOL_STATE_ERROR;
silc_free(channel_ids);
}
-/* Failure timeout callback. If this is called then we will immediately
- process the received failure. We always process the failure with timeout
- since we do not want to blindly trust to received failure packets.
- This won't be called (the timeout is cancelled) if the failure was
- bogus (it is bogus if remote does not close the connection after sending
- the failure). */
-
-SILC_TASK_CALLBACK(silc_server_failure_callback)
-{
- SilcServer server = app_context;
- SilcServerFailureContext f = (SilcServerFailureContext)context;
-
- if (f->sock->protocol) {
- f->sock->protocol->state = SILC_PROTOCOL_STATE_FAILURE;
- silc_protocol_execute(f->sock->protocol, server->schedule, 0, 0);
- }
-
- silc_socket_free(f->sock);
- silc_free(f);
-}
-
/* Assembles user list and users mode list from the `channel'. */
bool silc_server_get_users_on_channel(SilcServer server,
if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
/* Error occured during protocol */
- SILC_LOG_ERROR(("Error occurred during rekey protocol"));
+ SILC_LOG_ERROR(("Error occurred during rekey protocol with
+ %s (%s)", sock->hostname, sock->ip));
silc_protocol_cancel(protocol, server->schedule);
silc_protocol_free(protocol);
sock->protocol = NULL;
(sock->protocol && sock->protocol->protocol && \
sock->protocol->protocol->type == SILC_PROTOCOL_SERVER_BACKUP)
-/* Output an error message wether to stderr or LOG_ERROR if we are in the
- background. */
-#define SILC_SERVER_LOG_ERROR(fmt) silc_server_stderr(silc_format fmt)
+/* Output a message to stderr or to the appropriate log facility wether
+ we are in the background or not. */
+#define SILC_SERVER_LOG_INFO(fmt) \
+ silc_server_stderr(SILC_LOG_INFO, silc_format fmt)
+#define SILC_SERVER_LOG_WARNING(fmt) \
+ silc_server_stderr(SILC_LOG_WARNING, silc_format fmt)
+#define SILC_SERVER_LOG_ERROR(fmt) \
+ silc_server_stderr(SILC_LOG_ERROR, silc_format fmt)
+#define SILC_SERVER_LOG_FATAL(fmt) \
+ silc_server_stderr(SILC_LOG_WARNING, silc_format fmt)
/* Prototypes */
int silc_server_alloc(SilcServer *new_server);
bool get_private,
bool get_secret,
SilcBuffer *user_mode_list);
-void silc_server_stderr(char *message);
+void silc_server_stderr(SilcLogType type, char *message);
#endif
}
}
+SILC_TASK_CALLBACK(silc_server_backup_timeout)
+{
+ SilcProtocol protocol = context;
+ SilcServer server = app_context;
+
+ SILC_LOG_INFO(("Timeout occurred during backup resuming protocol"));
+ silc_protocol_cancel(protocol, server->schedule);
+ protocol->state = SILC_PROTOCOL_STATE_ERROR;
+ silc_protocol_execute_final(protocol, server->schedule);
+}
+
/* Processes incoming RESUME_ROUTER packet. This can give the packet
for processing to the protocol handler or allocate new protocol if
start command is received. */
&sock->protocol, proto_ctx,
silc_server_protocol_backup_done);
silc_protocol_execute(sock->protocol, server->schedule, 0, 0);
+ silc_schedule_task_add(server->schedule, sock->sock,
+ silc_server_backup_timeout,
+ sock->protocol, 30, 0, SILC_TASK_TIMEOUT,
+ SILC_TASK_PRI_NORMAL);
}
}
&sock->protocol, proto_ctx,
silc_server_protocol_backup_done);
silc_protocol_execute(sock->protocol, server->schedule, 0, 0);
+
+ silc_schedule_task_add(server->schedule, sock->sock,
+ silc_server_backup_timeout,
+ sock->protocol, 30, 0, SILC_TASK_TIMEOUT,
+ SILC_TASK_PRI_NORMAL);
}
/* Called when we've established connection back to our primary router
idata = (SilcIDListData)server_entry;
SILC_LOG_DEBUG(("Sending CONNECTED packet (session %d)", ctx->session));
+ SILC_LOG_INFO(("Sending CONNECTED (session %d) to backup router",
+ ctx->session));
/* Send the CONNECTED packet back to the backup router. */
buffer = silc_buffer_alloc(2);
ctx->sessions[ctx->sessions_count].connected = FALSE;
ctx->sessions[ctx->sessions_count].server_entry = server_entry;
- SILC_LOG_DEBUG(("Sending START to %s (session %d)",
+ SILC_LOG_DEBUG(("Sending START to %s (session %d)",
+ server_entry->server_name, ctx->sessions_count));
+ SILC_LOG_INFO(("Expecting CONNECTED from %s (session %d)",
server_entry->server_name, ctx->sessions_count));
/* This connection is performing this protocol too now */
SILC_LOG_DEBUG(("Sending START to %s (session %d)",
server_entry->server_name, ctx->sessions_count));
+ SILC_LOG_INFO(("Expecting CONNECTED from %s (session %d)",
+ server_entry->server_name, ctx->sessions_count));
/* This connection is performing this protocol too now */
((SilcSocketConnection)server_entry->connection)->protocol =
to be back online. We send the CONNECTED packet after we've
established the connection to the primary router. */
primary = silc_server_config_get_primary_router(server);
- if (primary && server->backup_primary) {
+ if (primary && server->backup_primary &&
+ !silc_server_num_sockets_by_remote(server,
+ silc_net_is_ip(primary->host) ?
+ primary->host : NULL,
+ silc_net_is_ip(primary->host) ?
+ NULL : primary->host,
+ primary->port,
+ SILC_SOCKET_TYPE_ROUTER)) {
SILC_LOG_DEBUG(("Received START (session %d), reconnect to router",
ctx->session));
silc_server_backup_reconnect(server,
/* Nowhere to connect just return the CONNECTED packet */
SILC_LOG_DEBUG(("Received START (session %d), send CONNECTED back",
ctx->session));
+ SILC_LOG_INFO(("Sending CONNECTED (session %d) to backup router",
+ ctx->session));
/* Send the CONNECTED packet back to the backup router. */
packet = silc_buffer_alloc(2);
break;
}
- SILC_LOG_DEBUG(("Received CONNECTED (session %d)", ctx->session));
-
for (i = 0; i < ctx->sessions_count; i++) {
if (ctx->sessions[i].session == ctx->session) {
ctx->sessions[i].connected = TRUE;
+ SILC_LOG_INFO(("Received CONNECTED from %s (session %d)",
+ ctx->sessions[i].server_entry->server_name,
+ ctx->session));
+ SILC_LOG_DEBUG(("Received CONNECTED (session %d)", ctx->session));
break;
}
}
return;
}
- SILC_LOG_DEBUG(("All sessions has returned CONNECTED packets"));
+ SILC_LOG_INFO(("All sessions have returned CONNECTED packets, "
+ "continuing"));
SILC_LOG_DEBUG(("Sending ENDING packet to primary router"));
/* Send with a timeout */
break;
}
- SILC_LOG_DEBUG(("Received RESUMED from new primary router"));
+ SILC_LOG_INFO(("Received RESUMED from new primary router"));
if (server->backup_router)
server->server_type = SILC_BACKUP_ROUTER;
SILC_LOG_INFO(("Resuming the use of primary router %s",
router->server_name));
}
+ server->backup_primary = FALSE;
/* Update the client entries of the backup router to the new
router */
SilcIDCacheList list;
SilcIDCacheEntry id_cache;
+ silc_schedule_task_del_by_context(server->schedule, protocol);
+
if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
SILC_LOG_ERROR(("Error occurred during backup router resuming protcool"));
}
+ if (server->server_shutdown)
+ return;
+
/* Remove this protocol from all server entries that has it */
if (silc_idcache_get_all(server->local_list->servers, &list)) {
if (silc_idcache_list_first(list, &id_cache)) {
if (sock->protocol == protocol) {
sock->protocol = NULL;
+ /* Backup closes connection and reconnects if error occurred */
+ if (SILC_PRIMARY_ROUTE(server) == sock && server->backup_router) {
+ if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
+ protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
+ server->backup_noswitch = TRUE;
+ server->server_type = SILC_BACKUP_ROUTER;
+
+ if (sock->user_data)
+ silc_server_free_sock_user_data(server, sock, NULL);
+ silc_server_close_connection(server, sock);
+
+ silc_schedule_task_add(server->schedule, 0,
+ silc_server_connect_to_router,
+ server, 1, 0,
+ SILC_TASK_TIMEOUT,
+ SILC_TASK_PRI_NORMAL);
+
+ if (!silc_idcache_list_next(list, &id_cache))
+ break;
+ continue;
+ }
+ }
+
if (server_entry->data.status & SILC_IDLIST_STATUS_DISABLED)
server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
}
if (sock->protocol == protocol) {
sock->protocol = NULL;
+ /* Backup closes connection and reconnects if error occurred */
+ if (SILC_PRIMARY_ROUTE(server) == sock && server->backup_router) {
+ if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
+ protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
+ server->backup_noswitch = TRUE;
+ server->server_type = SILC_BACKUP_ROUTER;
+
+ if (sock->user_data)
+ silc_server_free_sock_user_data(server, sock, NULL);
+ silc_server_close_connection(server, sock);
+
+ silc_schedule_task_add(server->schedule, 0,
+ silc_server_connect_to_router,
+ server, 1, 0,
+ SILC_TASK_TIMEOUT,
+ SILC_TASK_PRI_NORMAL);
+
+ if (!silc_idcache_list_next(list, &id_cache))
+ break;
+ continue;
+ }
+ }
+
if (server_entry->data.status & SILC_IDLIST_STATUS_DISABLED)
server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
}
silc_idcache_list_free(list);
}
- SILC_LOG_DEBUG(("Backup resuming protocol has ended"));
+ if (protocol->state != SILC_PROTOCOL_STATE_ERROR &&
+ protocol->state != SILC_PROTOCOL_STATE_FAILURE)
+ SILC_LOG_INFO(("Backup resuming protocol ended successfully"));
if (ctx->sock->protocol)
ctx->sock->protocol = NULL;
/* Prototypes */
SILC_TASK_CALLBACK_GLOBAL(silc_server_rekey_final);
SILC_TASK_CALLBACK_GLOBAL(silc_server_rekey_callback);
+SILC_TASK_CALLBACK_GLOBAL(silc_server_connect_to_router);
void silc_server_watcher_list_destroy(void *key, void *context,
void *user_context);
SilcAttributeObjPk pk;
SilcAttributeObjService service;
unsigned char *tmp;
- unsigned char sign[2048];
+ unsigned char sign[2048 + 1];
SilcUInt32 sign_len;
SILC_LOG_DEBUG(("Constructing Requested Attributes"));
return ret;
}
+static void silc_server_inviteban_dummy_dest(void *key, void *context,
+ void *user_context)
+{
+ /* Nothing */
+}
+
/* Process invite or ban information */
void silc_server_inviteban_process(SilcServer server, SilcHashTable list,
char *string = NULL;
silc_hash_table_find(list, (void *)1,
NULL, (void **)&string);
- silc_hash_table_del(list, (void *)1);
+ silc_hash_table_del_ext(list, (void *)1, NULL, NULL, NULL, NULL,
+ silc_server_inviteban_dummy_dest, NULL);
if (!string)
string = silc_calloc(len + 2, sizeof(*string));
else
char *string = NULL, *start, *end, *n;
if (silc_hash_table_find(list, (void *)1, NULL, (void **)&string)) {
- silc_hash_table_del(list, (void *)1);
-
if (!strncmp(string, tmp, strlen(string) - 1)) {
- silc_free(string);
+ silc_hash_table_del(list, (void *)1);
string = NULL;
} else {
start = strstr(string, tmp);
n = silc_calloc(strlen(string) - len, sizeof(*n));
strncat(n, string, start - string);
strncat(n, end + 1, ((string + strlen(string)) - end) - 1);
- silc_free(string);
+ silc_hash_table_del(list, (void *)1);
string = n;
}
}
while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp2)) {
if (type == 2 && !memcmp(tmp2->data, tmp, len)) {
silc_hash_table_del_by_context(list, (void *)2, tmp2);
- silc_buffer_free(tmp2);
break;
}
}
while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp2)) {
if (type == 3 && !memcmp(tmp2->data, tmp, len)) {
silc_hash_table_del_by_context(list, (void *)3, tmp2);
- silc_buffer_free(tmp2);
break;
}
}
}
}
}
+
+/* Destructor for invite or ban list entrys */
+
+void silc_server_inviteban_destruct(void *key, void *context,
+ void *user_context)
+{
+ switch ((SilcUInt32)key) {
+ case 1:
+ /* Invite string */
+ silc_free(context);
+ break;
+ case 2:
+ case 3:
+ /* Public key/Channel ID SilcBuffer */
+ silc_buffer_free(context);
+ break;
+ default:
+ break;
+ }
+}
void silc_server_inviteban_process(SilcServer server, SilcHashTable list,
SilcUInt8 action, SilcArgumentPayload args);
+/* Destructor for invite or ban list entrys */
+void silc_server_inviteban_destruct(void *key, void *context,
+ void *user_context);
+
#endif /* SERVER_UTIL_H */
#include "serverincludes.h"
#include "server_internal.h"
+#include <dirent.h>
#if 0
#define SERVER_CONFIG_DEBUG(fmt) SILC_LOG_DEBUG(fmt)
}
/* parse an authdata according to its auth method */
-static bool my_parse_authdata(SilcAuthMethod auth_meth, char *p,
+static bool my_parse_authdata(SilcAuthMethod auth_meth, const char *p,
void **auth_data, SilcUInt32 *auth_data_len)
{
if (auth_meth == SILC_AUTH_PASSWORD) {
} else if (auth_meth == SILC_AUTH_PUBLIC_KEY) {
/* p is a public key file name */
SilcPublicKey public_key;
+ SilcPublicKey cached_key;
if (!silc_pkcs_load_public_key(p, &public_key, SILC_PKCS_FILE_PEM))
if (!silc_pkcs_load_public_key(p, &public_key, SILC_PKCS_FILE_BIN)) {
return FALSE;
}
+ if (*auth_data &&
+ silc_hash_table_find_ext(*auth_data, public_key, (void **)&cached_key,
+ NULL, silc_hash_public_key, NULL,
+ silc_hash_public_key_compare, NULL)) {
+ silc_pkcs_public_key_free(public_key);
+ SILC_SERVER_LOG_WARNING(("Warning: public key file \"%s\" already "
+ "configured, ignoring this key", p));
+ return TRUE; /* non fatal error */
+ }
+
/* The auth_data is a pointer to the hash table of public keys. */
if (auth_data) {
if (*auth_data == NULL)
return TRUE;
}
+static bool my_parse_publickeydir(const char *dirname, void **auth_data)
+{
+ int total = 0;
+ struct dirent *get_file;
+ DIR *dp;
+
+ if (!(dp = opendir(dirname))) {
+ SILC_SERVER_LOG_ERROR(("Error while parsing config file: "
+ "Could not open directory \"%s\"", dirname));
+ return FALSE;
+ }
+
+ /* errors are not considered fatal */
+ while ((get_file = readdir(dp))) {
+ const char *filename = get_file->d_name;
+ char buf[1024];
+ int dirname_len = strlen(dirname), filename_len = strlen(filename);
+ struct stat check_file;
+
+ /* Ignore "." and "..", and take files only with ".pub" suffix. */
+ if (!strcmp(filename, ".") || !strcmp(filename, "..") ||
+ (filename_len < 5) || strcmp(filename + filename_len - 4, ".pub"))
+ continue;
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf) - 1, "%s%s%s", dirname,
+ (dirname[dirname_len - 1] == '/' ? "" : "/"), filename);
+
+ if (stat(buf, &check_file) < 0) {
+ SILC_SERVER_LOG_ERROR(("Error stating file %s: %s", buf,
+ strerror(errno)));
+ } else if (S_ISREG(check_file.st_mode)) {
+ my_parse_authdata(SILC_AUTH_PUBLIC_KEY, buf, auth_data, NULL);
+ total++;
+ }
+ }
+
+ SILC_LOG_DEBUG(("Tried to load %d public keys in \"%s\"", total, dirname));
+ return TRUE;
+}
+
/* Callbacks */
SILC_CONFIG_CALLBACK(fetch_generic)
}
else if (!strcmp(name, "publickey")) {
char *file_tmp = (char *) val;
+ CONFIG_IS_DOUBLE(server_info->public_key);
/* try to load specified file, if fail stop config parsing */
if (!silc_pkcs_load_public_key(file_tmp, &server_info->public_key,
}
else if (!strcmp(name, "privatekey")) {
char *file_tmp = (char *) val;
+ CONFIG_IS_DOUBLE(server_info->private_key);
/* try to load specified file, if fail stop config parsing */
if (!silc_pkcs_load_private_key(file_tmp, &server_info->private_key,
goto got_err;
}
}
+ else if (!strcmp(name, "publickeydir")) {
+ if (!my_parse_publickeydir((char *) val, (void **)&tmp->publickeys)) {
+ got_errno = SILC_CONFIG_EPRINTLINE;
+ goto got_err;
+ }
+ }
else if (!strcmp(name, "params")) {
CONFIG_IS_DOUBLE(tmp->param);
tmp->param = my_find_param(config, (char *) val);
}
}
else if (!strcmp(name, "publickey")) {
- CONFIG_IS_DOUBLE(tmp->publickeys);
if (!my_parse_authdata(SILC_AUTH_PUBLIC_KEY, (char *) val,
(void **)&tmp->publickeys, NULL)) {
got_errno = SILC_CONFIG_EPRINTLINE;
goto got_err;
}
}
+ else if (!strcmp(name, "publickeydir")) {
+ if (!my_parse_publickeydir((char *) val, (void **)&tmp->publickeys)) {
+ got_errno = SILC_CONFIG_EPRINTLINE;
+ goto got_err;
+ }
+ }
else
return SILC_CONFIG_EINTERNAL;
return SILC_CONFIG_OK;
{ "host", SILC_CONFIG_ARG_STRE, fetch_client, NULL },
{ "passphrase", SILC_CONFIG_ARG_STR, fetch_client, NULL },
{ "publickey", SILC_CONFIG_ARG_STR, fetch_client, NULL },
+ { "publickeydir", SILC_CONFIG_ARG_STR, fetch_client, NULL },
{ "params", SILC_CONFIG_ARG_STR, fetch_client, NULL },
{ 0, 0, 0, 0 }
};
{ "nick", SILC_CONFIG_ARG_STRE, fetch_admin, NULL },
{ "passphrase", SILC_CONFIG_ARG_STR, fetch_admin, NULL },
{ "publickey", SILC_CONFIG_ARG_STR, fetch_admin, NULL },
+ { "publickeydir", SILC_CONFIG_ARG_STR, fetch_admin, NULL },
{ "port", SILC_CONFIG_ARG_INT, fetch_admin, NULL },
{ "params", SILC_CONFIG_ARG_STR, fetch_admin, NULL },
{ 0, 0, 0, 0 }
SILC_SERVER_CONNAUTH_TIMEOUT);
}
+/* Check for correctness of the configuration */
+
+static bool silc_server_config_check(SilcServerConfig config)
+{
+ bool ret = TRUE;
+ SilcServerConfigServer *s;
+ SilcServerConfigRouter *r;
+ bool b = FALSE;
+
+ /* ServerConfig is mandatory */
+ if (!config->server_info) {
+ SILC_SERVER_LOG_ERROR(("\nError: Missing mandatory block `ServerInfo'"));
+ ret = FALSE;
+ }
+
+ /* RouterConnection sanity checks */
+
+ if (config->routers && config->routers->backup_router == TRUE &&
+ !config->servers) {
+ SILC_SERVER_LOG_ERROR((
+ "\nError: First RouterConnection block must be primary router "
+ "connection. You have marked it incorrectly as backup router."));
+ ret = FALSE;
+ }
+ if (config->routers && config->routers->initiator == FALSE &&
+ config->routers->backup_router == FALSE) {
+ SILC_SERVER_LOG_ERROR((
+ "\nError: First RouterConnection block must be primary router "
+ "connection and it must be marked as Initiator."));
+ ret = FALSE;
+ }
+ if (config->routers && config->routers->backup_router == TRUE &&
+ !config->servers && !config->routers->next) {
+ SILC_SERVER_LOG_ERROR((
+ "\nError: You have configured backup router but not primary router. "
+ "If backup router is configured also primary router must be "
+ "configured."));
+ ret = FALSE;
+ }
+
+ /* Backup router sanity checks */
+
+ for (r = config->routers; r; r = r->next) {
+ if (r->backup_router && !strcmp(r->host, r->backup_replace_ip)) {
+ SILC_SERVER_LOG_ERROR((
+ "\nError: Backup router connection incorrectly configured to use "
+ "primary and backup router as same host `%s'. They must not be "
+ "same host.", r->host));
+ ret = FALSE;
+ }
+ }
+
+ /* ServerConnection sanity checks */
+
+ for (s = config->servers; s; s = s->next) {
+ if (s->backup_router) {
+ b = TRUE;
+ break;
+ }
+ }
+ if (b) {
+ for (s = config->servers; s; s = s->next) {
+ if (!s->backup_router) {
+ SILC_SERVER_LOG_ERROR((
+ "\nError: Your server is backup router but not all ServerConnection "
+ "blocks were marked as backup connections. They all must be "
+ "marked as backup connections."));
+ ret = FALSE;
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+
/* Allocates a new configuration object, opens configuration file and
parses it. The parsed data is returned to the newly allocated
configuration object. The SilcServerConfig must be freed by calling
SILC_SERVER_LOG_ERROR(("Error while parsing config file: %s.",
silc_config_strerror(ret)));
linebuf = silc_config_read_line(file, line);
- SILC_SERVER_LOG_ERROR((" file %s line %lu: %s\n", filename,
- line, linebuf));
- silc_free(linebuf);
+ if (linebuf) {
+ SILC_SERVER_LOG_ERROR((" file %s line %lu: %s\n", filename,
+ line, linebuf));
+ silc_free(linebuf);
+ }
}
silc_server_config_destroy(config_new);
return NULL;
/* close (destroy) the file object */
silc_config_close(file);
- /* If config_new is incomplete, abort the object and return NULL */
- if (!config_new->server_info) {
- SILC_SERVER_LOG_ERROR(("\nError: Missing mandatory block "
- "`server_info'"));
+ /* Check the configuration */
+ if (!silc_server_config_check(config_new)) {
silc_server_config_destroy(config_new);
return NULL;
}
#undef STAT_OUTPUT
+#ifdef SILC_DEBUG
+ /* Dump lists */
+ {
+ SilcIDCacheList list = NULL;
+ SilcIDCacheEntry id_cache = NULL;
+ SilcServerEntry server_entry;
+ SilcClientEntry client_entry;
+ SilcChannelEntry channel_entry;
+ int c;
+
+ fprintf(fdd, "\nDumping databases\n");
+
+ if (silc_idcache_get_all(silcd->local_list->servers, &list)) {
+ if (silc_idcache_list_first(list, &id_cache)) {
+ fprintf(fdd, "\nServers in local-list:\n");
+ c = 1;
+ while (id_cache) {
+ server_entry = (SilcServerEntry)id_cache->context;
+ fprintf(fdd, " %d: name %s id %s status 0x%x\n", c,
+ server_entry->server_name ? server_entry->server_name :
+ "N/A", server_entry->id ?
+ silc_id_render(server_entry->id, SILC_ID_SERVER) : "N/A",
+ server_entry->data.status);
+ if (!silc_idcache_list_next(list, &id_cache))
+ break;
+ c++;
+ }
+ }
+ silc_idcache_list_free(list);
+ }
+ if (silc_idcache_get_all(silcd->global_list->servers, &list)) {
+ if (silc_idcache_list_first(list, &id_cache)) {
+ fprintf(fdd, "\nServers in global-list:\n");
+ c = 1;
+ while (id_cache) {
+ server_entry = (SilcServerEntry)id_cache->context;
+ fprintf(fdd, " %d: name %s id %s status 0x%x\n", c,
+ server_entry->server_name ? server_entry->server_name :
+ "N/A", server_entry->id ?
+ silc_id_render(server_entry->id, SILC_ID_SERVER) : "N/A",
+ server_entry->data.status);
+ if (!silc_idcache_list_next(list, &id_cache))
+ break;
+ c++;
+ }
+ }
+ silc_idcache_list_free(list);
+ }
+ if (silc_idcache_get_all(silcd->local_list->clients, &list)) {
+ if (silc_idcache_list_first(list, &id_cache)) {
+ fprintf(fdd, "\nClients in local-list:\n");
+ c = 1;
+ while (id_cache) {
+ client_entry = (SilcClientEntry)id_cache->context;
+ fprintf(fdd, " %d: name %s id %s status 0x%x\n", c,
+ client_entry->nickname ? client_entry->nickname :
+ (unsigned char *)"N/A", client_entry->id ?
+ silc_id_render(client_entry->id, SILC_ID_CLIENT) : "N/A",
+ client_entry->data.status);
+ if (!silc_idcache_list_next(list, &id_cache))
+ break;
+ c++;
+ }
+ }
+ silc_idcache_list_free(list);
+ }
+ if (silc_idcache_get_all(silcd->global_list->clients, &list)) {
+ if (silc_idcache_list_first(list, &id_cache)) {
+ fprintf(fdd, "\nClients in global-list:\n");
+ c = 1;
+ while (id_cache) {
+ client_entry = (SilcClientEntry)id_cache->context;
+ fprintf(fdd, " %d: name %s id %s status 0x%x\n", c,
+ client_entry->nickname ? client_entry->nickname :
+ (unsigned char *)"N/A", client_entry->id ?
+ silc_id_render(client_entry->id, SILC_ID_CLIENT) : "N/A",
+ client_entry->data.status);
+ if (!silc_idcache_list_next(list, &id_cache))
+ break;
+ c++;
+ }
+ }
+ silc_idcache_list_free(list);
+ }
+ if (silc_idcache_get_all(silcd->local_list->channels, &list)) {
+ if (silc_idcache_list_first(list, &id_cache)) {
+ fprintf(fdd, "\nChannels in local-list:\n");
+ c = 1;
+ while (id_cache) {
+ channel_entry = (SilcChannelEntry)id_cache->context;
+ fprintf(fdd, " %d: name %s id %s\n", c,
+ channel_entry->channel_name ? channel_entry->channel_name :
+ "N/A", channel_entry->id ?
+ silc_id_render(channel_entry->id, SILC_ID_CHANNEL) : "N/A");
+ if (!silc_idcache_list_next(list, &id_cache))
+ break;
+ c++;
+ }
+ }
+ silc_idcache_list_free(list);
+ }
+ if (silc_idcache_get_all(silcd->global_list->channels, &list)) {
+ if (silc_idcache_list_first(list, &id_cache)) {
+ fprintf(fdd, "\nChannels in global-list:\n");
+ c = 1;
+ while (id_cache) {
+ channel_entry = (SilcChannelEntry)id_cache->context;
+ fprintf(fdd, " %d: name %s id %s\n", c,
+ channel_entry->channel_name ? channel_entry->channel_name :
+ "N/A", channel_entry->id ?
+ silc_id_render(channel_entry->id, SILC_ID_CHANNEL) : "N/A");
+ if (!silc_idcache_list_next(list, &id_cache))
+ break;
+ c++;
+ }
+ }
+ silc_idcache_list_free(list);
+ }
+ }
+#endif
+
fflush(fdd);
fclose(fdd);
}
}
}
-/* This function should not be called directly but thru the wrapper
- macro SILC_SERVER_LOG_STDERR() */
+/* This function should not be called directly but through the appropriate
+ wrapper macro defined in server.h */
-void silc_server_stderr(char *message)
+void silc_server_stderr(SilcLogType type, char *message)
{
if (silcd->background) {
char *p, *n = message;
}
*n = 0;
- silc_log_output(SILC_LOG_ERROR, message);
+ /* the message is freed inside the logging function */
+ silc_log_output(type, message);
}
else {
fprintf(stderr, "%s\n", message);
CFLAGS="-Wall -finline-functions $CFLAGS"
fi
+#
+# Library versioning.
+#
+# Do the releases and library versioning according to following rules:
+#
+# - If any code has changed in library, increment [LIB]_REVISION
+# - If functions were added, set [LIB]_REVISION to 0
+# - If functions were added, removed or changed, increment [LIB]_CURRENT
+# - If functions were added, increment [LIB]_AGE
+# - If functions were removed, set [LIB]_AGE to 0
+#
+# where [LIB] is LIBSILC and LIBSILCCLIENT, and where "functions" means
+# functions public interfaces.
+#
+# The LIB_BASE_VERSION defines the SILC software major.minor version and
+# it is increment only when these version numbers actually change.
+#
+
+# Base version for libraries. Do not change this unless SILC version
+# changes too.
+LIB_BASE_VERSION=1.0
+
+# libsilc versions
+LIBSILC_CURRENT=1
+LIBSILC_REVISION=0
+LIBSILC_AGE=1
+
+# libsilcclient versions
+LIBSILCCLIENT_CURRENT=1
+LIBSILCCLIENT_REVISION=1
+LIBSILCCLIENT_AGE=0
+
+# Substitute the version numbers
+AC_SUBST(LIB_BASE_VERSION)
+AC_SUBST(LIBSILC_CURRENT)
+AC_SUBST(LIBSILC_REVISION)
+AC_SUBST(LIBSILC_AGE)
+AC_SUBST(LIBSILCCLIENT_CURRENT)
+AC_SUBST(LIBSILCCLIENT_REVISION)
+AC_SUBST(LIBSILCCLIENT_AGE)
+
#
# Program checking
#
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_MAKE_SET
+AC_DISABLE_SHARED
AC_PROG_LIBTOOL
AC_PATH_PROG(sedpath, sed)
AC_MSG_CHECKING(for SIM support)
AC_MSG_RESULT()
AC_CHECK_HEADERS(dlfcn.h,
- AC_CHECK_LIB(dl, dlopen,
- [
- AC_DEFINE(SILC_SIM)
- sim_support=true
- LIBS="$LIBS -ldl"
- ],
- [
- AC_CHECK_LIB(c, dlopen,
- [
- AC_DEFINE(SILC_SIM)
- sim_support=true
- ])
- ])
- )
+ [
+ AC_CHECK_LIB(dl, dlopen,
+ [
+ AC_DEFINE(SILC_SIM)
+ sim_support=true
+ LIBS="$LIBS -ldl"
+ ],
+ [
+ AC_CHECK_LIB(c, dlopen,
+ [
+ AC_DEFINE(SILC_SIM)
+ sim_support=true
+ ])
+ ])
+ ])
AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
if test x$sim_support = xtrue; then
case "${withval}" in
no)
AC_MSG_RESULT(no)
-
- AC_CHECK_HEADERS(iconv.h, AC_CHECK_FUNC(iconv, has_iconv=true))
+ AC_CHECK_HEADERS(iconv.h,
+ [
+ AC_CHECK_FUNC(iconv, has_iconv=true)
+ ])
check_iconv=false
;;
*)
AC_MSG_RESULT(yes)
-
if test -d $withval/include; then
CPPFLAGS="$CPPFLAGS -I$withval/include"
CFLAGS="$CFLAGS -I$withval/include"
if test -d $withval/lib; then
LDFLAGS="$LDFLAGS -L$withval/lib"
fi
+ ;;
esac
],
[
AC_MSG_RESULT(no)
-
- AC_CHECK_HEADERS(iconv.h, AC_CHECK_FUNCS(iconv,
- [
- has_iconv=true
- check_iconv=false
- ]))
+ AC_CHECK_HEADERS(iconv.h,
+ [
+ AC_CHECK_FUNCS(iconv,
+ [
+ has_iconv=true
+ check_iconv=false
+ ])
+ ])
])
if test x$check_iconv = xtrue; then
AC_MSG_RESULT(yes)
])
+libtoolfix=true
+AC_MSG_CHECKING(whether to do libtoolfix)
+AC_ARG_WITH(libtoolfix,
+ [ --without-libtoolfix Do not fix libtool, for package builders],
+ [
+ AC_MSG_RESULT(no)
+ libtoolfix=false
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ ])
+
+AC_SUBST(ETCDIR)
+AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
+
+
##
## Misc
AC_SUBST(INCLUDE_DEFINES_INT)
AC_SUBST(SILC_DIST_SUBDIRS)
+#
+# Fix the libtool to support run-time configuration. This allows us
+# to in run-time specify when to compile shared/static libraries without
+# need to reconfigure the entire libtool.
+#
+if test x$libtoolfix = xtrue; then
+ ./libtoolfix $SILC_TOP_SRCDIR/ltmain.sh
+fi
+AM_CONDITIONAL(SILC_LIBTOOLFIX, test x$libtoolfix = xtrue)
+
+
+#
# Makefile outputs
#
AC_CONFIG_FILES(
lib/Makefile
lib/contrib/Makefile
lib/silccore/Makefile
+lib/silccore/tests/Makefile
lib/silccrypt/Makefile
+lib/silccrypt/tests/Makefile
lib/silcmath/Makefile
lib/silcmath/mpi/Makefile.defines
lib/silcmath/mpi/Makefile.defines_int
test "x$silc_dist" = "xsilc-toolkit"; then
silcd="yes"
if test x$without_silcd = xtrue; then
- without_silcd="no"
+ silcd="no"
fi
echo " Compile SILC Server ...........: $silcd"
echo " Server configuration file .....: $summary_silcd_configfile"
touch draft-riikonen-silc-pp-06.txt
touch draft-riikonen-silc-ke-auth-06.txt
touch draft-riikonen-silc-commands-04.txt
- touch draft-riikonen-silc-flags-payloads-01.txt
+ touch draft-riikonen-silc-flags-payloads-02.txt
touch draft-riikonen-presence-attrs-01.txt
if SILC_DIST_TOOLKIT
touch draft-riikonen-silc-pp-06.txt
touch draft-riikonen-silc-ke-auth-06.txt
touch draft-riikonen-silc-commands-04.txt
- touch draft-riikonen-silc-flags-payloads-01.txt
+ touch draft-riikonen-silc-flags-payloads-02.txt
touch draft-riikonen-presence-attrs-01.txt
$(makerfc) draft-riikonen-silc-spec-06.nroff \
draft-riikonen-silc-spec-06.txt
draft-riikonen-silc-ke-auth-06.txt
$(makerfc) draft-riikonen-silc-commands-04.nroff \
draft-riikonen-silc-commands-04.txt
- $(makerfc) draft-riikonen-silc-flags-payloads-01.nroff \
- draft-riikonen-silc-flags-payloads-01.txt
+ $(makerfc) draft-riikonen-silc-flags-payloads-02.nroff \
+ draft-riikonen-silc-flags-payloads-02.txt
$(makerfc) draft-riikonen-presence-attrs-01.nroff \
draft-riikonen-presence-attrs-01.txt
touch draft-riikonen-silc-pp-06.txt
touch draft-riikonen-silc-ke-auth-06.txt
touch draft-riikonen-silc-commands-04.txt
- touch draft-riikonen-silc-flags-payloads-01.txt
+ touch draft-riikonen-silc-flags-payloads-02.txt
touch draft-riikonen-presence-attrs-01.txt
endif
--- /dev/null
+.pl 10.0i
+.po 0
+.ll 7.2i
+.lt 7.2i
+.nr LL 7.2i
+.nr LT 7.2i
+.ds LF Riikonen
+.ds RF FORMFEED[Page %]
+.ds CF
+.ds LH Internet Draft
+.ds RH 7 December 2002
+.ds CH
+.na
+.hy 0
+.in 0
+.nf
+Network Working Group P. Riikonen
+Internet-Draft
+draft-riikonen-flags-payloads-02.txt 7 December 2003
+Expires: 7 May 2003
+
+.in 3
+
+.ce 2
+SILC Message Flag Payloads
+<draft-riikonen-flags-payloads-02.txt>
+
+.ti 0
+Status of this Memo
+
+This document is an Internet-Draft and is in full conformance with
+all provisions of Section 10 of RFC 2026. Internet-Drafts are
+working documents of the Internet Engineering Task Force (IETF), its
+areas, and its working groups. Note that other groups may also
+distribute working documents as Internet-Drafts.
+
+Internet-Drafts are draft documents valid for a maximum of six months
+and may be updated, replaced, or obsoleted by other documents at any
+time. It is inappropriate to use Internet-Drafts as reference
+material or to cite them other than as "work in progress."
+
+The list of current Internet-Drafts can be accessed at
+http://www.ietf.org/ietf/1id-abstracts.txt
+
+The list of Internet-Draft Shadow Directories can be accessed at
+http://www.ietf.org/shadow.html
+
+The distribution of this memo is unlimited.
+
+
+.ti 0
+Abstract
+
+This memo describes the data payloads associated with the SILC Message
+Flags, as defined in the SILC Packet Protocol Internet Draft [SILC2]. The
+purpose of the Message Flags is to augment the function of the Message
+Payload used to send both private and channel messages, by allowing the
+sender to tell the receiver what type of data the payload includes, and
+how the data should be processed. Some of the Message Flags may define
+additional payloads to be associated with the flag, and this memo
+describes these payloads.
+
+
+
+
+
+
+
+
+.ti 0
+Table of Contents
+
+.nf
+1 Introduction .................................................. 2
+ 1.1 Requirements Terminology .................................. 2
+2 SILC Message Flags ............................................ 2
+3 SILC Message Flag Payloads .................................... 3
+ 3.1 SILC_MESSAGE_FLAG_REQUEST ................................. 3
+ 3.2 SILC_MESSAGE_FLAG_REPLY ................................... 3
+ 3.3 SILC_MESSAGE_FLAG_SIGNED .................................. 4
+ 3.4 SILC_MESSAGE_FLAG_DATA .................................... 6
+4 Security Considerations ....................................... 7
+5 References .................................................... 7
+6 Author's Address .............................................. 8
+
+
+.ti 0
+1. Introduction
+
+The Secure Internet Live Conferencing [SILC1] supports sending binary
+messages between users in the network. To make the data sending, and
+processing at the receiver's end as simple as possible the SILC defines
+Message Flags to the Message Payload [SILC2] that is used to send private
+and channel messages, which can help the receiver to decide how the data
+is encoded, and how it should be interpreted. Some of the Message Flags
+may define additional payloads to be associated with the flag, but the
+[SILC2] does not define them. This memo defines the payloads for those
+Message Flags that was marked to include additional payloads in [SILC2].
+
+By defining the payloads for the Message Flags the Message Payload
+can be augmented to support any kind of data, which can be easily
+interpreted at the receiver end. For example, it would be possible to
+send audio stream, video stream, image files and HTML pages as messages,
+and the receiver can either choose to ignore the message or to process
+it, or to perhaps pass the message to some application for processing.
+Without specific payloads for Message Flags it is almost impossible for
+the receiver to interpret binary data from the payload.
+
+
+.ti 0
+1.1 Requirements Terminology
+
+The keywords MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED,
+MAY, and OPTIONAL, when they appear in this document, are to be
+interpreted as described in [RFC2119].
+
+
+.ti 0
+2 SILC Message Flags
+
+The Message Flags was added to the SILC protocol for the reason that SILC
+provides sending binary data as messages between users, and entities in
+the network, and interpreting pure binary data is almost impossible.
+With the flags the purpose, the reason, and the way the message is
+supposed to be interpreted can be told to the recipient. Other
+conferencing protocols which are usually ASCII based protocols do not have
+such problems since they do not generally support sending of binary data
+at all, or require encoding of the data before it can be sent over the
+network.
+
+The Message Payload in SILC can have flags that can augment the function
+of the payload. The flags can tell for example that the message is a
+request, or a reply to an earlier received request. They can tell that
+the message is some action that the sender is performing, or they can tell
+that the message is an auto reply, or that it is explicitly digitally
+signed by the sender.
+
+The problem of Message Flags is that the space for flags mask is only 16
+bits, so there is a limited number of flags available. For this reason a
+flag that defines some generic way of sending any kind of data as a
+message, and that it can be easily interpreted at the receiver's end is
+important. For this reason the flag SILC_MESSAGE_FLAG_DATA was added to
+the protocol which can represent any data. This memo describe how this
+flag is used and how the associated payload is constructed and processed.
+This memo also describes payloads for all the other flags that can have
+associated payloads.
+
+
+.ti 0
+3 SILC Message Flag Payloads
+
+The [SILC2] defines the flags which may have associated payloads. This
+section will list these flags and define the payloads.
+
+
+.ti 0
+3.1 SILC_MESSAGE_FLAG_REQUEST
+
+Currently this flag can be used in the context of application specific,
+service specific or vendor specific requests, and the data payload type is
+dependent of this context. Therefore, payload is not defined for this
+flag in this memo. This flag may also be masked with some other flag in
+the message payload, including with some other flag that defines
+additional payload.
+
+
+.ti 0
+3.2 SILC_MESSAGE_FLAG_REPLY
+
+Currently this flag can be used in the context of application specific,
+service specific or vendor specific replies, and the data payload type is
+dependent of this context. Therefore, payload is not defined for this
+flag in this memo. This flag may also be masked with some other flag in
+the message payload, including with some other flag that defines
+additional payload.
+
+
+.ti 0
+3.3 SILC_MESSAGE_FLAG_SIGNED
+
+This flag is used to tell the recipient that the sent message is
+digitally signed by the sender, and that the recipient should verify
+the signature to verify the true authenticity of the received message.
+All message payloads in SILC provides message authentication code (MAC)
+which can be used to verify that the sender produced and sent the message.
+Even so, signing messages digitally can be used to verify the authenticity
+of the message when recipient trusts the sender.
+
+This flag defines a payload which is used to deliver the actual message,
+sender's public key and the digital signature. The payload for
+SILC_MESSAGE_FLAG_SIGNED is as follows:
+
+.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
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| |
+~ Start of Message Payload ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| |
+~ Public Key Payload ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Signature Data Length | |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
+| |
+~ Signature Data ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| |
+~ Initial Vector * ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| |
+~ MAC * ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+.in 3
+
+.ce
+Figure 1: SILC_MESSAGE_FLAG_SIGNED Payload
+
+
+.in 6
+o Start of Message Payload (variable length) - This is the
+ start of the Message Payload without the IV and MAC fields,
+ since those fields are appended at the end of this payload.
+
+o Public Key Payload (variable length) - This includes the
+ Public Key Payload [SILC2] which can be used to deliver the
+ sender's public key (or certificate). It also indicates the
+ type of the public key (or certificate) which the recipient
+ use to identify how the signature must be verified. This
+ payload must always be present but it is not required to
+ include the public key data. The Public Key Type field in
+ the Public Key Payload MUST be set to the correct type of
+ the key, even if the actual public key data is not included.
+
+o Signature Data Length (2 bytes) - Indicates the length of
+ the Signature Data field not including any other field.
+
+o Signature Data (variable length) - Includes the actual
+ signature data. The signature computation and encoding
+ is key type specific. See [SILC3] for all key types, and
+ their respective references of how to compute and encode
+ the signature.
+
+o Initial Vector (variable length) - the IV of the Message
+ Payload as defined in [SILC2]. This field is not encrypted.
+
+o MAC (variable length) - the MAC of the Message Payload as
+ defined in [SILC2]. The MAC is computed after encryption
+ and after signature computation. All data in the Message
+ Payload and this payload, including the IV field are
+ included in the MAC computation. This field is not
+ encrypted.
+.in 3
+
+How the data is processed before it is signed is key type specific.
+The actual data that to be signed MUST be the plaintext message
+payload before encryption. The data to be signed is concatenation
+of the Start of Message Payload field and the Public Key Payload,
+in that order. Any other fields are not included for signature data.
+Before signing, the data is always processed, usually hashed. The
+hash function to be used is defined in the key type specific
+definitions. See the key type specific references in [SILC3].
+
+If the public key of the sender is included in the payload the
+recipient SHOULD verify it before accepting the public key. Recipient
+SHOULD verify the signature before accepting a public key. With
+certificates the certificate verification may be done before
+verifying the signature. If the signature verification fails the
+message should still be displayed. The end user should also be
+notified about the result of the signature verification.
+
+To make the packet size smaller implementations may not want to
+include the actual public key in all signed messages. Sending the
+public key in the first message is usually sufficient. Subsequent
+messages may include empty Public Key Payload with an indication of
+the public key type.
+
+Implementations that do not support this flag can still process the
+message payload in normal manner. These implementations merely parse
+the decrypted payload in normal manner and ignore the extra data in
+the payload.
+
+This flag MAY be masked with any other Message Flag including those that
+define additional payloads. As long as the defined payload resides in
+the data area of the message payload this flag may be masked with the
+other flags.
+
+
+
+.ti 0
+3.4 SILC_MESSAGE_FLAG_DATA
+
+This flag is used to represent any data as a message in the way that it
+can be easily interpreted by the recipient. This flag is used to send
+MIME objects as messages from the sender to the receiver. The MIME as
+defined in [RFC2045], [RFC2046], [RFC2047], [RFC2048] and [RFC2049] is
+well established protocol for sending different kind of data with many
+applications and protocols. It support dozens of different media types
+and encodings, and for this reason is ideal for sending data in SILC
+message payloads as well.
+
+When the receiver has checked that the message payload includes the
+SILC_MESSAGE_FLAG_DATA flag, it may then start parsing the MIME header.
+It would also be possible to pass the message to some application which
+can already interpret MIME objects. If the receiver does not support the
+media type received in the MIME header, it SHOULD be treated as
+"application/octet-stream". The receiver MAY also ignore and discard
+messages that it does not support.
+
+The MIME header MUST be at the start of the data area of the Message
+Payload. The MIME header received in the data area of the payload SHOULD
+have the MIME-Version field at first and then Content-Type field. The
+MIME-Version field is not required to be present in each body part of
+multipart entity. Additionally the header MAY also include any other
+MIME compliant headers. The character encoding for the MIME Header
+strings inside the message payload is US-ASCII, as defined in [RFC2045].
+The actual MIME object may define additional character sets or encodings
+for the data it delivers.
+
+Hence, the MIME Header in the message payload may be as follows:
+
+.in 8
+.nf
+MIME-Version: 1.0\\r\\n
+Content-Type: discrete/composite\\r\\n
+Content-Transfer-Encoding: binary\\r\\n
+\\r\\n
+.in 3
+
+The Content-Transfer-Encoding field behaves as defined in [RFC2045] and
+defines the encoding of the data in the MIME object. The preferred data
+encoding with SILC is "binary". However, many MIME media types defines
+their preferred encoding and they may be used if binary encoding is not
+suitable.
+
+When sending large amounts of traffic or large files as MIME objects the
+limits of the SILC Packet needs to be taken into consideration. The
+maximum length of SILC Packet is 2^16 bytes, and larger messages would
+need to be fragmented. MIME provides way of fragmenting and reassembling
+messages, and it is to be done with SILC as defined in [RFC2046]. The
+MIME fragmentation is defined for gateway usage, but in case of SILC the
+sender may also start sending fragmented MIME objects.
+
+This flag SHOULD NOT be masked with some other Message Flag that defines
+payloads for message data. Generally this sort of setting would be
+impossible for the receiver to interpret. However, flags that does not
+define any specific payloads MAY be masked with this flag as well. For
+example, this flag could be masked also with SILC_MESSAGE_FLAG_REQUEST flag.
+It also can be masked with SILC_MESSAGE_FLAG_SIGNED flag since it does not
+define data specific payload.
+
+
+.ti 0
+4 Security Considerations
+
+In case of SILC_MESSAGE_FLAG_DATA the implementors should pay special
+attention to the security implications of any media type that can cause
+the remote execution of any actions in the receiver's environment. The
+[RFC2046] and [RFC2048] discusses more MIME specific security
+considerations. Even though SILC provides secured messages, in case of
+MIME which can be used to transfer files and documents which are stored in
+the receiver's local environment, securing separately the MIME object may
+be desired. For example, augmenting the MIME support in SILC messages to
+support S/MIME may be desired in some implementations.
+
+
+
+.ti 0
+5 References
+
+[SILC1] Riikonen, P., "Secure Internet Live Conferencing (SILC),
+ Protocol Specification", Internet Draft, May 2002.
+
+[SILC2] Riikonen, P., "SILC Packet Protocol", Internet Draft,
+ May 2002.
+
+[SILC3] Riikonen, P., "SILC Key Exchange and Authentication
+ Protocols", Internet Draft, May 2002.
+
+[RFC2045] Freed, N., et al., "Multipurpose Internet Mail Extensions
+ (MIME) Part One: Format of Internet Message Bodies",
+ Standards Track, RFC 2045, November 1996.
+
+[RFC2046] Freed, N., et al., "Multipurpose Internet Mail Extensions
+ (MIME) Part Two: Media Types", Standards Track, RFC 2045,
+ November 1996.
+
+[RFC2047] Moore K., "MIME (Multipurpose Internet Mail Extensions)
+ Part Three: Message Header Extensions for Non-ASCII Text"
+ Standards Track, RFC 2047, November 1996.
+
+[RFC2048] Freed, N., et al., "Multipurpose Internet Mail Extensions
+ (MIME) Part Four: Registration Procedures", Standards
+ Track, RFC 2048, November 1996.
+
+[RFC2049] Freed, N., et al., "Multipurpose Internet Mail Extensions
+ (MIME) Part Five: Conformance Criteria and Examples",
+ Standards Track, RFC 2049, November 1996.
+
+[RFC2119] Bradner, S., "Key Words for use in RFCs to Indicate
+ Requirement Levels", BCP 14, RFC 2119, March 1997.
+
+
+
+.ti 0
+6 Author's Address
+
+Pekka Riikonen
+Snellmaninkatu 34 A 15
+70100 Kuopio
+Finland
+
+EMail: priikone@iki.fi
+
+This Internet-Draft expires 7 May 2003
--- /dev/null
+.pl 10.0i
+.po 0
+.ll 7.2i
+.lt 7.2i
+.nr LL 7.2i
+.nr LT 7.2i
+.ds LF Riikonen
+.ds RF FORMFEED[Page %]
+.ds CF
+.ds LH Internet Draft
+.ds RH XXX
+.ds CH
+.na
+.hy 0
+.in 0
+.nf
+Network Working Group P. Riikonen
+Internet-Draft
+draft-riikonen-silc-spec-06.txt XXX
+Expires: XXX
+
+.in 3
+
+.ce 3
+Secure Internet Live Conferencing (SILC),
+Protocol Specification
+<draft-riikonen-silc-spec-07.txt>
+
+.ti 0
+Status of this Memo
+
+This document is an Internet-Draft and is in full conformance with
+all provisions of Section 10 of RFC 2026. Internet-Drafts are
+working documents of the Internet Engineering Task Force (IETF), its
+areas, and its working groups. Note that other groups may also
+distribute working documents as Internet-Drafts.
+
+Internet-Drafts are draft documents valid for a maximum of six months
+and may be updated, replaced, or obsoleted by other documents at any
+time. It is inappropriate to use Internet-Drafts as reference
+material or to cite them other than as "work in progress."
+
+The list of current Internet-Drafts can be accessed at
+http://www.ietf.org/ietf/1id-abstracts.txt
+
+The list of Internet-Draft Shadow Directories can be accessed at
+http://www.ietf.org/shadow.html
+
+The distribution of this memo is unlimited.
+
+
+.ti 0
+Abstract
+
+This memo describes a Secure Internet Live Conferencing (SILC)
+protocol which provides secure conferencing services over insecure
+network channel. SILC is IRC [IRC] like protocol, however, it is
+not equivalent to IRC and does not support IRC. Strong cryptographic
+methods are used to protect SILC packets inside the SILC network.
+Three other Internet Drafts relates very closely to this memo;
+SILC Packet Protocol [SILC2], SILC Key Exchange and Authentication
+Protocols [SILC3] and SILC Commands [SILC4].
+
+
+
+
+
+
+.ti 0
+Table of Contents
+
+.nf
+1 Introduction .................................................. 3
+ 1.1 Requirements Terminology .................................. 4
+2 SILC Concepts ................................................. 4
+ 2.1 SILC Network Topology ..................................... 4
+ 2.2 Communication Inside a Cell ............................... 6
+ 2.3 Communication in the Network .............................. 6
+ 2.4 Channel Communication ..................................... 7
+ 2.5 Router Connections ........................................ 8
+3 SILC Specification ............................................ 8
+ 3.1 Client .................................................... 9
+ 3.1.1 Client ID ........................................... 9
+ 3.2 Server .................................................... 10
+ 3.2.1 Server's Local ID List .............................. 10
+ 3.2.2 Server ID ........................................... 11
+ 3.2.3 SILC Server Ports ................................... 12
+ 3.3 Router .................................................... 12
+ 3.3.1 Router's Local ID List .............................. 13
+ 3.3.2 Router's Global ID List ............................. 13
+ 3.3.3 Router's Server ID .................................. 14
+ 3.4 Channels .................................................. 14
+ 3.4.1 Channel ID .......................................... 15
+ 3.5 Operators ................................................. 16
+ 3.6 SILC Commands ............................................. 16
+ 3.7 SILC Packets .............................................. 17
+ 3.8 Packet Encryption ......................................... 17
+ 3.8.1 Determination of the Source and the Destination ..... 18
+ 3.8.2 Client To Client .................................... 18
+ 3.8.3 Client To Channel ................................... 20
+ 3.8.4 Server To Server .................................... 20
+ 3.9 Key Exchange And Authentication ........................... 20
+ 3.9.1 Authentication Payload .............................. 21
+ 3.10 Algorithms ............................................... 23
+ 3.10.1 Ciphers ............................................ 23
+ 3.10.1.1 CBC Mode .................................. 24
+ 3.10.1.2 CTR Mode .................................. 24
+ 3.10.1.3 Randomized CBC Mode ....................... 25
+ 3.10.2 Public Key Algorithms .............................. 26
+ 3.10.3 Hash Functions ..................................... 26
+ 3.10.4 MAC Algorithms ..................................... 27
+ 3.10.5 Compression Algorithms ............................. 27
+ 3.11 SILC Public Key .......................................... 28
+ 3.12 SILC Version Detection ................................... 30
+ 3.13 Backup Routers ........................................... 31
+ 3.13.1 Switching to Backup Router ......................... 32
+ 3.13.2 Resuming Primary Router ............................ 33
+ 3.13.3 Discussion on Backup Router Scheme ................. 36
+4 SILC Procedures ............................................... 36
+ 4.1 Creating Client Connection ................................ 36
+ 4.2 Creating Server Connection ................................ 38
+ 4.2.1 Announcing Clients, Channels and Servers ............ 38
+ 4.3 Joining to a Channel ...................................... 39
+ 4.4 Channel Key Generation .................................... 41
+ 4.5 Private Message Sending and Reception ..................... 41
+ 4.6 Private Message Key Generation ............................ 42
+ 4.7 Channel Message Sending and Reception ..................... 43
+ 4.8 Session Key Regeneration .................................. 43
+ 4.9 Command Sending and Reception ............................. 44
+ 4.10 Closing Connection ....................................... 45
+ 4.11 Detaching and Resuming a Session ......................... 45
+5 Security Considerations ....................................... 47
+6 References .................................................... 48
+7 Author's Address .............................................. 49
+
+
+.ti 0
+List of Figures
+
+.nf
+Figure 1: SILC Network Topology
+Figure 2: Communication Inside cell
+Figure 3: Communication Between Cells
+Figure 4: Router Connections
+Figure 5: SILC Public Key
+Figure 6: Counter Block
+
+
+.ti 0
+1. Introduction
+
+This document describes a Secure Internet Live Conferencing (SILC)
+protocol which provides secure conferencing services over insecure
+network channel. SILC is IRC [IRC] like protocol, however, it is
+not equivalent to IRC and does not support IRC. Some of the SILC's
+features are not found in IRC but in traditional Instant Message (IM)
+protocols. SILC combines features from both of these chat protocol
+styles, and SILC can be implemented as either IRC-like system or
+IM-like system.
+
+Strong cryptographic methods are used to protect SILC packets inside
+the SILC network. Three other Internet Drafts relates very closely
+to this memo; SILC Packet Protocol [SILC2], SILC Key Exchange and
+Authentication Protocols [SILC3] and SILC Commands [SILC4].
+
+The protocol uses extensively packets as conferencing protocol
+requires message and command sending. The SILC Packet Protocol is
+described in [SILC2] and should be read to fully comprehend this
+document and protocol. [SILC2] also describes the packet encryption
+and decryption in detail. The SILC Packet Protocol provides secured
+and authenticated packets, and the protocol is designed to be compact.
+This makes SILC also suitable in environment of low bandwidth
+requirements such as mobile networks. All packet payloads in SILC
+can be also compressed.
+
+The security of SILC protocol, and for any security protocol for that
+matter, is based on strong and secure key exchange protocol. The SILC
+Key Exchange protocol is described in [SILC3] along with connection
+authentication protocol and should be read to fully comprehend this
+document and protocol.
+
+The SILC protocol has been developed to work on TCP/IP network
+protocol, although it could be made to work on other network protocols
+with only minor changes. However, it is recommended that TCP/IP
+protocol is used under SILC protocol. Typical implementation would
+be made in client-server model.
+
+
+.ti 0
+1.1 Requirements Terminology
+
+The keywords MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED,
+MAY, and OPTIONAL, when they appear in this document, are to be
+interpreted as described in [RFC2119].
+
+
+.ti 0
+2. SILC Concepts
+
+This section describes various SILC protocol concepts that forms the
+actual protocol, and in the end, the actual SILC network. The mission
+of the protocol is to deliver messages from clients to other clients
+through routers and servers in secure manner. The messages may also
+be delivered from one client to many clients forming a group, also
+known as a channel.
+
+This section does not focus to security issues. Instead, basic network
+concepts are introduced to make the topology of the SILC network
+clear.
+
+
+.ti 0
+2.1 SILC Network Topology
+
+SILC network forms a ring as opposed to tree style network topology that
+conferencing protocols usually have. The network has a cells which are
+constructed from router and zero or more servers. The servers are
+connected to the router in a star like network topology. Routers in the
+network are connected to each other forming a ring. The rationale for
+this is to have servers that can perform specific kind of tasks what
+other servers cannot perform. This leads to two kinds of servers; normal
+SILC servers and SILC routers.
+
+A difference between normal server and router server is that routers
+knows everything about everything in the network. They also do the
+actual routing of the messages to the correct receiver. Normal servers
+knows only about local information and nothing about global information.
+This makes the network faster as there are less servers that needs to
+keep global information up to date at all time.
+
+This, on the other hand, leads to kind of a cellular like network, where
+routers are in the center of the cell and servers are connected to the
+router.
+
+The following diagram represents SILC network topology.
+
+.in 8
+.nf
+ ---- ---- ---- ---- ---- ----
+ | S8 | S5 | S4 | | S7 | S5 | S6 |
+ ----- ---- ----- ----- ---- -----
+| S7 | S/R1 | S2 | --- | S8 | S/R2 | S4 |
+ ---- ------ ---- ---- ------ ----
+ | S6 | S3 | S1 | | S1 | S3 | S2 | ---- ----
+ ---- ---- ---- ---- ---- ---- | S3 | S1 |
+ Cell 1. \\ Cell 2. | \\____ ----- -----
+ | | | S4 | S/R4 |
+ ---- ---- ---- ---- ---- ---- ---- ------
+ | S7 | S4 | S2 | | S1 | S3 | S2 | | S2 | S5 |
+ ----- ---- ----- ----- ---- ----- ---- ----
+ | S6 | S/R3 | S1 | --- | S4 | S/R5 | S5 | ____/ Cell 4.
+ ---- ------ ---- ---- ------ ----
+ | S8 | S5 | S3 | | S6 | S7 | S8 | ... etc ...
+ ---- ---- ---- ---- ---- ----
+ Cell 3. Cell 5.
+.in 3
+
+.ce
+Figure 1: SILC Network Topology
+
+
+A cell is formed when a server or servers connect to one router. In
+SILC network normal server cannot directly connect to other normal
+server. Normal server may only connect to SILC router which then
+routes the messages to the other servers in the cell. Router servers
+on the other hand may connect to other routers to form the actual SILC
+network, as seen in above figure. However, router is also normal SILC
+server; clients may connect to it the same way as to normal SILC
+server. Normal server also cannot have active connections to more
+than one router. Normal server cannot be connected to two different
+cells. Router servers, on the other hand, may have as many router to
+router connections as needed.
+
+There are many issues in this network topology that needs to be careful
+about. Issues like the size of the cells, the number of the routers in
+the SILC network and the capacity requirements of the routers. These
+issues should be discussed in the Internet Community and additional
+documents on the issue may be written.
+
+
+.ti 0
+2.2 Communication Inside a Cell
+
+It is always guaranteed that inside a cell message is delivered to the
+recipient with at most two server hops. A client which is connected to
+server in the cell and is talking on channel to other client connected
+to other server in the same cell, will have its messages delivered from
+its local server first to the router of the cell, and from the router
+to the other server in the cell.
+
+The following diagram represents this scenario:
+
+
+.in 25
+.nf
+1 --- S1 S4 --- 5
+ S/R
+ 2 -- S2 S3
+ / |
+ 4 3
+.in 3
+
+
+.ce
+Figure 2: Communication Inside cell
+
+
+Example: Client 1. connected to Server 1. send message to
+ Client 4. connected to Server 2. travels from Server 1.
+ first to Router which routes the message to Server 2.
+ which then sends it to the Client 4. All the other
+ servers in the cell will not see the routed message.
+
+
+If the client is connected directly to the router, as router is also normal
+SILC server, the messages inside the cell are always delivered only with
+one server hop. If clients communicating with each other are connected
+to the same server, no router interaction is needed. This is the optimal
+situation of message delivery in the SILC network.
+
+
+.ti 0
+2.3 Communication in the Network
+
+If the message is destined to server that does not belong to local cell
+the message is routed to the router server to which the destination
+server belongs, if the local router is connected to destination router.
+If there is no direct connection to the destination router, the local
+router routes the message to its primary route. The following diagram
+represents message sending between cells.
+
+
+
+.in 16
+.nf
+1 --- S1 S4 --- 5 S2 --- 1
+ S/R - - - - - - - - S/R
+ 2 -- S2 S3 S1
+ / | \\
+ 4 3 2
+
+ Cell 1. Cell 2.
+.in 3
+
+
+.ce
+Figure 3: Communication Between Cells
+
+
+Example: Client 5. connected to Server 4. in Cell 1. sends message
+ to Client 2. connected to Server 1. in Cell 2. travels
+ from Server 4. to Router which routes the message to
+ Router in Cell 2, which then routes the message to
+ Server 1. All the other servers and routers in the
+ network will not see the routed message.
+
+
+The optimal case of message delivery from the client point of view is
+when clients are connected directly to the routers and the messages
+are delivered from one router to the other.
+
+
+.ti 0
+2.4 Channel Communication
+
+Messages may be sent to group of clients as well. Sending messages to
+many clients works the same way as sending messages point to point, from
+message delivery point of view. Security issues are another matter
+which are not discussed in this section.
+
+Router server handles the message routing to multiple recipients. If
+any recipient is not in the same cell as the sender the messages are
+routed further.
+
+Server distributes the channel message to its local clients which are
+joined to the channel. Router also distributes the message to its
+local clients on the channel.
+
+
+
+.ti 0
+2.5 Router Connections
+
+Router connections play very important role in making the SILC like
+network topology to work. For example, sending broadcast packets in
+SILC network require special connections between routers; routers must
+be connected in a specific way.
+
+Every router has their primary route which is a connection to another
+router in the network. Unless there is only two routers in the network
+must not routers use each other as their primary routes. The router
+connections in the network must form a ring.
+
+Example with three routers in the network:
+
+
+.in 16
+.nf
+ S/R1 - < - < - < - < - < - < - S/R2
+ \\ /
+ v ^
+ \\ - > - > - S/R3 - > - > - /
+.in 3
+
+
+.ce
+Figure 4: Router Connections
+
+
+Example: Network with three routers. Router 1. uses Router 2. as its
+ primary router. Router 2. uses Router 3. as its primary router,
+ and Router 3. uses Router 1. as its primary router. There may
+ be other direct connections between the routers but they must
+ not be used as primary routes.
+
+The above example is applicable to any amount of routers in the network
+except for two routers. If there are only two routers in the network both
+routers must be able to handle situation where they use each other as their
+primary routes.
+
+The issue of router connections are very important especially with SILC
+broadcast packets. Usually all router wide information in the network is
+distributed by SILC broadcast packets. This sort of ring network, with
+ability to have other direct routes in the network cause interesting
+routing problems. The [SILC2] discusses the routing of packets in this
+sort of network in more detail.
+
+
+.ti 0
+3. SILC Specification
+
+This section describes the SILC protocol. However, [SILC2] and
+[SILC3] describes other important protocols that are part of this SILC
+specification and must be read.
+
+
+.ti 0
+3.1 Client
+
+A client is a piece of software connecting to SILC server. SILC client
+cannot be SILC server. Purpose of clients is to provide the user
+interface of the SILC services for end user. Clients are distinguished
+from other clients by unique Client ID. Client ID is a 128 bit ID that
+is used in the communication in the SILC network. The client ID is
+based on the nickname selected by the user. User uses logical nicknames
+in communication which are then mapped to the corresponding Client ID.
+Client ID's are low level identifications and should not be seen by the
+end user.
+
+Clients provide other information about the end user as well. Information
+such as the nickname of the user, username and the host name of the end
+user and user's real name. See section 3.2 Server for information of
+the requirements of keeping this information.
+
+The nickname selected by the user is not unique in the SILC network.
+There can be 2^8 same nicknames for one IP address. As for comparison to
+IRC [IRC] where nicknames are unique this is a fundamental difference
+between SILC and IRC. This typically causes the server names or client's
+host names to be used along with the nicknames on user interface to
+identify specific users when sending messages. This feature of SILC
+makes IRC style nickname-wars obsolete as no one owns their nickname;
+there can always be someone else with the same nickname. The maximum
+length of nickname is 128 bytes.
+
+
+.ti 0
+3.1.1 Client ID
+
+Client ID is used to identify users in the SILC network. The Client ID
+is unique to the extent that there can be 2^128 different Client ID's,
+and ID's based on IPv6 addresses extends this to 2^224 different Client
+ID's. Collisions are not expected to happen. The Client ID is defined
+as follows.
+
+.in 6
+128 bit Client ID based on IPv4 addresses:
+
+32 bit Server ID IP address (bits 1-32)
+ 8 bit Random number or counter
+88 bit Truncated MD5 hash value of the nickname
+
+224 bit Client ID based on IPv6 addresses:
+
+128 bit Server ID IP address (bits 1-128)
+ 8 bit Random number or counter
+ 88 bit Truncated MD5 hash value of the nickname
+
+o Server ID IP address - Indicates the server where this
+ client is coming from. The IP address hence equals the
+ server IP address where to the client has connected.
+
+o Random number or counter - Random number to further
+ randomize the Client ID. Another choice is to use
+ a counter starting from the zero (0). This makes it
+ possible to have 2^8 same nicknames from the same
+ server IP address.
+
+o MD5 hash - MD5 hash value of the lowercase nickname is
+ truncated taking 88 bits from the start of the hash value.
+ This hash value is used to search the user's Client ID
+ from the ID lists. Note that the nickname MUST be in
+ lowercase format.
+
+.in 3
+Collisions could occur when more than 2^8 clients using same nickname
+from the same server IP address is connected to the SILC network.
+Server MUST be able to handle this situation by refusing to accept
+anymore of that nickname.
+
+Another possible collision may happen with the truncated hash value of
+the nickname. It could be possible to have same truncated hash value for
+two different nicknames. However, this is not expected to happen nor
+cause any problems if it would occur. Nicknames are usually logical and
+it is unlikely to have two distinct logical nicknames produce same
+truncated hash value.
+
+
+.ti 0
+3.2 Server
+
+Servers are the most important parts of the SILC network. They form the
+basis of the SILC, providing a point to which clients may connect to.
+There are two kinds of servers in SILC; normal servers and router servers.
+This section focus on the normal server and router server is described
+in the section 3.3 Router.
+
+Normal servers MUST NOT directly connect to other normal server. Normal
+servers may only directly connect to router server. If the message sent
+by the client is destined outside the local server it is always sent to
+the router server for further routing. Server may only have one active
+connection to router on same port. Normal server MUST NOT connect to other
+cell's router except in situations where its cell's router is unavailable.
+
+
+.ti 0
+3.2.1 Server's Local ID List
+
+Normal server keeps various information about the clients and their end
+users connected to it. Every normal server MUST keep list of all locally
+connected clients, Client ID's, nicknames, usernames and host names and
+user's real name. Normal servers only keeps local information and it
+does not keep any global information. Hence, normal servers knows only
+about their locally connected clients. This makes servers efficient as
+they don't have to worry about global clients. Server is also responsible
+of creating the Client ID's for their clients.
+
+Normal server also keeps information about locally created channels and
+their Channel ID's.
+
+Hence, local list for normal server includes:
+
+.in 6
+server list - Router connection
+ o Server name
+ o Server IP address
+ o Server ID
+ o Sending key
+ o Receiving key
+ o Public key
+
+client list - All clients in server
+ o Nickname
+ o Username@host
+ o Real name
+ o Client ID
+ o Sending key
+ o Receiving key
+ o Public key
+
+
+channel list - All channels in server
+ o Channel name
+ o Channel ID
+ o Client ID's on channel
+ o Client ID modes on channel
+ o Channel key
+.in 3
+
+
+.ti 0
+3.2.2 Server ID
+
+Servers are distinguished from other servers by unique 64 bit Server ID
+(for IPv4) or 160 bit Server ID (for IPv6). The Server ID is used in
+the SILC to route messages to correct servers. Server ID's also provide
+information for Client ID's, see section 3.1.1 Client ID. Server ID is
+defined as follows.
+
+.in 6
+64 bit Server ID based on IPv4 addresses:
+
+32 bit IP address of the server
+16 bit Port
+16 bit Random number
+
+160 bit Server ID based on IPv6 addresses:
+
+128 bit IP address of the server
+ 16 bit Port
+ 16 bit Random number
+
+o IP address of the server - This is the real IP address of
+ the server.
+
+o Port - This is the port the server is bound to.
+
+o Random number - This is used to further randomize the Server ID.
+
+.in 3
+Collisions are not expected to happen in any conditions. The Server ID
+is always created by the server itself and server is responsible of
+distributing it to the router.
+
+
+.ti 0
+3.2.3 SILC Server Ports
+
+The following ports has been assigned by IANA for the SILC protocol:
+
+.in 10
+silc 706/tcp SILC
+silc 706/udp SILC
+.in 3
+
+
+If there are needs to create new SILC networks in the future the port
+numbers must be officially assigned by the IANA.
+
+Server on network above privileged ports (>1023) SHOULD NOT be trusted
+as they could have been set up by untrusted party.
+
+
+.ti 0
+3.3 Router
+
+Router server in SILC network is responsible for keeping the cell together
+and routing messages to other servers and to other routers. Router server
+is also a normal server thus clients may connect to it as it would be
+just normal SILC server.
+
+However, router servers has a lot of important tasks that normal servers
+do not have. Router server knows everything about everything in the SILC.
+They know all clients currently on SILC, all servers and routers and all
+channels in SILC. Routers are the only servers in SILC that care about
+global information and keeping them up to date at all time. And, this
+is what they must do.
+
+
+.ti 0
+3.3.1 Router's Local ID List
+
+Router server as well MUST keep local list of connected clients and
+locally created channels. However, this list is extended to include all
+the informations of the entire cell, not just the server itself as for
+normal servers.
+
+However, on router this list is a lot smaller since routers do not need
+to keep information about user's nickname, username and host name and real
+name since these are not needed by the router. The router keeps only
+information that it needs.
+
+Hence, local list for router includes:
+
+.in 6
+server list - All servers in the cell
+ o Server name
+ o Server ID
+ o Router's Server ID
+ o Sending key
+ o Receiving key
+
+client list - All clients in the cell
+ o Client ID
+
+channel list - All channels in the cell
+ o Channel ID
+ o Client ID's on channel
+ o Client ID modes on channel
+ o Channel key
+.in 3
+
+
+Note that locally connected clients and other information include all the
+same information as defined in section section 3.2.1 Server's Local ID
+List.
+
+
+.ti 0
+3.3.2 Router's Global ID List
+
+Router server MUST also keep global list. Normal servers do not have
+global list as they know only about local information. Global list
+includes all the clients on SILC, their Client ID's, all created channels
+and their Channel ID's and all servers and routers on SILC and their
+Server ID's. That is said, global list is for global information and the
+list must not include the local information already on the router's local
+list.
+
+Note that the global list does not include information like nicknames,
+usernames and host names or user's real names. Router does not need to
+keep these informations as they are not needed by the router. This
+information is available from the client's server which maybe queried
+when needed.
+
+Hence, global list includes:
+
+.in 6
+server list - All servers in SILC
+ o Server name
+ o Server ID
+ o Router's Server ID
+
+client list - All clients in SILC
+ o Client ID
+
+channel list - All channels in SILC
+ o Channel ID
+ o Client ID's on channel
+ o Client ID modes on channel
+.in 3
+
+
+
+.ti 0
+3.3.3 Router's Server ID
+
+Router's Server ID's are equivalent to normal Server ID's. As routers
+are normal servers as well same types of ID's applies for routers as well.
+Thus, see section 3.2.2 Server ID.
+
+
+.ti 0
+3.4 Channels
+
+A channel is a named group of one or more clients which will all receive
+messages addressed to that channel. The channel is created when first
+client requests JOIN command to the channel, and the channel ceases to
+exist when the last client has left it. When channel exists, any client
+can reference it using the name of the channel. If the channel has
+a founder mode set and last client leaves the channel the channel does
+not cease to exist. The founder mode can be used to make permanent
+channels in the network. The founder of the channel can regain the
+channel founder privileges on the channel later when he joins the
+channel.
+
+Channel names are unique although the real uniqueness comes from 64 bit
+Channel ID. However, channel names are still unique and no two global
+channels with same name may exist. The channel name is a string of
+maximum length of 256 bytes. Channel names MUST NOT contain any
+whitespaces (` '), any non-printable ASCII characters, commas (`,')
+and wildcard characters.
+
+Channels can have operators that can administrate the channel and
+operate all of its modes. The following operators on channel exist on
+the SILC network.
+
+.in 6
+o Channel founder - When channel is created the joining client becomes
+ channel founder. Channel founder is channel operator with some more
+ privileges. Basically, channel founder can fully operate the channel
+ and all of its modes. The privileges are limited only to the
+ particular channel. There can be only one channel founder per
+ channel. Channel founder supersedes channel operator's privileges.
+
+ Channel founder privileges cannot be removed by any other operator on
+ channel. When channel founder leaves the channel there is no channel
+ founder on the channel. However, it is possible to set a mode for
+ the channel which allows the original channel founder to regain the
+ founder privileges even after leaving the channel. Channel founder
+ also cannot be removed by force from the channel.
+
+o Channel operator - When client joins to channel that has not existed
+ previously it will become automatically channel operator (and channel
+ founder discussed above). Channel operator is able administrate the
+ channel, set some modes on channel, remove a badly behaving client
+ from the channel and promote other clients to become channel
+ operator. The privileges are limited only to the particular channel.
+
+ Normal channel user may be promoted (opped) to channel operator
+ gaining channel operator privileges. Channel founder or other
+ channel operator may also demote (deop) channel operator to normal
+ channel user.
+.in 3
+
+
+.ti 0
+3.4.1 Channel ID
+
+Channels are distinguished from other channels by unique Channel ID.
+The Channel ID is a 64 bit ID (for IPv4) or 160 bit ID (for IPv6), and
+collisions are not expected to happen in any conditions. Channel names
+are just for logical use of channels. The Channel ID is created by the
+server where the channel is created. The Channel ID is defined as
+follows.
+
+.in 6
+64 bit Channel ID based on IPv4 addresses:
+
+32 bit Router's Server ID IP address (bits 1-32)
+16 bit Router's Server ID port (bits 33-48)
+16 bit Random number
+
+160 bit Channel ID based on IPv6 addresses:
+
+128 bit Router's Server ID IP address (bits 1-128)
+ 16 bit Router's Server ID port (bits 129-144)
+ 16 bit Random number
+
+o Router's Server ID IP address - Indicates the IP address of
+ the router of the cell where this channel is created. This is
+ taken from the router's Server ID. This way SILC router knows
+ where this channel resides in the SILC network.
+
+o Router's Server ID port - Indicates the port of the channel on
+ the server. This is taken from the router's Server ID.
+
+o Random number - To further randomize the Channel ID. This makes
+ sure that there are no collisions. This also means that
+ in a cell there can be 2^16 channels.
+.in 3
+
+
+.ti 0
+3.5 Operators
+
+Operators are normal users with extra privileges to their server or
+router. Usually these people are SILC server and router administrators
+that take care of their own server and clients on them. The purpose of
+operators is to administrate the SILC server or router. However, even
+an operator with highest privileges is not able to enter invite-only
+channel, to gain access to the contents of a encrypted and authenticated
+packets traveling in the SILC network or to gain channel operator
+privileges on public channels without being promoted. They have the
+same privileges as everyone else except they are able to administrate
+their server or router.
+
+
+.ti 0
+3.6 SILC Commands
+
+Commands are very important part on SILC network especially for client
+which uses commands to operate on the SILC network. Commands are used
+to set nickname, join to channel, change modes and many other things.
+
+Client usually sends the commands and server replies by sending a reply
+packet to the command. Server MAY also send commands usually to serve
+the original client's request. Usually server cannot send commands to
+clients, however there MAY be commands that allow the server to send
+commands to client. By default servers MAY send commands only to other
+servers and routers.
+
+Note that the command reply is usually sent only after client has sent
+the command request but server is allowed to send command reply packet
+to client even if client has not requested the command. Client MAY
+choose to ignore the command reply.
+
+It is expected that some of the commands may be miss-used by clients
+resulting various problems on the server side. Every implementation
+SHOULD assure that commands may not be executed more than once, say,
+in two (2) seconds. However, to keep response rate up, allowing for
+example five (5) commands before limiting is allowed. It is RECOMMENDED
+that commands such as SILC_COMMAND_NICK, SILC_COMMAND_JOIN,
+SILC_COMMAND_LEAVE and SILC_COMMAND_KILL SHOULD be limited in all cases
+as they require heavy operations. This should be sufficient to prevent
+the miss-use of commands.
+
+SILC commands are described in [SILC4].
+
+
+.ti 0
+3.7 SILC Packets
+
+Packets are naturally the most important part of the protocol and the
+packets are what actually makes the protocol. Packets in SILC network
+are always encrypted using, usually the shared secret session key
+or some other key, for example, channel key, when encrypting channel
+messages. It is not possible to send packet in SILC network without
+encryption. The SILC Packet Protocol is a wide protocol and is described
+in [SILC2]. This document does not define or describe details of
+SILC packets.
+
+
+.ti 0
+3.8 Packet Encryption
+
+All packets passed in SILC network MUST be encrypted. This section
+defines how packets must be encrypted in the SILC network. The detailed
+description of the actual encryption process of the packets are
+described in [SILC2].
+
+Client and its server shares secret symmetric session key which is
+established by the SILC Key Exchange Protocol, described in [SILC3].
+Every packet sent from client to server, with exception of packets for
+channels, are encrypted with this session key.
+
+Channels has a channel key that are shared by every client on the channel.
+However, the channel keys are cell specific thus one cell does not know
+the channel key of the other cell, even if that key is for same channel.
+Channel key is also known by the routers and all servers that has clients
+on the channel. However, channels MAY have channel private keys that
+are entirely local setting for the client. All clients on the channel
+MUST know the channel private key before hand to be able to talk on the
+channel. In this case, no server or router know the key for channel.
+
+Server shares secret symmetric session key with router which is
+established by the SILC Key Exchange Protocol. Every packet passed from
+server to router, with exception of packets for channels, are encrypted
+with the shared session key. Same way, router server shares secret
+symmetric key with its primary route. However, every packet passed
+from router to other router, including packets for channels, are
+encrypted with the shared session key. Every router connection has
+their own session keys.
+
+
+.ti 0
+3.8.1 Determination of the Source and the Destination
+
+The source and the destination of the packet needs to be determined
+to be able to route the packets to correct receiver. This information
+is available in the SILC Packet Header which is included in all packets
+sent in SILC network. The SILC Packet Header is described in [SILC2].
+
+The header MUST be encrypted with the session key who is next receiver
+of the packet along the route. The receiver of the packet, for example
+a router along the route, is able to determine the sender and the
+destination of the packet by decrypting the SILC Packet Header and
+checking the ID's attached to the header. The ID's in the header will
+tell to where the packet needs to be sent and where it is coming from.
+
+The header in the packet MUST NOT change during the routing of the
+packet. The original sender, for example client, assembles the packet
+and the packet header and server or router between the sender and the
+receiver MUST NOT change the packet header. Note however, that some
+packets such as commands may be resent by a server to serve the client's
+original command. In this case the command packet sent by the server
+includes the server's IDs.
+
+Note that the packet and the packet header may be encrypted with
+different keys. For example, packets to channels are encrypted with
+the channel key, however, the header is encrypted with the session key
+as described above. However, the header and the packet may be encrypted
+with same key. This is the case, for example, with command packets.
+
+
+.ti 0
+3.8.2 Client To Client
+
+The process of message delivery and encryption from client to another
+client is as follows.
+
+Example: Private message from client to another client on different
+ servers. Clients do not share private message delivery
+ keys; normal session keys are used.
+
+o Client 1. sends encrypted packet to its server. The packet is
+ encrypted with the session key shared between client and its
+ server.
+
+o Server determines the destination of the packet and decrypts
+ the packet. Server encrypts the packet with session key shared
+ between the server and its router, and sends the packet to the
+ router.
+
+o Router determines the destination of the packet and decrypts
+ the packet. Router encrypts the packet with session key
+ shared between the router and the destination server, and sends
+ the packet to the server.
+
+o Server determines the client to which the packet is destined
+ to and decrypts the packet. Server encrypts the packet with
+ session key shared between the server and the destination client,
+ and sends the packet to the client.
+
+o Client 2. decrypts the packet.
+
+
+Example: Private message from client to another client on different
+ servers. Clients has established secret shared private
+ message delivery key with each other and that is used in
+ the message encryption.
+
+o Client 1. sends encrypted packet to its server. The packet header
+ is encrypted with the session key shared between the client and
+ server, and the private message is encrypted with the private
+ message delivery key shared between clients.
+
+o Server determines the destination of the packet and sends the
+ packet to the router.
+
+o Router determines the destination of the packet and sends the
+ packet to the server.
+
+o Server determines the client to which the packet is destined
+ to and sends the packet to the client.
+
+o Client 2. decrypts the packet with the secret shared key.
+
+If clients share secret key with each other the private message
+delivery is much simpler since servers and routers between the
+clients do not need to decrypt and re-encrypt the packet.
+
+The process for clients on same server is much simpler as there are
+no need to send the packet to the router. The process for clients
+on different cells is same as above except that the packet is routed
+outside the cell. The router of the destination cell routes the
+packet to the destination same way as described above.
+
+
+.ti 0
+3.8.3 Client To Channel
+
+Process of message delivery from client on channel to all the clients
+on the channel.
+
+Example: Channel of four users; two on same server, other two on
+ different cells. Client sends message to the channel.
+
+o Client 1. encrypts the packet with channel key and sends the
+ packet to its server.
+
+o Server determines local clients on the channel and sends the
+ packet to the Client on the same server. Server then sends
+ the packet to its router for further routing.
+
+o Router determines local clients on the channel, if found
+ sends packet to the local clients. Router determines global
+ clients on the channel and sends the packet to its primary
+ router or fastest route.
+
+o (Other router(s) do the same thing and sends the packet to
+ the server(s))
+
+o Server determines local clients on the channel and sends the
+ packet to the client.
+
+o All clients receiving the packet decrypts it.
+
+
+.ti 0
+3.8.4 Server To Server
+
+Server to server packet delivery and encryption is described in above
+examples. Router to router packet delivery is analogous to server to
+server. However, some packets, such as channel packets, are processed
+differently. These cases are described later in this document and
+more in detail in [SILC2].
+
+
+.ti 0
+3.9 Key Exchange And Authentication
+
+Key exchange is done always when for example client connects to server
+but also when server and router, and router and router connects to each
+other. The purpose of key exchange protocol is to provide secure key
+material to be used in the communication. The key material is used to
+derive various security parameters used to secure SILC packets. The
+SILC Key Exchange protocol is described in detail in [SILC3].
+
+Authentication is done after key exchange protocol has been successfully
+completed. The purpose of authentication is to authenticate for example
+client connecting to the server. However, clients may be accepted
+to connect to server without explicit authentication. Servers are
+required to use authentication protocol when connecting. The
+authentication may be based on passphrase (pre-shared-secret) or public
+key based on digital signatures. All passphrases sent in SILC protocol
+MUST be UTF-8 [RFC2279] encoded. The connection authentication protocol
+is described in detail in [SILC3].
+
+
+.ti 0
+3.9.1 Authentication Payload
+
+Authentication payload is used separately from the SKE and the Connection
+Authentication protocol. It can be used during the session to authenticate
+with the remote. For example, the client can authenticate itself to the
+server to become server operator. In this case, Authentication Payload is
+used.
+
+The format of the Authentication Payload is as follows:
+
+.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
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Payload Length | Authentication Method |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Public Data Length | |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
+| |
+~ Public Data ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Authentication Data Length | |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
+| |
+~ Authentication Data ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+.in 3
+
+.ce
+Figure 5: Authentication Payload
+
+
+.in 6
+o Payload Length (2 bytes) - Length of the entire payload.
+
+o Authentication Method (2 bytes) - The method of the
+ authentication. The authentication methods are defined
+ in [SILC2] in the Connection Auth Request Payload. The NONE
+ authentication method SHOULD NOT be used.
+
+o Public Data Length (2 bytes) - Indicates the length of
+ the Public Data field.
+
+o Public Data (variable length) - This is defined only if
+ the authentication method is public key. If it is any other
+ this field MAY include a random data for padding purposes.
+ However, in this case the field MUST be ignored by the
+ receiver.
+
+ When the authentication method is public key this includes
+ 128 to 4096 bytes of non-zero random data that is used in
+ the signature process, described subsequently.
+
+o Authentication Data Length (2 bytes) - Indicates the
+ length of the Authentication Data field. If zero (0)
+ value is found in this field the payload MUST be
+ discarded.
+
+o Authentication Data (variable length) - Authentication
+ method dependent authentication data.
+.in 3
+
+
+If the authentication method is password based, the Authentication
+Data field includes the plaintext UTF-8 encoded password. It is safe
+to send plaintext password since the entire payload is encrypted. In
+this case the Public Data Length is set to zero (0), but MAY also include
+random data for padding purposes. It is also RECOMMENDED that maximum
+amount of padding is applied to SILC packet when using password based
+authentication. This way it is not possible to approximate the length
+of the password from the encrypted packet.
+
+If the authentication method is public key based (or certificate)
+the Authentication Data is computed as follows:
+
+ HASH = hash(random bytes | ID | public key (or certificate));
+ Authentication Data = sign(HASH);
+
+The hash() and the sign() are the hash function and the public key
+cryptography function selected in the SKE protocol, unless otherwise
+stated in the context where this payload is used. The public key
+is SILC style public key unless certificates are used. The ID is the
+entity's ID (Client or Server ID) which is authenticating itself. The
+ID encoding is described in [SILC2]. The random bytes are non-zero
+random bytes of length between 128 and 4096 bytes, and will be included
+into the Public Data field as is.
+
+The receiver will compute the signature using the random data received
+in the payload, the ID associated to the connection and the public key
+(or certificate) received in the SKE protocol. After computing the
+receiver MUST verify the signature. In case of public key authentication
+also this payload is encrypted.
+
+
+.ti 0
+3.10 Algorithms
+
+This section defines all the allowed algorithms that can be used in
+the SILC protocol. This includes mandatory cipher, mandatory public
+key algorithm and MAC algorithms.
+
+
+.ti 0
+3.10.1 Ciphers
+
+Cipher is the encryption algorithm that is used to protect the data
+in the SILC packets. See [SILC2] of the actual encryption process and
+definition of how it must be done. SILC has a mandatory algorithm that
+must be supported in order to be compliant with this protocol.
+
+The following ciphers are defined in SILC protocol:
+
+aes-256-cbc AES in CBC mode, 256 bit key (REQUIRED)
+aes-256-ctr AES in CTR mode, 256 bit key (RECOMMENDED)
+aes-256-rcbc AES in randomized CBC mode, 256 bit key (OPTIONAL)
+aes-192-<mode> AES in <mode> mode, 192 bit key (OPTIONAL)
+aes-128-<mode> AES in <mode> mode, 128 bit key (RECOMMENDED)
+twofish-256-<mode> Twofish in <mode> mode, 256 bit key (OPTIONAL)
+twofish-192-<mode> Twofish in <mode> mode, 192 bit key (OPTIONAL)
+twofish-128-<mode> Twofish in <mode> mode, 128 bit key (OPTIONAL)
+cast-256-<mode> CAST-256 in <mode> mode, 256 bit key (OPTIONAL)
+cast-192-<mode> CAST-256 in <mode> mode, 192 bit key (OPTIONAL)
+cast-128-<mode> CAST-256 in <mode> mode, 128 bit key (OPTIONAL)
+serpent-<len>-<mode> Serpent in <mode> mode, <len> bit key (OPTIONAL)
+rc6-<len>-<mode> RC6 in <mode> mode, <len> bit key (OPTIONAL)
+mars-<len>-<mode> MARS in <mode> mode, <len> bit key (OPTIONAL)
+none No encryption (OPTIONAL)
+
+The <mode> is either "cbc", "ctr" or "rcbc". Other encryption modes MAY
+be defined as to be used in SILC using the same format. The <len> is
+either 256, 192 or 128 bit key length. Also, additional ciphers MAY be
+defined to be used in SILC by using the same name format as above.
+
+Algorithm "none" does not perform any encryption process at all and
+thus is not recommended to be used. It is recommended that no client
+or server implementation would accept none algorithm except in special
+debugging mode.
+
+
+.ti 0
+3.10.1.1 CBC Mode
+
+The "cbc" encryption mode is CBC mode with inter-packet chaining. This
+means that the Initial Vector (IV) for the next encryption block is
+the previous ciphertext block. The very first IV MUST be random and is
+generated as described in [SILC3].
+
+
+.ti 0
+3.10.1.2 CTR Mode
+
+The "ctr" encryption mode is CTR mode. The CTR mode in SILC is stateful
+in encryption and decryption. Both sender and receiver maintain the
+counter for the CTR mode and thus can precompute the key stream for
+encryption and decryption. By default, CTR mode does not require
+plaintext padding, however implementations MAY apply padding to the
+packets. If the last key block is larger than the last plaintext block
+the resulted value is truncated to the size of the plaintext block and
+the most significant bits are used. When sending authentication data
+inside packets the maximum amount of padding SHOULD be applied with
+CTR mode as well.
+
+In CTR mode only the encryption operation of the cipher is used. The
+decryption operation is not needed since both encryption and decryption
+process is simple XOR with the plaintext block and the key stream block.
+
+The counter block is used to create the key for the CTR mode. When
+SILC specifications refer to Initial Vector (IV) in general cases, in
+case of CTR mode it refers to the counter block. The format of the
+128 bit counter block is as follows:
+
+.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
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Truncated HASH from SKE |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Sending/Receiving IV from SKE |
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Block Counter |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+.in 3
+
+.ce
+Figure 6: Counter Block
+
+.in 6
+o Truncated HASH from SKE (4 bytes) - This value is the first 4
+ bytes from the HASH value that was computed as a result of SKE
+ protocol. This acts as session identifier and each rekey MUST
+ produce a new HASH value.
+
+o Sending/Receiving IV from SKE (8 bytes) - This value is the
+ first 8 bytes from the Sending IV or Receiving IV generated in
+ the SKE protocol. When this mode is used to encrypt sending
+ traffic the Sending IV is used, when used to decrypt receiving
+ traffic the Receiving IV is used. This assures that two parties
+ of the protocol use different IV for sending traffic. Each rekey
+ MUST produce a new value.
+
+o Block Counter (4 bytes) - This is the counter value for the
+ counter block and is MSB ordered number starting from one (1)
+ value for first block and incrementing for subsequent blocks.
+ The same value MUST NOT be used twice. The rekey MUST be
+ performed before this counter value wraps.
+.in 3
+
+CTR mode MUST NOT be used with "none" MAC. Implementations also MUST
+assure that the same counter block is not used to encrypt more than
+one block. Also, the key material used with CTR mode MUST be fresh
+key material. Static keys (pre-shared keys) MUST NOT be used with
+CTR mode. For this reason using CTR mode to encrypt for example
+channel messages or private messages with a pre-shared key is
+inappropriate. For private messages, the Key Agreement could be
+performed to produce fresh key material.
+
+If the IV Included flag was negotiated in SKE, implementations SHOULD
+still use the same counter block format as defined above. However,
+implementations are RECOMMENDED to replace the Truncated HASH field
+with a 32 bit random value for each IV (counter block) per encrypted
+SILC packet. Also note, that in this case the decryption process is
+not stateful and receiver cannot precompute the key stream.
+
+
+.ti 0
+3.10.1.3 Randomized CBC Mode
+
+The "rcbc" encryption mode is CBC mode with randomized IV. This means
+that each IV for each packet MUST be chosen randomly. When encrypting
+more than one block the normal inter-packet chaining is used, but for
+the first block new random IV is selected in each packet. In this mode
+the IV is appended at the end of the last ciphertext block and thus
+delivered to the recipient. This mode increases the ciphertext size by
+one ciphertext block. Note also that some data payloads in SILC are
+capable of delivering the IV to the recipient. When explicitly
+encrypting these payloads with randomized CBC the IV MUST NOT be appended
+at the end of the ciphertext. When encrypting these payloads with
+"cbc" mode they implicitly become randomized CBC since the IV is
+usually selected random and included in the ciphertext. In these
+cases using either CBC or randomized CBC is actually equivalent.
+
+
+.ti 0
+3.10.2 Public Key Algorithms
+
+Public keys are used in SILC to authenticate entities in SILC network
+and to perform other tasks related to public key cryptography. The
+public keys are also used in the SILC Key Exchange protocol [SILC3].
+
+The following public key algorithms are defined in SILC protocol:
+
+.in 6
+rsa RSA (REQUIRED)
+dss DSS (OPTIONAL)
+.in 3
+
+DSS is described in [Menezes]. The RSA MUST be implemented according
+PKCS #1 [PKCS1]. The mandatory PKCS #1 implementation in SILC MUST be
+compliant to either PKCS #1 version 1.5 or newer with the following
+notes: The signature encoding is always in same format as the encryption
+encoding regardless of the PKCS #1 version. The signature with appendix
+(with hash algorithm OID in the data) MUST NOT be used in the SILC. The
+rationale for this is that there is no binding between the PKCS #1 OIDs
+and the hash algorithms used in the SILC protocol. Hence, the encoding
+is always in PKCS #1 version 1.5 format.
+
+Additional public key algorithms MAY be defined to be used in SILC.
+
+When signatures are computed in SILC the computing of the signature is
+represented as sign(). The signature computing procedure is dependent
+of the public key algorithm, and the public key or certificate encoding.
+When using SILC public key the signature is computed as described in
+previous paragraph for RSA and DSS keys. If the hash function is not
+specified separately for signing process sha1 MUST be used. When using
+SSH2 public keys the signature is computed as described in [SSH-TRANS].
+When using X.509 version 3 certificates the signature is computed as
+described in [PKCS7]. When using OpenPGP certificates the signature is
+computed as described in [PGP].
+
+
+.ti 0
+3.10.3 Hash Functions
+
+Hash functions are used as part of MAC algorithms defined in the next
+section. They are also used in the SILC Key Exchange protocol defined
+in the [SILC3].
+
+The following Hash algorithm are defined in SILC protocol:
+
+.in 6
+sha1 SHA-1, length = 20 (REQUIRED)
+md5 MD5, length = 16 (RECOMMENDED)
+.in 3
+
+
+
+.ti 0
+3.10.4 MAC Algorithms
+
+Data integrity is protected by computing a message authentication code
+(MAC) of the packet data. See [SILC2] for details how to compute the
+MAC.
+
+The following MAC algorithms are defined in SILC protocol:
+
+.in 6
+hmac-sha1-96 HMAC-SHA1, length = 12 bytes (REQUIRED)
+hmac-md5-96 HMAC-MD5, length = 12 bytes (OPTIONAL)
+hmac-sha1 HMAC-SHA1, length = 20 bytes (OPTIONAL)
+hmac-md5 HMAC-MD5, length = 16 bytes (OPTIONAL)
+none No MAC (OPTIONAL)
+.in 3
+
+The "none" MAC is not recommended to be used as the packet is not
+authenticated when MAC is not computed. It is recommended that no
+client or server would accept none MAC except in special debugging
+mode.
+
+The HMAC algorithm is described in [HMAC] and hash algorithms that
+are used as part of the HMACs are described in [Scheneir] and in
+[Menezes].
+
+Additional MAC algorithms MAY be defined to be used in SILC.
+
+
+.ti 0
+3.10.5 Compression Algorithms
+
+SILC protocol supports compression that may be applied to unencrypted
+data. It is recommended to use compression on slow links as it may
+significantly speed up the data transmission. By default, SILC does not
+use compression which is the mode that must be supported by all SILC
+implementations.
+
+The following compression algorithms are defined:
+
+.in 6
+none No compression (REQUIRED)
+zlib GNU ZLIB (LZ77) compression (OPTIONAL)
+.in 3
+
+Additional compression algorithms MAY be defined to be used in SILC.
+
+
+
+.ti 0
+3.11 SILC Public Key
+
+This section defines the type and format of the SILC public key. All
+implementations MUST support this public key type. See [SILC3] for
+other optional public key and certificate types allowed in the SILC
+protocol. Public keys in SILC may be used to authenticate entities
+and to perform other tasks related to public key cryptography.
+
+The format of the SILC Public Key is as follows:
+
+
+.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
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Public Key Length |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Algorithm Name Length | |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
+| |
+~ Algorithm Name ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| Identifier Length | |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
+| |
+~ Identifier ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+| |
+~ Public Data ~
+| |
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+.in 3
+
+.ce
+Figure 5: SILC Public Key
+
+
+.in 6
+o Public Key Length (4 bytes) - Indicates the full length
+ of the public key, not including this field.
+
+o Algorithm Name Length (2 bytes) - Indicates the length
+ of the Algorithm Length field, not including this field.
+
+o Algorithm name (variable length) - Indicates the name
+ of the public key algorithm that the key is. See the
+ section 3.10.2 Public Key Algorithms for defined names.
+
+o Identifier Length (2 bytes) - Indicates the length of
+ the Identifier field, not including this field.
+
+o Identifier (variable length) - Indicates the identifier
+ of the public key. This data can be used to identify
+ the owner of the key. The identifier is of the following
+ format:
+
+ UN User name
+ HN Host name or IP address
+ RN Real name
+ E EMail address
+ O Organization
+ C Country
+
+
+ Examples of an identifier:
+
+ `UN=priikone, HN=poseidon.pspt.fi, E=priikone@poseidon.pspt.fi'
+
+ `UN=sam, HN=dummy.fi, RN=Sammy Sam, O=Company XYZ, C=Finland'
+
+ At least user name (UN) and host name (HN) MUST be provided as
+ identifier. The fields are separated by commas (`,'). If
+ comma is in the identifier string it must be written as `\\,',
+ for example, `O=Company XYZ\\, Inc.'.
+
+o Public Data (variable length) - Includes the actual
+ public data of the public key.
+
+ The format of this field for RSA algorithm is
+ as follows:
+
+ 4 bytes Length of e
+ variable length e
+ 4 bytes Length of n
+ variable length n
+
+
+ The format of this field for DSS algorithm is
+ as follows:
+
+ 4 bytes Length of p
+ variable length p
+ 4 bytes Length of q
+ variable length q
+ 4 bytes Length of g
+ variable length g
+ 4 bytes Length of y
+ variable length y
+
+ The variable length fields are multiple precession
+ integers encoded as strings in both examples.
+
+ Other algorithms must define their own type of this
+ field if they are used.
+.in 3
+
+All fields in the public key are in MSB (most significant byte first)
+order. All strings in the public key are UTF-8 encoded.
+
+If an external protocol need to refer to SILC Public Key by name, the
+name "silc-rsa" and "silc-dss" for SILC Public Key based on RSA algorithm
+and SILC Public Key based on DSS algorithm, respectively, are to be used.
+However, this SILC specification does not use these names directly, and
+they are defined here for external protocols (protocols that may like
+to use SILC Public Key).
+
+
+.ti 0
+3.12 SILC Version Detection
+
+The version detection of both client and server is performed at the
+connection phase while executing the SILC Key Exchange protocol. The
+version identifier is exchanged between initiator and responder. The
+version identifier is of the following format:
+
+.in 6
+SILC-<protocol version>-<software version>
+.in 3
+
+The version strings are of the following format:
+
+.in 6
+protocol version = <major>.<minor>
+software version = <major>[.<minor>[.<build or vendor string>]]
+.in 3
+
+Protocol version MUST provide both major and minor version. Currently
+implementations MUST set the protocol version and accept at least the
+protocol version as SILC-1.2-<software version>. If new protocol version
+causes incompatibilities with older version the <minor> version number
+MUST be incremented. The <major> is incremented if new protocol version
+is fully incompatible.
+
+Software version MAY provide major, minor and build (vendor) version.
+The software version MAY be freely set and accepted. The version string
+MUST consist of printable US-ASCII characters.
+
+Thus, the version strings could be, for example:
+
+.in 6
+SILC-1.1-2.0.2
+SILC-1.0-1.2
+SILC-1.2-1.0.VendorXYZ
+SILC-1.2-2.4.5 Vendor Limited
+.in 3
+
+
+.ti 0
+3.13 Backup Routers
+
+Backup routers may exist in the cell in addition of the primary router.
+However, they must not be active routers and act as routers in the cell.
+Only one router may be acting as primary router in the cell. In the case
+of failure of the primary router may one of the backup routers become
+active. The purpose of backup routers are in case of failure of the
+primary router to maintain working connections inside the cell and outside
+the cell and to avoid netsplits.
+
+Backup routers are normal servers in the cell that are prepared to take
+over the tasks of the primary router if needed. They need to have at
+least one direct and active connection to the primary router of the cell.
+This communication channel is used to send the router information to
+the backup router. When the backup router connects to the primary router
+of the cell it MUST present itself as router server in the Connection
+Authentication protocol, even though it is normal server as long as the
+primary router is available. Reason for this is that the configuration
+needed in the responder end requires usually router connection level
+configuration. The responder, however must understand and treat the
+connection as normal server (except when feeding router level data to
+the backup router).
+
+Backup router must know everything that the primary router knows to be
+able to take over the tasks of the primary router. It is the primary
+router's responsibility to feed the data to the backup router. If the
+backup router does not know all the data in the case of failure some
+connections may be lost. The primary router of the cell must consider
+the backup router being actual router server when it feeds the data to
+it.
+
+In addition of having direct connection to the primary router of the
+cell, the backup router must also have connection to the same router
+the primary router of the cell is connected. However, it must not be
+active router connection meaning that the backup router must not use
+that channel as its primary route and it must not notify the router
+about having connected servers, channels and clients behind it. It
+merely connects to the router. This sort of connection is later
+referred as being passive connection. Some keepalive actions may be
+needed by the router to keep the connection alive.
+
+It is required that other normal servers have passive connections to
+the backup router(s) in the cell. Some keepalive actions may be needed
+by the server to keep the connection alive. After they notice the
+failure of the primary router they must start using the connection to
+the first backup router as their primary route.
+
+Also, if any other router in the network is using the cell's primary
+router as its own primary router, it must also have passive connection
+to the cell's backup router. It too is prepared to switch to use the
+backup router as its new primary router as soon as the original primary
+router becomes unresponsive.
+
+All of the parties of this protocol knows which one is the backup router
+of the cell from their local configuration. Each of the entity must
+be configured accordingly and care must be taken when configuring the
+backup routers, servers and other routers in the network.
+
+It must be noted that some of the channel messages and private messages
+may be lost during the switch to the backup router. The announcements
+assures that the state of the network is not lost during the switch.
+
+It is RECOMMENDED that there would be at least one backup router in
+the cell. It is NOT RECOMMENDED to have all servers in the cell acting
+as backup routers as it requires establishing several connections to
+several servers in the cell. Large cells can easily have several
+backup routers in the cell.
+
+The order of the backup routers are decided at the configuration phase.
+All the parties of this protocol must be configured accordingly to
+understand the order of the backup routers. It is not required that
+the backup server is actually active server in the cell. Backup router
+may be a spare server in the cell that does not accept normal client
+connections at all. It may be reserved purely for the backup purposes.
+These, however, are cell management issues.
+
+If also the first backup router is down as well and there is another
+backup router in the cell then it will start acting as the primary
+router as described above.
+
+
+.ti 0
+3.13.1 Switching to Backup Router
+
+When the primary router of the cell becomes unresponsive, for example
+by sending EOF to the connection, all the parties of this protocol MUST
+replace the old connection to the primary router with first configured
+backup router. The backup router usually needs to do local modifications
+to its database in order to update all the information needed to maintain
+working routes. The backup router must understand that clients that
+were originated from the primary router are now originated from some of
+the existing server connections and must update them accordingly. It
+must also remove those clients that were owned by the primary router
+since those connections were lost when the primary router became
+unresponsive.
+
+All the other parties of the protocol must also update their local
+database to understand that the route to the primary router will now go
+to the backup router.
+
+Servers connected to the backup router MUST send SILC_PACKET_RESUME_ROUTER
+packet with type number 21, to indicate that the server will start using
+the backup router as primary router. The backup router MUST NOT allow
+this action if it detects that primary is still up and running. If
+backup router knows that primary is up and running it MUST send type
+number 22 back to the server. The server then MUST NOT use the backup
+as primary router, but must try to establish connection back to the
+primary router. If the action is allowed type number 21 is sent back
+to the server from the backup router.
+
+The servers connected to the backup router must then announce their
+clients, channels, channel users, channel user modes and channel modes
+to the backup router. This is to assure that none of the important notify
+packets were lost during the switch to the backup router. The backup
+router must check which of these announced entities it already have
+and distribute the new ones to the primary route.
+
+The backup router too must announce its servers, clients, channels
+and other information to the new primary router. The primary router
+of the backup router too must announce its informations to the backup
+router. Both must process only the ones they do not know about. If
+any of the announced modes does not match then they are enforced in
+normal manner defined later in this specification.
+
+
+.ti 0
+3.13.2 Resuming Primary Router
+
+Usually the primary router is unresponsive only a short period of time
+and it is intended that the original router of the cell will resume
+its position as primary router when it comes back online. The backup
+router that is now acting as primary router of the cell must constantly
+try to connect to the original primary router of the cell. It is
+RECOMMENDED that it would try to reconnect in 30 second intervals to
+the primary router.
+
+When the connection is established to the primary router the backup
+resuming protocol is executed. The protocol is advanced as follows:
+
+ 1. Backup router sends SILC_PACKET_RESUME_ROUTER packet with type
+ value 1 the primary router that came back online. The packet
+ will indicate the primary router has been replaced by the backup
+ router. After sending the packet the backup router will announce
+ all of its channels, channel users, modes etc. to the primary
+ router.
+
+ If the primary knows that it has not been replaced (for example
+ the backup itself disconnected from the primary router and thinks
+ that it is now primary in the cell) the primary router send
+ SILC_PACKET_FAILURE with the type value 1 back to the backup
+ router. If backup receives this it MUST NOT continue with the
+ backup resuming protocol.
+
+ 2. Backup router sends SILC_PACKET_RESUME_ROUTER packet with type
+ value 2 to its current primary router to indicate that it will
+ resign as being primary router. Then, backup router sends the
+ SILC_PACKET_RESUME_ROUTER packet with type value 1 to all
+ connected servers to also indicate that it will resign as being
+ primary router.
+
+ 3. Backup router also send SILC_PACKET_RESUME_ROUTER packet with
+ type value 2 to the router that is using the backup router
+ currently as its primary router.
+
+ 4. Any server and router that receives the SILC_PACKET_RESUME_ROUTER
+ with type value 1 or 2 must reconnect immediately to the
+ primary router of the cell that came back online. After they
+ have created the connection they MUST NOT use that connection
+ as active primary route but still route all packets to the
+ backup router. After the connection is created they MUST send
+ SILC_PACKET_RESUME_ROUTER with type value 3 back to the
+ backup router. The session ID value found in the first packet
+ MUST be set in this packet.
+
+ 5. Backup router MUST wait for all packets with type value 3 before
+ it continues with the protocol. It knows from the session ID values
+ set in the packet when it have received all packets. The session
+ value should be different in all packets it have sent earlier.
+ After the packets is received the backup router sends the
+ SILC_PACKET_RESUME_ROUTER packet with type value 4 to the
+ primary router that came back online. This packet will indicate
+ that the backup router is now ready to resign as being primary
+ router. The session ID value in this packet MUST be the same as
+ in first packet sent to the primary router. During this time
+ the backup router must still route all packets it is receiving
+ from server connections.
+
+ 6. The primary router receives the packet and send the
+ SILC_PACKET_RESUME_ROUTER with type value 5 to all connected servers
+ including the backup router. It also sends the packet with type
+ value 6 to its primary router, and to the router that is using
+ it as its primary router. The Session ID value in this packet
+ SHOULD be zero (0).
+
+ 7. Any server and router that receives the SILC_PACKET_RESUME_ROUTER
+ with type value 5 or 6 must switch their primary route to the
+ new primary router and remove the route for the backup router, since
+ it is not anymore the primary router of the cell. They must also
+ update their local database to understand that the clients are
+ not originated from the backup router but from the locally connected
+ servers. After that they MUST announce their channels, channel
+ users, modes etc. to the primary router. They must not use the
+ backup router connection after this and the connection is considered
+ to be passive connection. The implementations SHOULD be able
+ to disable the connection without closing the actual link.
+
+After this protocol is executed the backup router is now again normal
+server in the cell that has the backup link to the primary router. The
+primary router feeds the router specific data again to the backup router.
+All server connections in the backup router are considered passive
+connections.
+
+When the primary router of the cell comes back online and connects
+to its primary router, the remote primary router must send the
+SILC_PACKET_RESUME_ROUTER with type value 20 indicating that the
+connection is not allowed since the router has been replaced by an
+backup router. The session ID value in this packet SHOULD be zero (0).
+When the router receives this packet it must not use the connection
+as active connection but to understand that it cannot act as primary
+router in the cell. It must wait that the backup router connects to
+it, and the backup resuming protocol is executed.
+
+The following type values has been defined for SILC_PACKET_RESUME_ROUTER
+packet:
+
+ 1 SILC_SERVER_BACKUP_START
+ 2 SILC_SERVER_BACKUP_START_GLOBAL
+ 3 SILC_SERVER_BACKUP_START_CONNECTED
+ 4 SILC_SERVER_BACKUP_START_ENDING
+ 5 SILC_SERVER_BACKUP_START_RESUMED
+ 6 SILC_SERVER_BACKUP_START_RESUMED_GLOBAL
+ 20 SILC_SERVER_BACKUP_START_REPLACED
+ 21 SILC_SERVER_BACKUP_START_USE
+ 22 SILC_SERVER_BACKUP_START_USE_DENIED
+
+If any other value is found in the type field the packet must be
+discarded. The SILC_PACKET_RESUME_ROUTER packet and its payload
+is defined in [SILC2].
+
+
+
+
+.ti 0
+3.13.3 Discussion on Backup Router Scheme
+
+It is clear that this backup router support is not able to handle all
+possible situations arising in unreliable network environment. This
+scheme for example does not handle situation when the router actually
+does not go offline but the network link goes down temporarily. It would
+require some intelligence to figure out when it is best time to switch
+to the backup router. To make it even more complicated it is possible
+that the backup router may have not lost the network link to the primary
+router.
+
+Other possible situation is when the network link is lost temporarily
+between two primary routers in the SILC network. Unless the routers
+notice the link going down they cannot perhaps find alternative routes.
+Worst situation is when the link goes down only for a short period of
+time, thus causing lag. Should the routers or servers find alternative
+routes if they cannot get response from the router during the lag?
+When alternative routes are being found it must be careful not to
+mess up existing primary routes between routers in the network.
+
+It is suggested that the current backup router scheme is only temporary
+solution and existing backup router protocols are studied further. It
+is also suggested that the backup router specification will be separated
+from this SILC specification Internet-Draft and additional specification
+is written on the subject.
+
+
+.ti 0
+4 SILC Procedures
+
+This section describes various SILC procedures such as how the
+connections are created and registered, how channels are created and
+so on. The section describes the procedures only generally as details
+are described in [SILC2] and [SILC3].
+
+
+.ti 0
+4.1 Creating Client Connection
+
+This section describes the procedure when client connects to SILC server.
+When client connects to server the server MUST perform IP address lookup
+and reverse IP address lookup to assure that the origin host really is
+who it claims to be. Client, host, connecting to server SHOULD have
+both valid IP address and fully qualified domain name (FQDN).
+
+After that the client and server performs SILC Key Exchange protocol
+which will provide the key material used later in the communication.
+The key exchange protocol MUST be completed successfully before the
+connection registration may continue. The SILC Key Exchange protocol
+is described in [SILC3].
+
+Typical server implementation would keep a list of connections that it
+allows to connect to the server. The implementation would check, for
+example, the connecting client's IP address from the connection list
+before the SILC Key Exchange protocol has been started. Reason for
+this is that if the host is not allowed to connect to the server there
+is no reason to perform the key exchange protocol.
+
+After successful key exchange protocol the client and server performs
+connection authentication protocol. The purpose of the protocol is to
+authenticate the client connecting to the server. Flexible
+implementation could also accept the client to connect to the server
+without explicit authentication. However, if authentication is
+desired for a specific client it may be based on passphrase or
+public key authentication. If authentication fails the connection
+MUST be terminated. The connection authentication protocol is described
+in [SILC3].
+
+After successful key exchange and authentication protocol the client
+registers itself by sending SILC_PACKET_NEW_CLIENT packet to the
+server. This packet includes various information about the client
+that the server uses to create the client. Server creates the client
+and sends SILC_PACKET_NEW_ID to the client which includes the created
+Client ID that the client MUST start using after that. After that
+all SILC packets from the client MUST have the Client ID as the
+Source ID in the SILC Packet Header, described in [SILC2].
+
+Client MUST also get the server's Server ID that is to be used as
+Destination ID in the SILC Packet Header when communicating with
+the server (for example when sending commands to the server). The
+ID may be resolved in two ways. Client can take the ID from an
+previously received packet from server that MUST include the ID,
+or to send SILC_COMMAND_INFO command and receive the Server ID as
+command reply.
+
+Server MAY choose not to use the information received in the
+SILC_PACKET_NEW_CLIENT packet. For example, if public key or
+certificate were used in the authentication, server MAY use those
+informations rather than what it received from client. This is suitable
+way to get the true information about client if it is available.
+
+The nickname of client is initially set to the username sent in the
+SILC_PACKET_NEW_CLIENT packet. User should set the nickname to more
+suitable by sending SILC_COMMAND_NICK command. However, this is not
+required as part of registration process.
+
+Server MUST also distribute the information about newly registered
+client to its router (or if the server is router, to all routers in
+the SILC network). More information about this in [SILC2].
+
+Router server MUST also check whether some client in the local cell
+is watching for the nickname this new client has, and send the
+SILC_NOTIFY_TYPE_WATCH to the watcher.
+
+
+.ti 0
+4.2 Creating Server Connection
+
+This section describes the procedure when server connects to its
+router (or when router connects to other router, the cases are
+equivalent). The procedure is very much alike when client connects
+to the server thus it is not repeated here.
+
+One difference is that server MUST perform connection authentication
+protocol with proper authentication. A proper authentication is based
+on passphrase authentication or public key authentication based on
+digital signatures.
+
+After server and router has successfully performed the key exchange
+and connection authentication protocol, the server register itself
+to the router by sending SILC_PACKET_NEW_SERVER packet. This packet
+includes the server's Server ID that it has created by itself and
+other relevant information about the server.
+
+After router has received the SILC_PACKET_NEW_SERVER packet it
+distributes the information about newly registered server to all routers
+in the SILC network. More information about this in [SILC2].
+
+As client needed to resolve the destination ID this MUST be done by the
+server that connected to the router, as well. The way to resolve it is
+to get the ID from previously received packet. The server MAY also
+use SILC_COMMAND_INFO command to resolve the ID. Server MUST also start
+using its own Server ID as Source ID in SILC Packet Header and the
+router's Server ID as Destination when communicating with the router.
+
+
+.ti 0
+4.2.1 Announcing Clients, Channels and Servers
+
+After server or router has connected to the remote router, and it already
+has connected clients and channels it MUST announce them to the router.
+If the server is router server, also all the local servers in the cell
+MUST be announced.
+
+All clients are announced by compiling a list of ID Payloads into the
+SILC_PACKET_NEW_ID packet. All channels are announced by compiling a
+list of Channel Payloads into the SILC_PACKET_NEW_CHANNEL packet.
+Channels' mode and founder public key and other channel mode specific
+data is announced by sending SILC_NOTIFY_TYPE_CMODE_CHANGE notify list.
+Also, the channel users on the channels must be announced by compiling a
+list of Notify Payloads with the SILC_NOTIFY_TYPE_JOIN notify type into
+the SILC_PACKET_NOTIFY packet. The users' modes on the channel must
+also be announced by compiling list of Notify Payloads with the
+SILC_NOTIFY_TYPE_CUMODE_CHANGE notify type into the SILC_PACKET_NOTIFY
+packet.
+
+The router MUST also announce the local servers by compiling list of
+ID Payloads into the SILC_PACKET_NEW_ID packet.
+
+Also, clients' modes (user modes in SILC) MUST be announced. This is
+done by compiling a list of Notify Payloads with SILC_NOTIFY_UMODE_CHANGE
+notify type into the SILC_PACKET_NOTIFY packet. Also, channel's topics
+MUST be announced by compiling a list of Notify Payloads with the
+SILC_NOTIFY_TOPIC_SET notify type into the SILC_PACKET_NOTIFY packet.
+
+The router which receives these lists MUST process them and broadcast
+the packets to its primary route. When processing the announced channels
+and channel users the router MUST check whether a channel exists already
+with the same name. If channel exists with the same name it MUST check
+whether the Channel ID is different. If the Channel ID is different the
+router MUST send the notify type SILC_NOTIFY_TYPE_CHANNEL_CHANGE to the
+server to force the channel ID change to the ID the router has. If the
+mode of the channel is different the router MUST send the notify type
+SILC_NOTIFY_TYPE_CMODE_CHANGE to the server to force the mode change
+to the mode that the router has.
+
+The router MUST also generate new channel key and distribute it to the
+channel. The key MUST NOT be generated if the SILC_CMODE_PRIVKEY mode
+is set.
+
+If the channel has channel founder on the router the router MUST send
+the notify type SILC_NOTIFY_TYPE_CUMODE_CHANGE to the server to force
+the mode change for the channel founder on the server. The channel
+founder privileges MUST be removed.
+
+The router processing the channels MUST also compile a list of
+Notify Payloads with the SILC_NOTIFY_TYPE_JOIN notify type into the
+SILC_PACKET_NOTIFY and send the packet to the server. This way the
+server (or router) will receive the clients on the channel that
+the router has.
+
+
+.ti 0
+4.3 Joining to a Channel
+
+This section describes the procedure when client joins to a channel.
+Client joins to channel by sending command SILC_COMMAND_JOIN to the
+server. If the receiver receiving join command is normal server the
+server MUST check its local list whether this channel already exists
+locally. This would indicate that some client connected to the server
+has already joined to the channel. If this is case the client is
+joined to the channel, new channel key is created and information about
+newly joined channel is sent to the router. The router is informed
+by sending SILC_NOTIFY_TYPE_JOIN notify type. The notify type MUST
+also be sent to the local clients on the channel. The new channel key
+is also sent to the router and to local clients on the channel.
+
+If the channel does not exist in the local list the client's command
+MUST be sent to the router which will then perform the actual joining
+procedure. When server receives the reply to the command from the
+router it MUST be sent to the client which sent the command originally.
+Server will also receive the channel key from the server that it MUST
+send to the client which originally requested the join command. The
+server MUST also save the channel key.
+
+If the receiver of the join command is router it MUST first check its
+local list whether anyone in the cell has already joined to the channel.
+If this is the case the client is joined to the channel and reply is
+sent to the client. If the command was sent by server the command reply
+is sent to the server which sent it. Then the router MUST also create
+new channel key and distribute it to all clients on the channel and
+all servers that has clients on the channel. Router MUST also send
+the SILC_NOTIFY_TYPE_JOIN notify type to local clients on the channel
+and to local servers that has clients on the channel.
+
+If the channel does not exist on the router's local list it MUST
+check the global list whether the channel exists at all. If it does
+the client is joined to the channel as described previously. If
+the channel does not exist the channel is created and the client
+is joined to the channel. The channel key is also created and
+distributed as previously described. The client joining to the created
+channel is made automatically channel founder and both channel founder
+and channel operator privileges is set for the client.
+
+If the router created the channel in the process, information about the
+new channel MUST be broadcasted to all routers. This is done by
+broadcasting SILC_PACKET_NEW_CHANNEL packet to the router's primary
+route. When the router joins the client to the channel it MUST also
+send information about newly joined client to all routers in the SILC
+network. This is done by broadcasting the SILC_NOTIFY_TYPE_JOIN notify
+type to the router's primary route.
+
+It is important to note that new channel key is created always when
+new client joins to channel, whether the channel has existed previously
+or not. This way the new client on the channel is not able to decrypt
+any of the old traffic on the channel. Client which receives the reply to
+the join command MUST start using the received Channel ID in the channel
+message communication thereafter. Client also receives the key for the
+channel in the command reply. Note that the channel key is never
+generated if the SILC_CMODE_PRIVKEY mode is set.
+
+
+.ti 0
+4.4 Channel Key Generation
+
+Channel keys are created by router which creates the channel by taking
+enough randomness from cryptographically strong random number generator.
+The key is generated always when channel is created, when new client
+joins a channel and after the key has expired. Key could expire for
+example in an hour.
+
+The key MUST also be re-generated whenever some client leaves a channel.
+In this case the key is created from scratch by taking enough randomness
+from the random number generator. After that the key is distributed to
+all clients on the channel. However, channel keys are cell specific thus
+the key is created only on the cell where the client, which left the
+channel, exists. While the server or router is creating the new channel
+key, no other client may join to the channel. Messages that are sent
+while creating the new key are still processed with the old key. After
+server has sent the SILC_PACKET_CHANNEL_KEY packet MUST client start
+using the new key. If server creates the new key the server MUST also
+send the new key to its router. See [SILC2] on more information about
+how channel messages must be encrypted and decrypted when router is
+processing them.
+
+When client receives the SILC_PACKET_CHANNEL_KEY packet with the
+Channel Key Payload it MUST process the key data to create encryption
+and decryption key, and to create the HMAC key that is used to compute
+the MACs of the channel messages. The processing is as follows:
+
+ channel_key = raw key data
+ HMAC key = hash(raw key data)
+
+The raw key data is the key data received in the Channel Key Payload.
+The hash() function is the hash function used in the HMAC of the channel.
+Note that the server also MUST save the channel key.
+
+
+.ti 0
+4.5 Private Message Sending and Reception
+
+Private messages are sent point to point. Client explicitly destine
+a private message to specific client that is delivered to only to that
+client. No other client may receive the private message. The receiver
+of the private message is destined in the SILC Packet Header as any
+other packet as well.
+
+If the sender of a private message does not know the receiver's Client
+ID, it MUST resolve it from server. There are two ways to resolve the
+client ID from server; it is RECOMMENDED that client implementations
+send SILC_COMMAND_IDENTIFY command to receive the Client ID. Client
+MAY also send SILC_COMMAND_WHOIS command to receive the Client ID.
+If the sender has received earlier a private message from the receiver
+it should have cached the Client ID from the SILC Packet Header.
+
+If server receives a private message packet which includes invalid
+destination Client ID the server MUST send SILC_NOTIFY_TYPE_ERROR
+notify to the client with error status indicating that such Client ID
+does not exist.
+
+See [SILC2] for description of private message encryption and decryption
+process.
+
+
+.ti 0
+4.6 Private Message Key Generation
+
+Private message MAY be protected with a key generated by the client.
+The key may be generated and sent to the other client by sending packet
+SILC_PACKET_PRIVATE_MESSAGE_KEY which travels through the network
+and is secured by session keys. After that the private message key
+is used in the private message communication between those clients.
+The key sent inside the payload SHOULD be randomly generated. This
+packet MUST NOT be used to send pre-shared keys.
+
+Other choice is to entirely use keys that are not sent through
+the SILC network at all. This significantly adds security. This key
+could be a pre-shared-key that is known by both of the clients. Both
+agree about using the key and starts sending packets that indicate
+that the private message is secured using private message key. In
+case of pre-shared keys (static keys) the IV used in encryption SHOULD
+be chosen randomly.
+
+It is also possible to negotiate fresh key material by performing
+Key Agreement. The SILC_PACKET_KEY_AGREEMENT packet MAY be used to
+negotiate the fresh key material. In this case the resulted key
+material is used to secure the private messages. Also, the IV used
+in encryption is used as defined in [SILC3], unless otherwise stated
+by the encryption mode used. By performing Key Agreement the clients
+may negotiate the cipher and HMAC to be used in the private message
+encryption and to negotiate additional security parameters.
+
+If the key is pre-shared key or other key material not generated by
+Key Agreement, then the key material SHOULD be processed as defined
+in [SILC3]. The hash function to be used SHOULD be SHA1. In the
+processing, however, the HASH, as defined in [SILC3] MUST be ignored.
+After processing the key material it is employed as defined in [SILC3].
+In this case also, implementations SHOULD use the SILC protocol's
+mandatory cipher and HMAC in private message encryption.
+
+
+.ti 0
+4.7 Channel Message Sending and Reception
+
+Channel messages are delivered to group of users. The group forms a
+channel and all clients on the channel receives messages sent to the
+channel.
+
+Channel messages are destined to channel by specifying the Channel ID
+as Destination ID in the SILC Packet Header. The server MUST then
+distribute the message to all clients on the channel by sending the
+channel message destined explicitly to a client on the channel.
+
+If server receives a channel message packet which includes invalid
+destination Channel ID the server MUST send SILC_NOTIFY_TYPE_ERROR
+notify to the sender with error status indicating that such Channel ID
+does not exist.
+
+See the [SILC2] for description of channel message routing for router
+servers, and channel message encryption and decryption process.
+
+
+.ti 0
+4.8 Session Key Regeneration
+
+Session keys MUST be regenerated periodically, say, once in an hour.
+The re-key process is started by sending SILC_PACKET_REKEY packet to
+other end, to indicate that re-key must be performed. The initiator
+of the connection SHOULD initiate the re-key.
+
+If perfect forward secrecy (PFS) flag was selected in the SILC Key
+Exchange protocol [SILC3] the re-key MUST cause new key exchange with
+SKE protocol. In this case the protocol is secured with the old key
+and the protocol results to new key material. See [SILC3] for more
+information. After the SILC_PACKET_REKEY packet is sent the sender
+will perform the SKE protocol.
+
+If PFS flag was set the resulted key material is processed as described
+in the section Processing the Key Material in [SILC3]. The difference
+with re-key in the processing is that the initial data for the hash
+function is just the resulted key material and not the HASH as it
+is not computed at all with re-key. Other than that, the key processing
+it equivalent to normal SKE negotiation.
+
+If PFS flag was not set, which is the default case, then re-key is done
+without executing SKE protocol. In this case, the new key is created by
+providing the current sending encryption key to the SKE protocol's key
+processing function. The process is described in the section Processing
+the Key Material in [SILC3]. The difference in the processing is that
+the initial data for the hash function is the current sending encryption
+key and not the SKE's KEY and HASH values. Other than that, the key
+processing is equivalent to normal SKE negotiation.
+
+After both parties has regenerated the session key, both MUST send
+SILC_PACKET_REKEY_DONE packet to each other. These packets are still
+secured with the old key. After these packets, the subsequent packets
+MUST be protected with the new key.
+
+
+.ti 0
+4.9 Command Sending and Reception
+
+Client usually sends the commands in the SILC network. In this case
+the client simply sends the command packet to server and the server
+processes it and replies with command reply packet. See the [SILC3]
+for detailed description of all commands.
+
+However, if the server is not able to process the command, it is sent
+to the server's router. This is case for example with commands such
+as, SILC_COMMAND_JOIN and SILC_COMMAND_WHOIS commands. However, there
+are other commands as well. For example, if client sends the WHOIS
+command requesting specific information about some client the server must
+send the WHOIS command to router so that all clients in SILC network
+are searched. The router, on the other hand, sends the WHOIS command
+further to receive the exact information about the requested client.
+The WHOIS command travels all the way to the server which owns the client
+and it replies with command reply packet. Finally, the server which
+sent the command receives the command reply and it must be able to
+determine which client sent the original command. The server then
+sends command reply to the client. Implementations should have some
+kind of cache to handle, for example, WHOIS information. Servers
+and routers along the route could all cache the information for faster
+referencing in the future.
+
+The commands sent by server may be sent hop by hop until someone is able
+to process the command. However, it is preferred to destine the command
+as precisely as it is possible. In this case, other routers en route
+MUST route the command packet by checking the true sender and true
+destination of the packet. However, servers and routers MUST NOT route
+command reply packets to clients coming from other server. Client
+MUST NOT accept command reply packet originated from anyone else but
+from its own server.
+
+
+
+.ti 0
+4.10 Closing Connection
+
+When remote client connection is closed the server MUST send the notify
+type SILC_NOTIFY_TYPE_SIGNOFF to its primary router and to all channels
+the client was joined. The server MUST also save the client's information
+for a period of time for history purposes.
+
+When remote server or router connection is closed the server or router
+MUST also remove all the clients that was behind the server or router
+from the SILC Network. The server or router MUST also send the notify
+type SILC_NOTIFY_TYPE_SERVER_SIGNOFF to its primary router and to all
+local clients that are joined on the same channels with the remote
+server's or router's clients.
+
+Router server MUST also check whether some client in the local cell
+is watching for the nickname this client has, and send the
+SILC_NOTIFY_TYPE_WATCH to the watcher, unless the client which left
+the network has the SILC_UMODE_REJECT_WATCHING user mode set.
+
+
+.ti 0
+4.11 Detaching and Resuming a Session
+
+SILC protocol provides a possibility for a client to detach itself from
+the network without actually signing off from the network. The client
+connection to the server is closed but the client remains as valid client
+in the network. The client may then later resume its session back from
+any server in the network.
+
+When client wishes to detach from the network it MUST send the
+SILC_COMMAND_DETACH command to its server. The server then MUST set
+SILC_UMODE_DETACHED mode to the client and send SILC_NOTIFY_UMODE_CHANGE
+notify to its primary router, which will then MUST broadcast it further
+to other routers in the network. This user mode indicates that the
+client is detached from the network. Implementations MUST NOT use
+the SILC_UMODE_DETACHED flag to determine whether a packet can be sent
+to the client. All packets MUST still be sent to the client even if
+client is detached from the network. Only the server that originally
+had the active client connection is able to make the decision after it
+notices that the network connection is not active. In this case the
+default case is to discard the packet.
+
+The SILC_UMODE_DETACHED flag cannot be set by client itself directly
+with SILC_COMMAND_UMODE command, but only implicitly by sending the
+SILC_COMMAND_DETACH command. The flag also cannot be unset by the
+client, server or router with SILC_COMMAND_UMODE command, but only
+implicitly by sending and receiving the SILC_PACKET_RESUME_CLIENT
+packet.
+
+When the client wishes to resume its session in the SILC Network it
+connects to a server in the network, which MAY also be a different
+from the original server, and performs normal procedures regarding
+creating a connection as described in section 4.1. After the SKE
+and the Connection Authentication protocols has been successfully
+completed the client MUST NOT send SILC_PACKET_NEW_CLIENT packet, but
+MUST send SILC_PACKET_RESUME_CLIENT packet. This packet is used to
+perform the resuming procedure. The packet MUST include the detached
+client's Client ID, which the client must know. It also includes
+Authentication Payload which includes signature made with the client's
+private key. The signature is computed as defined in the section
+3.9.1. Thus, the authentication method MUST be based in public key
+authentication.
+
+When server receives the SILC_PACKET_RESUME_CLIENT packet it MUST
+do the following: Server checks that the Client ID is valid client
+and that it has the SILC_UMODE_DETACHED mode set. Then it verifies
+the Authentication Payload with the detached client's public key.
+If it does not have the public key it retrieves it by sending
+SILC_COMMAND_GETKEY command to the server that has the public key from
+the original client connection. The server MUST NOT use the public
+key received in the SKE protocol for this connection. If the
+signature is valid the server unsets the SILC_UMODE_DETACHED flag,
+and sends the SILC_PACKET_RESUME_CLIENT packet to its primary router.
+The routers MUST broadcast the packet and unset the SILC_UMODE_DETACHED
+flag when the packet is received. If the server is router server it
+also MUST send the SILC_PACKET_RESUME_CLIENT packet to the original
+server whom owned the detached client.
+
+The servers and routers that receives the SILC_PACKET_RESUME_CLIENT
+packet MUST know whether the packet already has been received for
+the client. It is protocol error to attempt to resume the client
+session from more than one server. The implementations could set
+internal flag that indicates that the client is resumed. If router
+receive SILC_PACKET_RESUME_CLIENT packet for client that is already
+resumed the client MUST be killed from the network. This would
+indicate that the client is attempting to resume the session more
+than once which is protocol error. In this case the router sends
+SILC_NOTIFY_TYPE_KILLED to the client. All routers that detect
+the same situation MUST also send the notify for the client.
+
+The servers and routers that receive the SILC_PACKET_RESUME_CLIENT
+must also understand that the client may not be found behind the
+same server that it originally came from. They must update their
+caches according this. The server that now owns the client session
+MUST check whether the Client ID of the resumed client is based
+on the server's Server ID. If it is not it creates a new Client
+ID and send SILC_NOTIFY_TYPE_NICK_CHANGE to the network. It MUST
+also send the channel keys of all channels that the client is
+joined to the client since it does not have them. Whether the
+Client ID was changed or not the server MUST send SILC_PACKET_NEW_ID
+packet to the client. Only after this the client is resumed back
+to the network and may start sending packets and messages.
+
+It is also possible that the server does not know about the channels
+that the client has joined. In this case it join the client internally
+to the channels, generate new channel keys and distribute the keys
+to the channels as described in section 4.4.
+
+It is implementation issue for how long servers keep detached client
+sessions. It is RECOMMENDED that the detached sessions would be
+persistent as long as the server is running.
+
+
+.ti 0
+5 Security Considerations
+
+Security is central to the design of this protocol, and these security
+considerations permeate the specification. Common security considerations
+such as keeping private keys truly private and using adequate lengths for
+symmetric and asymmetric keys must be followed in order to maintain the
+security of this protocol.
+
+Special attention must also be paid on the servers and routers that are
+running the SILC service. The SILC protocol's security depends greatly
+on the security and the integrity of the servers and administrators that
+are running the service. It is recommended that some form of registration
+is required by the server and router administrator prior acceptance to
+the SILC Network. Even though, the SILC protocol is secure in a network
+of mutual distrust between clients, servers, routers and administrators
+of the servers, the client should be able to trust the servers they are
+using if they wish to do so.
+
+It however must be noted that if the client requires absolute security
+by not trusting any of the servers or routers in the SILC Network, it can
+be accomplished by negotiating private keys outside the SILC Network,
+either using SKE or some other key exchange protocol, or to use some
+other external means for distributing the keys. This applies for all
+messages, private messages and channel messages.
+
+It is important to note that SILC, like any other security protocol is
+not full proof system; the SILC servers and routers could very well be
+compromised. However, to provide acceptable level of security and
+usability for end user the protocol use many times session keys or other
+keys generated by the servers to secure the messages. This is
+intentional design feature to allow ease of use for end user. This way
+the network is still usable, and remains encrypted even if the external
+means of distributing the keys is not working. The implementation,
+however, may like to not follow this design feature, and always negotiate
+the keys outside SILC network. This is acceptable solution and many times
+recommended. The implementation still must be able to work with the
+server generated keys.
+
+If this is unacceptable for the client or end user, the private keys
+negotiated outside the SILC Network should always be used. In the end
+it is always implementor's choice whether to negotiate private keys by
+default or whether to use the keys generated by the servers.
+
+It is also recommended that router operators in the SILC Network would
+form a joint forum to discuss the router and SILC Network management
+issues. Also, router operators along with the cell's server operators
+should have a forum to discuss the cell management issues.
+
+
+.ti 0
+6 References
+
+[SILC2] Riikonen, P., "SILC Packet Protocol", Internet Draft,
+ May 2002.
+
+[SILC3] Riikonen, P., "SILC Key Exchange and Authentication
+ Protocols", Internet Draft, May 2002.
+
+[SILC4] Riikonen, P., "SILC Commands", Internet Draft, May 2002.
+
+[IRC] Oikarinen, J., and Reed D., "Internet Relay Chat Protocol",
+ RFC 1459, May 1993.
+
+[IRC-ARCH] Kalt, C., "Internet Relay Chat: Architecture", RFC 2810,
+ April 2000.
+
+[IRC-CHAN] Kalt, C., "Internet Relay Chat: Channel Management", RFC
+ 2811, April 2000.
+
+[IRC-CLIENT] Kalt, C., "Internet Relay Chat: Client Protocol", RFC
+ 2812, April 2000.
+
+[IRC-SERVER] Kalt, C., "Internet Relay Chat: Server Protocol", RFC
+ 2813, April 2000.
+
+[SSH-TRANS] Ylonen, T., et al, "SSH Transport Layer Protocol",
+ Internet Draft.
+
+[PGP] Callas, J., et al, "OpenPGP Message Format", RFC 2440,
+ November 1998.
+
+[SPKI] Ellison C., et al, "SPKI Certificate Theory", RFC 2693,
+ September 1999.
+
+[PKIX-Part1] Housley, R., et al, "Internet X.509 Public Key
+ Infrastructure, Certificate and CRL Profile", RFC 2459,
+ January 1999.
+
+[Schneier] Schneier, B., "Applied Cryptography Second Edition",
+ John Wiley & Sons, New York, NY, 1996.
+
+[Menezes] Menezes, A., et al, "Handbook of Applied Cryptography",
+ CRC Press 1997.
+
+[OAKLEY] Orman, H., "The OAKLEY Key Determination Protocol",
+ RFC 2412, November 1998.
+
+[ISAKMP] Maughan D., et al, "Internet Security Association and
+ Key Management Protocol (ISAKMP)", RFC 2408, November
+ 1998.
+
+[IKE] Harkins D., and Carrel D., "The Internet Key Exchange
+ (IKE)", RFC 2409, November 1998.
+
+[HMAC] Krawczyk, H., "HMAC: Keyed-Hashing for Message
+ Authentication", RFC 2104, February 1997.
+
+[PKCS1] Kalinski, B., and Staddon, J., "PKCS #1 RSA Cryptography
+ Specifications, Version 2.0", RFC 2437, October 1998.
+
+[RFC2119] Bradner, S., "Key Words for use in RFCs to Indicate
+ Requirement Levels", BCP 14, RFC 2119, March 1997.
+
+[RFC2279] Yergeau, F., "UTF-8, a transformation format of ISO
+ 10646", RFC 2279, January 1998.
+
+[PKCS7] Kalinski, B., "PKCS #7: Cryptographic Message Syntax,
+ Version 1.5", RFC 2315, March 1998.
+
+
+.ti 0
+7 Author's Address
+
+.nf
+Pekka Riikonen
+Snellmaninkatu 34 A 15
+70100 Kuopio
+Finland
+
+EMail: priikone@iki.fi
+
+This Internet-Draft expires XXX
#
# The authentication data is specified by Passphrase and/or PublicKey.
# If both are provided then both password and public key based authentication
-# is allowed. If the Publickey is used it includes the file path to the
-# public key file. If none of them is provided then authentication is not
-# required. The PublicKey can be set multiple times to set multiple
-# public keys for one connection.
+# is allowed. The "PublicKey" includes the single key contained in the
+# specified file, while "PublicKeyDir" includes all files in the specified
+# directory, which must all be valid public keys with ".pub" suffix.
#
# Next example connection will match to all incoming client connections,
# and no authentication is required.
Client {
#Host = "10.1.*";
#Passphrase = "secret";
- #PublicKey = "/path/to/the/user_my.key";
- #PublicKey = "/path/to/the/user_221.key";
- #PublicKey = "/path/to/the/user_313.key";
+ #PublicKey = "/path/to/the/user_my.pub";
+ #PublicKey = "/path/to/the/user_221.pub";
+ #PublicKey = "/path/to/the/user_313.pub";
+ #PublicKeyDir = "/path/to/keys/dir/";
Params = "normal";
};
User = "priikone";
Nick = "pekka";
Passphrase = "verysecret";
- # PublicKey = "/path/to/the/public.key";
+ # PublicKey = "/path/to/the/public.pub";
};
#
ServerConnection {
Host = "10.2.1.7";
Passphrase = "verysecret";
- #PublicKey = "/path/to/the/public.key";
+ #PublicKey = "/path/to/the/public.pub";
Params = "normal";
Backup = false;
};
Host = "10.2.1.100";
Port = 706;
Passphrase = "verysecret";
- #PublicKey = "/path/to/the/public.key";
+ #PublicKey = "/path/to/the/public.pub";
Params = "normal";
Initiator = true;
#BackupHost = "10.2.1.6";
-manpage(SILC) (1) (October 31 2002) (silc-client-0.9.7) (silc-client)
+manpage(SILC) (1) (December 7 2002) (silc-client) (silc-client)
manpagename(silc) (client for SILC, a secure and flexible conferencing network)
using easier for new users.
bf(Silc) supports sending of practically any kind of messages in addition
-of normal text messages in the SILC network. The session to SILC server
+of normal text messages in the SILC network. This includes multimedia
+messages like images, video and audio stream. The session to SILC server
is secured with session key, channel messages are protected with channel
key and private messages with session keys. It is also possible to use
private channel keys and private message keys in addition to server
-generated keys.
+generated keys. It is also possible to digitally sign all messages.
bf(Silc) supports em(passphrase) authentication and public key authentication
based on em(digital signatures), when connecting to SILC server. bf(Silc)
-manpage(SILCD_CONF) (5) (November 2 2002) (silc-server-0.9.7.1) (silc-server)
+manpage(SILCD_CONF) (5) (November 2 2002) (silc-server) (silc-server)
manpagename(silcd.conf) (format of configuration file for silcd)
-manpage(SILCD) (8) (October 31 2002) (silc-server-0.9.7.1) (silc-server)
+manpage(SILCD) (8) (October 31 2002) (silc-server) (silc-server)
manpagename(silcd) (SILC server)
#endif
#endif
+# Some winsock compatiblity requirements
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x400
+#else
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x400
+#endif /* _WIN32_WINNT */
+#if !defined(SO_SYNCHRONOUS_NONALERT)
+#define SO_SYNCHRONOUS_NONALERT 0x20
+#endif
+#if !defined(SO_OPENTYPE)
+#define SO_OPENTYPE 0x7008
+#endif
+
#undef inline
#define inline __inline
-rm -rf libsilc.a
-rm -rf libsilcclient.a
+if SILC_DIST_TOOLKIT
+install-exec-hook:
+ -mkdir -p $(DESTDIR)$(libdir)
+ -$(LIBTOOL) $(INSTALL) libsilc.la $(DESTDIR)$(libdir)/
+ -$(LIBTOOL) $(INSTALL) libsilcclient.la $(DESTDIR)$(libdir)/
+else
install-exec-hook:
-mkdir -p $(libdir)
- -$(LIBTOOL) $(INSTALL) libsilc.la $(libdir)/
- -$(LIBTOOL) $(INSTALL) libsilcclient.la $(libdir)/
+ -$(LIBTOOL) $(INSTALL) libsilc.la $(DESTDIR)$(libdir)/
+ -rm -rf $(DESTDIR)$(libdir)/libsilc.a
+if SILC_DIST_CLIENT
+ -$(LIBTOOL) $(INSTALL) libsilcclient.la $(DESTDIR)$(libdir)/
+ -rm -rf $(DESTDIR)$(libdir)/libsilcclient.a
+endif
+endif
if SILC_DIST_WIN32DLL
# WIN32 DLL generation
-mno-cygwin -o silcclient.dll libsilcclient.a -L. -lsilc -lwsock32
endif
+LIB_BASE_VERSION=@LIB_BASE_VERSION@
+LIBSILC_CURRENT=@LIBSILC_CURRENT@
+LIBSILC_REVISION=@LIBSILC_REVISION@
+LIBSILC_AGE=@LIBSILC_AGE@
+LIBSILCCLIENT_CURRENT=@LIBSILCCLIENT_CURRENT@
+LIBSILCCLIENT_REVISION=@LIBSILCCLIENT_REVISION@
+LIBSILCCLIENT_AGE=@LIBSILCCLIENT_AGE@
+
libsilc.a:
find $(SILCLIB_DIRS) -type f -name *.lo | xargs \
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) \
- -rpath $(libdir) -o libsilc.la
+ -version-info $(LIBSILC_CURRENT):$(LIBSILC_REVISION):$(LIBSILC_AGE) \
+ -release $(LIB_BASE_VERSION) -rpath $(DESTDIR)$(libdir) -o libsilc.la
libsilcclient.a:
find $(SILCCLIENTLIB_DIRS) -type f -name *.lo | xargs \
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) \
- -rpath $(libdir) -o libsilcclient.la
+ -version-info $(LIBSILCCLIENT_CURRENT):$(LIBSILCCLIENT_REVISION):$(LIBSILCCLIENT_AGE) \
+ -release $(LIB_BASE_VERSION) -rpath $(DESTDIR)$(libdir) -o libsilcclient.la
if SILC_DIST_TOOLKIT
SILC_EXTRA_DIST = doc
--- /dev/null
+Makefile
+Makefile.in
{
SilcClientConnection conn = (SilcClientConnection)context;
SilcClient client = conn->client;
-
- silc_client_command_send(client, conn, SILC_COMMAND_NICK,
- ++conn->cmd_ident, 1, 1,
- client->nickname, strlen(client->nickname));
+ if (client)
+ silc_client_command_send(client, conn, SILC_COMMAND_NICK,
+ ++conn->cmd_ident, 1, 1,
+ client->nickname, strlen(client->nickname));
}
/* Client session resuming callback. If the session was resumed
SilcAttribute attribute;
SilcAttributePayload attr;
SilcAttributeObjPk pk;
- unsigned char sign[2048];
+ unsigned char sign[2048 + 1];
SilcUInt32 sign_len;
SILC_LOG_DEBUG(("Process Requested Attributes"));
/* Encode the message payload. This also encrypts the message payload. */
payload = silc_message_payload_encode(flags, data, data_len, TRUE, FALSE,
- cipher, hmac, client->rng);
+ cipher, hmac, client->rng, NULL,
+ client->private_key, client->sha1hash);
/* Get data used in packet header encryption, keys and stuff. */
cipher = conn->internal->send_key;
/* Pass the message to application */
client->internal->ops->channel_message(
- client, conn, clients[0], channel,
- silc_message_get_flags(res->payload),
- message, message_len);
+ client, conn, clients[0], channel, res->payload,
+ silc_message_get_flags(res->payload),
+ message, message_len);
}
out:
/* Pass the message to application */
client->internal->ops->channel_message(
- client, conn, client_entry, channel,
- silc_message_get_flags(payload),
- message, message_len);
+ client, conn, client_entry, channel, payload,
+ silc_message_get_flags(payload),
+ message, message_len);
out:
silc_free(id);
/* Produce the key material */
keymat = silc_calloc(1, sizeof(*keymat));
if (silc_ske_process_key_material_data(key, key_len, 16, 256, 16,
- client->md5hash, keymat)
+ client->sha1hash, keymat)
!= SILC_SKE_STATUS_OK)
return FALSE;
if (!client_id)
goto out;
- /* From protocol version 1.1 we get the new nickname in notify as well,
- so we don't have to resolve it. Do it the hard way if server doesn't
- send it to us. */
+ /* Take the nickname */
tmp = silc_argument_get_arg_type(args, 3, NULL);
- if (tmp) {
- /* Protocol version 1.1 */
- char *tmp_nick = NULL;
-
- /* Check whether nickname changed at all. It is possible that nick
- change notify is received but nickname didn't changed, only the
- ID changes. */
- if (client->internal->params->nickname_parse)
- client->internal->params->nickname_parse(client_entry->nickname,
- &tmp_nick);
- else
- tmp_nick = strdup(tmp);
-
- if (tmp_nick && !strcmp(tmp, tmp_nick)) {
- /* Nickname didn't change. Update only the ID */
- silc_idcache_del_by_context(conn->internal->client_cache,
- client_entry);
- silc_free(client_entry->id);
- client_entry->id = silc_id_dup(client_id, SILC_ID_CLIENT);
- silc_idcache_add(conn->internal->client_cache, strdup(tmp),
- client_entry->id, client_entry, 0, NULL);
-
- /* Notify application */
- client->internal->ops->notify(client, conn, type,
- client_entry, client_entry);
- break;
- }
- silc_free(tmp_nick);
-
- /* Create new client entry, and save all old information with the
- new nickname and client ID */
- client_entry2 = silc_client_add_client(client, conn, NULL, NULL,
- client_entry->realname,
- silc_id_dup(client_id,
- SILC_ID_CLIENT), 0);
- if (!client_entry2)
- goto out;
-
- if (client_entry->server)
- client_entry2->server = strdup(client_entry->server);
- if (client_entry->username)
- client_entry2->username = strdup(client_entry->username);
- if (client_entry->hostname)
- client_entry2->hostname = strdup(client_entry->hostname);
- silc_client_update_client(client, conn, client_entry2, tmp, NULL, NULL,
- client_entry->mode);
- } else {
- /* Protocol version 1.0 */
+ if (!tmp)
+ goto out;
- /* Find client entry and if not found resolve it */
- client_entry2 = silc_client_get_client_by_id(client, conn, client_id);
- if (!client_entry2) {
- /* Resolve the entry information */
- silc_client_notify_by_server_resolve(client, conn, packet,
- SILC_ID_CLIENT, client_id);
+ /* Check whether nickname changed at all. It is possible that nick
+ change notify is received but nickname didn't changed, only the
+ ID changes. Check whether the hashes in the Client ID match, if
+ they do nickname didn't change. */
+ if (SILC_ID_COMPARE_HASH(client_entry->id, client_id)) {
+ /* Nickname didn't change. Update only the ID */
+ silc_idcache_del_by_context(conn->internal->client_cache,
+ client_entry);
+ silc_free(client_entry->id);
+ client_entry->id = silc_id_dup(client_id, SILC_ID_CLIENT);
+ silc_idcache_add(conn->internal->client_cache, strdup(tmp),
+ client_entry->id, client_entry, 0, NULL);
+
+ /* Notify application */
+ client->internal->ops->notify(client, conn, type,
+ client_entry, client_entry);
+ break;
+ }
- /* Add the new entry even though we resolved it. This is because we
- want to replace the old entry with the new entry here right now. */
- client_entry2 =
- silc_client_add_client(client, conn, NULL, NULL, NULL,
- silc_id_dup(client_id, SILC_ID_CLIENT),
- client_entry->mode);
-
- /* Replace old ID entry with new one on all channels. */
- silc_client_replace_from_channels(client, conn, client_entry,
- client_entry2);
- break;
- }
+ /* Create new client entry, and save all old information with the
+ new nickname and client ID */
+ client_entry2 = silc_client_add_client(client, conn, NULL, NULL,
+ client_entry->realname,
+ silc_id_dup(client_id,
+ SILC_ID_CLIENT), 0);
+ if (!client_entry2)
+ goto out;
- if (client_entry2 != conn->local_entry)
- silc_client_nickname_format(client, conn, client_entry2);
- }
+ if (client_entry->server)
+ client_entry2->server = strdup(client_entry->server);
+ if (client_entry->username)
+ client_entry2->username = strdup(client_entry->username);
+ if (client_entry->hostname)
+ client_entry2->hostname = strdup(client_entry->hostname);
+ client_entry2->fingerprint = client_entry->fingerprint;
+ client_entry2->fingerprint_len = client_entry->fingerprint_len;
+ client_entry->fingerprint = NULL;
+ client_entry->fingerprint_len = NULL;
+ silc_client_update_client(client, conn, client_entry2, tmp, NULL, NULL,
+ client_entry->mode);
/* Remove the old from cache */
silc_idcache_del_by_context(conn->internal->client_cache, client_entry);
static void
silc_channel_message(SilcClient client, SilcClientConnection conn,
SilcClientEntry sender, SilcChannelEntry channel,
- SilcMessageFlags flags, const unsigned char *message,
- SilcUInt32 message_len)
+ SilcMessagePayload payload, SilcMessageFlags flags,
+ const unsigned char *message, SilcUInt32 message_len)
{
}
static void
silc_private_message(SilcClient client, SilcClientConnection conn,
- SilcClientEntry sender, SilcMessageFlags flags,
- const unsigned char *message,
+ SilcClientEntry sender, SilcMessagePayload payload,
+ SilcMessageFlags flags, const unsigned char *message,
SilcUInt32 message_len)
{
!client_entry->generated,
TRUE, client_entry->send_key,
client_entry->hmac_send,
- client->rng);
+ client->rng, NULL, client->private_key,
+ client->sha1hash);
/* If we don't have private message specific key then private messages
are just as any normal packet thus call normal packet sending. If
/* Pass the private message to application */
message = silc_message_get_data(payload, &message_len);
- client->internal->ops->private_message(client, conn, remote_client, flags,
- message, message_len);
+ client->internal->ops->private_message(client, conn, remote_client, payload,
+ flags, message, message_len);
/* See if we are away (gone). If we are away we will reply to the
sender with the set away message. */
/* Produce the key material as the protocol defines */
keymat = silc_calloc(1, sizeof(*keymat));
if (silc_ske_process_key_material_data(key, key_len, 16, 256, 16,
- client->md5hash, keymat)
+ client->sha1hash, keymat)
!= SILC_SKE_STATUS_OK)
return FALSE;
SilcClientEntry client_entry = NULL;
SilcChannelEntry channel;
SilcBuffer buffer, clidp, chidp, args = NULL;
+ SilcPublicKey pubkey = NULL;
char *nickname = NULL, *name;
char *invite = NULL;
unsigned char action[1];
goto out;
}
} else {
- invite = cmd->argv[2];
- invite++;
if (cmd->argv[2][0] == '+')
action[0] = 0x00;
else
action[0] = 0x01;
+
+ /* Check if it is public key file to be added to invite list */
+ if (!silc_pkcs_load_public_key(cmd->argv[2] + 1, &pubkey,
+ SILC_PKCS_FILE_PEM))
+ silc_pkcs_load_public_key(cmd->argv[2] + 1, &pubkey,
+ SILC_PKCS_FILE_BIN);
+ invite = cmd->argv[2];
+ if (!pubkey)
+ invite++;
}
}
silc_buffer_format(args,
SILC_STR_UI_SHORT(1),
SILC_STR_END);
- args = silc_argument_payload_encode_one(args, invite, strlen(invite), 1);
+ if (pubkey) {
+ chidp = silc_pkcs_public_key_payload_encode(pubkey);
+ args = silc_argument_payload_encode_one(args, chidp->data,
+ chidp->len, 2);
+ silc_buffer_free(chidp);
+ silc_pkcs_public_key_free(pubkey);
+ } else {
+ args = silc_argument_payload_encode_one(args, invite, strlen(invite), 1);
+ }
}
/* Send the command */
SilcClientCommandContext cmd = (SilcClientCommandContext)context;
SilcClientConnection conn = cmd->conn;
SilcChannelEntry channel;
- SilcBuffer buffer, chidp, auth = NULL;
+ SilcBuffer buffer, chidp, auth = NULL, pk = NULL;
unsigned char *name, *cp, modebuf[4], tmp[4], *arg = NULL;
SilcUInt32 mode, add, type, len, arg_len = 0;
int i;
break;
case 'f':
if (add) {
+ SilcPublicKey pubkey = cmd->client->public_key;
+ SilcPrivateKey privkey = cmd->client->private_key;
+
mode |= SILC_CHANNEL_MODE_FOUNDER_AUTH;
type = 7;
- auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
- cmd->client->private_key,
+
+ if (cmd->argc >= 5) {
+ char *pass = "";
+ if (cmd->argc >= 6)
+ pass = cmd->argv[5];
+ if (!silc_load_key_pair(cmd->argv[3], cmd->argv[4], pass,
+ NULL, &pubkey, &privkey)) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "Could not load key pair, check your arguments");
+ COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+ goto out;
+ }
+ }
+
+ pk = silc_pkcs_public_key_payload_encode(pubkey);
+ auth = silc_auth_public_key_auth_generate(pubkey, privkey,
cmd->client->rng,
cmd->client->sha1hash,
conn->local_id,
that requires an argument. */
if (type && arg) {
buffer =
- silc_command_payload_encode_va(SILC_COMMAND_CMODE, 0, 3,
+ silc_command_payload_encode_va(SILC_COMMAND_CMODE, 0, 4,
1, chidp->data, chidp->len,
2, modebuf, sizeof(modebuf),
- type, arg, arg_len);
+ type, arg, arg_len,
+ 8, pk ? pk->data : NULL,
+ pk ? pk->len : 0);
} else {
buffer =
silc_command_payload_encode_va(SILC_COMMAND_CMODE, 0, 2,
0, NULL, NULL, buffer->data, buffer->len, TRUE);
silc_buffer_free(buffer);
silc_buffer_free(chidp);
- if (auth)
- silc_buffer_free(auth);
+ silc_buffer_free(auth);
+ silc_buffer_free(pk);
/* Notify application */
COMMAND(SILC_STATUS_OK);
break;
case 'f':
if (add) {
- auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
- cmd->client->private_key,
+ SilcPublicKey pubkey = cmd->client->public_key;
+ SilcPrivateKey privkey = cmd->client->private_key;
+
+ if (cmd->argc >= 6) {
+ char *pass = "";
+ if (cmd->argc >= 7)
+ pass = cmd->argv[6];
+ if (!silc_load_key_pair(cmd->argv[4], cmd->argv[5], pass,
+ NULL, &pubkey, &privkey)) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "Could not load key pair, check your arguments");
+ COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+ goto out;
+ }
+ }
+
+ auth = silc_auth_public_key_auth_generate(pubkey, privkey,
cmd->client->rng,
cmd->client->sha1hash,
conn->local_id,
SilcBuffer buffer, chidp, args = NULL;
char *name, *ban = NULL;
unsigned char action[1];
-
+ SilcPublicKey pubkey = NULL;
+
if (!cmd->conn) {
SILC_NOT_CONNECTED(cmd->client, cmd->conn);
COMMAND_ERROR(SILC_STATUS_ERR_NOT_REGISTERED);
else
action[0] = 0x01;
+ /* Check if it is public key file to be added to invite list */
+ if (!silc_pkcs_load_public_key(cmd->argv[2] + 1, &pubkey,
+ SILC_PKCS_FILE_PEM))
+ silc_pkcs_load_public_key(cmd->argv[2] + 1, &pubkey,
+ SILC_PKCS_FILE_BIN);
ban = cmd->argv[2];
- ban++;
+ if (!pubkey)
+ ban++;
}
if (ban) {
silc_buffer_format(args,
SILC_STR_UI_SHORT(1),
SILC_STR_END);
- args = silc_argument_payload_encode_one(args, ban, strlen(ban), 1);
+ if (pubkey) {
+ chidp = silc_pkcs_public_key_payload_encode(pubkey);
+ args = silc_argument_payload_encode_one(args, chidp->data,
+ chidp->len, 2);
+ silc_buffer_free(chidp);
+ silc_pkcs_public_key_free(pubkey);
+ } else {
+ args = silc_argument_payload_encode_one(args, ban, strlen(ban), 1);
+ }
}
chidp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL);
SILC_CLIENT_CMD(join, JOIN, "JOIN", 9);
SILC_CLIENT_CMD(motd, MOTD, "MOTD", 2);
SILC_CLIENT_CMD(umode, UMODE, "UMODE", 2);
- SILC_CLIENT_CMD(cmode, CMODE, "CMODE", 4);
- SILC_CLIENT_CMD(cumode, CUMODE, "CUMODE", 5);
+ SILC_CLIENT_CMD(cmode, CMODE, "CMODE", 6);
+ SILC_CLIENT_CMD(cumode, CUMODE, "CUMODE", 9);
SILC_CLIENT_CMD(kick, KICK, "KICK", 4);
SILC_CLIENT_CMD(ban, BAN, "BAN", 3);
SILC_CLIENT_CMD(detach, DETACH, "DETACH", 0);
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ SilcClientCommandReplyContext r = (SilcClientCommandReplyContext)context2;
SILC_LOG_DEBUG(("Start"));
goto out;
}
+ if (r && !silc_command_get_status(r->payload, NULL, &cmd->error)) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_get_status_message(cmd->error));
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
if (silc_client_command_reply_users_save(cmd, cmd->status, TRUE,
silc_client_command_reply_users_cb,
silc_client_command_reply_users))
goto out;
}
+ /* Save fingerprint */
+ if (!client_entry->fingerprint) {
+ client_entry->fingerprint = silc_calloc(20, sizeof(unsigned char));
+ client_entry->fingerprint_len = 20;
+ silc_hash_make(cmd->client->sha1hash, tmp + 4, len - 4,
+ client_entry->fingerprint);
+ }
+
/* Notify application */
COMMAND_REPLY((SILC_ARGS, id_type, client_entry, public_key));
} else if (id_type == SILC_ID_SERVER) {
(like it may tell the message is multimedia message). */
void (*channel_message)(SilcClient client, SilcClientConnection conn,
SilcClientEntry sender, SilcChannelEntry channel,
- SilcMessageFlags flags,
+ SilcMessagePayload payload, SilcMessageFlags flags,
const unsigned char *message,
SilcUInt32 message_len);
can be interpreted (like it may tell the message is multimedia
message). */
void (*private_message)(SilcClient client, SilcClientConnection conn,
- SilcClientEntry sender, SilcMessageFlags flags,
+ SilcClientEntry sender, SilcMessagePayload payload,
+ SilcMessageFlags flags,
const unsigned char *message,
SilcUInt32 message_len);
* keys are set then the first key (the key that was added first as
* private key) is used.
*
+ * If the `flags' includes SILC_MESSAGE_FLAG_SIGNED the message will be
+ * digitally signed with the SILC key pair.
+ *
***/
void silc_client_send_channel_message(SilcClient client,
SilcClientConnection conn,
* message. The `data' is the private message. If the `force_send' is
* TRUE the packet is sent immediately.
*
+ * If the `flags' includes SILC_MESSAGE_FLAG_SIGNED the message will be
+ * digitally signed with the SILC key pair.
+ *
***/
void silc_client_send_private_message(SilcClient client,
SilcClientConnection conn,
len = 0;
for (i = 0; i < argc; i++)
- len += 3 + argv_lens[i];
+ len += 3 + (SilcUInt16)argv_lens[i];
buffer = silc_buffer_alloc_size(len);
if (!buffer)
silc_buffer_format(buffer,
SILC_STR_UI_SHORT(argv_lens[i]),
SILC_STR_UI_CHAR(argv_types[i]),
- SILC_STR_UI_XNSTRING(argv[i], argv_lens[i]),
+ SILC_STR_UI_XNSTRING(argv[i], (SilcUInt16)argv_lens[i]),
SILC_STR_END);
- silc_buffer_pull(buffer, 3 + argv_lens[i]);
+ silc_buffer_pull(buffer, 3 + (SilcUInt16)argv_lens[i]);
}
silc_buffer_push(buffer, len);
SilcUInt32 arg_type)
{
SilcBuffer buffer = args;
- int len;
+ SilcUInt32 len;
- len = 3 + arg_len;
+ len = 3 + (SilcUInt16)arg_len;
buffer = silc_buffer_realloc(buffer,
(buffer ? buffer->truelen + len : len));
if (!buffer)
silc_buffer_format(buffer,
SILC_STR_UI_SHORT(arg_len),
SILC_STR_UI_CHAR(arg_type),
- SILC_STR_UI_XNSTRING(arg, arg_len),
+ SILC_STR_UI_XNSTRING(arg, (SilcUInt16)arg_len),
SILC_STR_END);
silc_buffer_push(buffer, buffer->data - buffer->head);
{
SilcBuffer tmpbuf = NULL;
unsigned char tmp[4], *str = NULL, *ret;
- int len;
+ SilcUInt32 len;
/* Encode according to attribute type */
if (flags & SILC_ATTRIBUTE_FLAG_VALID) {
case SILC_ATTRIBUTE_SERVICE:
{
SilcAttributeObjService *service = object;
- int len2;
+ SilcUInt32 len2;
if (object_size != sizeof(*service))
return NULL;
len = strlen(service->address);
case SILC_ATTRIBUTE_GEOLOCATION:
{
SilcAttributeObjGeo *geo = object;
- int len1, len2, len3, len4;
+ SilcUInt32 len1, len2, len3, len4;
if (object_size != sizeof(*geo))
return NULL;
len1 = (geo->longitude ? strlen(geo->longitude) : 0);
case SILC_ATTRIBUTE_DEVICE_INFO:
{
SilcAttributeObjDevice *dev = object;
- int len1, len2, len3, len4;
+ SilcUInt32 len1, len2, len3, len4;
if (object_size != sizeof(*dev))
return NULL;
len1 = (dev->manufacturer ? strlen(dev->manufacturer) : 0);
SilcBufferStruct buffer;
SilcDList list;
SilcAttributePayload newp;
- int len, ret;
+ SilcUInt32 len;
+ int ret;
SILC_LOG_DEBUG(("Parsing Attribute Payload list"));
SilcUInt32 data_len)
{
SilcBuffer buffer = attrs;
- int len;
+ SilcUInt32 len;
- len = 4 + data_len;
+ len = 4 + (SilcUInt16)data_len;
buffer = silc_buffer_realloc(buffer,
(buffer ? buffer->truelen + len : len));
if (!buffer)
SILC_STR_UI_CHAR(attribute),
SILC_STR_UI_CHAR(flags),
SILC_STR_UI_SHORT((SilcUInt16)data_len),
- SILC_STR_UI_XNSTRING(data, data_len),
+ SILC_STR_UI_XNSTRING(data, (SilcUInt16)data_len),
SILC_STR_END);
silc_buffer_push(buffer, buffer->data - buffer->head);
const void *id, SilcIdType type)
{
unsigned char *randomdata;
- unsigned char auth_data[2048];
+ unsigned char auth_data[2048 + 1];
SilcUInt32 auth_len;
unsigned char *tmp;
SilcUInt32 tmp_len;
/*
- silcchannel.c
+ silcchannel.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
-/* Channel Payload, Channel Message Payload and Channel Key Payload
- implementations. */
+/* Channel Payload and Channel Key Payload implementations. */
/* $Id$ */
#include "silcincludes.h"
#include "silcchannel.h"
-#include "silcchannel_i.h"
+
+/******************************************************************************
+
+ Channel Payload
+
+******************************************************************************/
+
+/* Channel Message Payload structure. Contents of this structure is parsed
+ from SILC packets. */
+struct SilcChannelPayloadStruct {
+ unsigned char *channel_name;
+ unsigned char *channel_id;
+ SilcUInt32 mode;
+ SilcUInt16 name_len;
+ SilcUInt16 id_len;
+};
/* Parses channel payload returning new channel payload structure. */
SilcBufferStruct buffer;
SilcDList list;
SilcChannelPayload newp;
- int len, ret;
+ SilcUInt32 len;
+ int ret;
SILC_LOG_DEBUG(("Parsing channel payload list"));
******************************************************************************/
+/* Channel Key Payload structrue. Channel keys are parsed from SILC
+ packets into this structure. */
+struct SilcChannelKeyPayloadStruct {
+ unsigned char *id;
+ unsigned char *cipher;
+ unsigned char *key;
+ SilcUInt16 id_len;
+ SilcUInt16 cipher_len;
+ SilcUInt16 key_len;
+};
+
/* Parses channel key payload returning new channel key payload structure */
SilcChannelKeyPayload
+++ /dev/null
-/*
-
- silcchannel_i.h
-
- Author: Pekka Riikonen <priikone@silcnet.org>
-
- Copyright (C) 1997 - 2002 Pekka Riikonen
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
-*/
-
-#ifndef SILCCHANNEL_I_H
-#define SILCCHANNEL_I_H
-
-#ifndef SILCCHANNEL_H
-#error "Do not include internal header file directly"
-#endif
-
-/******************************************************************************
-
- Channel Payload
-
-******************************************************************************/
-
-/* Channel Message Payload structure. Contents of this structure is parsed
- from SILC packets. */
-struct SilcChannelPayloadStruct {
- unsigned char *channel_name;
- unsigned char *channel_id;
- SilcUInt32 mode;
- SilcUInt16 name_len;
- SilcUInt16 id_len;
-};
-
-
-/******************************************************************************
-
- Channel Key Payload
-
-******************************************************************************/
-
-/* Channel Key Payload structrue. Channel keys are parsed from SILC
- packets into this structure. */
-struct SilcChannelKeyPayloadStruct {
- unsigned char *id;
- unsigned char *cipher;
- unsigned char *key;
- SilcUInt16 id_len;
- SilcUInt16 cipher_len;
- SilcUInt16 key_len;
-};
-
-#endif /* SILCCHANNEL_I_H */
/*
- silccommand.c
+ silccommand.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
}
if (newp->cmd == 0) {
+ SILC_LOG_ERROR(("Incorrect command type in command payload"));
silc_free(newp);
return NULL;
}
if (argc) {
args = silc_argument_payload_encode(argc, argv, argv_lens, argv_types);
+ if (!args)
+ return NULL;
len = args->len;
}
if (payload->args) {
args = silc_argument_payload_encode_payload(payload->args);
- len = args->len;
+ if (args)
+ len = args->len;
argc = silc_argument_get_arg_num(payload->args);
}
static void silc_idcache_destructor(void *key, void *context,
void *user_context)
{
- silc_free(context);
+ SilcIDCacheEntry c = context;
+ if (c) {
+ memset(c, 'F', sizeof(*c));
+ silc_free(c);
+ }
}
/* Delete cache entry from cache. */
if (old->id)
ret = silc_hash_table_del(cache->id_table, old->id);
else
- silc_free(old);
+ silc_idcache_destructor(NULL, old, NULL);
return ret;
}
if (c->id)
ret = silc_hash_table_del_by_context(cache->id_table, c->id, c);
else
- silc_free(c);
+ silc_idcache_destructor(NULL, c, NULL);
return ret;
}
SilcIDCache cache = (SilcIDCache)user_context;
SilcUInt32 curtime = time(NULL);
SilcIDCacheEntry c = (SilcIDCacheEntry)context;
+ bool ret = FALSE;
if (!context)
return;
if (c->expire && c->expire < curtime) {
/* Remove the entry from the hash tables */
if (c->name)
- silc_hash_table_del_by_context(cache->name_table, c->name, c);
+ ret = silc_hash_table_del_by_context(cache->name_table, c->name, c);
if (c->context)
- silc_hash_table_del(cache->context_table, c->context);
+ ret = silc_hash_table_del(cache->context_table, c->context);
if (c->id)
- silc_hash_table_del_by_context_ext(cache->id_table, c->id, c,
- NULL, NULL, NULL, NULL,
- silc_idcache_destructor_dummy, NULL);
-
- /* Call the destructor */
- if (cache->destructor)
- cache->destructor(cache, c);
-
- /* Free the entry, it has been deleted from the hash tables */
- silc_free(c);
+ ret =
+ silc_hash_table_del_by_context_ext(cache->id_table, c->id, c,
+ NULL, NULL, NULL, NULL,
+ silc_idcache_destructor_dummy,
+ NULL);
+ if (ret == TRUE) {
+ /* Call the destructor */
+ if (cache->destructor)
+ cache->destructor(cache, c);
+
+ /* Free the entry, it has been deleted from the hash tables */
+ silc_idcache_destructor(NULL, c, NULL);
+ }
}
}
silc_hash_table_del_by_context_ext(cache->id_table, c->id, c,
NULL, NULL, NULL, NULL,
silc_idcache_destructor_dummy, NULL);
-
- /* Call the destructor */
- if (cache->destructor)
- cache->destructor(cache, c);
+ if (ret == TRUE) {
+ /* Call the destructor */
+ if (cache->destructor)
+ cache->destructor(cache, c);
- /* Free the entry, it has been deleted from the hash tables */
- silc_free(c);
+ /* Free the entry, it has been deleted from the hash tables */
+ silc_idcache_destructor(NULL, c, NULL);
+ }
return ret;
}
unsigned char *pad;
unsigned char *iv;
unsigned char *mac;
- /*SilcMessageSignedPayload sig;*/
+ SilcMessageSignedPayload sig;
};
/* Decrypts the Message Payload. The `data' is the actual Message Payload */
SilcHmac hmac,
bool check_mac)
{
- SilcUInt32 mac_len = 0, iv_len = 0;
- unsigned char *mac, mac2[32];
-
+ SilcUInt32 mac_len, iv_len = 0, block_len;
+ SilcUInt16 len, totlen, dlen;
+ unsigned char mac[32], *ivp, *dec;
+
mac_len = silc_hmac_len(hmac);
- /* IV is present for channel messages and private messages when static
- key (pre-shared key) is used. */
+ /* IV is present for all channel messages, and private messages when
+ static key (pre-shared key) is used. */
if (!private_message || (private_message && static_key))
iv_len = silc_cipher_get_block_len(cipher);
return FALSE;
if (check_mac) {
- /* Take the MAC */
- mac = data + (data_len - mac_len);
-
/* Check the MAC of the message */
SILC_LOG_DEBUG(("Checking message MAC"));
silc_hmac_init(hmac);
silc_hmac_update(hmac, data, data_len - mac_len);
- silc_hmac_final(hmac, mac2, &mac_len);
- if (memcmp(mac, mac2, mac_len)) {
+ silc_hmac_final(hmac, mac, &mac_len);
+ if (memcmp(data + (data_len - mac_len), mac, mac_len)) {
SILC_LOG_DEBUG(("Message MAC does not match"));
return FALSE;
}
SILC_LOG_DEBUG(("MAC is Ok"));
}
- /* Decrypt the message */
- silc_cipher_decrypt(cipher, data, data, data_len - iv_len - mac_len,
- (iv_len ? data + (data_len - iv_len - mac_len) : NULL));
+ /* Decrypt the entire buffer into allocated decryption buffer, since we
+ do not reliably know its encrypted length (it may include unencrypted
+ data at the end). */
+
+ /* Get pointer to the IV */
+ ivp = (iv_len ? data + (data_len - iv_len - mac_len) :
+ silc_cipher_get_iv(cipher));
+
+ /* Allocate buffer for decryption. Since there might be unencrypted
+ data at the end, it might not be multiple by block size, make it so. */
+ block_len = silc_cipher_get_block_len(cipher);
+ dlen = data_len - iv_len - mac_len;
+ if (dlen & (block_len - 1))
+ dlen += SILC_MESSAGE_PAD(dlen);
+ if (dlen > data_len - iv_len - mac_len)
+ dlen -= block_len;
+ dec = silc_malloc(dlen);
+
+ /* Decrypt */
+ silc_cipher_decrypt(cipher, data, dec, dlen, ivp);
+
+ /* Now verify the true length of the payload and copy the decrypted
+ part over the original data. First get data length, and then padding
+ length from the decrypted data. Then, copy over the original data. */
+
+ totlen = 2;
+ SILC_GET16_MSB(len, dec + totlen);
+ totlen += 2 + len;
+ if (totlen + iv_len + mac_len + 2 > data_len) {
+ memset(dec, 0, dlen);
+ silc_free(dec);
+ return FALSE;
+ }
+ SILC_GET16_MSB(len, dec + totlen);
+ totlen += 2 + len;
+ if (totlen + iv_len + mac_len > data_len) {
+ memset(dec, 0, dlen);
+ silc_free(dec);
+ return FALSE;
+ }
+
+ memcpy(data, dec, totlen);
+ memset(dec, 0, dlen);
+ silc_free(dec);
+
return TRUE;
}
if (hmac)
mac_len = silc_hmac_len(hmac);
- /* IV is present for channel messages and private messages when static
- key (pre-shared key) is used. */
+ /* IV is present for all channel messages, and private messages when
+ static key (pre-shared key) is used. */
if (cipher && (!private_message || (private_message && static_key)))
iv_len = silc_cipher_get_block_len(cipher);
&newp->data_len),
SILC_STR_UI16_NSTRING_ALLOC(&newp->pad,
&newp->pad_len),
- SILC_STR_UI_XNSTRING(&newp->iv, iv_len),
- SILC_STR_UI_XNSTRING(&newp->mac, mac_len),
SILC_STR_END);
if (ret == -1)
goto err;
goto err;
}
- newp->iv_len = iv_len;
+ /* Parse Signed Message Payload if provided */
+ if (newp->flags & SILC_MESSAGE_FLAG_SIGNED &&
+ newp->data_len + newp->pad_len + 6 + mac_len + iv_len < buffer.len) {
+ newp->sig =
+ silc_message_signed_payload_parse(buffer.data + 6 + newp->data_len +
+ newp->pad_len,
+ buffer.len - iv_len - mac_len);
+ }
+
+ /* Parse IV and MAC from the payload */
+ if (iv_len) {
+ newp->iv = buffer.data + (buffer.len - iv_len - mac_len);
+ newp->iv_len = iv_len;
+ }
+ if (mac_len)
+ newp->mac = buffer.data + (buffer.len - mac_len);
return newp;
/* This function is used to encrypt the Messsage Payload which is
the `data' and `data_len'. This is used internally by the Message
Payload encoding routines but application may call this too if needed.
- The `data_len' is the data lenght which is used to create MAC out of. */
+ The `true_len' is the data length which is used to create MAC out of. */
bool silc_message_payload_encrypt(unsigned char *data,
SilcUInt32 data_len,
+ SilcUInt32 true_len,
unsigned char *iv,
SilcUInt32 iv_len,
SilcCipher cipher,
/* Encrypt payload of the packet. If the IV is added to packet do
not encrypt that. */
- silc_cipher_encrypt(cipher, data, data, data_len - iv_len,
- iv_len ? iv : NULL);
+ silc_cipher_encrypt(cipher, data, data, data_len, iv_len ? iv : NULL);
/* Compute the MAC of the encrypted message data */
silc_hmac_init(hmac);
- silc_hmac_update(hmac, data, data_len);
+ silc_hmac_update(hmac, data, true_len);
silc_hmac_final(hmac, mac, &mac_len);
/* Put rest of the data to the payload */
- silc_buffer_set(&buf, data, data_len + mac_len);
- silc_buffer_pull(&buf, data_len);
+ silc_buffer_set(&buf, data, true_len + mac_len);
+ silc_buffer_pull(&buf, true_len);
silc_buffer_put(&buf, mac, mac_len);
return TRUE;
bool private_message,
SilcCipher cipher,
SilcHmac hmac,
- SilcRng rng)
+ SilcRng rng,
+ SilcPublicKey public_key,
+ SilcPrivateKey private_key,
+ SilcHash hash)
{
int i;
SilcBuffer buffer;
SilcUInt32 len, pad_len = 0, mac_len = 0, iv_len = 0;
unsigned char pad[16], iv[SILC_CIPHER_MAX_IV_SIZE];
+ SilcBuffer sig = NULL;
SILC_LOG_DEBUG(("Encoding Message Payload"));
}
/* Encode the Message Payload */
- silc_buffer_pull_tail(buffer, 6 + data_len + pad_len + iv_len);
+ silc_buffer_pull_tail(buffer, 6 + data_len + pad_len);
silc_buffer_format(buffer,
SILC_STR_UI_SHORT(flags),
SILC_STR_UI_SHORT(data_len),
SILC_STR_UI_XNSTRING(data, data_len),
SILC_STR_UI_SHORT(pad_len),
SILC_STR_UI_XNSTRING(pad, pad_len),
- SILC_STR_UI_XNSTRING(iv, iv_len),
SILC_STR_END);
memset(pad, 0, sizeof(pad));
- /* Now encrypt the Message Payload */
+ /* Sign the message if wanted */
+ if (flags & SILC_MESSAGE_FLAG_SIGNED && private_key && hash) {
+ sig = silc_message_signed_payload_encode(buffer->data, buffer->len,
+ public_key, private_key, hash);
+ if (sig) {
+ buffer = silc_buffer_realloc(buffer, buffer->truelen + sig->len);
+ if (buffer) {
+ silc_buffer_pull(buffer, 6 + data_len + pad_len);
+ silc_buffer_pull_tail(buffer, sig->len);
+ silc_buffer_put(buffer, sig->data, sig->len);
+ silc_buffer_push(buffer, 6 + data_len + pad_len);
+ }
+ }
+ }
+
+ /* Put IV */
+ silc_buffer_pull(buffer, 6 + data_len + pad_len + (sig ? sig->len : 0));
+ silc_buffer_pull_tail(buffer, iv_len);
+ silc_buffer_format(buffer,
+ SILC_STR_UI_XNSTRING(iv, iv_len),
+ SILC_STR_END);
+ silc_buffer_push(buffer, 6 + data_len + pad_len + (sig ? sig->len : 0));
+
+ SILC_LOG_HEXDUMP(("foo"), buffer->data, buffer->len);
+
+ /* Now encrypt the Message Payload and compute MAC */
if (cipher) {
- if (!silc_message_payload_encrypt(buffer->data, buffer->len,
- iv, iv_len, cipher, hmac)) {
+ if (!silc_message_payload_encrypt(buffer->data,
+ buffer->len - iv_len -
+ (sig ? sig->len : 0),
+ buffer->len, iv, iv_len,
+ cipher, hmac)) {
silc_buffer_free(buffer);
+ silc_buffer_free(sig);
return NULL;
}
}
silc_buffer_pull_tail(buffer, SILC_BUFFER_END(buffer) - buffer->len);
+ silc_buffer_free(sig);
return buffer;
}
memset(payload->data, 0, payload->data_len);
silc_free(payload->data);
}
+ if (payload->sig)
+ silc_message_signed_payload_free(payload->sig);
silc_free(payload->pad);
silc_free(payload);
}
return payload->iv;
}
+/* Return signature of the message */
+
+const SilcMessageSignedPayload
+silc_message_get_signature(SilcMessagePayload payload)
+{
+ return (const SilcMessageSignedPayload)payload->sig;
+}
+
/******************************************************************************
SILC_MESSAGE_FLAG_SIGNED Payload
SILC_LOG_DEBUG(("Parsing SILC_MESSAGE_FLAG_SIGNED Payload"));
+ SILC_LOG_HEXDUMP(("sig payload"), (unsigned char *)data, data_len);
+
silc_buffer_set(&buffer, (unsigned char *)data, data_len);
sig = silc_calloc(1, sizeof(*sig));
if (!sig)
SILC_STR_END);
if (ret == -1 || sig->pk_len > data_len - 4) {
silc_message_signed_payload_free(sig);
+ SILC_LOG_DEBUG(("Malformed public key in SILC_MESSAGE_FLAG_SIGNED "
+ "Payload"));
return NULL;
}
SILC_STR_END);
if (ret == -1) {
silc_message_signed_payload_free(sig);
+ SILC_LOG_DEBUG(("Malformed SILC_MESSAGE_FLAG_SIGNED Payload"));
return NULL;
}
silc_buffer_push(&buffer, 4);
/* Signature must be provided */
if (sig->sign_len < 1) {
+ SILC_LOG_DEBUG(("Malformed signature in SILC_MESSAGE_SIGNED_PAYLOAD "
+ "Payload"));
silc_message_signed_payload_free(sig);
return NULL;
}
SilcUInt32 message_payload_len,
SilcPublicKey public_key,
SilcPrivateKey private_key,
- SilcHash hash,
- bool include_public_key)
+ SilcHash hash)
{
SilcBuffer buffer, sign;
SilcPKCS pkcs;
- unsigned char auth_data[2048];
+ unsigned char auth_data[2048 + 1];
SilcUInt32 auth_len;
unsigned char *pk = NULL;
SilcUInt32 pk_len = 0;
if (!message_payload || !message_payload_len || !private_key || !hash)
return NULL;
- if (include_public_key && !public_key)
- return NULL;
-
- if (include_public_key)
+
+ if (public_key)
pk = silc_pkcs_public_key_encode(public_key, &pk_len);
/* Now we support only SILC style public key */
/* Allocate PKCS object */
if (!silc_pkcs_alloc(private_key->name, &pkcs)) {
+ SILC_LOG_ERROR(("Could not allocated PKCS"));
silc_buffer_clear(sign);
silc_buffer_free(sign);
silc_free(pk);
if (silc_pkcs_get_key_len(pkcs) / 8 > sizeof(auth_data) - 1 ||
!silc_pkcs_sign_with_hash(pkcs, hash, sign->data, sign->len, auth_data,
&auth_len)) {
+ SILC_LOG_ERROR(("Could not compute signature"));
silc_buffer_clear(sign);
silc_buffer_free(sign);
silc_pkcs_free(pkcs);
return NULL;
}
- silc_buffer_format(sign,
+ silc_buffer_format(buffer,
SILC_STR_UI_SHORT(pk_len),
SILC_STR_UI_SHORT(pk_type),
SILC_STR_END);
if (pk_len && pk) {
- silc_buffer_pull(sign, 4);
- silc_buffer_format(sign,
+ silc_buffer_pull(buffer, 4);
+ silc_buffer_format(buffer,
SILC_STR_UI_XNSTRING(pk, pk_len),
SILC_STR_END);
- silc_buffer_push(sign, 4);
+ silc_buffer_push(buffer, 4);
}
- silc_buffer_pull(sign, 4 + pk_len);
- silc_buffer_format(sign,
+ silc_buffer_pull(buffer, 4 + pk_len);
+ silc_buffer_format(buffer,
SILC_STR_UI_SHORT(auth_len),
SILC_STR_UI_XNSTRING(auth_data, auth_len),
SILC_STR_END);
- silc_buffer_push(sign, 4 + pk_len);
+ silc_buffer_push(buffer, 4 + pk_len);
+
+ SILC_LOG_HEXDUMP(("sig payload"), buffer->data, buffer->len);
memset(auth_data, 0, sizeof(auth_data));
silc_pkcs_free(pkcs);
void silc_message_signed_payload_free(SilcMessageSignedPayload sig)
{
- if (sig) {
- memset(sig->sign_data, 0, sig->sign_len);
- silc_free(sig->sign_data);
- silc_free(sig->pk_data);
- silc_free(sig);
- }
+ memset(sig->sign_data, 0, sig->sign_len);
+ silc_free(sig->sign_data);
+ silc_free(sig->pk_data);
+ silc_free(sig);
}
/* Verify the signature in SILC_MESSAGE_FLAG_SIGNED Payload */
return ret;
/* Generate the signature verification data, the Message Payload */
- tmp = silc_buffer_alloc_size(6 + message->data_len + message->pad_len +
- message->iv_len);
+ tmp = silc_buffer_alloc_size(6 + message->data_len + message->pad_len);
silc_buffer_format(tmp,
SILC_STR_UI_SHORT(message->flags),
SILC_STR_UI_SHORT(message->data_len),
SILC_STR_UI_XNSTRING(message->data, message->data_len),
SILC_STR_UI_SHORT(message->pad_len),
SILC_STR_UI_XNSTRING(message->pad, message->pad_len),
- SILC_STR_UI_XNSTRING(message->iv, message->iv_len),
SILC_STR_END);
sign = silc_message_signed_encode_data(tmp->data, tmp->len,
sig->pk_data, sig->pk_len,
/* Return the public key from the payload */
SilcPublicKey
-silc_message_signed_get_public_key(SilcMessageSignedPayload sig)
+silc_message_signed_get_public_key(SilcMessageSignedPayload sig,
+ unsigned char **pk_data,
+ SilcUInt32 *pk_data_len)
{
SilcPublicKey pk;
sig->pk_len, &pk))
return NULL;
+ if (pk_data)
+ *pk_data = sig->pk_data;
+ if (pk_data_len)
+ *pk_data_len = sig->pk_len;
+
return pk;
}
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 -2002 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
***/
typedef struct SilcMessagePayloadStruct *SilcMessagePayload;
+/****s* silccore/SilcMessageAPI/SilcMessageSignedPayload
+ *
+ * NAME
+ *
+ * typedef struct SilcMessageSignedPayloadStruct *SilcMessageSignedPayload;
+ *
+ *
+ * DESCRIPTION
+ *
+ * This context represents the SILC_MESSAGE_FLAG_SIGNED Payload which
+ * is used with channel messages and private messages to indicate that
+ * the message is digitally signed. This payload may include the
+ * message sender's public key and it includes the digital signature.
+ * This payload MUST NOT be used in any other context except with
+ * channel and private message sending and reception.
+ *
+ ***/
+typedef struct SilcMessageSignedPayloadStruct *SilcMessageSignedPayload;
+
/****d* silccore/SilcMessageAPI/SilcMessageFlags
*
* NAME
*
* bool silc_message_payload_encrypt(unsigned char *data,
* SilcUInt32 data_len,
+ * SilcUInt32 true_len,
* unsigned char *iv,
* SilcUInt32 iv_len,
* SilcCipher cipher,
* This function is used to encrypt the Messsage Payload which is
* the `data' and `data_len'. The `data_len' is the data length which
* is used to create MAC out of. The `data' MUST have additional space
- * after `data_len' bytes for the MAC which is appended to the data.
+ * after `true_len' bytes for the MAC which is appended to the data.
*
* This is usually used by the Message Payload interface itself but can
* be called by the appliation if separate encryption process is required.
***/
bool silc_message_payload_encrypt(unsigned char *data,
SilcUInt32 data_len,
+ SilcUInt32 true_len,
unsigned char *iv,
SilcUInt32 iv_len,
SilcCipher cipher,
* bool private_message,
* SilcCipher cipher,
* SilcHmac hmac,
- * SilcRng rng);
+ * SilcRng rng,
+ * SilcPublicKey public_key,
+ * SilcPrivateKey private_key,
+ * SilcHash hash);
*
* DESCRIPTION
*
* message that will be encrypted with session keys (no private message
* key) then `cipher' and `hmac' is NULL and this merely encodes the
* payload buffer, and the caller must encrypt the packet later.
- *
* If `rng' is NULL then global RNG is used, if non-NULL then the
* `rng' is used (for IV and padding generation).
*
+ * The `public_key', `private_key' and `hash' are provided only if the
+ * flags includes SILC_MESSAGE_FLAG_SIGNED, in which case the message
+ * will be digitally signed. If `public_key' is non-NULL then it will
+ * be included in the message. The `private_message' and `hash' MUST
+ * be provided. The `hash' SHOULD be SHA1.
+ *
***/
SilcBuffer silc_message_payload_encode(SilcMessageFlags flags,
const unsigned char *data,
bool private_message,
SilcCipher cipher,
SilcHmac hmac,
- SilcRng rng);
+ SilcRng rng,
+ SilcPublicKey public_key,
+ SilcPrivateKey private_key,
+ SilcHash hash);
/****f* silccore/SilcMessageAPI/silc_message_payload_free
*
***/
unsigned char *silc_message_get_iv(SilcMessagePayload payload);
-/****s* silccore/SilcMessageAPI/SilcMessageSignedPayload
+/****f* silccore/SilcMessageAPI/silc_message_get_signature
*
- * NAME
- *
- * typedef struct SilcMessageSignedPayloadStruct *SilcMessageSignedPayload;
+ * SYNOPSIS
*
+ * const SilcMessageSignedPayload
+ * silc_message_get_signature(SilcMessagePayload payload);
*
* DESCRIPTION
*
- * This context represents the SILC_MESSAGE_FLAG_SIGNED Payload which
- * is used with channel messages and private messages to indicate that
- * the message is digitally signed. This payload may include the
- * message sender's public key and it includes the digital signature.
- * This payload MUST NOT be used in any other context except with
- * channel and private message sending and reception.
+ * Returns the pointer to the signature of the message if the
+ * SILC_MESSAGE_FLAG_SIGNED was set. If the flag is set and this
+ * function returns NULL then error had occurred and the signature
+ * could not be retrieved from the message.
+ *
+ * The caller SHOULD verify the signature by calling the
+ * silc_message_signed_verify function.
*
***/
-typedef struct SilcMessageSignedPayloadStruct *SilcMessageSignedPayload;
+const SilcMessageSignedPayload
+silc_message_get_signature(SilcMessagePayload payload);
/****f* silccore/SilcMessageAPI/silc_message_signed_payload_parse
*
*
* DESCRIPTION
*
- * Parses the SILC_MESSAGE_FLAG_SIGNED Payload from the `data' of
+ * Parses the SilcMessageSignedPayload Payload from the `data' of
* length of `data_len' bytes. The `data' must be payload without
* the actual message payload. Returns the parsed payload or NULL
- * on error. Caller must free the returned payload.
+ * on error. Caller must free the returned payload. Application
+ * usually does not need to call this since the function
+ * silc_message_payload_parse calls this automatically for signed
+ * messages.
*
***/
SilcMessageSignedPayload
* SilcUInt32 message_payload_len,
* SilcPublicKey public_key,
* SilcPrivateKey private_key,
- * bool include_public_key);
+ * SilcHash hash);
*
* DESCRIPTION
*
- * Encodes the SILC_MESSAGE_FLAG_SIGNED Payload and computes the
+ * Encodes the SilcMessageSignedPayload Payload and computes the
* digital signature. The `message_payload' is the message data that
* is used in the signature computation. The encoding of the buffer
- * is specified in the SILC protocol. If `include_public_key' is
- * TRUE then the public key included in the payload. The `private_key'
+ * is specified in the SILC protocol. If `public_key' is provided
+ * then the public key included in the payload. The `private_key'
* is used to produce the signature. This function returns the encoded
* payload with the signature or NULL on error. Caller must free the
- * returned buffer.
+ * returned buffer. The `hash' SHOULD be SHA-1 hash function.
+ *
+ * Application usually does not need to call this since the function
+ * silc_message_payload_encode calls this automatically if the caller
+ * wants to sign the message.
*
***/
SilcBuffer
SilcUInt32 message_payload_len,
SilcPublicKey public_key,
SilcPrivateKey private_key,
- SilcHash hash,
- bool include_public_key);
+ SilcHash hash);
/****f* silccore/SilcMessageAPI/silc_message_signed_payload_free
*
*
* DESCRIPTION
*
- * Frees the SILC_MESSAGE_FLAG_SIGNED Payload.
+ * Frees the SilcMessageSignedPayload Payload.
*
***/
void silc_message_signed_payload_free(SilcMessageSignedPayload sig);
* DESCRIPTION
*
* This routine can be used to verify the signature found in
- * SILC_MESSAGE_FLAG_SIGNED Payload. This returns SILC_AUTH_OK if the
+ * SilcMessageSignedPayload Payload. This returns SILC_AUTH_OK if the
* signature verification was successful.
*
***/
*
* DESCRIPTION
*
- * Returns the public key from the SILC_MESSAGE_FLAG_SIGNED Payload
- * or NULL if it does not include public key. The caller must free
- * the returned public key.
+ * Returns the decoded SilcPublicKey from the SilcMessageSignedPayload
+ * Payload or NULL if it does not include public key. The caller must
+ * free the returned public key pointer. This also returns the raw
+ * public key (before decoding) into `pk_data' and `pk_data_len' if
+ * they are provided. The caller must not free these pointers.
*
***/
SilcPublicKey
-silc_message_signed_get_public_key(SilcMessageSignedPayload sig);
+silc_message_signed_get_public_key(SilcMessageSignedPayload sig,
+ unsigned char **pk_data,
+ SilcUInt32 *pk_data_len);
#endif /* SILCMESSAGE_H */
/*
- silcnotify.c
+ silcnotify.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2000 Pekka Riikonen
+ Copyright (C) 2000 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
unsigned char **argv;
SilcUInt32 *argv_lens = NULL, *argv_types = NULL;
unsigned char *x;
- SilcUInt32 x_len;
- int i, k = 0, len = 0;
+ SilcUInt32 x_len, len = 0;
+ int i, k = 0;
if (argc) {
argv = silc_calloc(argc, sizeof(unsigned char *));
SilcBuffer args)
{
SilcBuffer buffer;
- int len;
+ SilcUInt32 len;
len = 5 + (args ? args->len : 0);
buffer = silc_buffer_alloc_size(len);
/* Encrypt the data area of the packet. */
if (cipher) {
- SILC_LOG_DEBUG(("Encrypting packet, cipher %s, len %d",
- silc_cipher_get_name(cipher), len));
+ SILC_LOG_DEBUG(("Encrypting packet (%d), cipher %s, len %d",
+ sequence, silc_cipher_get_name(cipher), len));
silc_cipher_encrypt(cipher, buffer->data, buffer->data, len, NULL);
}
const SilcBuffer assembled_packet)
{
unsigned char tmppad[SILC_PACKET_MAX_PADLEN];
- int block_len = cipher ? silc_cipher_get_block_len(cipher) : 0;
+ unsigned int block_len = cipher ? silc_cipher_get_block_len(cipher) : 0;
int i, ret;
SILC_LOG_DEBUG(("Assembling outgoing packet"));
SilcHmac hmac,
const SilcBuffer packet)
{
- int totlen;
+ SilcUInt32 totlen;
unsigned char *oldptr;
- int mac_len = hmac ? silc_hmac_len(hmac) : 0;
+ unsigned int mac_len = hmac ? silc_hmac_len(hmac) : 0;
if (!packet)
return FALSE;
void *parser_context)
{
SilcPacketParserContext *parse_ctx;
- int packetlen, paddedlen, mac_len = 0, ret, block_len;
+ SilcUInt16 packetlen;
+ SilcUInt32 paddedlen, mac_len = 0, block_len;
+ int ret;
bool cont = TRUE;
unsigned char tmp[SILC_PACKET_MIN_HEADER_LEN], *header;
unsigned char iv[SILC_CIPHER_MAX_IV_SIZE];
/* Check MAC of the packet */
if (!silc_packet_check_mac(hmac, sock->inbuf->data, paddedlen,
sock->inbuf->data + paddedlen, sequence)) {
- SILC_LOG_WARNING(("Packet MAC check failed %s:%d [%s] [%s]",
+ SILC_LOG_WARNING(("Packet MAC check failed %s:%d "
+ "[%s type %d len %dB seq %d] [%s]",
sock->hostname, sock->port,
silc_get_packet_name(header[3]),
+ header[3], paddedlen, sequence,
(sock->type == SILC_SOCKET_TYPE_UNKNOWN ? "Unknown" :
sock->type == SILC_SOCKET_TYPE_CLIENT ? "Client" :
sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" :
return FALSE;
parse_ctx->packet = silc_packet_context_alloc();
parse_ctx->packet->buffer = silc_buffer_alloc_size(paddedlen);
- parse_ctx->packet->type = header[3];
- parse_ctx->packet->padlen = header[4];
+ parse_ctx->packet->type = (SilcPacketType)header[3];
+ parse_ctx->packet->padlen = (SilcUInt8)header[4];
parse_ctx->packet->sequence = sequence++;
parse_ctx->sock = sock;
parse_ctx->context = parser_context;
if (cipher) {
/* Decrypt rest of the packet */
SILC_LOG_DEBUG(("Decrypting the packet"));
- silc_cipher_decrypt(cipher, buffer->data, buffer->data, buffer->len,
- NULL);
+ if (!silc_cipher_decrypt(cipher, buffer->data, buffer->data,
+ buffer->len, NULL)) {
+ SILC_LOG_ERROR(("silc_cipher_decrypt failed"));
+ return -1;
+ }
}
return 0;
/* Decrypt rest of the header plus padding */
if (cipher) {
SilcUInt16 len;
- int block_len = silc_cipher_get_block_len(cipher);
+ SilcUInt32 block_len = silc_cipher_get_block_len(cipher);
SILC_LOG_DEBUG(("Decrypting the header"));
return -1;
}
silc_buffer_pull(buffer, block_len);
- silc_cipher_decrypt(cipher, buffer->data, buffer->data, len, NULL);
+ if (!silc_cipher_decrypt(cipher, buffer->data, buffer->data,
+ len, NULL)) {
+ SILC_LOG_ERROR(("silc_cipher_decrypt failed"));
+ return -1;
+ }
}
return 1;
#define SILC_PACKET_LENGTH(__packetdata, __ret_truelen, __ret_paddedlen) \
do { \
SILC_GET16_MSB((__ret_truelen), (__packetdata)); \
- (__ret_paddedlen) = (__ret_truelen) + (__packetdata)[4]; \
+ (__ret_paddedlen) = (__ret_truelen) + (SilcUInt8)(__packetdata)[4]; \
} while(0)
/***/
--- /dev/null
+#
+# Makefile.am
+#
+# Author: Pekka Riikonen <priikone@silcnet.org>
+#
+# Copyright (C) 2002 Pekka Riikonen
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign
+
+bin_PROGRAMS = test_silcargument
+
+test_silcargument_SOURCES = test_silcargument.c
+
+LIBS = $(SILC_COMMON_LIBS)
+LDADD = -L.. -L../.. -lsilc
+
+include $(top_srcdir)/Makefile.defines.in
--- /dev/null
+/*
+
+ test_silcargument.c
+
+ Author: Pekka Riikonen <priikone@silcnet.org>
+
+ Copyright (C) 2002 Pekka Riikonen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+*/
+
+/* Tests:
+ silc_argument_payload_parse
+ silc_argument_payload_encode
+ silc_argument_payload_encode_one
+ silc_argument_payload_encode_payload
+ silc_argument_payload_free
+ silc_argument_get_arg_num
+ silc_argument_get_arg_first_arg
+ silc_argument_get_arg_next_arg
+ silc_argument_get_arg_type
+*/
+
+#include "silcincludes.h"
+#include "silcargument.h"
+
+#define ARG_NUM 250
+
+int main(int argc, char **argv)
+{
+ SilcArgumentPayload payload;
+ SilcBuffer args, args2;
+ char arg[ARG_NUM + 2];
+ int i;
+ unsigned char **argvv, *a;
+ SilcUInt32 *argvv_lens, l;
+ SilcUInt32 *argvv_types, t;
+ bool success = FALSE;
+
+ if (argc > 1 && !strcmp(argv[1], "-d")) {
+ silc_debug = 1;
+ silc_debug_hexdump = 1;
+ silc_log_set_debug_string("*argument*");
+ }
+
+ SILC_LOG_DEBUG(("Encoding %d arguments", ARG_NUM));
+ argvv = silc_calloc(ARG_NUM, sizeof(unsigned char *));
+ argvv_lens = silc_calloc(ARG_NUM, sizeof(SilcUInt32));
+ argvv_types = silc_calloc(ARG_NUM, sizeof(SilcUInt32));
+ for (i = 0; i < ARG_NUM; i++) {
+ memset(arg, 0, sizeof(arg));
+ memset(arg, 'a', i + 1);
+
+ SILC_LOG_DEBUG(("Argument %d, len %d, type %d", i + 1,
+ strlen(arg), i + 1));
+ SILC_LOG_HEXDUMP(("Argument data"), arg, strlen(arg));
+
+ argvv[i] = silc_memdup(arg, strlen(arg));
+ argvv_lens[i] = strlen(arg);
+ argvv_types[i] = i + 1;
+ }
+ args = silc_argument_payload_encode(ARG_NUM, argvv, argvv_lens, argvv_types);
+ if (!args)
+ goto out;
+ SILC_LOG_DEBUG(("Encoding was successful"));
+
+
+ SILC_LOG_DEBUG(("Adding one extra argument"));
+ memset(arg, 0, sizeof(arg));
+ memset(arg, 'a', ARG_NUM + 1);
+ SILC_LOG_DEBUG(("Argument %d, len %d, type %d", ARG_NUM + 1,
+ strlen(arg), ARG_NUM + 1));
+ SILC_LOG_HEXDUMP(("Argument data"), arg, strlen(arg));
+ args = silc_argument_payload_encode_one(args, arg, strlen(arg),
+ ARG_NUM + 1);
+ if (!args)
+ goto out;
+ SILC_LOG_DEBUG(("Adding one argument was successful"));
+
+ SILC_LOG_HEXDUMP(("Encoded payload"), args->data, args->len);
+
+
+ SILC_LOG_DEBUG(("Parsing the encoded payload"));
+ payload = silc_argument_payload_parse(args->data, args->len, ARG_NUM + 1);
+ if (!payload)
+ goto out;
+ SILC_LOG_DEBUG(("Parsing was successful"));
+
+
+ SILC_LOG_DEBUG(("Re-encoding the parsed payload"));
+ args2 = silc_argument_payload_encode_payload(payload);
+ if (!args2)
+ goto out;
+ if (args2->len != args->len ||
+ memcmp(args2->data, args->data, args->len)) {
+ SILC_LOG_DEBUG(("Re-encoding failed"));
+ goto out;
+ }
+ silc_buffer_free(args2);
+ SILC_LOG_DEBUG(("Re-encoding was successful"));
+
+
+ SILC_LOG_DEBUG(("Checking number of arguments"));
+ SILC_LOG_DEBUG(("Number of arguments: %d (expecting %d)",
+ silc_argument_get_arg_num(payload), ARG_NUM + 1));
+ if (silc_argument_get_arg_num(payload) != ARG_NUM + 1)
+ goto out;
+
+
+ SILC_LOG_DEBUG(("Traversing the parsed arguments"));
+ i = 0;
+ a = silc_argument_get_first_arg(payload, &t, &l);
+ if (!a || t != argvv_types[0] || l != argvv_lens[0] ||
+ memcmp(a, argvv[0], l)) {
+ SILC_LOG_DEBUG(("First argument failed"));
+ goto out;
+ }
+ while (a) {
+ if (i + 1 == ARG_NUM + 1) {
+ SILC_LOG_DEBUG(("Argument %d, len %d (expected %d), "
+ "type %d (expected %d)", i + 1, l, strlen(arg),
+ t, ARG_NUM + 1));
+ if (!a || t != ARG_NUM + 1 || l != strlen(arg) ||
+ memcmp(a, arg, l)) {
+ SILC_LOG_DEBUG(("Argument %d failed", ARG_NUM + 1));
+ goto out;
+ }
+ } else {
+ SILC_LOG_DEBUG(("Argument %d, len %d (expected %d), "
+ "type %d (expected %d)", i + 1, l, argvv_lens[i],
+ t, argvv_types[i]));
+ if (!a || t != argvv_types[i] || l != argvv_lens[i] ||
+ memcmp(a, argvv[i], l)) {
+ SILC_LOG_DEBUG(("Argument %d failed", i + 1));
+ goto out;
+ }
+ }
+ a = silc_argument_get_next_arg(payload, &t, &l);
+ i++;
+ }
+ if (i != ARG_NUM + 1) {
+ SILC_LOG_DEBUG(("All arguments was not parsed, missing %d args",
+ ARG_NUM + 1 - i));
+ goto out;
+ }
+ SILC_LOG_DEBUG(("Traversing successful"));
+
+
+ SILC_LOG_DEBUG(("Traversing arguments by type"));
+ for (i = 0; i < ARG_NUM + 1; i++) {
+ a = silc_argument_get_arg_type(payload, i + 1, &l);
+ if (i + 1 == ARG_NUM + 1) {
+ if (!a || t != ARG_NUM + 1 || l != strlen(arg) ||
+ memcmp(a, arg, l)) {
+ SILC_LOG_DEBUG(("Argument %d failed", ARG_NUM + 1));
+ goto out;
+ }
+ } else {
+ if (!a || l != argvv_lens[i] || memcmp(a, argvv[i], l)) {
+ SILC_LOG_DEBUG(("Argument %d failed", i + 1));
+ goto out;
+ }
+ }
+ }
+ SILC_LOG_DEBUG(("Traversing successful"));
+
+ success = TRUE;
+
+ out:
+ silc_argument_payload_free(payload);
+ for (i = 0; i < ARG_NUM; i++)
+ silc_free(argvv[i]);
+ silc_free(argvv);
+ silc_free(argvv_lens);
+ silc_free(argvv_types);
+ silc_buffer_free(args);
+
+ SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
+ fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
+
+ exit(success);
+}
silcpkcs.c \
pkcs1.c
+if SILC_LIBTOOLFIX
+# Tell libtool to compile silccrypt as shared since silcsim will need it.
+LTFLAGS = --libtool-enable-shared
+else
+LTFLAGS =
+endif
+
+CFLAGS = $(LTFLAGS)
+
if SILC_DIST_TOOLKIT
include_HEADERS = \
aes.h \
twofish.h
endif
-EXTRA_DIST = *.h
+EXTRA_DIST = *.h tests
include $(top_srcdir)/Makefile.defines.in
#define MD5_INTERNAL_H
struct MD5Context {
- SilcUInt32 buf[4];
- SilcUInt32 bits[2];
- unsigned char in[64];
+ SilcUInt32 buf[4];
+ SilcUInt32 bits[2];
+ unsigned char in[64];
};
void MD5Init(struct MD5Context *context);
unsigned char *dst, SilcUInt32 len,
unsigned char *iv)
{
+#ifdef SILC_DEBUG
+ assert((len & (cipher->cipher->block_len - 1)) == 0);
+#endif
+ if (len & (cipher->cipher->block_len - 1))
+ return FALSE;
return cipher->cipher->encrypt(cipher->context, src, dst, len,
iv ? iv : cipher->iv);
}
unsigned char *dst, SilcUInt32 len,
unsigned char *iv)
{
+#ifdef SILC_DEBUG
+ assert((len & (cipher->cipher->block_len - 1)) == 0);
+#endif
+ if (len & (cipher->cipher->block_len - 1))
+ return FALSE;
return cipher->cipher->decrypt(cipher->context, src, dst, len,
iv ? iv : cipher->iv);
}
if (!public_key)
return FALSE;
-#if 1
- /* XXX 1.1 version support. Check whether the data is actually raw
- public key and attempt to decode. Remove this later! */
- if (silc_pkcs_public_key_decode(data, data_len, public_key)) {
- (*public_key)->pk_type = SILC_SKE_PK_TYPE_SILC;
- return TRUE;
- }
-#endif
-
silc_buffer_set(&buf, data, data_len);
ret = silc_buffer_unformat(&buf,
SILC_STR_UI_SHORT(&pk_len),
/* Internal routine to save public key */
-static bool silc_pkcs_save_public_key_internal(char *filename,
+static bool silc_pkcs_save_public_key_internal(const char *filename,
unsigned char *data,
SilcUInt32 data_len,
SilcUInt32 encoding)
/* Saves public key into file */
-bool silc_pkcs_save_public_key(char *filename, SilcPublicKey public_key,
+bool silc_pkcs_save_public_key(const char *filename, SilcPublicKey public_key,
SilcUInt32 encoding)
{
unsigned char *data;
/* Saves public key into file */
-bool silc_pkcs_save_public_key_data(char *filename, unsigned char *data,
- SilcUInt32 data_len,
- SilcUInt32 encoding)
+bool silc_pkcs_save_public_key_data(const char *filename, unsigned char *data,
+ SilcUInt32 data_len, SilcUInt32 encoding)
{
return silc_pkcs_save_public_key_internal(filename, data, data_len,
encoding);
/* Internal routine to save private key. */
-static bool silc_pkcs_save_private_key_internal(char *filename,
+static bool silc_pkcs_save_private_key_internal(const char *filename,
unsigned char *data,
SilcUInt32 data_len,
unsigned char *key,
SilcUInt32 encoding)
{
SilcCipher aes;
- SilcHash md5;
+ SilcHash sha1;
SilcHmac sha1hmac;
SilcBuffer buf, enc;
- SilcUInt32 len, blocklen;
- unsigned char tmp[32], keymat[32];
+ SilcUInt32 len, blocklen, padlen;
+ unsigned char tmp[32], keymat[64];
int i;
memset(tmp, 0, sizeof(tmp));
if (blocklen * 2 > sizeof(tmp))
return FALSE;
- /* Allocate MD5 hash */
- if (!silc_hash_alloc("md5", &md5)) {
- SILC_LOG_ERROR(("Could not allocate MD5 hash, probably not registered"));
+ /* Allocate SHA1 hash */
+ if (!silc_hash_alloc("sha1", &sha1)) {
+ SILC_LOG_ERROR(("Could not allocate SHA1 hash, probably not registered"));
silc_cipher_free(aes);
return FALSE;
}
/* Allocate HMAC */
if (!silc_hmac_alloc("hmac-sha1-96", NULL, &sha1hmac)) {
SILC_LOG_ERROR(("Could not allocate SHA1 HMAC, probably not registered"));
- silc_hash_free(md5);
+ silc_hash_free(sha1);
silc_cipher_free(aes);
return FALSE;
}
is 256 bits length, and derived by taking hash of the data, then
re-hashing the data and the previous digest, and using the first and
second digest as the key. */
- silc_hash_init(md5);
- silc_hash_update(md5, key, key_len);
- silc_hash_final(md5, keymat);
- silc_hash_init(md5);
- silc_hash_update(md5, key, key_len);
- silc_hash_update(md5, keymat, 16);
- silc_hash_final(md5, keymat + 16);
+ silc_hash_init(sha1);
+ silc_hash_update(sha1, key, key_len);
+ silc_hash_final(sha1, keymat);
+ silc_hash_init(sha1);
+ silc_hash_update(sha1, key, key_len);
+ silc_hash_update(sha1, keymat, 16);
+ silc_hash_final(sha1, keymat + 16);
/* Set the key to the cipher */
- silc_cipher_set_key(aes, keymat, sizeof(keymat) * 8);
+ silc_cipher_set_key(aes, keymat, 256);
/* Encode the buffer to be encrypted. Add padding to it too, at least
block size of the cipher. */
/* Allocate buffer for encryption */
len = silc_hmac_len(sha1hmac);
- enc = silc_buffer_alloc_size(data_len + 4 + 4 +
- (blocklen + (data_len % blocklen)) + len);
+ padlen = 16 + (16 - ((data_len + 4) % blocklen));
+ enc = silc_buffer_alloc_size(4 + 4 + data_len + padlen + len);
if (!enc) {
silc_hmac_free(sha1hmac);
- silc_hash_free(md5);
+ silc_hash_free(sha1);
silc_cipher_free(aes);
return FALSE;
}
/* Generate padding */
- for (i = 0; i < blocklen + (data_len % blocklen); i++)
+ for (i = 0; i < padlen; i++)
tmp[i] = silc_rng_global_get_byte_fast();
/* Put magic number */
silc_buffer_format(enc,
SILC_STR_UI_INT(data_len),
SILC_STR_UI_XNSTRING(data, data_len),
- SILC_STR_UI_XNSTRING(tmp, blocklen + (data_len %
- blocklen)),
+ SILC_STR_UI_XNSTRING(tmp, padlen),
SILC_STR_END);
/* Encrypt. */
memset(keymat, 0, sizeof(keymat));
memset(tmp, 0, sizeof(tmp));
silc_hmac_free(sha1hmac);
- silc_hash_free(md5);
+ silc_hash_free(sha1);
silc_cipher_free(aes);
data = enc->data;
/* Saves private key into file. */
-bool silc_pkcs_save_private_key(char *filename, SilcPrivateKey private_key,
+bool silc_pkcs_save_private_key(const char *filename,
+ SilcPrivateKey private_key,
unsigned char *passphrase,
SilcUInt32 passphrase_len,
SilcUInt32 encoding)
/* Loads public key from file and allocates new public key. Returns TRUE
if loading was successful. */
-bool silc_pkcs_load_public_key(char *filename, SilcPublicKey *public_key,
+bool silc_pkcs_load_public_key(const char *filename, SilcPublicKey *public_key,
SilcUInt32 encoding)
{
unsigned char *cp, *old, *data, byte;
SilcUInt32 i, data_len, len;
+ SILC_LOG_DEBUG(("Loading public key `%s' with %s encoding", filename,
+ encoding == SILC_PKCS_FILE_PEM ? "Base64" :
+ encoding == SILC_PKCS_FILE_BIN ? "Binary" : "Unkonwn"));
+
old = data = silc_file_readfile(filename, &data_len);
if (!data)
return FALSE;
/* Load private key from file and allocates new private key. Returns TRUE
if loading was successful. */
-bool silc_pkcs_load_private_key(char *filename, SilcPrivateKey *private_key,
+bool silc_pkcs_load_private_key(const char *filename,
+ SilcPrivateKey *private_key,
unsigned char *passphrase,
SilcUInt32 passphrase_len,
SilcUInt32 encoding)
{
SilcCipher aes;
- SilcHash md5;
+ SilcHash sha1;
SilcHmac sha1hmac;
SilcUInt32 blocklen;
- unsigned char tmp[32], keymat[32];
+ unsigned char tmp[32], keymat[64];
unsigned char *cp, *old, *data, byte;
SilcUInt32 i, data_len, len, magic, mac_len;
+ SILC_LOG_DEBUG(("Loading private key `%s' with %s encoding", filename,
+ encoding == SILC_PKCS_FILE_PEM ? "Base64" :
+ encoding == SILC_PKCS_FILE_BIN ? "Binary" : "Unkonwn"));
+
old = data = silc_file_readfile(filename, &data_len);
if (!data)
return FALSE;
return FALSE;
}
- /* Allocate MD5 hash */
- if (!silc_hash_alloc("md5", &md5)) {
- SILC_LOG_ERROR(("Could not allocate MD5 hash, probably not registered"));
+ /* Allocate SHA1 hash */
+ if (!silc_hash_alloc("sha1", &sha1)) {
+ SILC_LOG_ERROR(("Could not allocate SHA1 hash, probably not registered"));
silc_cipher_free(aes);
memset(old, 0, data_len);
silc_free(old);
/* Allocate HMAC */
if (!silc_hmac_alloc("hmac-sha1-96", NULL, &sha1hmac)) {
SILC_LOG_ERROR(("Could not allocate SHA1 HMAC, probably not registered"));
- silc_hash_free(md5);
+ silc_hash_free(sha1);
silc_cipher_free(aes);
memset(old, 0, data_len);
silc_free(old);
is 256 bits length, and derived by taking hash of the data, then
re-hashing the data and the previous digest, and using the first and
second digest as the key. */
- silc_hash_init(md5);
- silc_hash_update(md5, passphrase, passphrase_len);
- silc_hash_final(md5, keymat);
- silc_hash_init(md5);
- silc_hash_update(md5, passphrase, passphrase_len);
- silc_hash_update(md5, keymat, 16);
- silc_hash_final(md5, keymat + 16);
+ silc_hash_init(sha1);
+ silc_hash_update(sha1, passphrase, passphrase_len);
+ silc_hash_final(sha1, keymat);
+ silc_hash_init(sha1);
+ silc_hash_update(sha1, passphrase, passphrase_len);
+ silc_hash_update(sha1, keymat, 16);
+ silc_hash_final(sha1, keymat + 16);
/* Set the key to the cipher */
- silc_cipher_set_key(aes, keymat, sizeof(keymat) * 8);
+ silc_cipher_set_key(aes, keymat, 256);
/* First, verify the MAC of the private key data */
mac_len = silc_hmac_len(sha1hmac);
memset(keymat, 0, sizeof(keymat));
memset(tmp, 0, sizeof(tmp));
silc_hmac_free(sha1hmac);
- silc_hash_free(md5);
+ silc_hash_free(sha1);
silc_cipher_free(aes);
memset(old, 0, data_len);
silc_free(old);
len -= 4;
/* Decrypt the private key buffer */
- silc_cipher_decrypt(aes, data, data, len - mac_len, silc_cipher_get_iv(aes));
+ silc_cipher_decrypt(aes, data, data, len - mac_len, NULL);
SILC_GET32_MSB(i, data);
if (i > len) {
SILC_LOG_DEBUG(("Bad private key length in buffer!"));
memset(keymat, 0, sizeof(keymat));
memset(tmp, 0, sizeof(tmp));
silc_hmac_free(sha1hmac);
- silc_hash_free(md5);
+ silc_hash_free(sha1);
silc_cipher_free(aes);
memset(old, 0, data_len);
silc_free(old);
memset(keymat, 0, sizeof(keymat));
memset(tmp, 0, sizeof(tmp));
silc_hmac_free(sha1hmac);
- silc_hash_free(md5);
+ silc_hash_free(sha1);
silc_cipher_free(aes);
/* Now decode the actual private key */
/****s* silccrypt/SilcPKCSAPI/SilcPKCS
*
* NAME
- *
+ *
* typedef struct SilcPKCSStruct *SilcPKCS;
*
* DESCRIPTION
*
* This context is the actual PKCS context and is allocated
* by silc_pkcs_alloc and given as argument usually to all
- * silc_pkcs _* functions. It is freed by the silc_pkcs_free
+ * silc_pkcs_* functions. It is freed by the silc_pkcs_free
* function.
*
***/
/****s* silccrypt/SilcPKCSAPI/SilcPublicKey
*
* NAME
- *
+ *
* typedef struct { ... } *SilcPublicKey;
*
* DESCRIPTION
*
* SILC style public key object. Public key is read from file to this
- * object. Public keys received from network must be in this format as
+ * object. Public keys received from network must be in this format as
* well. The format is defined by the SILC protocol specification.
* This object is allocated by silc_pkcs_public_key_alloc and freed
* by silc_pkcs_public_key_free. The object is given as argument to
/****s* silccrypt/SilcPKCSAPI/SilcPublicKeyIdentifier
*
* NAME
- *
+ *
* typedef struct { ... } *SilcPublicKeyIdentifier;
*
* DESCRIPTION
*
- * Decoded SILC Public Key identifier. Note that some of the fields
- * may be NULL. This context is allcated by the function
+ * Decoded SILC Public Key identifier. Note that some of the fields
+ * may be NULL. This context is allocated by the function
* silc_pkcs_decode_identifier and freed by silc_pkcs_free_identifier.
- * The identifier in SilcPublicKey is the 'identifier' field, which
+ * The identifier in SilcPublicKey is the `identifier' field, which
* can be given as argument to silc_pkcs_decode_identifier.
*
* SOURCE
/****s* silccrypt/SilcPKCSAPI/SilcPrivateKey
*
* NAME
- *
+ *
* typedef struct { ... } *SilcPrivateKey;
*
* DESCRIPTION
as argument to the init function. By doing this we would achieve
that PKCS could be used as SIM's. The only requirement would be
that they are compiled against GMP (well, actually even that would
- not be a requirement, but the most generic case anyway). The new init
+ not be a requirement, but the most generic case anyway). The new init
would look something like this:
#define SILC_PKCS_API_INIT(pkcs) \
inline int silc_##pkcs##_init(void *context, SilcUInt32 keylen, \
void *p1, void *p2)
- Now we wouldn't have to send the SilcRng object since the primes are
- provided as arguments. To send them as void * they could actually be
- used as in anyway for real (MP_INT (SilcMPInt) or even something else
+ Now we wouldn't have to send the SilcRng object since the primes are
+ provided as arguments. To send them as void * they could actually be
+ used as in anyway for real (MP_INT (SilcMPInt) or even something else
(the pointer could be kludged to be something else in the module))
(Plus, the SilcRng object management in prime generation would be
simpler and better what it is now (in silcprimegen.c, that is)).
*
* DESCRIPTION
*
- * Allocates a new SilcPKCS object. The new allocated object is returned
- * to the 'new_pkcs' argument. Returns FALSE on error.
+ * Allocates a new SilcPKCS object. The new allocated object is returned
+ * to the 'new_pkcs' argument. Returns FALSE on error.
*
***/
bool silc_pkcs_alloc(const unsigned char *name, SilcPKCS *new_pkcs);
* SYNOPSIS
*
* unsigned char *silc_pkcs_get_private_key(SilcPKCS pkcs,
- * SilcUInt32 *len);
+ * SilcUInt32 *len);
*
* DESCRIPTION
*
* SYNOPSIS
*
* SilcUInt32 silc_pkcs_public_key_set(SilcPKCS pkcs,
- * SilcPublicKey public_key);
+ * SilcPublicKey public_key);
*
* DESCRIPTION
*
*
* SilcUInt32 silc_pkcs_public_key_data_set(SilcPKCS pkcs,
* unsigned char *pk,
- * SilcUInt32 pk_len);
+ * SilcUInt32 pk_len);
*
* DESCRIPTION
*
* SYNOPSIS
*
* SilcUInt32 silc_pkcs_private_key_set(SilcPKCS pkcs,
- * SilcPrivateKey private_key);
+ * SilcPrivateKey private_key);
*
* DESCRIPTION
*
* SYNOPSIS
*
* SilcUInt32 silc_pkcs_private_key_data_set(SilcPKCS pkcs,
- * unsigned char *prv,
- * SilcUInt32 prv_len);
+ * unsigned char *prv,
+ * SilcUInt32 prv_len);
*
* DESCRIPTION
*
* SYNOPSIS
*
* bool silc_pkcs_encrypt(SilcPKCS pkcs, unsigned char *src,
- * SilcUInt32 src_len, unsigned char *dst,
- * SilcUInt32 *dst_len);
+ * SilcUInt32 src_len, unsigned char *dst,
+ * SilcUInt32 *dst_len);
*
* DESCRIPTION
*
* SYNOPSIS
*
* bool silc_pkcs_decrypt(SilcPKCS pkcs, unsigned char *src,
- * SilcUInt32 src_len, unsigned char *dst,
- * SilcUInt32 *dst_len);
+ * SilcUInt32 src_len, unsigned char *dst,
+ * SilcUInt32 *dst_len);
*
* DESCRIPTION
*
- * Decrypts. Returns FALSE on error.
+ * Decrypts. Returns FALSE on error.
*
***/
bool silc_pkcs_decrypt(SilcPKCS pkcs, unsigned char *src, SilcUInt32 src_len,
* SYNOPSIS
*
* bool silc_pkcs_sign(SilcPKCS pkcs, unsigned char *src,
- * SilcUInt32 src_len, unsigned char *dst,
- * SilcUInt32 *dst_len);
+ * SilcUInt32 src_len, unsigned char *dst,
+ * SilcUInt32 *dst_len);
*
* DESCRIPTION
*
- * Generates signature. Returns FALSE on error.
+ * Generates signature. Returns FALSE on error.
*
***/
bool silc_pkcs_sign(SilcPKCS pkcs, unsigned char *src, SilcUInt32 src_len,
* SYNOPSIS
*
* bool silc_pkcs_verify(SilcPKCS pkcs, unsigned char *signature,
- * SilcUInt32 signature_len, unsigned char *data,
- * SilcUInt32 data_len);
+ * SilcUInt32 signature_len, unsigned char *data,
+ * SilcUInt32 data_len);
*
* DESCRIPTION
*
- * Verifies signature. Returns FALSE on error.
+ * Verifies signature. Returns FALSE on error.
*
***/
bool silc_pkcs_verify(SilcPKCS pkcs, unsigned char *signature,
* SYNOPSIS
*
* bool silc_pkcs_sign_with_hash(SilcPKCS pkcs, SilcHash hash,
- * unsigned char *src, SilcUInt32 src_len,
- * unsigned char *dst, SilcUInt32 *dst_len);
+ * unsigned char *src, SilcUInt32 src_len,
+ * unsigned char *dst, SilcUInt32 *dst_len);
*
* DESCRIPTION
*
- * Generates signature with hash. The hash is signed. Returns FALSE on
+ * Generates signature with hash. The hash is signed. Returns FALSE on
* error.
*
***/
* SYNOPSIS
*
* bool silc_pkcs_verify_with_hash(SilcPKCS pkcs, SilcHash hash,
- * unsigned char *signature,
- * SilcUInt32 signature_len,
- * unsigned char *data,
- * SilcUInt32 data_len);
+ * unsigned char *signature,
+ * SilcUInt32 signature_len,
+ * unsigned char *data,
+ * SilcUInt32 data_len);
*
* DESCRIPTION
*
- * Verifies signature with hash. The `data' is hashed and verified against
- * the `signature'. Returns FALSE on error.
+ * Verifies signature with hash. The `data' is hashed and verified against
+ * the `signature'. Returns FALSE on error.
*
***/
bool silc_pkcs_verify_with_hash(SilcPKCS pkcs, SilcHash hash,
* SYNOPSIS
*
* char *silc_pkcs_encode_identifier(char *username, char *host,
- * char *realname, char *email,
- * char *org, char *country);
+ * char *realname, char *email,
+ * char *org, char *country);
*
* DESCRIPTION
*
*
* DESCRIPTION
*
- * Frees decoded public key identifier context. Call this to free the
+ * Frees decoded public key identifier context. Call this to free the
* context returned by the silc_pkcs_decode_identifier.
*
***/
* SYNOPSIS
*
* SilcPublicKey silc_pkcs_public_key_alloc(const char *name,
- * const char *identifier,
- * const unsigned char *pk,
- * SilcUInt32 pk_len);
+ * const char *identifier,
+ * const unsigned char *pk,
+ * SilcUInt32 pk_len);
*
* DESCRIPTION
*
- * Allocates SILC style public key formed from sent arguments. All data
+ * Allocates SILC style public key formed from sent arguments. All data
* is duplicated.
*
***/
* SYNOPSIS
*
* SilcPrivateKey silc_pkcs_private_key_alloc(const char *name,
- * const unsigned char *prv,
- * SilcUInt32 prv_len);
+ * const unsigned char *prv,
+ * SilcUInt32 prv_len);
*
* DESCRIPTION
*
- * Allocates SILC private key formed from sent arguments. All data is
+ * Allocates SILC private key formed from sent arguments. All data is
* duplicated.
*
***/
*
* DESCRIPTION
*
- * Encodes SILC style public key from SilcPublicKey. Returns the encoded
+ * Encodes SILC style public key from SilcPublicKey. Returns the encoded
* data.
*
***/
*
* unsigned char *
* silc_pkcs_public_key_data_encode(unsigned char *pk, SilcUInt32 pk_len,
- * char *pkcs, char *identifier,
- * SilcUInt32 *len);
+ * char *pkcs, char *identifier,
+ * SilcUInt32 *len);
*
* DESCRIPTION
*
- * Encodes SILC style public key. Returns the encoded data.
+ * Encodes SILC style public key. Returns the encoded data.
*
***/
unsigned char *
silc_pkcs_public_key_data_encode(unsigned char *pk, SilcUInt32 pk_len,
- char *pkcs, char *identifier,
- SilcUInt32 *len);
+ char *pkcs, char *identifier,
+ SilcUInt32 *len);
/****f* silccrypt/SilcPKCSAPI/silc_pkcs_public_key_decode
*
bool silc_pkcs_public_key_decode(unsigned char *data, SilcUInt32 data_len,
SilcPublicKey *public_key);
-/****f* silccrypt/SilcPKCSAPI/silc_pkcs_public_key_decode
+/****f* silccrypt/SilcPKCSAPI/silc_pkcs_public_key_payload_encode
*
* SYNOPSIS
*
***/
SilcBuffer silc_pkcs_public_key_payload_encode(SilcPublicKey public_key);
-/****f* silccrypt/SilcPKCSAPI/silc_pkcs_public_key_decode
+/****f* silccrypt/SilcPKCSAPI/silc_pkcs_public_key_payload_decode
*
* SYNOPSIS
*
- * bool
- * silc_pkcs_public_key_payload_decode(unsigned char *data,
- * SilcUInt32 data_len,
- * SilcPublicKey *public_key);
+ * bool silc_pkcs_public_key_payload_decode(unsigned char *data,
+ * SilcUInt32 data_len,
+ * SilcPublicKey *public_key);
*
* DESCRIPTION
*
* Decodes Public Key Payload from `data' of `data_len' bytes in length
- * data buffer into `public_key' pointer. Returns FALSE if the payload
+ * data buffer into `public_key' pointer. Returns FALSE if the payload
* cannot be decoded.
*
***/
* SYNOPSIS
*
* bool silc_pkcs_public_key_compare(SilcPublicKey key1,
- * SilcPublicKey key2);
+ * SilcPublicKey key2);
*
* DESCRIPTION
*
*
* unsigned char *
* silc_pkcs_private_key_encode(SilcPrivateKey private_key,
- * SilcUInt32 *len);
+ * SilcUInt32 *len);
*
* DESCRIPTION
*
- * Encodes SILC private key from SilcPrivateKey. Returns the encoded data.
+ * Encodes SILC private key from SilcPrivateKey. Returns the encoded data.
*
***/
unsigned char *
*
* unsigned char *
* silc_pkcs_private_key_data_encode(unsigned char *prv, SilcUInt32 prv_len,
- * char *pkcs, SilcUInt32 *len);
+ * char *pkcs, SilcUInt32 *len);
*
* DESCRIPTION
*
- * Encodes SILC private key. Returns the encoded data.
+ * Encodes SILC private key. Returns the encoded data.
*
***/
unsigned char *
* SYNOPSIS
*
* bool silc_pkcs_private_key_decode(unsigned char *data,
- * SilcUInt32 data_len,
- * SilcPrivateKey *private_key);
+ * SilcUInt32 data_len,
+ * SilcPrivateKey *private_key);
*
* DESCRIPTION
*
- * Decodes SILC style private key. Returns TRUE if the decoding was
- * successful. Allocates new private key as well.
+ * Decodes SILC style private key. Returns TRUE if the decoding was
+ * successful. Allocates new private key as well.
*
***/
bool silc_pkcs_private_key_decode(unsigned char *data, SilcUInt32 data_len,
*
* SYNOPSIS
*
- * bool silc_pkcs_save_public_key(char *filename, SilcPublicKey public_key,
- * SilcUInt32 encoding);
+ * bool silc_pkcs_save_public_key(const char *filename,
+ * SilcPublicKey public_key,
+ * SilcUInt32 encoding);
*
* DESCRIPTION
*
- * Saves public key into file. Returns FALSE on error.
+ * Saves public key into file. Returns FALSE on error.
*
***/
-bool silc_pkcs_save_public_key(char *filename, SilcPublicKey public_key,
+bool silc_pkcs_save_public_key(const char *filename, SilcPublicKey public_key,
SilcUInt32 encoding);
/****f* silccrypt/SilcPKCSAPI/silc_pkcs_save_public_key_data
*
* SYNOPSIS
*
- * bool silc_pkcs_save_public_key_data(char *filename, unsigned char *data,
- * SilcUInt32 data_len,
- * SilcUInt32 encoding);
+ * bool silc_pkcs_save_public_key_data(const char *filename,
+ * unsigned char *data,
+ * SilcUInt32 data_len,
+ * SilcUInt32 encoding);
*
* DESCRIPTION
*
* data when calling this function. Returns FALSE on error.
*
***/
-bool silc_pkcs_save_public_key_data(char *filename, unsigned char *data,
- SilcUInt32 data_len,
- SilcUInt32 encoding);
+bool silc_pkcs_save_public_key_data(const char *filename, unsigned char *data,
+ SilcUInt32 data_len, SilcUInt32 encoding);
/****f* silccrypt/SilcPKCSAPI/silc_pkcs_save_private_key
*
* SYNOPSIS
*
- * bool silc_pkcs_save_private_key(char *filename,
- * SilcPrivateKey private_key,
+ * bool silc_pkcs_save_private_key(const char *filename,
+ * SilcPrivateKey private_key,
* unsigned char *passphrase,
* SilcUInt32 passphrase_len,
* SilcUInt32 encoding);
* is AES with 256 bit key in CBC mode. Returns FALSE on error.
*
***/
-bool silc_pkcs_save_private_key(char *filename, SilcPrivateKey private_key,
+bool silc_pkcs_save_private_key(const char *filename,
+ SilcPrivateKey private_key,
unsigned char *passphrase,
SilcUInt32 passphrase_len,
SilcUInt32 encoding);
*
* SYNOPSIS
*
- * bool silc_pkcs_load_public_key(char *filename, SilcPublicKey *public_key,
- * SilcUInt32 encoding);
+ * bool silc_pkcs_load_public_key(const char *filename,
+ * SilcPublicKey *public_key,
+ * SilcUInt32 encoding);
*
* DESCRIPTION
*
- * Loads public key from file and allocates new public key. Returns TRUE
+ * Loads public key from file and allocates new public key. Returns TRUE
* if loading was successful.
*
***/
-bool silc_pkcs_load_public_key(char *filename, SilcPublicKey *public_key,
+bool silc_pkcs_load_public_key(const char *filename, SilcPublicKey *public_key,
SilcUInt32 encoding);
/****f* silccrypt/SilcPKCSAPI/silc_pkcs_load_private_key
*
* SYNOPSIS
*
- * bool silc_pkcs_load_private_key(char *filename,
+ * bool silc_pkcs_load_private_key(const char *filename,
* SilcPrivateKey *private_key,
* unsigned char *passphrase,
* SilcUInt32 passphrase_len,
*
* DESCRIPTION
*
- * Load private key from file and allocates new private key. Returns TRUE
- * if loading was successful. The `passphrase' is used as decryption
+ * Loads private key from file and allocates new private key. Returns TRUE
+ * if loading was successful. The `passphrase' is used as decryption
* key of the private key file.
*
***/
-bool silc_pkcs_load_private_key(char *filename, SilcPrivateKey *private_key,
+bool silc_pkcs_load_private_key(const char *filename,
+ SilcPrivateKey *private_key,
unsigned char *passphrase,
SilcUInt32 passphrase_len,
SilcUInt32 encoding);
-#endif /* SILCPKCS_H */
+#endif /* !SILCPKCS_H */
--- /dev/null
+#
+# Makefile.am
+#
+# Author: Pekka Riikonen <priikone@silcnet.org>
+#
+# Copyright (C) 2002 Pekka Riikonen
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign
+
+bin_PROGRAMS = test_sha1 \
+ test_md5 \
+ test_hmacsha1 \
+ test_hmacmd5 \
+ test_aes \
+ test_twofish
+
+test_sha1_SOURCES = test_sha1.c
+test_md5_SOURCES = test_md5.c
+test_hmacsha1_SOURCES = test_hmacsha1.c
+test_hmacmd5_SOURCES = test_hmacmd5.c
+
+test_aes_SOURCES = test_aes.c
+test_twofish_SOURCES = test_aes.c
+
+LIBS = $(SILC_COMMON_LIBS)
+LDADD = -L.. -L../.. -lsilc
+
+include $(top_srcdir)/Makefile.defines.in
+++ /dev/null
-gcc -I.. \
--I../../../includes -I../../silccore -I../../trq -I../../silcske \
--I../.. -I../../silccore -I../../silcmath -I../../silcutil \
--I../../silcmath/mpi -I../../silcske -I../../silcsim \
--I../../silcsftp -Wall -finline-functions \
--o test_aes test_aes.c -L../.. -lsilc
-
+++ /dev/null
-gcc -I.. \
--I../../../includes -I../../silccore -I../../trq -I../../silcske \
--I../.. -I../../silccore -I../../silcmath -I../../silcutil \
--I../../silcmath/gmp -I../../silcske -I../../silcsim \
--Wall -finline-functions \
--o test_twofish test_twofish.c -L../.. -lsilc
-
--- /dev/null
+#include "silcincludes.h"
+
+/* Test vectors from RFC 2202 */
+
+/* First test vector */
+const unsigned char key1[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
+int key1_len = 16;
+const unsigned char data1[] = "Hi There";
+const unsigned char data1_digest[] = "\x92\x94\x72\x7a\x36\x38\xbb\x1c\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d";
+
+/* Second test vector */
+const unsigned char key2[] = "Jefe";
+int key2_len = 4;
+const unsigned char data2[] = "what do ya want for nothing?";
+const unsigned char data2_digest[] = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38";
+
+/* Third test vector, data 0xdd repeated 50 times */
+const unsigned char key3[] = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa";
+int key3_len = 16;
+unsigned char data3[50];
+const unsigned char data3_digest[] = "\x56\xbe\x34\x52\x1d\x14\x4c\x88\xdb\xb8\xc7\x33\xf0\xe8\xb3\xf6";
+
+/* Fourth test vector, key 0xaa 80 times */
+unsigned char key4[80];
+int key4_len = 80;
+const unsigned char data4[] = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data";
+const unsigned char data4_digest[] = "\x6f\x63\x0f\xad\x67\xcd\xa0\xee\x1f\xb1\xf5\x62\xdb\x3a\xa5\x3e";
+
+int main(int argc, char **argv)
+{
+ bool success = FALSE;
+ unsigned char digest[16];
+ SilcUInt32 len;
+ SilcHmac hmac;
+
+ if (argc > 1 && !strcmp(argv[1], "-d")) {
+ silc_debug = 1;
+ silc_debug_hexdump = 1;
+ silc_log_set_debug_string("*crypt*,*hash*,*md5*,*hmac*");
+ }
+
+ SILC_LOG_DEBUG(("Registering builtin hash functions"));
+ silc_hash_register_default();
+ silc_hmac_register_default();
+
+ SILC_LOG_DEBUG(("Allocating md5 HMAC"));
+ if (!silc_hmac_alloc("hmac-md5", NULL, &hmac)) {
+ SILC_LOG_DEBUG(("Allocating md5 HMAC failed"));
+ goto err;
+ }
+
+ /* First test vector */
+ SILC_LOG_DEBUG(("First test vector"));
+ silc_hmac_init_with_key(hmac, key1, key1_len);
+ silc_hmac_update(hmac, data1, strlen(data1));
+ silc_hmac_final(hmac, digest, &len);
+ SILC_LOG_HEXDUMP(("Key"), (unsigned char *)key1, key1_len);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data1, strlen(data1));
+ SILC_LOG_HEXDUMP(("Digest"), digest, len);
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data1_digest, len);
+ if (memcmp(digest, data1_digest, len)) {
+ SILC_LOG_DEBUG(("HMAC failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("HMAC is successful"));
+
+ /* Second test vector */
+ SILC_LOG_DEBUG(("Second test vector"));
+ silc_hmac_init_with_key(hmac, key2, key2_len);
+ silc_hmac_update(hmac, data2, strlen(data2));
+ silc_hmac_final(hmac, digest, &len);
+ SILC_LOG_HEXDUMP(("Key"), (unsigned char *)key2, key2_len);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data2, strlen(data2));
+ SILC_LOG_HEXDUMP(("Digest"), digest, len);
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data2_digest, len);
+ if (memcmp(digest, data2_digest, len)) {
+ SILC_LOG_DEBUG(("HMAC failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("HMAC is successful"));
+
+ /* Third test vector */
+ SILC_LOG_DEBUG(("Third test vector"));
+ silc_hmac_init_with_key(hmac, key3, key3_len);
+ memset(data3, '\xdd', sizeof(data3));
+ silc_hmac_update(hmac, data3, sizeof(data3));
+ silc_hmac_final(hmac, digest, &len);
+ SILC_LOG_HEXDUMP(("Key"), (unsigned char *)key3, key3_len);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data3, sizeof(data3));
+ SILC_LOG_HEXDUMP(("Digest"), digest, len);
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data3_digest, len);
+ if (memcmp(digest, data3_digest, len)) {
+ SILC_LOG_DEBUG(("HMAC failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("HMAC is successful"));
+
+ /* Fourth test vector */
+ SILC_LOG_DEBUG(("Fourth test vector"));
+ memset(key4, '\xaa', key4_len);
+ silc_hmac_init_with_key(hmac, key4, key4_len);
+ silc_hmac_update(hmac, data4, strlen(data4));
+ silc_hmac_final(hmac, digest, &len);
+ SILC_LOG_HEXDUMP(("Key"), (unsigned char *)key4, key4_len);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data4, sizeof(data4));
+ SILC_LOG_HEXDUMP(("Digest"), digest, len);
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data4_digest, len);
+ if (memcmp(digest, data4_digest, len)) {
+ SILC_LOG_DEBUG(("HMAC failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("HMAC is successful"));
+
+ success = TRUE;
+
+ err:
+ SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
+ fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
+
+ silc_hmac_free(hmac);
+ silc_hash_unregister_all();
+ silc_hmac_unregister_all();
+ return success;
+}
--- /dev/null
+#include "silcincludes.h"
+
+/* Test vectors from RFC 2202 */
+
+/* First test vector */
+const unsigned char key1[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b";
+int key1_len = 20;
+const unsigned char data1[] = "Hi There";
+const unsigned char data1_digest[] = "\xb6\x17\x31\x86\x55\x05\x72\x64\xe2\x8b\xc0\xb6\xfb\x37\x8c\x8e\xf1\x46\xbe\x00";
+
+/* Second test vector */
+const unsigned char key2[] = "Jefe";
+int key2_len = 4;
+const unsigned char data2[] = "what do ya want for nothing?";
+const unsigned char data2_digest[] = "\xef\xfc\xdf\x6a\xe5\xeb\x2f\xa2\xd2\x74\x16\xd5\xf1\x84\xdf\x9c\x25\x9a\x7c\x79";
+
+/* Third test vector, data 0xdd repeated 50 times */
+const unsigned char key3[] = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa";
+int key3_len = 20;
+unsigned char data3[50];
+const unsigned char data3_digest[] = "\x12\x5d\x73\x42\xb9\xac\x11\xcd\x91\xa3\x9a\xf4\x8a\xa1\x7b\x4f\x63\xf1\x75\xd3";
+
+/* Fourth test vector, key 0xaa 80 times */
+unsigned char key4[80];
+int key4_len = 80;
+const unsigned char data4[] = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data";
+const unsigned char data4_digest[] = "\xe8\xe9\x9d\x0f\x45\x23\x7d\x78\x6d\x6b\xba\xa7\x96\x5c\x78\x08\xbb\xff\x1a\x91";
+
+int main(int argc, char **argv)
+{
+ bool success = FALSE;
+ unsigned char digest[20];
+ SilcUInt32 len;
+ SilcHmac hmac;
+
+ if (argc > 1 && !strcmp(argv[1], "-d")) {
+ silc_debug = 1;
+ silc_debug_hexdump = 1;
+ silc_log_set_debug_string("*crypt*,*hash*,*sha1*,*hmac*");
+ }
+
+ SILC_LOG_DEBUG(("Registering builtin hash functions"));
+ silc_hash_register_default();
+ silc_hmac_register_default();
+
+ SILC_LOG_DEBUG(("Allocating sha1 HMAC"));
+ if (!silc_hmac_alloc("hmac-sha1", NULL, &hmac)) {
+ SILC_LOG_DEBUG(("Allocating sha1 HMAC failed"));
+ goto err;
+ }
+
+ /* First test vector */
+ SILC_LOG_DEBUG(("First test vector"));
+ silc_hmac_init_with_key(hmac, key1, key1_len);
+ silc_hmac_update(hmac, data1, strlen(data1));
+ silc_hmac_final(hmac, digest, &len);
+ SILC_LOG_HEXDUMP(("Key"), (unsigned char *)key1, key1_len);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data1, strlen(data1));
+ SILC_LOG_HEXDUMP(("Digest"), digest, len);
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data1_digest, len);
+ if (memcmp(digest, data1_digest, len)) {
+ SILC_LOG_DEBUG(("HMAC failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("HMAC is successful"));
+
+ /* Second test vector */
+ SILC_LOG_DEBUG(("Second test vector"));
+ silc_hmac_init_with_key(hmac, key2, key2_len);
+ silc_hmac_update(hmac, data2, strlen(data2));
+ silc_hmac_final(hmac, digest, &len);
+ SILC_LOG_HEXDUMP(("Key"), (unsigned char *)key2, key2_len);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data2, strlen(data2));
+ SILC_LOG_HEXDUMP(("Digest"), digest, len);
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data2_digest, len);
+ if (memcmp(digest, data2_digest, len)) {
+ SILC_LOG_DEBUG(("HMAC failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("HMAC is successful"));
+
+ /* Third test vector */
+ SILC_LOG_DEBUG(("Third test vector"));
+ silc_hmac_init_with_key(hmac, key3, key3_len);
+ memset(data3, '\xdd', sizeof(data3));
+ silc_hmac_update(hmac, data3, sizeof(data3));
+ silc_hmac_final(hmac, digest, &len);
+ SILC_LOG_HEXDUMP(("Key"), (unsigned char *)key3, key3_len);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data3, sizeof(data3));
+ SILC_LOG_HEXDUMP(("Digest"), digest, len);
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data3_digest, len);
+ if (memcmp(digest, data3_digest, len)) {
+ SILC_LOG_DEBUG(("HMAC failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("HMAC is successful"));
+
+ /* Fourth test vector */
+ SILC_LOG_DEBUG(("Fourth test vector"));
+ memset(key4, '\xaa', key4_len);
+ silc_hmac_init_with_key(hmac, key4, key4_len);
+ silc_hmac_update(hmac, data4, strlen(data4));
+ silc_hmac_final(hmac, digest, &len);
+ SILC_LOG_HEXDUMP(("Key"), (unsigned char *)key4, key4_len);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data4, sizeof(data4));
+ SILC_LOG_HEXDUMP(("Digest"), digest, len);
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data4_digest, len);
+ if (memcmp(digest, data4_digest, len)) {
+ SILC_LOG_DEBUG(("HMAC failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("HMAC is successful"));
+
+ success = TRUE;
+
+ err:
+ SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
+ fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
+
+ silc_hmac_free(hmac);
+ silc_hash_unregister_all();
+ silc_hmac_unregister_all();
+ return success;
+}
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "mars.h"
-
-int main()
-{
- int i;
- unsigned char key[256];
- unsigned char plain[256];
- unsigned char plain2[256];
- unsigned char cipher[256];
- unsigned char iv[256];
-
- memset(&key, 0, sizeof(key));
- memset(&plain, 0, sizeof(plain));
- memset(&plain2, 0, sizeof(plain2));
- memset(&cipher, 0, sizeof(cipher));
- memset(&iv, 0, sizeof(iv));
-
- fprintf(stderr, "\nKey:\n");
- for (i = 0; i < (sizeof(key) / 2); i += 2) {
- fprintf(stderr, "%02x%02x ", key[i], key[i+1]);
- }
-
- fprintf(stderr, "\nSetting key\n");
- silc_mars_init(NULL, key, 128);
-
- fprintf(stderr, "\nPlaintext:\n");
- for (i = 0; i < (sizeof(plain) / 2); i += 2) {
- plain[i] = i;
- plain[i+1] = i+1;
- fprintf(stderr, "%02x%02x ", plain[i], plain[i+1]);
- }
-
- fprintf(stderr, "\n\nEncrypting\n");
- silc_mars_encrypt_cbc(NULL, plain, cipher, 256, iv);
-
- fprintf(stderr, "Ciphertext:\n");
- for (i = 0; i < (sizeof(cipher)/2); i += 2) {
- fprintf(stderr, "%02x", cipher[i]);
- fprintf(stderr, "%02x ", cipher[i+1]);
- }
-
- fprintf(stderr, "\n\nDecrypting\n");
- silc_mars_decrypt_cbc(NULL, cipher, plain2, 256, iv);
-
- fprintf(stderr, "Decryptedtext:\n");
- for (i = 0; i < (sizeof(plain2)/2); i += 2) {
- fprintf(stderr, "%02x", plain2[i]);
- fprintf(stderr, "%02x ", plain2[i+1]);
- }
- fprintf(stderr, "\nDone\n");
-
- return 0;
-}
--- /dev/null
+#include "silcincludes.h"
+
+/* Test vectors from RFC 1321 */
+
+/* First test vector */
+const unsigned char data1[] = "a";
+const unsigned char data1_digest[] = "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8\x31\xc3\x99\xe2\x69\x77\x26\x61";
+
+/* Second test vector. */
+const unsigned char data2[] = "message digest";
+const unsigned char data2_digest[] = "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d\x52\x5a\x2f\x31\xaa\xf1\x61\xd0";
+
+/* Third test vector. */
+const unsigned char data3[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+const unsigned char data3_digest[] = "\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f";
+
+int main(int argc, char **argv)
+{
+ bool success = FALSE;
+ unsigned char digest[16];
+ SilcHash md5;
+
+ if (argc > 1 && !strcmp(argv[1], "-d")) {
+ silc_debug = 1;
+ silc_debug_hexdump = 1;
+ silc_log_set_debug_string("*crypt*,*hash*,*md5*");
+ }
+
+ SILC_LOG_DEBUG(("Registering builtin hash functions"));
+ silc_hash_register_default();
+
+ SILC_LOG_DEBUG(("Allocating md5 hash function"));
+ if (!silc_hash_alloc("md5", &md5)) {
+ SILC_LOG_DEBUG(("Allocating md5 hash function failed"));
+ goto err;
+ }
+
+ /* First test vector */
+ SILC_LOG_DEBUG(("First test vector"));
+ silc_hash_init(md5);
+ silc_hash_update(md5, data1, strlen(data1));
+ silc_hash_final(md5, digest);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data1, strlen(data1));
+ SILC_LOG_HEXDUMP(("Digest"), digest, sizeof(digest));
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data1_digest,
+ sizeof(digest));
+ if (memcmp(digest, data1_digest, sizeof(digest))) {
+ SILC_LOG_DEBUG(("Hash failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("Hash is successful"));
+
+ /* Second test vector */
+ SILC_LOG_DEBUG(("Second test vector"));
+ silc_hash_init(md5);
+ silc_hash_update(md5, data2, strlen(data2));
+ silc_hash_final(md5, digest);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data2, strlen(data2));
+ SILC_LOG_HEXDUMP(("Digest"), digest, sizeof(digest));
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data2_digest,
+ sizeof(digest));
+ if (memcmp(digest, data2_digest, sizeof(digest))) {
+ SILC_LOG_DEBUG(("Hash failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("Hash is successful"));
+
+ /* Third test vector */
+ SILC_LOG_DEBUG(("Third test vector"));
+ silc_hash_init(md5);
+ silc_hash_update(md5, data3, strlen(data3));
+ silc_hash_final(md5, digest);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data3, strlen(data3));
+ SILC_LOG_HEXDUMP(("Digest"), digest, sizeof(digest));
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data3_digest,
+ sizeof(digest));
+ if (memcmp(digest, data3_digest, sizeof(digest))) {
+ SILC_LOG_DEBUG(("Hash failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("Hash is successful"));
+
+ success = TRUE;
+
+ err:
+ SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
+ fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
+
+ silc_hash_free(md5);
+ silc_hash_unregister_all();
+ return success;
+}
--- /dev/null
+#include "silcincludes.h"
+
+/* Test vectors from NIST secure hashing definition for SHA-1 */
+
+/* First test vector */
+const unsigned char data1[] = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
+const unsigned char data1_digest[] = "\x84\x98\x3e\x44\x1c\x3b\xd2\x6e\xba\xae\x4a\xa1\xf9\x51\x29\xe5\xe5\x46\x70\xf1";
+
+/* Second test vector. This will be allocated with 1000000 'a' characters
+ and hashed */
+char *data2 = NULL;
+const unsigned char data2_digest[] = "\x34\xaa\x97\x3c\xd4\xc4\xda\xa4\xf6\x1e\xeb\x2b\xdb\xad\x27\x31\x65\x34\x01\x6f";
+
+int main(int argc, char **argv)
+{
+ bool success = FALSE;
+ unsigned char digest[20];
+ SilcHash sha1;
+
+ if (argc > 1 && !strcmp(argv[1], "-d")) {
+ silc_debug = 1;
+ silc_debug_hexdump = 1;
+ silc_log_set_debug_string("*crypt*,*hash*,*sha1*");
+ }
+
+ SILC_LOG_DEBUG(("Registering builtin hash functions"));
+ silc_hash_register_default();
+
+ SILC_LOG_DEBUG(("Allocating sha1 hash function"));
+ if (!silc_hash_alloc("sha1", &sha1)) {
+ SILC_LOG_DEBUG(("Allocating sha1 hash function failed"));
+ goto err;
+ }
+
+ /* First test vector */
+ SILC_LOG_DEBUG(("First test vector"));
+ silc_hash_init(sha1);
+ silc_hash_update(sha1, data1, strlen(data1));
+ silc_hash_final(sha1, digest);
+ SILC_LOG_HEXDUMP(("Message"), (unsigned char *)data1, strlen(data1));
+ SILC_LOG_HEXDUMP(("Digest"), digest, sizeof(digest));
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data1_digest,
+ sizeof(digest));
+ if (memcmp(digest, data1_digest, sizeof(digest))) {
+ SILC_LOG_DEBUG(("Hash failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("Hash is successful"));
+
+ /* First test vector */
+ SILC_LOG_DEBUG(("Second test vector"));
+ data2 = silc_malloc(1000000);
+ memset(data2, 'a', 1000000);
+ silc_hash_init(sha1);
+ silc_hash_update(sha1, data2, 1000000);
+ silc_hash_final(sha1, digest);
+ SILC_LOG_HEXDUMP(("Digest"), digest, sizeof(digest));
+ SILC_LOG_HEXDUMP(("Expected digest"), (unsigned char *)data2_digest,
+ sizeof(digest));
+ if (memcmp(digest, data2_digest, sizeof(digest))) {
+ SILC_LOG_DEBUG(("Hash failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("Hash is successful"));
+
+ success = TRUE;
+
+ err:
+ SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
+ fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
+
+ silc_free(data2);
+ silc_hash_free(sha1);
+ silc_hash_unregister_all();
+ return success;
+}
if SILC_MP_NSS_MPI
MP_SOURCE = mp_mpi.c
if SILC_DIST_TOOLKIT
-MP_HEADER = mpi/mpi.h mpi/mplogic.h mpi/mpprime.h mpi/mpi-config.h
+MP_HEADER = mpi/mpi.h mpi/mplogic.h mpi/mpi-config.h
else
MP_HEADER =
endif
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 Pekka Riikonen
+ Copyright (C) 2001 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
SilcBuffer silc_sftp_attr_encode(SilcSFTPAttributes attr)
{
SilcBuffer buffer;
- int i, ret, len = 4;
+ int i, ret;
+ SilcUInt32 len = 4;
if (attr->flags & SILC_SFTP_ATTR_SIZE)
len += 8;
}
}
- buffer = silc_buffer_alloc(len);
+ buffer = silc_buffer_alloc_size(len);
if (!buffer)
return NULL;
- silc_buffer_pull_tail(buffer, SILC_BUFFER_END(buffer));
silc_buffer_format(buffer,
SILC_STR_UI_INT(attr->flags),
*/
+/* Tests:
+ silc_sftp_client_start();
+ silc_sftp_client_receive_process();
+ silc_sftp_opendir();
+ silc_sftp_readdir();
+ silc_sftp_open();
+ silc_sftp_read();
+ silc_sftp_fstat();
+ silc_sftp_lstat();
+ silc_sftp_close();
+*/
+
#include "silcincludes.h"
#include "silcsftp.h"
char *file;
bool opendir;
SilcUInt64 offset;
+bool success = FALSE;
static void sftp_name(SilcSFTP sftp, SilcSFTPStatus status,
const SilcSFTPName name, void *context);
static void sftp_data(SilcSFTP sftp, SilcSFTPStatus status,
const unsigned char *data, SilcUInt32 data_len,
void *context);
+static void end_test(void);
-static void send_packet(SilcSocketConnection sock,
- SilcBuffer packet, void *context)
+static void send_packet(SilcBuffer packet, void *context)
{
Client client = (Client)context;
+ SilcSocketConnection sock = client->sock;
SilcPacketContext packetdata;
+ const SilcBufferStruct p;
int ret;
memset(&packetdata, 0, sizeof(packetdata));
packetdata.type = SILC_PACKET_FTP;
packetdata.truelen = packet->len + SILC_PACKET_HEADER_LEN;
- packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen, 0);
- silc_packet_send_prepare(sock,
- SILC_PACKET_HEADER_LEN,
- packetdata.padlen,
- packet->len);
- packetdata.buffer = sock->outbuf;
- silc_buffer_put(sock->outbuf, packet->data, packet->len);
- silc_packet_assemble(&packetdata, NULL);
+ SILC_PACKET_PADLEN(packetdata.truelen, 0, packetdata.padlen);
+ silc_packet_assemble(&packetdata, NULL, NULL, NULL, sock,
+ packet->data, packet->len, (const SilcBuffer)&p);
ret = silc_packet_send(sock, TRUE);
if (ret != -2)
return;
-
+
silc_schedule_set_listen_fd(client->schedule, sock->sock,
(SILC_TASK_READ | SILC_TASK_WRITE), FALSE);
SILC_SET_OUTBUF_PENDING(sock);
assert(packet->type == SILC_PACKET_FTP);
silc_sftp_client_receive_process(client->sftp, sock, packet);
-
+
return TRUE;
}
if (type == SILC_TASK_WRITE) {
if (sock->outbuf->data - sock->outbuf->head)
- silc_buffer_push(sock->outbuf, sock->outbuf->data - sock->outbuf->head);
+ silc_buffer_push(sock->outbuf, sock->outbuf->data - sock->outbuf->head);
ret = silc_packet_send(sock, TRUE);
if (ret < 0)
return;
-
+
silc_schedule_set_listen_fd(client->schedule, fd, SILC_TASK_READ, FALSE);
SILC_UNSET_OUTBUF_PENDING(sock);
silc_buffer_clear(sock->outbuf);
return;
+
}
if (type == SILC_TASK_READ) {
ret = silc_packet_receive(sock);
if (ret < 0)
return;
-
+
if (ret == 0) {
silc_net_close_connection(sock->sock);
silc_socket_free(sock);
}
}
+static void sftp_status(SilcSFTP sftp, SilcSFTPStatus status,
+ const char *message, const char *lang_tag,
+ void *context)
+{
+ fprintf(stderr, "Status %d\n", status);
+ if (status != SILC_SFTP_STATUS_OK) {
+ SILC_LOG_DEBUG(("Error status"));
+ success = FALSE;
+ end_test();
+ return;
+ }
+
+ success = TRUE;
+ end_test();
+}
+
+static void sftp_attr(SilcSFTP sftp, SilcSFTPStatus status,
+ const SilcSFTPAttributes attrs, void *context)
+{
+ SilcSFTPHandle handle = (SilcSFTPHandle)context;
+ int debug = silc_debug;
+ int i;
+
+ fprintf(stderr, "Status %d\n", status);
+ if (status != SILC_SFTP_STATUS_OK) {
+ SILC_LOG_DEBUG(("Error status"));
+ success = FALSE;
+ end_test();
+ return;
+ }
+
+ if (!debug)
+ silc_debug = 1;
+
+ SILC_LOG_DEBUG(("Attr.flags: %d", attrs->flags));
+ SILC_LOG_DEBUG(("Attr.size: %lu", attrs->size));
+ SILC_LOG_DEBUG(("Attr.uid: %d", attrs->uid));
+ SILC_LOG_DEBUG(("Attr.gid: %d", attrs->gid));
+ SILC_LOG_DEBUG(("Attr.permissions: %d", attrs->permissions));
+ SILC_LOG_DEBUG(("Attr.atime: %d", attrs->atime));
+ SILC_LOG_DEBUG(("Attr.mtime: %d", attrs->mtime));
+ SILC_LOG_DEBUG(("Attr.extended count: %d", attrs->extended_count));
+ for (i = 0; i < attrs->extended_count; i++) {
+ SILC_LOG_HEXDUMP(("Attr.extended_type[i]:", i),
+ attrs->extended_type[i]->data,
+ attrs->extended_type[i]->len);
+ SILC_LOG_HEXDUMP(("Attr.extended_data[i]:", i),
+ attrs->extended_data[i]->data,
+ attrs->extended_data[i]->len);
+ }
+
+ silc_debug = debug;
+
+ if (!file) {
+ fprintf(stderr, "Closing file\n");
+ silc_sftp_close(sftp, handle, sftp_status, context);
+ return;
+ }
+
+ fprintf(stderr, "LStatting file %s\n", file);
+ silc_sftp_lstat(sftp, file, sftp_attr, context);
+ file = NULL;
+}
+
static void sftp_data(SilcSFTP sftp, SilcSFTPStatus status,
const unsigned char *data, SilcUInt32 data_len,
void *context)
fprintf(stderr, "Status %d\n", status);
- if (!strcmp(file, "/sftp/sftp_server.c"))
+ if (status != SILC_SFTP_STATUS_EOF) {
+ SILC_LOG_DEBUG(("Error status"));
+ success = FALSE;
+ end_test();
return;
-
+ }
+
+ if (!strcmp(file, "/sftp/sftp_server.c")) {
+ fprintf(stderr, "FStatting file handle %s\n", file);
+ silc_sftp_fstat(sftp, handle, sftp_attr, context);
+ return;
+ }
+
/* Open another file */
opendir = FALSE;
memset(&attrs, 0, sizeof(attrs));
SILC_LOG_DEBUG(("Name"));
fprintf(stderr, "Status %d\n", status);
+ if (status != SILC_SFTP_STATUS_OK) {
+ SILC_LOG_DEBUG(("Error status"));
+ success = FALSE;
+ end_test();
+ return;
+ }
+
fprintf(stderr, "Directory: %s\n", dir);
for (i = 0; i < name->count; i++) {
fprintf(stderr, "%s\n", name->long_filename[i]);
SILC_LOG_DEBUG(("Handle"));
fprintf(stderr, "Status %d\n", status);
- if (status != SILC_SFTP_STATUS_OK)
+ if (status != SILC_SFTP_STATUS_OK) {
+ SILC_LOG_DEBUG(("Error status"));
+ success = FALSE;
+ end_test();
return;
-
+ }
+
if (opendir) {
fprintf(stderr, "Reading %s\n", dir);
/* Readdir */
SILC_LOG_DEBUG(("Version"));
fprintf(stderr, "Status %d\n", status);
+ if (status != SILC_SFTP_STATUS_OK) {
+ SILC_LOG_DEBUG(("Error status"));
+ success = FALSE;
+ end_test();
+ return;
+ }
/* opendir */
dir = "/";
if (argc > 1 && !strcmp(argv[1], "-d")) {
silc_debug = 1;
silc_debug_hexdump = 1;
- silc_log_set_debug_string("");
+ silc_log_set_debug_string("*sftp*");
}
- client->schedule = silc_schedule_init(100);
+ client->schedule = silc_schedule_init(100, NULL);
if (!client->schedule)
return -1;
SILC_TASK_GENERIC, SILC_TASK_PRI_NORMAL);
/* Start SFTP session */
- client->sftp = silc_sftp_client_start(client->sock, send_packet, client,
+ client->sftp = silc_sftp_client_start(send_packet, client,
sftp_version, client);
silc_schedule(client->schedule);
return 0;
}
+
+static void end_test(void)
+{
+ SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
+ fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
+ exit(success);
+}
#include "silcincludes.h"
#include "silcsftp.h"
+typedef struct {
+ SilcSocketConnection sock;
+ void *server;
+} *ServerSession;
+
typedef struct {
SilcSchedule schedule;
int sock;
SilcSFTPFilesystem fs;
- SilcSocketConnection socks[100];
+ ServerSession sessions[100];
SilcSFTP sftp[100];
} *Server;
-static void send_packet(SilcSocketConnection sock,
- SilcBuffer packet, void *context)
+static void send_packet(SilcBuffer packet, void *context)
{
- Server server = (Server)context;
+ ServerSession session = context;
+ Server server = session->server;
SilcPacketContext packetdata;
+ const SilcBufferStruct p;
int ret;
memset(&packetdata, 0, sizeof(packetdata));
packetdata.type = SILC_PACKET_FTP;
packetdata.truelen = packet->len + SILC_PACKET_HEADER_LEN;
- packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen, 0);
- silc_packet_send_prepare(sock,
- SILC_PACKET_HEADER_LEN,
- packetdata.padlen,
- packet->len);
- packetdata.buffer = sock->outbuf;
- silc_buffer_put(sock->outbuf, packet->data, packet->len);
- silc_packet_assemble(&packetdata, NULL);
- ret = silc_packet_send(sock, TRUE);
+ SILC_PACKET_PADLEN(packetdata.truelen, 0, packetdata.padlen);
+ silc_packet_assemble(&packetdata, NULL, NULL, NULL, session->sock,
+ packet->data, packet->len, (const SilcBuffer)&p);
+ ret = silc_packet_send(session->sock, TRUE);
if (ret != -2)
return;
- silc_schedule_set_listen_fd(server->schedule, sock->sock,
+ silc_schedule_set_listen_fd(server->schedule, session->sock->sock,
(SILC_TASK_READ | SILC_TASK_WRITE), FALSE);
- SILC_SET_OUTBUF_PENDING(sock);
+ SILC_SET_OUTBUF_PENDING(session->sock);
}
static bool packet_parse(SilcPacketParserContext *parser, void *context)
SILC_TASK_CALLBACK(packet_process)
{
- Server server = (Server)context;
- SilcSocketConnection sock = server->socks[fd];
+ Server server = context;
+ ServerSession session = server->sessions[fd];
+ SilcSocketConnection sock;
int ret;
- if (!sock)
+ if (!session)
return;
+ sock = session->sock;
if (type == SILC_TASK_WRITE) {
if (sock->outbuf->data - sock->outbuf->head)
if (ret == 0) {
silc_net_close_connection(sock->sock);
silc_schedule_unset_listen_fd(server->schedule, sock->sock);
- server->socks[sock->sock] = NULL;
+ silc_free(server->sessions[sock->sock]);
+ server->sessions[sock->sock] = NULL;
silc_socket_free(sock);
return;
}
silc_net_set_socket_opt(sock, SOL_SOCKET, SO_REUSEADDR, 1);
silc_socket_alloc(sock, 0, NULL, &sc);
- server->socks[sock] = sc;
+ server->sessions[sock] = silc_calloc(1, sizeof(server->sessions[0]));
+ server->sessions[sock]->sock = sc;
+ server->sessions[sock]->server = server;
server->sftp[sock] =
- silc_sftp_server_start(sc, send_packet, server,
+ silc_sftp_server_start(send_packet, server->sessions[sock],
server->fs);
silc_schedule_task_add(server->schedule, sock, packet_process,
server, 0, 0, SILC_TASK_GENERIC,
void *dir;
silc_debug = 1;
-
- server->schedule = silc_schedule_init(100);
+ silc_debug_hexdump = 1;
+ silc_log_set_debug_string("*sftp*");
+
+ server->schedule = silc_schedule_init(100, NULL);
if (!server->schedule)
return -1;
blowfish.o \
rc5.o \
rc6.o \
- mars.o \
aes.o \
rsa.o \
twofish.o \
all: $(SIM_CIPHER_OBJS) $(SIM_HASH_OBJS)
endif
+if SILC_LIBTOOLFIX
+LTFLAGS = --libtool-enable-shared
+else
+LTFLAGS =
+endif
+
$(SIM_CIPHER_OBJS):
@if test '!' -f lib$*.la ; then \
$(LIBTOOL) --mode=link $(CCLD) -rpath $(silc_modulesdir) \
- ../silccrypt/$*.lo -o lib$*.la; \
+ ../silccrypt/$*.lo -o lib$*.la $(LTFLAGS); \
cd $(srcdir) && $(LN_S) -f $(srcdir)/.libs/lib$*.so \
$(srcdir)/$*.sim.so; \
fi
$(SIM_HASH_OBJS):
@if test '!' -f lib$*.la ; then \
$(LIBTOOL) --mode=link $(CCLD) -rpath $(silc_modulesdir) \
- ../silccrypt/$*.lo -o lib$*.la; \
+ ../silccrypt/$*.lo -o lib$*.la $(LTFLAGS); \
cd $(srcdir) && $(LN_S) -f $(srcdir)/.libs/lib$*.so \
$(srcdir)/$*.sim.so; \
fi
/*
- payload.c
+ payload.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2000 - 2001 Pekka Riikonen
+ Copyright (C) 2000 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
if (!payload)
return SILC_SKE_STATUS_ERROR;
- buf = silc_buffer_alloc(payload->len);
+ buf = silc_buffer_alloc_size(payload->len);
if (!buf)
return SILC_SKE_STATUS_OUT_OF_MEMORY;
- silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
/* Encode the payload */
ret = silc_buffer_format(buf,
}
if (tmp != 0) {
- SILC_LOG_DEBUG(("Bad reserved field"));
SILC_LOG_ERROR(("Bad RESERVED field in KE Start Payload"));
status = SILC_SKE_STATUS_BAD_RESERVED_FIELD;
goto err;
/* Allocate channel payload buffer. The length of the buffer
is 4 + public key + 2 + x + 2 + signature. */
- buf = silc_buffer_alloc(4 + payload->pk_len + 2 + x_len +
- 2 + payload->sign_len);
+ buf = silc_buffer_alloc_size(4 + payload->pk_len + 2 + x_len +
+ 2 + payload->sign_len);
if (!buf)
return SILC_SKE_STATUS_OUT_OF_MEMORY;
- silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
/* Encode the payload */
ret = silc_buffer_format(buf,
}
silc_free(ske->hash);
silc_free(ske->callbacks);
+
+ memset(ske, 'F', sizeof(*ske));
silc_free(ske);
}
}
silc_free(x);
silc_mp_uninit(&payload->x);
silc_free(payload);
+ ske->ke1_payload = NULL;
ske->status = SILC_SKE_STATUS_OK;
return ske->status;
}
/* Compute signature data if we are doing mutual authentication */
if (private_key && ske->start_payload->flags & SILC_SKE_SP_FLAG_MUTUAL) {
- unsigned char hash[32], sign[2048];
+ unsigned char hash[32], sign[2048 + 1];
SilcUInt32 hash_len, sign_len;
SILC_LOG_DEBUG(("We are doing mutual authentication"));
silc_mp_uninit(&payload->x);
silc_free(payload->pk_data);
silc_free(payload);
+ ske->ke1_payload = NULL;
ske->status = SILC_SKE_STATUS_SIGNATURE_ERROR;
return ske->status;
}
silc_free(x);
silc_mp_uninit(&payload->x);
silc_free(payload->pk_data);
+ silc_free(payload->sign_data);
silc_free(payload);
+ ske->ke1_payload = NULL;
ske->status = status;
return status;
}
SilcSKEStatus status = SILC_SKE_STATUS_OK;
SilcBuffer payload_buf;
SilcMPInt *KEY;
- unsigned char hash[32], sign[2048], *pk;
+ unsigned char hash[32], sign[2048 + 1], *pk;
SilcUInt32 hash_len, sign_len, pk_len;
SILC_LOG_DEBUG(("Start"));
/* Set random cookie */
rp->cookie = silc_calloc(SILC_SKE_COOKIE_LEN, sizeof(*rp->cookie));
for (i = 0; i < SILC_SKE_COOKIE_LEN; i++)
- rp->cookie[i] = silc_rng_get_byte(ske->rng);
+ rp->cookie[i] = silc_rng_get_byte_fast(ske->rng);
rp->cookie_len = SILC_SKE_COOKIE_LEN;
/* Put version */
/* XXX */
/* Get supported compression algorithms */
- rp->comp_alg_list = strdup("");
- rp->comp_alg_len = 0;
+ rp->comp_alg_list = strdup("none");
+ rp->comp_alg_len = strlen("none");
rp->len = 1 + 1 + 2 + SILC_SKE_COOKIE_LEN +
2 + rp->version_len +
payload->hmac_alg_list = strdup(rp->hmac_alg_list);
}
-#if 0
/* Get supported compression algorithms */
- cp = rp->hash_alg_list;
+ cp = rp->comp_alg_list;
if (cp && strchr(cp, ',')) {
while(cp) {
char *item;
item = silc_calloc(len + 1, sizeof(char));
memcpy(item, cp, len);
- SILC_LOG_DEBUG(("Proposed hash alg `%s'", item));
+ SILC_LOG_DEBUG(("Proposed Compression `%s'", item));
- if (silc_hash_is_supported(item) == TRUE) {
- SILC_LOG_DEBUG(("Found hash alg `%s'", item));
-
- payload->hash_alg_len = len;
- payload->hash_alg_list = item;
+#if 1
+ if (!strcmp(item, "none")) {
+ SILC_LOG_DEBUG(("Found Compression `%s'", item));
+ payload->comp_alg_len = len;
+ payload->comp_alg_list = item;
+ break;
+ }
+#else
+ if (silc_hmac_is_supported(item) == TRUE) {
+ SILC_LOG_DEBUG(("Found Compression `%s'", item));
+ payload->comp_alg_len = len;
+ payload->comp_alg_list = item;
break;
}
+#endif
cp += len;
if (strlen(cp) == 0)
if (item)
silc_free(item);
}
-
- if (!payload->hash_alg_len && !payload->hash_alg_list) {
- SILC_LOG_DEBUG(("Could not find supported hash alg"));
- silc_ske_abort(ske, SILC_SKE_STATUS_UNKNOWN_HASH_FUNCTION);
- silc_free(payload->ke_grp_list);
- silc_free(payload->pkcs_alg_list);
- silc_free(payload->enc_alg_list);
- silc_free(payload);
- return;
- }
- } else {
-
}
-#endif
payload->len = 1 + 1 + 2 + SILC_SKE_COOKIE_LEN +
2 + payload->version_len +
{
SilcSKEStatus status = SILC_SKE_STATUS_OK;
unsigned char *string;
+ SilcUInt32 l;
+
+ if (!len)
+ return SILC_SKE_STATUS_ERROR;
SILC_LOG_DEBUG(("Creating random number"));
+ l = ((len - 1) / 8);
+
/* Get the random number as string */
- string = silc_rng_get_rn_data(ske->rng, ((len - 1) / 8));
+ string = silc_rng_get_rn_data(ske->rng, l);
if (!string)
return SILC_SKE_STATUS_OUT_OF_MEMORY;
/* Decode the string into a MP integer */
- silc_mp_bin2mp(string, ((len - 1) / 8), rnd);
+ silc_mp_bin2mp(string, l, rnd);
silc_mp_mod_2exp(rnd, rnd, len);
/* Checks */
if (silc_mp_cmp(rnd, n) >= 0)
status = SILC_SKE_STATUS_ERROR;
- memset(string, 'F', (len / 8));
+ memset(string, 'F', l);
silc_free(string);
return status;
#include "silcincludes.h"
-/* Macro to check whether there is enough free space to add the
+/* Macros to check whether there is enough free space to add the
required amount of data. For unformatting this means that there must
be the data that is to be extracted. */
-#define MY_HAS_SPACE(__x__, __req__) \
+#define FORMAT_HAS_SPACE(__x__, __req__) \
do { \
if (__req__ > (__x__)->len) \
goto fail; \
} while(0)
+#define UNFORMAT_HAS_SPACE(__x__, __req__) \
+ do { \
+ if (__req__ > (__x__)->len) \
+ goto fail; \
+ if ((__req__ + 1) <= 0) \
+ goto fail; \
+ } while(0)
/* Formats the arguments sent and puts them into the buffer sent as
argument. The buffer must be initialized beforehand and it must have
case SILC_BUFFER_PARAM_SI8_CHAR:
{
char x = (char)va_arg(ap, int);
- MY_HAS_SPACE(dst, 1);
+ FORMAT_HAS_SPACE(dst, 1);
silc_buffer_put(dst, &x, 1);
silc_buffer_pull(dst, 1);
break;
case SILC_BUFFER_PARAM_UI8_CHAR:
{
unsigned char x = (unsigned char)va_arg(ap, int);
- MY_HAS_SPACE(dst, 1);
+ FORMAT_HAS_SPACE(dst, 1);
silc_buffer_put(dst, &x, 1);
silc_buffer_pull(dst, 1);
break;
{
unsigned char xf[2];
SilcInt16 x = (SilcInt16)va_arg(ap, int);
- MY_HAS_SPACE(dst, 2);
+ FORMAT_HAS_SPACE(dst, 2);
SILC_PUT16_MSB(x, xf);
silc_buffer_put(dst, xf, 2);
silc_buffer_pull(dst, 2);
{
unsigned char xf[2];
SilcUInt16 x = (SilcUInt16)va_arg(ap, int);
- MY_HAS_SPACE(dst, 2);
+ FORMAT_HAS_SPACE(dst, 2);
SILC_PUT16_MSB(x, xf);
silc_buffer_put(dst, xf, 2);
silc_buffer_pull(dst, 2);
{
unsigned char xf[4];
SilcInt32 x = va_arg(ap, SilcInt32);
- MY_HAS_SPACE(dst, 4);
+ FORMAT_HAS_SPACE(dst, 4);
SILC_PUT32_MSB(x, xf);
silc_buffer_put(dst, xf, 4);
silc_buffer_pull(dst, 4);
{
unsigned char xf[4];
SilcUInt32 x = va_arg(ap, SilcUInt32);
- MY_HAS_SPACE(dst, 4);
+ FORMAT_HAS_SPACE(dst, 4);
SILC_PUT32_MSB(x, xf);
silc_buffer_put(dst, xf, 4);
silc_buffer_pull(dst, 4);
{
unsigned char xf[8];
SilcInt64 x = va_arg(ap, SilcInt64);
- MY_HAS_SPACE(dst, sizeof(SilcInt64));
+ FORMAT_HAS_SPACE(dst, sizeof(SilcInt64));
SILC_PUT64_MSB(x, xf);
silc_buffer_put(dst, xf, sizeof(SilcInt64));
silc_buffer_pull(dst, sizeof(SilcInt64));
{
unsigned char xf[8];
SilcUInt64 x = va_arg(ap, SilcUInt64);
- MY_HAS_SPACE(dst, sizeof(SilcUInt64));
+ FORMAT_HAS_SPACE(dst, sizeof(SilcUInt64));
SILC_PUT64_MSB(x, xf);
silc_buffer_put(dst, xf, sizeof(SilcUInt64));
silc_buffer_pull(dst, sizeof(SilcUInt64));
{
unsigned char *x = va_arg(ap, unsigned char *);
SilcUInt32 tmp_len = strlen(x);
- MY_HAS_SPACE(dst, tmp_len);
+ FORMAT_HAS_SPACE(dst, tmp_len);
silc_buffer_put(dst, x, tmp_len);
silc_buffer_pull(dst, tmp_len);
break;
unsigned char *x = va_arg(ap, unsigned char *);
SilcUInt32 len = va_arg(ap, SilcUInt32);
if (x && len) {
- MY_HAS_SPACE(dst, len);
+ FORMAT_HAS_SPACE(dst, len);
silc_buffer_put(dst, x, len);
silc_buffer_pull(dst, len);
}
case SILC_BUFFER_PARAM_SI8_CHAR:
{
char *x = va_arg(ap, char *);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
if (x)
*x = src->data[0];
silc_buffer_pull(src, 1);
case SILC_BUFFER_PARAM_UI8_CHAR:
{
unsigned char *x = va_arg(ap, unsigned char *);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
if (x)
*x = src->data[0];
silc_buffer_pull(src, 1);
case SILC_BUFFER_PARAM_SI16_SHORT:
{
SilcInt16 *x = va_arg(ap, SilcInt16 *);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
if (x)
SILC_GET16_MSB(*x, src->data);
silc_buffer_pull(src, 2);
case SILC_BUFFER_PARAM_UI16_SHORT:
{
SilcUInt16 *x = va_arg(ap, SilcUInt16 *);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
if (x)
SILC_GET16_MSB(*x, src->data);
silc_buffer_pull(src, 2);
case SILC_BUFFER_PARAM_SI32_INT:
{
SilcInt32 *x = va_arg(ap, SilcInt32 *);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
if (x)
SILC_GET32_MSB(*x, src->data);
silc_buffer_pull(src, 4);
case SILC_BUFFER_PARAM_UI32_INT:
{
SilcUInt32 *x = va_arg(ap, SilcUInt32 *);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
if (x)
SILC_GET32_MSB(*x, src->data);
silc_buffer_pull(src, 4);
case SILC_BUFFER_PARAM_SI64_INT:
{
SilcInt64 *x = va_arg(ap, SilcInt64 *);
- MY_HAS_SPACE(src, sizeof(SilcInt64));
+ UNFORMAT_HAS_SPACE(src, sizeof(SilcInt64));
if (x)
SILC_GET64_MSB(*x, src->data);
silc_buffer_pull(src, sizeof(SilcInt64));
case SILC_BUFFER_PARAM_UI64_INT:
{
SilcUInt64 *x = va_arg(ap, SilcUInt64 *);
- MY_HAS_SPACE(src, sizeof(SilcUInt64));
+ UNFORMAT_HAS_SPACE(src, sizeof(SilcUInt64));
if (x)
SILC_GET64_MSB(*x, src->data);
silc_buffer_pull(src, sizeof(SilcUInt64));
{
SilcUInt8 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
len2 = (SilcUInt8)src->data[0];
silc_buffer_pull(src, 1);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x)
*x = src->data;
silc_buffer_pull(src, len2);
{
SilcUInt16 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
SILC_GET16_MSB(len2, src->data);
silc_buffer_pull(src, 2);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x)
*x = src->data;
silc_buffer_pull(src, len2);
{
SilcUInt8 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
len2 = (SilcUInt8)src->data[0];
silc_buffer_pull(src, 1);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x && len2) {
*x = silc_calloc(len2 + 1, sizeof(unsigned char));
memcpy(*x, src->data, len2);
{
SilcUInt16 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
SILC_GET16_MSB(len2, src->data);
silc_buffer_pull(src, 2);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x && len2) {
*x = silc_calloc(len2 + 1, sizeof(unsigned char));
memcpy(*x, src->data, len2);
{
SilcUInt32 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
SILC_GET32_MSB(len2, src->data);
silc_buffer_pull(src, 4);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x)
*x = src->data;
silc_buffer_pull(src, len2);
{
SilcUInt32 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
SILC_GET32_MSB(len2, src->data);
silc_buffer_pull(src, 4);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x && len2) {
*x = silc_calloc(len2 + 1, sizeof(unsigned char));
memcpy(*x, src->data, len2);
SilcUInt8 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt8 *len = va_arg(ap, SilcUInt8 *);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
len2 = (SilcUInt8)src->data[0];
silc_buffer_pull(src, 1);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x)
SilcUInt16 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt16 *len = va_arg(ap, SilcUInt16 *);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
SILC_GET16_MSB(len2, src->data);
silc_buffer_pull(src, 2);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x)
SilcUInt8 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt8 *len = va_arg(ap, SilcUInt8 *);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
len2 = (SilcUInt8)src->data[0];
silc_buffer_pull(src, 1);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x && len2) {
SilcUInt16 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt16 *len = va_arg(ap, SilcUInt16 *);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
SILC_GET16_MSB(len2, src->data);
silc_buffer_pull(src, 2);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x && len2) {
SilcUInt32 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt32 *len = va_arg(ap, SilcUInt32 *);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
SILC_GET32_MSB(len2, src->data);
silc_buffer_pull(src, 4);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x)
{
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt32 len = va_arg(ap, SilcUInt32);
- MY_HAS_SPACE(src, len);
+ UNFORMAT_HAS_SPACE(src, len);
if (len && x)
*x = src->data;
silc_buffer_pull(src, len);
{
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt32 len = va_arg(ap, SilcUInt32);
- MY_HAS_SPACE(src, len);
+ UNFORMAT_HAS_SPACE(src, len);
if (len && x) {
*x = silc_calloc(len + 1, sizeof(unsigned char));
memcpy(*x, src->data, len);
/* unique for each config file (and included ones) */
struct SilcConfigFileObject {
- char *filename; /* the original filename opened */
- int level; /* parsing level, how many nested silc_config_main we have */
- char *base; /* this is a fixed pointer to the base location */
- char *p; /* the Parser poitner */
+ char *filename; /* the original filename opened */
+ int level; /* parsing level, how many nested
+ silc_config_main we have */
+ char *base; /* this is a fixed pointer to the base location */
+ char *p; /* the Parser poitner */
SilcUInt32 len; /* fixed length of the whole file */
SilcUInt32 line; /* current parsing line, strictly linked to p */
- bool included; /* wether this file is main or included */
+ bool included; /* wether this file is main or included */
};
/* We need the entity to base our block-style parsing on */
/* access error descriptions only with silc_config_strerror() */
static char *errorstrs[] = {
- "-OK", /* SILC_CONFIG_OK */
- "-SILENT", /* SILC_CONFIG_ESILENT */
- "-PRINTLINE", /* SILC_CONFIG_EPRINTLINE */
- "Invalid syntax", /* SILC_CONFIG_EGENERIC */
- "Internal error! Please report this bug", /* SILC_CONFIG_EINTERNAL */
- "Can't open specified file", /* SILC_CONFIG_ECANTOPEN */
- "Expected open-brace '{'", /* SILC_CONFIG_EOPENBRACE */
- "Missing close-brace '}'", /* SILC_CONFIG_ECLOSEBRACE */
- "Invalid data type", /* SILC_CONFIG_ETYPE */
- "Unknown option", /* SILC_CONFIG_EBADOPTION */
- "Invalid text", /* SILC_CONFIG_EINVALIDTEXT */
- "Double option specification", /* SILC_CONFIG_EDOUBLE */
- "Expected data but not found", /* SILC_CONFIG_EEXPECTED */
- "Expected '='", /* SILC_CONFIG_EEXPECTEDEQUAL */
- "Unexpected data", /* SILC_CONFIG_EUNEXPECTED */
- "Missing mandatory fields", /* SILC_CONFIG_EMISSFIELDS */
- "Missing ';'", /* SILC_CONFIG_EMISSCOLON */
+ "-OK", /* SILC_CONFIG_OK */
+ "-SILENT", /* SILC_CONFIG_ESILENT */
+ "-PRINTLINE", /* SILC_CONFIG_EPRINTLINE */
+ "Invalid syntax", /* SILC_CONFIG_EGENERIC */
+ "Internal error! Please report this bug", /* SILC_CONFIG_EINTERNAL */
+ "Can't open specified file", /* SILC_CONFIG_ECANTOPEN */
+ "Expected open-brace '{'", /* SILC_CONFIG_EOPENBRACE */
+ "Missing close-brace '}'", /* SILC_CONFIG_ECLOSEBRACE */
+ "Invalid data type", /* SILC_CONFIG_ETYPE */
+ "Unknown option", /* SILC_CONFIG_EBADOPTION */
+ "Invalid text", /* SILC_CONFIG_EINVALIDTEXT */
+ "Double option specification", /* SILC_CONFIG_EDOUBLE */
+ "Expected data but not found", /* SILC_CONFIG_EEXPECTED */
+ "Expected '='", /* SILC_CONFIG_EEXPECTEDEQUAL */
+ "Unexpected data", /* SILC_CONFIG_EUNEXPECTED */
+ "Missing mandatory fields", /* SILC_CONFIG_EMISSFIELDS */
+ "Missing ';'", /* SILC_CONFIG_EMISSCOLON */
};
/* return string describing SilcConfig's error code */
{
register char *p;
int len;
- char *ret, *endbuf;
+ char *ret = NULL, *endbuf;
if (!file || (line <= 0))
return NULL;
found:
if ((endbuf = strchr(p, '\n'))) {
len = endbuf - p;
- ret = silc_memdup(p, len);
+ if (len > 0)
+ ret = silc_memdup(p, len);
} else {
ret = silc_memdup(p, strlen(p));
}
const SilcConfigTable *subtable, void *context)
{
SilcConfigOption *newopt;
- SILC_CONFIG_DEBUG(("Register new option=\"%s\" type=%u cb=0x%08x context=0x%08x",
- name, type, (SilcUInt32) cb, (SilcUInt32) context));
+ SILC_CONFIG_DEBUG(("Register new option=\"%s\" "
+ "type=%u cb=0x%08x context=0x%08x",
+ name, type, (SilcUInt32) cb, (SilcUInt32) context));
/* if we are registering a block, make sure there is a specified sub-table */
if (!ent || !name || ((type == SILC_CONFIG_ARG_BLOCK) && !subtable))
/* obtain the keyword */
my_next_token(file, buf);
- SILC_CONFIG_DEBUG(("Looking up keyword=\"%s\" [line=%lu]", buf, file->line));
+ SILC_CONFIG_DEBUG(("Looking up keyword=\"%s\" [line=%lu]",
+ buf, file->line));
/* handle special directive */
if (!strcasecmp(buf, "include")) {
SilcUInt32 len)
{
int fd;
+ int flags = O_CREAT | O_WRONLY | O_TRUNC;
- if ((fd = creat(filename, 0644)) == -1) {
+#if defined(O_BINARY)
+ flags |= O_BINARY;
+#endif /* O_BINARY */
+
+ if ((fd = open(filename, flags, 0644)) == -1) {
SILC_LOG_ERROR(("Cannot open file %s for writing: %s", filename,
strerror(errno)));
return -1;
SilcUInt32 len, int mode)
{
int fd;
+ int flags = O_CREAT | O_WRONLY | O_TRUNC;
+
+#if defined(O_BINARY)
+ flags |= O_BINARY;
+#endif /* O_BINARY */
- if ((fd = creat(filename, mode)) == -1) {
+ if ((fd = open(filename, flags, 0644)) == -1) {
SILC_LOG_ERROR(("Cannot open file %s for writing: %s", filename,
strerror(errno)));
return -1;
#ifndef SILC_STACKTRACE
+#define SILC_MAX_ALLOC (1024 * 1024L * 1024L)
+
void *silc_malloc(size_t size)
{
void *addr;
+ assert(size >= 0 && size <= SILC_MAX_ALLOC);
addr = malloc(size);
assert(addr != NULL);
return addr;
void *silc_calloc(size_t items, size_t size)
{
void *addr;
+ assert(size * items >= 0 && size * items <= SILC_MAX_ALLOC);
addr = calloc(items, size);
assert(addr != NULL);
return addr;
void *silc_realloc(void *ptr, size_t size)
{
void *addr;
+ assert(size >= 0 && size <= SILC_MAX_ALLOC);
addr = realloc(ptr, size);
assert(addr != NULL);
return addr;
void *silc_memdup(const void *ptr, size_t size)
{
- unsigned char *addr = silc_malloc(size + 1);
+ unsigned char *addr;
+ addr = silc_malloc(size + 1);
assert(addr != NULL);
memcpy((void *)addr, ptr, size);
addr[size] = '\0';
/*
- silcschedule.c
+ silcschedule.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1998 - 2001 Pekka Riikonen
+ Copyright (C) 1998 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
return FALSE;
/* Dispatch all timeouts before going away */
+ SILC_SCHEDULE_LOCK(schedule);
silc_mutex_lock(schedule->timeout_queue->lock);
silc_schedule_dispatch_timeout(schedule, TRUE);
silc_mutex_unlock(schedule->timeout_queue->lock);
+ SILC_SCHEDULE_UNLOCK(schedule);
/* Deliver signals before going away */
if (schedule->signal_tasks) {
- SILC_SCHEDULE_UNLOCK(schedule);
silc_schedule_internal_signals_call(schedule->internal, schedule);
schedule->signal_tasks = FALSE;
- SILC_SCHEDULE_LOCK(schedule);
}
/* Unregister all tasks */
static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
{
SilcTask task;
- int i, last_fd = schedule->last_fd;
- SilcUInt32 fd;
+ int i;
+ SilcUInt32 fd, last_fd = schedule->last_fd;
for (i = 0; i <= last_fd; i++) {
if (schedule->fd_list[i].events == 0)
is cancelled also and we will not call the final callback. */
if (lookup->sock->users == 1) {
SILC_LOG_DEBUG(("Async host lookup was cancelled"));
- silc_free(lookup);
silc_socket_free(lookup->sock);
+ silc_free(lookup);
return;
}
if (mode & SILC_CHANNEL_MODE_SILENCE_OPERS)
strncat(string, "M", 1);
+
+ if (mode & SILC_CHANNEL_MODE_CIPHER)
+ strncat(string, "c", 1);
+
+ if (mode & SILC_CHANNEL_MODE_HMAC)
+ strncat(string, "h", 1);
if (mode & SILC_CHANNEL_MODE_CIPHER) {
- if (strlen(cipher) + strlen(string) < sizeof(string))
+ if (strlen(cipher) + strlen(string) + 1< sizeof(string)) {
+ strncat(string, " ", 1);
strncat(string, cipher, strlen(cipher));
+ }
}
if (mode & SILC_CHANNEL_MODE_HMAC) {
- if (strlen(hmac) + strlen(string) < sizeof(string))
+ if (strlen(hmac) + strlen(string) + 1< sizeof(string)) {
+ strncat(string, " ", 1);
strncat(string, hmac, strlen(hmac));
+ }
}
/* Rest of mode is ignored */
*
* DESCRIPTION
*
- * Creates fingerprint from data, usually used with SHA1 digests.
+ * Return a textual representation of the fingerprint in *data, the
+ * caller must free the returned string.
*
***/
char *silc_fingerprint(const unsigned char *data, SilcUInt32 data_len);
silc_buffer_strformat(&buffer,
"CATEGORIES:", vcard->categories, "\n",
SILC_STR_END);
- if (vcard->class)
+ if (vcard->catclass)
silc_buffer_strformat(&buffer,
- "CLASS:", vcard->class, "\n",
+ "CLASS:", vcard->catclass, "\n",
SILC_STR_END);
if (vcard->url)
silc_buffer_strformat(&buffer,
VCARD_FIELD(val, "TITLE:", vcard->title);
VCARD_FIELD(val, "ROLE:", vcard->role);
VCARD_FIELD(val, "CATEGORIES:", vcard->categories);
- VCARD_FIELD(val, "CLASS:", vcard->class);
+ VCARD_FIELD(val, "CLASS:", vcard->catclass);
VCARD_FIELD(val, "URL:", vcard->url);
VCARD_FIELD(val, "LABEL;", vcard->label);
VCARD_FIELD(val, "NOTE:", vcard->note);
silc_free(vcard->org_name);
silc_free(vcard->org_unit);
silc_free(vcard->categories);
- silc_free(vcard->class);
+ silc_free(vcard->catclass);
silc_free(vcard->url);
silc_free(vcard->label);
for (i = 0; i < vcard->num_addrs; i++) {
vcard->org_unit ? vcard->org_unit : "");
if (vcard->categories)
fprintf(stream, "CATEGORIES:%s\n", vcard->categories);
- if (vcard->class)
- fprintf(stream, "CLASS:%s\n", vcard->class);
+ if (vcard->catclass)
+ fprintf(stream, "CLASS:%s\n", vcard->catclass);
if (vcard->url)
fprintf(stream, "URL:%s\n", vcard->url);
if (vcard->label)
char *org_name; /* organization name, string */
char *org_unit; /* organization unit, string */
char *categories; /* application category, string */
- char *class; /* class (public, private, confidental), string */
+ char *catclass; /* class (public, private, confidental), string */
char *url; /* home page, URI string */
char *label; /* formatted address label, string (same
format as for 'addr' but comma sep.) */
*
* SYNOPSIS
*
- * void silc_vcard_free(SilcVcard vcard);
+ * void silc_vcard_free(SilcVCard vcard);
*
* DESCRIPTION
*
static void *st_blocks = NULL;
static unsigned long st_blocks_count = 0;
-static int dump = FALSE;
+static bool dump = FALSE;
+static bool malloc_check = FALSE;
#define SILC_ST_DEPTH 10
dump = TRUE;
}
+ if (!malloc_check) {
+ /* Linux libc malloc check */
+ setenv("MALLOC_CHECK_", "2", 1);
+
+ /* NetBSD malloc check */
+ setenv("MALLOC_OPTIONS", "AJ", 1);
+
+ malloc_check = TRUE;
+ }
+
/* Save the stack */
SILC_ST_GET_FP(fp);
for (stack->depth = 0; fp; stack->depth++) {
struct SilcMutexStruct {
#ifdef SILC_THREADS
pthread_mutex_t mutex;
+ unsigned int locked : 1;
#else
void *tmp;
#endif /* SILC_THREADS */
*mutex = silc_calloc(1, sizeof(**mutex));
if (*mutex == NULL)
return FALSE;
-
pthread_mutex_init(&(*mutex)->mutex, NULL);
#endif /* SILC_THREADS */
return TRUE;
#ifdef SILC_THREADS
if (pthread_mutex_lock(&mutex->mutex))
assert(FALSE);
+ assert(mutex->locked == 0);
+ mutex->locked = 1;
#endif /* SILC_THREADS */
}
void silc_mutex_unlock(SilcMutex mutex)
{
#ifdef SILC_THREADS
+ assert(mutex->locked == 1);
+ mutex->locked = 0;
if (pthread_mutex_unlock(&mutex->mutex))
assert(FALSE);
#endif /* SILC_THREADS */
int fd = sock->sock;
SilcBuffer src = sock->outbuf;
+ if (!src)
+ return -2;
if (SILC_IS_DISABLED(sock))
return -1;
#include "silcincludes.h"
/* SILC Mutex structure */
-struct SilcMutexStruct {
+struct SilcMutexStruct {
#ifdef SILC_THREADS
- HANDLE mutex;
+ CRITICAL_SECTION mutex;
+ BOOL locked;
#else
void *tmp;
#endif /* SILC_THREADS */
bool silc_mutex_alloc(SilcMutex *mutex)
{
#ifdef SILC_THREADS
- *mutex = silc_calloc(1, sizeof(**mutex));
- (*mutex)->mutex = CreateMutex(NULL, FALSE, NULL);
- if (!(*mutex)->mutex) {
- silc_free(*mutex);
- return FALSE;
- }
+ *mutex = silc_calloc(1, sizeof(**mutex));
+ InitializeCriticalSection(&((*mutex)->mutex));
#endif /* SILC_THREADS */
return TRUE;
}
void silc_mutex_free(SilcMutex mutex)
{
#ifdef SILC_THREADS
- CloseHandle(mutex->mutex);
+ DeleteCriticalSection(&mutex->mutex);
silc_free(mutex);
#endif /* SILC_THREADS */
}
void silc_mutex_lock(SilcMutex mutex)
{
#ifdef SILC_THREADS
- WaitForSingleObject(mutex->mutex, INFINITE);
+ EnterCriticalSection(&mutex->mutex);
+ assert(mutex->locked == FALSE);
+ mutex->locked = TRUE;
#endif /* SILC_THREADS */
}
void silc_mutex_unlock(SilcMutex mutex)
{
#ifdef SILC_THREADS
- ReleaseMutex(mutex->mutex);
+ assert(mutex->locked == TRUE);
+ mutex->locked = FALSE;
+ LeaveCriticalSection(&mutex->mutex);
#endif /* SILC_THREADS */
}
SOCKET fd = sock->sock;
SilcBuffer src = sock->outbuf;
+ if (!src)
+ return -2;
if (SILC_IS_DISABLED(sock))
return -1;
GNU General Public License for more details.
*/
-/* These routines are based on GLib's WIN32 gthread implementation and
- thus credits should go there. */
-/* XXX Is the use of Tls necessary?? */
/* $Id$ */
#include "silcincludes.h"
thread->start_func = start_func;
thread->context = context;
thread->waitable = waitable;
- thread->thread = (HANDLE)_beginthreadex(NULL, 0, silc_thread_win32_start,
- (void *)thread, 0, &id);
+ thread->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)silc_thread_win32_start, (void *)thread, 0, &id);
+
if (!thread->thread) {
SILC_LOG_ERROR(("Could not create new thread"));
silc_free(thread);
/* If the thread is waitable the memory is freed only in silc_thread_wait
by another thread. If not waitable, free it now. */
if (!thread->waitable) {
- CloseHandle(thread->thread);
+ TerminateThread(thread->thread, 0);
silc_free(thread);
}
TlsSetValue(silc_thread_tls, NULL);
}
-
- _endthreadex(0);
+ ExitThread(0);
#endif
}
/* The thread is waitable thus we will free all memory after the
WaitForSingleObject returns, the thread is destroyed after that. */
- WaitForSingleObject(self->thread, INFINITE);
- CloseHandle(self->thread);
+
+ /* 2 sec timeout, otherwise we would run to infinite loop some cases.. */
+ if (WaitForSingleObject(self->thread, 2000) == WAIT_TIMEOUT)
+ TerminateThread(self->thread, 0);
+
silc_free(self);
if (exit_value)
*exit_value = NULL;
return 0;
}
+
+char *silc_get_username(void)
+{
+ return strdup("foo");
+}
+
+char *silc_get_real_name(void)
+{
+ return strdup("Foo T. Bar");
+}
--- /dev/null
+#!/bin/sh
+#
+# No Copyright 2002 Pekka Riikonen <priikone@silcnet.org>
+#
+# This script fixes the fundamental problem of libtool: it is not
+# configurable in run-time. This changes the libtool so that it becomes
+# more generic and configurable in run-time.
+#
+# New command line options to libtool:
+#
+# --libtool-enable-shared Enable shared library compilation
+# --libtool-enable-static Enable static library compilation
+# --libtool-disable-shared Disable shared library compilation
+# --libtool-disable-static Disable static library compilation
+#
+# If options are omitted the default libtool configuration will apply.
+#
+
+# Sanity checks
+if test '!' -f ./libtool; then
+ echo "./libtool does not exist"
+ exit 0
+fi
+
+# Take configuration from the ./libtool
+sed '/^# ltmain\.sh/q' ./libtool >./libtool.tmp
+
+# Put our wrapper to the new libtool. This allows the run-time
+# configuration of the libtool.
+ltmain=`pwd`/ltmain.sh
+cat << EOF >> ./libtool.tmp
+args=\`echo \$*\`
+cargs=\`echo \$* | sed -e '/--libtool-enable-shared/s///' -e '/--libtool-enable-static/s///' -e '/--libtool-disable-shared/s///' -e '/--libtool-disable-static/s///'\`
+for i in \$args
+do
+ if test "\$i" = "--libtool-enable-shared"; then
+ build_libtool_libs=yes
+ fast_install=yes
+ continue
+ fi
+ if test "\$i" = "--libtool-disable-shared"; then
+ build_libtool_libs=no
+ continue
+ fi
+ if test "\$i" = "--libtool-enable-static"; then
+ build_old_libs=yes
+ continue
+ fi
+ if test "\$i" = "--libtool-disable-static"; then
+ build_old_libs=no
+ continue
+ fi
+done
+if test "\$cargs" = ""; then
+ cargs="--silent"
+fi
+. $ltmain \$cargs
+EOF
+
+mv -f ./libtool.tmp ./libtool
+chmod +x ./libtool
+
+exit 1
# SILC Distribution versions. Set here or give the version on the command
# line as argument.
#
-SILC_VERSION=0.9.5 # Base version
+SILC_VERSION=0.9.7 # Base version
#############################################################################
static void
silc_channel_message(SilcClient client, SilcClientConnection conn,
SilcClientEntry sender, SilcChannelEntry channel,
+ SilcMessagePayload payload,
SilcMessageFlags flags, const unsigned char *message,
SilcUInt32 message_len)
{
/* Yay! We got a message from channel. */
- fprintf(stdout, "<%s> %s\n", sender->nickname, message);
+
+ if (flags & SILC_MESSAGE_FLAG_SIGNED)
+ fprintf(stdout, "[SIGNED] <%s> %s\n", sender->nickname, message);
+ else
+ fprintf(stdout, "<%s> %s\n", sender->nickname, message);
}
static void
silc_private_message(SilcClient client, SilcClientConnection conn,
- SilcClientEntry sender, SilcMessageFlags flags,
+ SilcClientEntry sender, SilcMessagePayload payload,
+ SilcMessageFlags flags,
const unsigned char *message,
SilcUInt32 message_len)
{
silc_client_send_channel_message(client, conn, channel, NULL, 0,
"hello", strlen("hello"), FALSE);
fprintf(stdout, "MyBot: Sent 'hello' to channel\n");
+
+ /* Now send digitally signed "hello" to the channel */
+ silc_client_send_channel_message(client, conn, channel, NULL,
+ SILC_MESSAGE_FLAG_SIGNED,
+ "hello, with signature",
+ strlen("hello, with signature"), FALSE);
+ fprintf(stdout, "MyBot: Sent 'hello, with signature' to channel\n");
}
va_end(va);
-;
-; Exports file for SILC Core DLL.
-;
-; This file is generated from MinGW compiled object files using the
-; following command:
-;
-; dlltool --export-all --output-def libsilc.def libsilc.a
-;
-; ----------------------------------------------------------------------------
-;
-; If you edit this file by adding or removing any exports be sure to
-; preserve the ordinal values (the @ n in the exports) and add new exports
-; always at the end of the list with new ordinal value. Do not ever
-; add new export with old ordinal value if you need to preserve backwards
-; compatiblity. -Pekka
-;
-EXPORTS
- silc_aes_context_len @ 235 ;
- silc_aes_decrypt_cbc @ 236 ;
- silc_aes_encrypt_cbc @ 237 ;
- silc_aes_set_key @ 238 ;
- silc_aes_set_key_with_string @ 239 ;
- silc_argument_get_arg_num @ 240 ;
- silc_argument_get_arg_type @ 241 ;
- silc_argument_get_first_arg @ 242 ;
- silc_argument_get_next_arg @ 243 ;
- silc_argument_payload_encode @ 244 ;
- silc_argument_payload_encode_payload @ 245 ;
- silc_argument_payload_free @ 246 ;
- silc_argument_payload_parse @ 247 ;
- silc_auth_get_data @ 248 ;
- silc_auth_get_method @ 249 ;
- silc_auth_payload_encode @ 250 ;
- silc_auth_payload_free @ 251 ;
- silc_auth_payload_parse @ 252 ;
- silc_auth_public_key_auth_generate @ 253 ;
- silc_auth_public_key_auth_verify @ 254 ;
- silc_auth_public_key_auth_verify_data @ 255 ;
- silc_auth_verify @ 256 ;
- silc_auth_verify_data @ 257 ;
- silc_blowfish_context_len @ 258 ;
- silc_blowfish_decrypt_cbc @ 259 ;
- silc_blowfish_encrypt_cbc @ 260 ;
- silc_blowfish_set_key @ 261 ;
- silc_blowfish_set_key_with_string @ 262 ;
- silc_buffer_format @ 263 ;
- silc_buffer_unformat @ 264 ;
- silc_calloc @ 265 ;
- silc_cast_context_len @ 266 ;
- silc_cast_decrypt_cbc @ 267 ;
- silc_cast_encrypt_cbc @ 268 ;
- silc_cast_set_key @ 269 ;
- silc_cast_set_key_with_string @ 270 ;
- silc_channel_get_id @ 271 ;
- silc_channel_get_id_parse @ 272 ;
- silc_channel_get_mode @ 273 ;
- silc_channel_get_name @ 274 ;
- silc_channel_key_get_cipher @ 275 ;
- silc_channel_key_get_id @ 276 ;
- silc_channel_key_get_key @ 277 ;
- silc_channel_key_payload_encode @ 278 ;
- silc_channel_key_payload_free @ 279 ;
- silc_channel_key_payload_parse @ 280 ;
- silc_channel_message_get_mac @ 281 ;
- silc_channel_message_get_data @ 282 ;
- silc_channel_message_get_flags @ 283 ;
- silc_channel_message_get_iv @ 284 ;
- silc_channel_message_payload_decrypt @ 285 ;
- silc_channel_message_payload_encode @ 286 ;
- silc_channel_message_payload_free @ 287 ;
- silc_channel_message_payload_parse @ 288 ;
- silc_channel_payload_encode @ 289 ;
- silc_channel_payload_free @ 290 ;
- silc_channel_payload_list_free @ 291 ;
- silc_channel_payload_parse @ 292 ;
- silc_channel_payload_parse_list @ 293 ;
- silc_check_line @ 294 ;
- silc_cipher_alloc @ 295 ;
- silc_cipher_decrypt @ 296 ;
- silc_cipher_encrypt @ 297 ;
- silc_cipher_free @ 298 ;
- silc_cipher_get_block_len @ 299 ;
- silc_cipher_get_iv @ 300 ;
- silc_cipher_get_key_len @ 301 ;
- silc_cipher_get_supported @ 302 ;
- silc_cipher_is_supported @ 303 ;
- silc_cipher_list @ 304 ;
- silc_cipher_register @ 305 ;
- silc_cipher_register_default @ 306 ;
- silc_cipher_set_iv @ 307 ;
- silc_cipher_set_key @ 308 ;
- silc_cipher_unregister @ 309 ;
- silc_client_chmode @ 310 ;
- silc_client_chumode @ 311 ;
- silc_client_chumode_char @ 312 ;
- silc_command_get @ 313 ;
- silc_command_get_args @ 314 ;
- silc_command_get_ident @ 315 ;
- silc_command_payload_encode @ 316 ;
- silc_command_payload_encode_payload @ 317 ;
- silc_command_payload_encode_va @ 318 ;
- silc_command_payload_encode_vap @ 319 ;
- silc_command_payload_free @ 320 ;
- silc_command_payload_parse @ 321 ;
- silc_command_reply_payload_encode_va @ 322 ;
- silc_command_set_command @ 323 ;
- silc_command_set_ident @ 324 ;
- silc_config_open @ 327 ;
- silc_debug @ 328 DATA ;
- silc_pem_decode @ 329 ;
- silc_default_ciphers @ 330 DATA ;
- silc_default_hash @ 331 DATA ;
- silc_default_hmacs @ 332 DATA ;
- silc_default_pkcs @ 333 DATA ;
- silc_pem_encode @ 334 ;
- silc_pem_encode_file @ 335 ;
- silc_file_readfile @ 336 ;
- silc_file_writefile @ 337 ;
- silc_file_writefile_mode @ 338 ;
- silc_format @ 339 ;
- silc_free @ 340 ;
- silc_get_time @ 341 ;
- silc_gets @ 342 ;
- silc_gettimeofday @ 343 ;
- silc_hash_alloc @ 344 ;
- silc_hash_client_id_compare @ 345 ;
- silc_hash_data @ 346 ;
- silc_hash_data_compare @ 347 ;
- silc_hash_fingerprint @ 348 ;
- silc_hash_free @ 349 ;
- silc_hash_get_supported @ 350 ;
- silc_hash_id @ 351 ;
- silc_hash_id_compare @ 352 ;
- silc_hash_is_supported @ 353 ;
- silc_hash_len @ 354 ;
- silc_hash_list @ 355 ;
- silc_hash_make @ 356 ;
- silc_hash_ptr @ 357 ;
- silc_hash_register @ 358 ;
- silc_hash_register_default @ 359 ;
- silc_hash_string @ 360 ;
- silc_hash_string_compare @ 361 ;
- silc_hash_table_add @ 362 ;
- silc_hash_table_add_ext @ 363 ;
- silc_hash_table_alloc @ 364 ;
- silc_hash_table_count @ 365 ;
- silc_hash_table_del @ 366 ;
- silc_hash_table_del_by_context @ 367 ;
- silc_hash_table_del_by_context_ext @ 368 ;
- silc_hash_table_del_ext @ 369 ;
- silc_hash_table_find @ 370 ;
- silc_hash_table_find_ext @ 371 ;
- silc_hash_table_find_foreach @ 372 ;
- silc_hash_table_find_foreach_ext @ 373 ;
- silc_hash_table_foreach @ 374 ;
- silc_hash_table_free @ 375 ;
- silc_hash_table_get @ 376 ;
- silc_hash_table_list @ 377 ;
- silc_hash_table_rehash @ 378 ;
- silc_hash_table_rehash_ext @ 379 ;
- silc_hash_table_replace @ 380 ;
- silc_hash_table_replace_ext @ 381 ;
- silc_hash_table_size @ 382 ;
- silc_hash_uint @ 383 ;
- silc_hash_unregister @ 384 ;
- silc_hmac_alloc @ 385 ;
- silc_hmac_free @ 386 ;
- silc_hmac_get_supported @ 387 ;
- silc_hmac_is_supported @ 388 ;
- silc_hmac_len @ 389 ;
- silc_hmac_list @ 390 ;
- silc_hmac_make @ 391 ;
- silc_hmac_make_truncated @ 393 ;
- silc_hmac_make_with_key @ 394 ;
- silc_hmac_register @ 395 ;
- silc_hmac_register_default @ 396 ;
- silc_hmac_set_key @ 397 ;
- silc_hmac_unregister @ 398 ;
- silc_id_dup @ 399 ;
- silc_id_get_len @ 400 ;
- silc_id_id2str @ 401 ;
- silc_id_payload_encode @ 402 ;
- silc_id_payload_free @ 403 ;
- silc_id_payload_get_data @ 404 ;
- silc_id_payload_get_id @ 405 ;
- silc_id_payload_get_len @ 406 ;
- silc_id_payload_get_type @ 407 ;
- silc_id_payload_parse @ 408 ;
- silc_id_payload_parse_id @ 410 ;
- silc_id_render @ 411 ;
- silc_id_str2id @ 412 ;
- silc_idcache_add @ 413 ;
- silc_idcache_alloc @ 414 ;
- silc_idcache_del @ 415 ;
- silc_idcache_del_all @ 416 ;
- silc_idcache_del_by_context @ 417 ;
- silc_idcache_del_by_id @ 418 ;
- silc_idcache_del_by_id_ext @ 419 ;
- silc_idcache_find_by_context @ 420 ;
- silc_idcache_find_by_id @ 421 ;
- silc_idcache_find_by_id_one @ 422 ;
- silc_idcache_find_by_id_one_ext @ 423 ;
- silc_idcache_find_by_name @ 424 ;
- silc_idcache_find_by_name_one @ 425 ;
- silc_idcache_free @ 426 ;
- silc_idcache_get_all @ 427 ;
- silc_idcache_list_count @ 428 ;
- silc_idcache_list_first @ 429 ;
- silc_idcache_list_free @ 430 ;
- silc_idcache_list_next @ 431 ;
- silc_idcache_purge @ 432 ;
- silc_idcache_purge_by_context @ 433 ;
- silc_key_agreement_get_hostname @ 434 ;
- silc_key_agreement_get_port @ 435 ;
- silc_key_agreement_payload_encode @ 436 ;
- silc_key_agreement_payload_free @ 437 ;
- silc_key_agreement_payload_parse @ 438 ;
- silc_log_output @ 439 ;
- silc_log_output_debug @ 440 ;
- silc_log_output_hexdump @ 441 ;
- silc_log_reset_callbacks @ 442 ;
- silc_log_reset_debug_callbacks @ 443 ;
- silc_log_set_callback @ 444 ;
- silc_log_set_debug_callbacks @ 445 ;
- silc_log_set_file @ 446 ;
- silc_malloc @ 448 ;
- silc_mars_context_len @ 449 ;
- silc_mars_decrypt_cbc @ 450 ;
- silc_mars_encrypt_cbc @ 451 ;
- silc_mars_set_key @ 452 ;
- silc_mars_set_key_with_string @ 453 ;
- silc_math_gen_prime @ 454 ;
- silc_math_prime_test @ 455 ;
- silc_md5_context_len @ 456 ;
- silc_md5_final @ 457 ;
- silc_md5_init @ 458 ;
- silc_md5_transform @ 459 ;
- silc_md5_update @ 460 ;
- silc_mp_abs @ 461 ;
- silc_mp_add @ 462 ;
- silc_mp_add_ui @ 463 ;
- silc_mp_and @ 464 ;
- silc_mp_bin2mp @ 465 ;
- silc_mp_cmp @ 466 ;
- silc_mp_cmp_si @ 467 ;
- silc_mp_cmp_ui @ 468 ;
- silc_mp_div @ 469 ;
- silc_mp_div_2exp @ 470 ;
- silc_mp_div_2exp_qr @ 471 ;
- silc_mp_div_qr @ 472 ;
- silc_mp_div_ui @ 473 ;
- silc_mp_gcd @ 474 ;
- silc_mp_gcdext @ 475 ;
- silc_mp_get_str @ 476 ;
- silc_mp_get_ui @ 477 ;
- silc_mp_init @ 478 ;
- silc_mp_mod @ 479 ;
- silc_mp_mod_2exp @ 480 ;
- silc_mp_mod_ui @ 481 ;
- silc_mp_modinv @ 482 ;
- silc_mp_mp2bin @ 483 ;
- silc_mp_mp2bin_noalloc @ 484 ;
- silc_mp_mul @ 485 ;
- silc_mp_mul_2exp @ 486 ;
- silc_mp_mul_ui @ 487 ;
- silc_mp_neg @ 488 ;
- silc_mp_or @ 489 ;
- silc_mp_pow @ 490 ;
- silc_mp_pow_mod @ 491 ;
- silc_mp_pow_mod_ui @ 492 ;
- silc_mp_pow_ui @ 493 ;
- silc_mp_set @ 494 ;
- silc_mp_set_si @ 495 ;
- silc_mp_set_str @ 496 ;
- silc_mp_set_ui @ 497 ;
- silc_mp_size @ 498 ;
- silc_mp_sizeinbase @ 499 ;
- silc_mp_sqrt @ 500 ;
- silc_mp_sub @ 501 ;
- silc_mp_sub_ui @ 502 ;
- silc_mp_uninit @ 503 ;
- silc_mp_xor @ 504 ;
- silc_mutex_alloc @ 505 ;
- silc_mutex_free @ 506 ;
- silc_mutex_lock @ 507 ;
- silc_mutex_unlock @ 508 ;
- silc_net_accept_connection @ 509 ;
- silc_net_addr2bin @ 510 ;
- silc_net_check_host_by_sock @ 511 ;
- silc_net_check_local_by_sock @ 512 ;
- silc_net_close_connection @ 513 ;
- silc_net_close_server @ 514 ;
- silc_net_create_connection @ 515 ;
- silc_net_create_connection_async @ 516 ;
- silc_net_create_server @ 517 ;
- silc_net_get_local_port @ 518 ;
- silc_net_get_remote_port @ 519 ;
- silc_net_get_socket_opt @ 520 ;
- silc_net_is_ip @ 521 ;
- silc_net_localhost @ 522 ;
- silc_net_set_socket_nonblock @ 523 ;
- silc_net_set_socket_opt @ 524 ;
- silc_net_win32_init @ 525 ;
- silc_net_win32_uninit @ 526 ;
- silc_none_context_len @ 527 ;
- silc_none_decrypt_cbc @ 528 ;
- silc_none_encrypt_cbc @ 529 ;
- silc_none_set_key @ 530 ;
- silc_none_set_key_with_string @ 531 ;
- silc_notify_get_arg_num @ 532 ;
- silc_notify_get_args @ 533 ;
- silc_notify_get_type @ 534 ;
- silc_notify_payload_encode @ 535 ;
- silc_notify_payload_encode_args @ 536 ;
- silc_notify_payload_free @ 537 ;
- silc_notify_payload_parse @ 538 ;
- silc_packet_assemble @ 539 ;
- silc_packet_context_alloc @ 540 ;
- silc_packet_context_dup @ 541 ;
- silc_packet_context_free @ 542 ;
- silc_packet_encrypt @ 544 ;
- silc_packet_parse @ 545 ;
- silc_packet_parse_special @ 546 ;
- silc_packet_receive @ 547 ;
- silc_packet_receive_process @ 548 ;
- silc_packet_send @ 549 ;
- silc_packet_send_prepare @ 550 ;
- silc_parse_command_line @ 551 ;
- silc_parse_userfqdn @ 552 ;
- silc_pkcs1_decrypt @ 553 ;
- silc_pkcs1_encrypt @ 554 ;
- silc_pkcs1_sign @ 555 ;
- silc_pkcs1_verify @ 556 ;
- silc_pkcs_alloc @ 557 ;
- silc_pkcs_decode_identifier @ 558 ;
- silc_pkcs_decrypt @ 559 ;
- silc_pkcs_encode_identifier @ 560 ;
- silc_pkcs_encrypt @ 561 ;
- silc_pkcs_free @ 562 ;
- silc_pkcs_free_identifier @ 563 ;
- silc_pkcs_get_key_len @ 564 ;
- silc_pkcs_get_private_key @ 565 ;
- silc_pkcs_get_public_key @ 566 ;
- silc_pkcs_get_supported @ 567 ;
- silc_pkcs_is_supported @ 568 ;
- silc_pkcs_list @ 569 ;
- silc_pkcs_load_private_key @ 570 ;
- silc_pkcs_load_public_key @ 571 ;
- silc_pkcs_private_key_alloc @ 572 ;
- silc_pkcs_private_key_data_encode @ 573 ;
- silc_pkcs_private_key_data_set @ 574 ;
- silc_pkcs_private_key_decode @ 575 ;
- silc_pkcs_private_key_encode @ 576 ;
- silc_pkcs_private_key_free @ 577 ;
- silc_pkcs_private_key_set @ 578 ;
- silc_pkcs_public_key_alloc @ 579 ;
- silc_pkcs_public_key_data_encode @ 580 ;
- silc_pkcs_public_key_data_set @ 581 ;
- silc_pkcs_public_key_decode @ 582 ;
- silc_pkcs_public_key_encode @ 583 ;
- silc_pkcs_public_key_free @ 584 ;
- silc_pkcs_public_key_set @ 585 ;
- silc_pkcs_register @ 586 ;
- silc_pkcs_register_default @ 587 ;
- silc_pkcs_save_private_key @ 588 ;
- silc_pkcs_save_public_key @ 590 ;
- silc_pkcs_save_public_key_data @ 591 ;
- silc_pkcs_sign @ 592 ;
- silc_pkcs_sign_with_hash @ 593 ;
- silc_pkcs_unregister @ 594 ;
- silc_pkcs_verify @ 595 ;
- silc_pkcs_verify_with_hash @ 596 ;
- silc_private_message_get_flags @ 597 ;
- silc_private_message_get_message @ 598 ;
- silc_private_message_payload_encode @ 599 ;
- silc_private_message_payload_free @ 600 ;
- silc_private_message_payload_parse @ 601 ;
- silc_protocol_alloc @ 602 ;
- silc_protocol_cancel @ 603 ;
- silc_protocol_execute @ 604 ;
- silc_protocol_execute_final @ 605 ;
- silc_protocol_free @ 606 ;
- silc_protocol_list @ 607 ;
- silc_protocol_register @ 608 ;
- silc_protocol_unregister @ 609 ;
- silc_rc5_context_len @ 610 ;
- silc_rc5_decrypt_cbc @ 611 ;
- silc_rc5_encrypt_cbc @ 612 ;
- silc_rc5_set_key @ 613 ;
- silc_rc5_set_key_with_string @ 614 ;
- silc_rc6_context_len @ 615 ;
- silc_rc6_decrypt_cbc @ 616 ;
- silc_rc6_encrypt_cbc @ 617 ;
- silc_rc6_set_key @ 618 ;
- silc_rc6_set_key_with_string @ 619 ;
- silc_realloc @ 620 ;
- silc_rng_add_noise @ 621 ;
- silc_rng_alloc @ 622 ;
- silc_rng_free @ 623 ;
- silc_rng_get_byte @ 624 ;
- silc_rng_get_rn16 @ 625 ;
- silc_rng_get_rn32 @ 626 ;
- silc_rng_get_rn_data @ 627 ;
- silc_rng_get_rn_string @ 628 ;
- silc_rng_global_add_noise @ 629 ;
- silc_rng_global_get_byte @ 630 ;
- silc_rng_global_get_rn16 @ 631 ;
- silc_rng_global_get_rn32 @ 632 ;
- silc_rng_global_get_rn_data @ 633 ;
- silc_rng_global_get_rn_string @ 634 ;
- silc_rng_global_init @ 635 ;
- silc_rng_global_uninit @ 636 ;
- silc_rng_init @ 637 ;
- silc_rsa_clear_keys @ 638 ;
- silc_rsa_context_len @ 639 ;
- silc_rsa_decrypt @ 640 ;
- silc_rsa_encrypt @ 641 ;
- silc_rsa_get_private_key @ 642 ;
- silc_rsa_get_public_key @ 643 ;
- silc_rsa_init @ 644 ;
- silc_rsa_set_private_key @ 645 ;
- silc_rsa_set_public_key @ 646 ;
- silc_rsa_sign @ 647 ;
- silc_rsa_verify @ 648 ;
- silc_schedule @ 649 ;
- silc_schedule_init @ 650 ;
- silc_schedule_one @ 651 ;
- silc_schedule_set_listen_fd @ 652 ;
- silc_schedule_stop @ 653 ;
- silc_schedule_task_add @ 654 ;
- silc_schedule_task_del @ 655 ;
- silc_schedule_task_del_by_callback @ 656 ;
- silc_schedule_task_del_by_context @ 657 ;
- silc_schedule_task_del_by_fd @ 658 ;
- silc_schedule_uninit @ 659 ;
- silc_schedule_unset_listen_fd @ 660 ;
- silc_schedule_wakeup @ 661 ;
- silc_select @ 665 ;
- silc_sha1_context_len @ 666 ;
- silc_sha1_final @ 667 ;
- silc_sha1_init @ 668 ;
- silc_sha1_transform @ 669 ;
- silc_sha1_update @ 670 ;
- silc_ske_abort @ 671 ;
- silc_ske_alloc @ 672 ;
- silc_ske_assemble_security_properties @ 673 ;
- silc_ske_end @ 675 ;
- silc_ske_free @ 676 ;
- silc_ske_free_key_material @ 677 ;
- silc_ske_group_get_by_name @ 678 ;
- silc_ske_group_get_by_number @ 679 ;
- silc_ske_get_supported_groups @ 680 ;
- silc_ske_group_get_number @ 681 ;
- silc_ske_groups @ 682 ;
- silc_ske_initiator_finish @ 683 ;
- silc_ske_initiator_phase_1 @ 684 ;
- silc_ske_initiator_phase_2 @ 685 ;
- silc_ske_initiator_start @ 686 ;
- silc_ske_payload_ke_decode @ 688 ;
- silc_ske_payload_ke_encode @ 689 ;
- silc_ske_payload_ke_free @ 690 ;
- silc_ske_payload_start_decode @ 691 ;
- silc_ske_payload_start_encode @ 692 ;
- silc_ske_payload_start_free @ 693 ;
- silc_ske_process_key_material @ 694 ;
- silc_ske_process_key_material_data @ 695 ;
- silc_ske_responder_finish @ 696 ;
- silc_ske_responder_phase_1 @ 697 ;
- silc_ske_responder_phase_2 @ 698 ;
- silc_ske_responder_start @ 699 ;
- silc_ske_select_security_properties @ 700 ;
- silc_ske_set_callbacks @ 701 ;
- silc_socket_alloc @ 702 ;
- silc_socket_dup @ 703 ;
- silc_socket_free @ 704 ;
- silc_socket_host_lookup @ 705 ;
- silc_socket_read @ 706 ;
- silc_socket_set_heartbeat @ 707 ;
- silc_socket_write @ 708 ;
- silc_string_compare @ 709 ;
- silc_thread_create @ 710 ;
- silc_thread_exit @ 711 ;
- silc_thread_self @ 712 ;
- silc_thread_wait @ 713 ;
- silc_to_upper @ 715 ;
- silc_twofish_context_len @ 716 ;
- silc_twofish_decrypt_cbc @ 717 ;
- silc_twofish_encrypt_cbc @ 718 ;
- silc_twofish_set_key @ 719 ;
- silc_twofish_set_key_with_string @ 720 ;
- silc_buffer_format_vp @ 789 ;
- silc_buffer_unformat_vp @ 790 ;
- silc_sftp_client_start @ 791 ;
- silc_sftp_client_shutdown @ 792 ;
- silc_sftp_client_receive_process @ 793 ;
- silc_sftp_open @ 794 ;
- silc_sftp_close @ 795 ;
- silc_sftp_read @ 796 ;
- silc_sftp_write @ 797 ;
- silc_sftp_remove @ 798 ;
- silc_sftp_rename @ 799 ;
- silc_sftp_mkdir @ 800 ;
- silc_sftp_rmdir @ 801 ;
- silc_sftp_opendir @ 802 ;
- silc_sftp_readdir @ 803 ;
- silc_sftp_stat @ 804 ;
- silc_sftp_lstat @ 805 ;
- silc_sftp_fstat @ 806 ;
- silc_sftp_setstat @ 807 ;
- silc_sftp_fsetstat @ 808 ;
- silc_sftp_readlink @ 809 ;
- silc_sftp_symlink @ 810 ;
- silc_sftp_realpath @ 811 ;
- silc_sftp_extended @ 812 ;
- silc_sftp_server_start @ 813 ;
- silc_sftp_server_shutdown @ 814 ;
- silc_sftp_server_receive_process @ 815 ;
- silc_sftp_fs_memory @ 816 ;
- silc_sftp_fs_memory_alloc @ 817 ;
- silc_sftp_fs_memory_free @ 818 ;
- silc_sftp_fs_memory_add_dir @ 819 ;
- silc_sftp_fs_memory_del_dir @ 820 ;
- silc_sftp_fs_memory_add_file @ 821 ;
- silc_sftp_fs_memory_del_file @ 822 ;
- silc_file_open @ 824 ;
- silc_file_close @ 825 ;
- silc_file_read @ 826 ;
- silc_file_write @ 827 ;
- silc_file_size @ 828 ;
- silc_hmac_init @ 829 ;
- silc_hmac_update @ 830 ;
- silc_hmac_final @ 831 ;
- silc_hmac_init_with_key @ 832 ;
- silc_hmac_get_name @ 833 ;
- silc_hmac_get_hash @ 834 ;
- silc_net_localip @ 835 ;
- silc_sftp_server_set_monitor @ 836 ;
- silc_net_gethostbyname @ 837 ;
- silc_net_gethostbyaddr @ 838 ;
- silc_net_gethostbyname_async @ 839 ;
- silc_net_gethostbyaddr_async @ 840 ;
- silc_net_is_ip4 @ 841 ;
- silc_net_is_ip6 @ 842 ;
- silc_log_set_debug_string @ 843 ;
- silc_log_reset_all @ 844 ;
- silc_log_flush_all @ 845 ;
- silc_log_get_file @ 846 ;
- silc_log_quick @ 847 DATA ;
- silc_log_flushdelay @ 848 DATA ;
- silc_hash_table_list_reset @ 849 ;
- silc_debug_hexdump @ 850 DATA ;
- silc_memdup @ 851 ;
- silc_command_get_status @ 852 ;
- silc_utf8_encode @ 853 ;
- silc_utf8_decode @ 854 ;
- silc_utf8_encoded_len @ 855 ;
- silc_utf8_valid @ 856 ;
- silc_mime_parse @ 857 ;
- silc_get_status_message @ 858 ;
- silc_get_mode_list @ 859 ;
- silc_hash_table_find_by_context @ 860 ;
- silc_channel_message_payload_encrypt @ 861 ;
- silc_string_is_ascii @ 862 ;
- silc_parse_version_string @ 863 ;
- silc_version_to_num @ 864 ;
- silc_fingerprint @ 865 ;
- silc_get_packet_name @ 866 ;
- silc_get_command_name @ 867 ;
- silc_strncat @ 868 ;
- silc_attribute_payload_parse @ 869 ;
- silc_attribute_payload_encode @ 870 ;
- silc_attribute_payload_alloc @ 871 ;
- silc_attribute_payload_free @ 872 ;
- silc_attribute_payload_list_free @ 873 ;
- silc_attribute_payload_encode_data @ 874 ;
- silc_attribute_get_attribute @ 875 ;
- silc_attribute_get_data @ 876 ;
- silc_attribute_get_object @ 877 ;
- silc_attribute_get_flags @ 878 ;
- silc_attribute_get_verify_data @ 879 ;
- silc_hash_get_name @ 880 ;
- silc_create_key_pair @ 881 ;
- silc_load_key_pair @ 882 ;
- silc_show_public_key @ 883 ;
- silc_change_private_key_passphrase @ 884 ;
+;\r
+; Exports file for SILC Core DLL.\r
+;\r
+; This file is generated from MinGW compiled object files using the\r
+; following command:\r
+;\r
+; dlltool --export-all --output-def libsilc.def libsilc.a\r
+;\r
+; ----------------------------------------------------------------------------\r
+;\r
+; If you edit this file by adding or removing any exports be sure to\r
+; preserve the ordinal values (the @ n in the exports) and add new exports\r
+; always at the end of the list with new ordinal value. Do not ever\r
+; add new export with old ordinal value if you need to preserve backwards\r
+; compatiblity. -Pekka\r
+;\r
+EXPORTS\r
+ silc_aes_context_len @ 235 ; \r
+ silc_aes_decrypt_cbc @ 236 ; \r
+ silc_aes_encrypt_cbc @ 237 ; \r
+ silc_aes_set_key @ 238 ; \r
+ silc_aes_set_key_with_string @ 239 ; \r
+ silc_argument_get_arg_num @ 240 ; \r
+ silc_argument_get_arg_type @ 241 ; \r
+ silc_argument_get_first_arg @ 242 ; \r
+ silc_argument_get_next_arg @ 243 ; \r
+ silc_argument_payload_encode @ 244 ; \r
+ silc_argument_payload_encode_payload @ 245 ; \r
+ silc_argument_payload_free @ 246 ; \r
+ silc_argument_payload_parse @ 247 ; \r
+ silc_auth_get_data @ 248 ; \r
+ silc_auth_get_method @ 249 ; \r
+ silc_auth_payload_encode @ 250 ; \r
+ silc_auth_payload_free @ 251 ; \r
+ silc_auth_payload_parse @ 252 ; \r
+ silc_auth_public_key_auth_generate @ 253 ; \r
+ silc_auth_public_key_auth_verify @ 254 ; \r
+ silc_auth_public_key_auth_verify_data @ 255 ; \r
+ silc_auth_verify @ 256 ; \r
+ silc_auth_verify_data @ 257 ; \r
+ silc_blowfish_context_len @ 258 ; \r
+ silc_blowfish_decrypt_cbc @ 259 ; \r
+ silc_blowfish_encrypt_cbc @ 260 ; \r
+ silc_blowfish_set_key @ 261 ; \r
+ silc_blowfish_set_key_with_string @ 262 ; \r
+ silc_buffer_format @ 263 ; \r
+ silc_buffer_unformat @ 264 ; \r
+ silc_calloc @ 265 ; \r
+ silc_cast_context_len @ 266 ; \r
+ silc_cast_decrypt_cbc @ 267 ; \r
+ silc_cast_encrypt_cbc @ 268 ; \r
+ silc_cast_set_key @ 269 ; \r
+ silc_cast_set_key_with_string @ 270 ; \r
+ silc_channel_get_id @ 271 ; \r
+ silc_channel_get_id_parse @ 272 ; \r
+ silc_channel_get_mode @ 273 ; \r
+ silc_channel_get_name @ 274 ; \r
+ silc_channel_key_get_cipher @ 275 ; \r
+ silc_channel_key_get_id @ 276 ; \r
+ silc_channel_key_get_key @ 277 ; \r
+ silc_channel_key_payload_encode @ 278 ; \r
+ silc_channel_key_payload_free @ 279 ; \r
+ silc_channel_key_payload_parse @ 280 ; \r
+ silc_channel_payload_encode @ 289 ; \r
+ silc_channel_payload_free @ 290 ; \r
+ silc_channel_payload_list_free @ 291 ; \r
+ silc_channel_payload_parse @ 292 ; \r
+ silc_channel_payload_parse_list @ 293 ; \r
+ silc_check_line @ 294 ; \r
+ silc_cipher_alloc @ 295 ; \r
+ silc_cipher_decrypt @ 296 ; \r
+ silc_cipher_encrypt @ 297 ; \r
+ silc_cipher_free @ 298 ; \r
+ silc_cipher_get_block_len @ 299 ; \r
+ silc_cipher_get_iv @ 300 ; \r
+ silc_cipher_get_key_len @ 301 ; \r
+ silc_cipher_get_supported @ 302 ; \r
+ silc_cipher_is_supported @ 303 ; \r
+ silc_cipher_list @ 304 ; \r
+ silc_cipher_register @ 305 ; \r
+ silc_cipher_register_default @ 306 ; \r
+ silc_cipher_set_iv @ 307 ; \r
+ silc_cipher_set_key @ 308 ; \r
+ silc_cipher_unregister @ 309 ; \r
+ silc_client_chmode @ 310 ; \r
+ silc_client_chumode @ 311 ; \r
+ silc_client_chumode_char @ 312 ; \r
+ silc_command_get @ 313 ; \r
+ silc_command_get_args @ 314 ; \r
+ silc_command_get_ident @ 315 ; \r
+ silc_command_payload_encode @ 316 ; \r
+ silc_command_payload_encode_payload @ 317 ; \r
+ silc_command_payload_encode_va @ 318 ; \r
+ silc_command_payload_encode_vap @ 319 ; \r
+ silc_command_payload_free @ 320 ; \r
+ silc_command_payload_parse @ 321 ; \r
+ silc_command_reply_payload_encode_va @ 322 ; \r
+ silc_command_set_command @ 323 ; \r
+ silc_command_set_ident @ 324 ; \r
+ silc_config_open @ 327 ; \r
+ silc_debug @ 328 DATA ; \r
+ silc_pem_decode @ 329 ; \r
+ silc_default_ciphers @ 330 DATA ; \r
+ silc_default_hash @ 331 DATA ; \r
+ silc_default_hmacs @ 332 DATA ; \r
+ silc_default_pkcs @ 333 DATA ; \r
+ silc_pem_encode @ 334 ; \r
+ silc_pem_encode_file @ 335 ; \r
+ silc_file_readfile @ 336 ; \r
+ silc_file_writefile @ 337 ; \r
+ silc_file_writefile_mode @ 338 ; \r
+ silc_format @ 339 ; \r
+ silc_free @ 340 ; \r
+ silc_get_time @ 341 ; \r
+ silc_gets @ 342 ; \r
+ silc_gettimeofday @ 343 ; \r
+ silc_hash_alloc @ 344 ; \r
+ silc_hash_client_id_compare @ 345 ; \r
+ silc_hash_data @ 346 ; \r
+ silc_hash_data_compare @ 347 ; \r
+ silc_hash_fingerprint @ 348 ; \r
+ silc_hash_free @ 349 ; \r
+ silc_hash_get_supported @ 350 ; \r
+ silc_hash_id @ 351 ; \r
+ silc_hash_id_compare @ 352 ; \r
+ silc_hash_is_supported @ 353 ; \r
+ silc_hash_len @ 354 ; \r
+ silc_hash_list @ 355 ; \r
+ silc_hash_make @ 356 ; \r
+ silc_hash_ptr @ 357 ; \r
+ silc_hash_register @ 358 ; \r
+ silc_hash_register_default @ 359 ; \r
+ silc_hash_string @ 360 ; \r
+ silc_hash_string_compare @ 361 ; \r
+ silc_hash_table_add @ 362 ; \r
+ silc_hash_table_add_ext @ 363 ; \r
+ silc_hash_table_alloc @ 364 ; \r
+ silc_hash_table_count @ 365 ; \r
+ silc_hash_table_del @ 366 ; \r
+ silc_hash_table_del_by_context @ 367 ; \r
+ silc_hash_table_del_by_context_ext @ 368 ; \r
+ silc_hash_table_del_ext @ 369 ; \r
+ silc_hash_table_find @ 370 ; \r
+ silc_hash_table_find_ext @ 371 ; \r
+ silc_hash_table_find_foreach @ 372 ; \r
+ silc_hash_table_find_foreach_ext @ 373 ; \r
+ silc_hash_table_foreach @ 374 ; \r
+ silc_hash_table_free @ 375 ; \r
+ silc_hash_table_get @ 376 ; \r
+ silc_hash_table_list @ 377 ; \r
+ silc_hash_table_rehash @ 378 ; \r
+ silc_hash_table_rehash_ext @ 379 ; \r
+ silc_hash_table_replace @ 380 ; \r
+ silc_hash_table_replace_ext @ 381 ; \r
+ silc_hash_table_size @ 382 ; \r
+ silc_hash_uint @ 383 ; \r
+ silc_hash_unregister @ 384 ; \r
+ silc_hmac_alloc @ 385 ; \r
+ silc_hmac_free @ 386 ; \r
+ silc_hmac_get_supported @ 387 ; \r
+ silc_hmac_is_supported @ 388 ; \r
+ silc_hmac_len @ 389 ; \r
+ silc_hmac_list @ 390 ; \r
+ silc_hmac_make @ 391 ; \r
+ silc_hmac_make_truncated @ 393 ; \r
+ silc_hmac_make_with_key @ 394 ; \r
+ silc_hmac_register @ 395 ; \r
+ silc_hmac_register_default @ 396 ; \r
+ silc_hmac_set_key @ 397 ; \r
+ silc_hmac_unregister @ 398 ; \r
+ silc_id_dup @ 399 ; \r
+ silc_id_get_len @ 400 ; \r
+ silc_id_id2str @ 401 ; \r
+ silc_id_payload_encode @ 402 ; \r
+ silc_id_payload_free @ 403 ; \r
+ silc_id_payload_get_data @ 404 ; \r
+ silc_id_payload_get_id @ 405 ; \r
+ silc_id_payload_get_len @ 406 ; \r
+ silc_id_payload_get_type @ 407 ; \r
+ silc_id_payload_parse @ 408 ; \r
+ silc_id_payload_parse_id @ 410 ; \r
+ silc_id_render @ 411 ; \r
+ silc_id_str2id @ 412 ; \r
+ silc_idcache_add @ 413 ; \r
+ silc_idcache_alloc @ 414 ; \r
+ silc_idcache_del @ 415 ; \r
+ silc_idcache_del_all @ 416 ; \r
+ silc_idcache_del_by_context @ 417 ; \r
+ silc_idcache_del_by_id @ 418 ; \r
+ silc_idcache_del_by_id_ext @ 419 ; \r
+ silc_idcache_find_by_context @ 420 ; \r
+ silc_idcache_find_by_id @ 421 ; \r
+ silc_idcache_find_by_id_one @ 422 ; \r
+ silc_idcache_find_by_id_one_ext @ 423 ; \r
+ silc_idcache_find_by_name @ 424 ; \r
+ silc_idcache_find_by_name_one @ 425 ; \r
+ silc_idcache_free @ 426 ; \r
+ silc_idcache_get_all @ 427 ; \r
+ silc_idcache_list_count @ 428 ; \r
+ silc_idcache_list_first @ 429 ; \r
+ silc_idcache_list_free @ 430 ; \r
+ silc_idcache_list_next @ 431 ; \r
+ silc_idcache_purge @ 432 ; \r
+ silc_idcache_purge_by_context @ 433 ; \r
+ silc_key_agreement_get_hostname @ 434 ; \r
+ silc_key_agreement_get_port @ 435 ; \r
+ silc_key_agreement_payload_encode @ 436 ; \r
+ silc_key_agreement_payload_free @ 437 ; \r
+ silc_key_agreement_payload_parse @ 438 ; \r
+ silc_log_output @ 439 ; \r
+ silc_log_output_debug @ 440 ; \r
+ silc_log_output_hexdump @ 441 ; \r
+ silc_log_reset_callbacks @ 442 ; \r
+ silc_log_reset_debug_callbacks @ 443 ; \r
+ silc_log_set_callback @ 444 ; \r
+ silc_log_set_debug_callbacks @ 445 ; \r
+ silc_log_set_file @ 446 ; \r
+ silc_malloc @ 448 ; \r
+ silc_math_gen_prime @ 454 ; \r
+ silc_math_prime_test @ 455 ; \r
+ silc_md5_context_len @ 456 ; \r
+ silc_md5_final @ 457 ; \r
+ silc_md5_init @ 458 ; \r
+ silc_md5_transform @ 459 ; \r
+ silc_md5_update @ 460 ; \r
+ silc_mp_abs @ 461 ; \r
+ silc_mp_add @ 462 ; \r
+ silc_mp_add_ui @ 463 ; \r
+ silc_mp_and @ 464 ; \r
+ silc_mp_bin2mp @ 465 ; \r
+ silc_mp_cmp @ 466 ; \r
+ silc_mp_cmp_si @ 467 ; \r
+ silc_mp_cmp_ui @ 468 ; \r
+ silc_mp_div @ 469 ; \r
+ silc_mp_div_2exp @ 470 ; \r
+ silc_mp_div_2exp_qr @ 471 ; \r
+ silc_mp_div_qr @ 472 ; \r
+ silc_mp_div_ui @ 473 ; \r
+ silc_mp_gcd @ 474 ; \r
+ silc_mp_gcdext @ 475 ; \r
+ silc_mp_get_str @ 476 ; \r
+ silc_mp_get_ui @ 477 ; \r
+ silc_mp_init @ 478 ; \r
+ silc_mp_mod @ 479 ; \r
+ silc_mp_mod_2exp @ 480 ; \r
+ silc_mp_mod_ui @ 481 ; \r
+ silc_mp_modinv @ 482 ; \r
+ silc_mp_mp2bin @ 483 ; \r
+ silc_mp_mp2bin_noalloc @ 484 ; \r
+ silc_mp_mul @ 485 ; \r
+ silc_mp_mul_2exp @ 486 ; \r
+ silc_mp_mul_ui @ 487 ; \r
+ silc_mp_neg @ 488 ; \r
+ silc_mp_or @ 489 ; \r
+ silc_mp_pow @ 490 ; \r
+ silc_mp_pow_mod @ 491 ; \r
+ silc_mp_pow_mod_ui @ 492 ; \r
+ silc_mp_pow_ui @ 493 ; \r
+ silc_mp_set @ 494 ; \r
+ silc_mp_set_si @ 495 ; \r
+ silc_mp_set_str @ 496 ; \r
+ silc_mp_set_ui @ 497 ; \r
+ silc_mp_size @ 498 ; \r
+ silc_mp_sizeinbase @ 499 ; \r
+ silc_mp_sqrt @ 500 ; \r
+ silc_mp_sub @ 501 ; \r
+ silc_mp_sub_ui @ 502 ; \r
+ silc_mp_uninit @ 503 ; \r
+ silc_mp_xor @ 504 ; \r
+ silc_mutex_alloc @ 505 ; \r
+ silc_mutex_free @ 506 ; \r
+ silc_mutex_lock @ 507 ; \r
+ silc_mutex_unlock @ 508 ; \r
+ silc_net_accept_connection @ 509 ; \r
+ silc_net_addr2bin @ 510 ; \r
+ silc_net_check_host_by_sock @ 511 ; \r
+ silc_net_check_local_by_sock @ 512 ; \r
+ silc_net_close_connection @ 513 ; \r
+ silc_net_close_server @ 514 ; \r
+ silc_net_create_connection @ 515 ; \r
+ silc_net_create_connection_async @ 516 ; \r
+ silc_net_create_server @ 517 ; \r
+ silc_net_get_local_port @ 518 ; \r
+ silc_net_get_remote_port @ 519 ; \r
+ silc_net_get_socket_opt @ 520 ; \r
+ silc_net_is_ip @ 521 ; \r
+ silc_net_localhost @ 522 ; \r
+ silc_net_set_socket_nonblock @ 523 ; \r
+ silc_net_set_socket_opt @ 524 ; \r
+ silc_net_win32_init @ 525 ; \r
+ silc_net_win32_uninit @ 526 ; \r
+ silc_none_context_len @ 527 ; \r
+ silc_none_decrypt_cbc @ 528 ; \r
+ silc_none_encrypt_cbc @ 529 ; \r
+ silc_none_set_key @ 530 ; \r
+ silc_none_set_key_with_string @ 531 ; \r
+ silc_notify_get_arg_num @ 532 ; \r
+ silc_notify_get_args @ 533 ; \r
+ silc_notify_get_type @ 534 ; \r
+ silc_notify_payload_encode @ 535 ; \r
+ silc_notify_payload_encode_args @ 536 ; \r
+ silc_notify_payload_free @ 537 ; \r
+ silc_notify_payload_parse @ 538 ; \r
+ silc_packet_assemble @ 539 ; \r
+ silc_packet_context_alloc @ 540 ; \r
+ silc_packet_context_dup @ 541 ; \r
+ silc_packet_context_free @ 542 ; \r
+ silc_packet_encrypt @ 544 ; \r
+ silc_packet_parse @ 545 ; \r
+ silc_packet_parse_special @ 546 ; \r
+ silc_packet_receive @ 547 ; \r
+ silc_packet_receive_process @ 548 ; \r
+ silc_packet_send @ 549 ; \r
+ silc_packet_send_prepare @ 550 ; \r
+ silc_parse_command_line @ 551 ; \r
+ silc_parse_userfqdn @ 552 ; \r
+ silc_pkcs1_decrypt @ 553 ; \r
+ silc_pkcs1_encrypt @ 554 ; \r
+ silc_pkcs1_sign @ 555 ; \r
+ silc_pkcs1_verify @ 556 ; \r
+ silc_pkcs_alloc @ 557 ; \r
+ silc_pkcs_decode_identifier @ 558 ; \r
+ silc_pkcs_decrypt @ 559 ; \r
+ silc_pkcs_encode_identifier @ 560 ; \r
+ silc_pkcs_encrypt @ 561 ; \r
+ silc_pkcs_free @ 562 ; \r
+ silc_pkcs_free_identifier @ 563 ; \r
+ silc_pkcs_get_key_len @ 564 ; \r
+ silc_pkcs_get_private_key @ 565 ; \r
+ silc_pkcs_get_public_key @ 566 ; \r
+ silc_pkcs_get_supported @ 567 ; \r
+ silc_pkcs_is_supported @ 568 ; \r
+ silc_pkcs_list @ 569 ; \r
+ silc_pkcs_load_private_key @ 570 ; \r
+ silc_pkcs_load_public_key @ 571 ; \r
+ silc_pkcs_private_key_alloc @ 572 ; \r
+ silc_pkcs_private_key_data_encode @ 573 ; \r
+ silc_pkcs_private_key_data_set @ 574 ; \r
+ silc_pkcs_private_key_decode @ 575 ; \r
+ silc_pkcs_private_key_encode @ 576 ; \r
+ silc_pkcs_private_key_free @ 577 ; \r
+ silc_pkcs_private_key_set @ 578 ; \r
+ silc_pkcs_public_key_alloc @ 579 ; \r
+ silc_pkcs_public_key_data_encode @ 580 ; \r
+ silc_pkcs_public_key_data_set @ 581 ; \r
+ silc_pkcs_public_key_decode @ 582 ; \r
+ silc_pkcs_public_key_encode @ 583 ; \r
+ silc_pkcs_public_key_free @ 584 ; \r
+ silc_pkcs_public_key_set @ 585 ; \r
+ silc_pkcs_register @ 586 ; \r
+ silc_pkcs_register_default @ 587 ; \r
+ silc_pkcs_save_private_key @ 588 ; \r
+ silc_pkcs_save_public_key @ 590 ; \r
+ silc_pkcs_save_public_key_data @ 591 ; \r
+ silc_pkcs_sign @ 592 ; \r
+ silc_pkcs_sign_with_hash @ 593 ; \r
+ silc_pkcs_unregister @ 594 ; \r
+ silc_pkcs_verify @ 595 ; \r
+ silc_pkcs_verify_with_hash @ 596 ; \r
+ silc_protocol_alloc @ 602 ; \r
+ silc_protocol_cancel @ 603 ; \r
+ silc_protocol_execute @ 604 ; \r
+ silc_protocol_execute_final @ 605 ; \r
+ silc_protocol_free @ 606 ; \r
+ silc_protocol_list @ 607 ; \r
+ silc_protocol_register @ 608 ; \r
+ silc_protocol_unregister @ 609 ; \r
+ silc_rc5_context_len @ 610 ; \r
+ silc_rc5_decrypt_cbc @ 611 ; \r
+ silc_rc5_encrypt_cbc @ 612 ; \r
+ silc_rc5_set_key @ 613 ; \r
+ silc_rc5_set_key_with_string @ 614 ; \r
+ silc_rc6_context_len @ 615 ; \r
+ silc_rc6_decrypt_cbc @ 616 ; \r
+ silc_rc6_encrypt_cbc @ 617 ; \r
+ silc_rc6_set_key @ 618 ; \r
+ silc_rc6_set_key_with_string @ 619 ; \r
+ silc_realloc @ 620 ; \r
+ silc_rng_add_noise @ 621 ; \r
+ silc_rng_alloc @ 622 ; \r
+ silc_rng_free @ 623 ; \r
+ silc_rng_get_byte @ 624 ; \r
+ silc_rng_get_rn16 @ 625 ; \r
+ silc_rng_get_rn32 @ 626 ; \r
+ silc_rng_get_rn_data @ 627 ; \r
+ silc_rng_get_rn_string @ 628 ; \r
+ silc_rng_global_add_noise @ 629 ; \r
+ silc_rng_global_get_byte @ 630 ; \r
+ silc_rng_global_get_rn16 @ 631 ; \r
+ silc_rng_global_get_rn32 @ 632 ; \r
+ silc_rng_global_get_rn_data @ 633 ; \r
+ silc_rng_global_get_rn_string @ 634 ; \r
+ silc_rng_global_init @ 635 ; \r
+ silc_rng_global_uninit @ 636 ; \r
+ silc_rng_init @ 637 ; \r
+ silc_rsa_clear_keys @ 638 ; \r
+ silc_rsa_context_len @ 639 ; \r
+ silc_rsa_decrypt @ 640 ; \r
+ silc_rsa_encrypt @ 641 ; \r
+ silc_rsa_get_private_key @ 642 ; \r
+ silc_rsa_get_public_key @ 643 ; \r
+ silc_rsa_init @ 644 ; \r
+ silc_rsa_set_private_key @ 645 ; \r
+ silc_rsa_set_public_key @ 646 ; \r
+ silc_rsa_sign @ 647 ; \r
+ silc_rsa_verify @ 648 ; \r
+ silc_schedule @ 649 ; \r
+ silc_schedule_init @ 650 ; \r
+ silc_schedule_one @ 651 ; \r
+ silc_schedule_set_listen_fd @ 652 ; \r
+ silc_schedule_stop @ 653 ; \r
+ silc_schedule_task_add @ 654 ; \r
+ silc_schedule_task_del @ 655 ; \r
+ silc_schedule_task_del_by_callback @ 656 ; \r
+ silc_schedule_task_del_by_context @ 657 ; \r
+ silc_schedule_task_del_by_fd @ 658 ; \r
+ silc_schedule_uninit @ 659 ; \r
+ silc_schedule_unset_listen_fd @ 660 ; \r
+ silc_schedule_wakeup @ 661 ; \r
+ silc_select @ 665 ; \r
+ silc_sha1_context_len @ 666 ; \r
+ silc_sha1_final @ 667 ; \r
+ silc_sha1_init @ 668 ; \r
+ silc_sha1_transform @ 669 ; \r
+ silc_sha1_update @ 670 ; \r
+ silc_ske_abort @ 671 ; \r
+ silc_ske_alloc @ 672 ; \r
+ silc_ske_assemble_security_properties @ 673 ; \r
+ silc_ske_end @ 675 ; \r
+ silc_ske_free @ 676 ; \r
+ silc_ske_free_key_material @ 677 ; \r
+ silc_ske_group_get_by_name @ 678 ; \r
+ silc_ske_group_get_by_number @ 679 ; \r
+ silc_ske_get_supported_groups @ 680 ; \r
+ silc_ske_group_get_number @ 681 ; \r
+ silc_ske_groups @ 682 ; \r
+ silc_ske_initiator_finish @ 683 ; \r
+ silc_ske_initiator_phase_1 @ 684 ; \r
+ silc_ske_initiator_phase_2 @ 685 ; \r
+ silc_ske_initiator_start @ 686 ; \r
+ silc_ske_payload_ke_decode @ 688 ; \r
+ silc_ske_payload_ke_encode @ 689 ; \r
+ silc_ske_payload_ke_free @ 690 ; \r
+ silc_ske_payload_start_decode @ 691 ; \r
+ silc_ske_payload_start_encode @ 692 ; \r
+ silc_ske_payload_start_free @ 693 ; \r
+ silc_ske_process_key_material @ 694 ; \r
+ silc_ske_process_key_material_data @ 695 ; \r
+ silc_ske_responder_finish @ 696 ; \r
+ silc_ske_responder_phase_1 @ 697 ; \r
+ silc_ske_responder_phase_2 @ 698 ; \r
+ silc_ske_responder_start @ 699 ; \r
+ silc_ske_select_security_properties @ 700 ; \r
+ silc_ske_set_callbacks @ 701 ; \r
+ silc_socket_alloc @ 702 ; \r
+ silc_socket_dup @ 703 ; \r
+ silc_socket_free @ 704 ; \r
+ silc_socket_host_lookup @ 705 ; \r
+ silc_socket_read @ 706 ; \r
+ silc_socket_set_heartbeat @ 707 ; \r
+ silc_socket_write @ 708 ; \r
+ silc_string_compare @ 709 ; \r
+ silc_thread_create @ 710 ; \r
+ silc_thread_exit @ 711 ; \r
+ silc_thread_self @ 712 ; \r
+ silc_thread_wait @ 713 ; \r
+ silc_to_upper @ 715 ; \r
+ silc_twofish_context_len @ 716 ; \r
+ silc_twofish_decrypt_cbc @ 717 ; \r
+ silc_twofish_encrypt_cbc @ 718 ; \r
+ silc_twofish_set_key @ 719 ; \r
+ silc_twofish_set_key_with_string @ 720 ; \r
+ silc_buffer_format_vp @ 789 ; \r
+ silc_buffer_unformat_vp @ 790 ; \r
+ silc_sftp_client_start @ 791 ;\r
+ silc_sftp_client_shutdown @ 792 ;\r
+ silc_sftp_client_receive_process @ 793 ;\r
+ silc_sftp_open @ 794 ;\r
+ silc_sftp_close @ 795 ;\r
+ silc_sftp_read @ 796 ;\r
+ silc_sftp_write @ 797 ;\r
+ silc_sftp_remove @ 798 ;\r
+ silc_sftp_rename @ 799 ;\r
+ silc_sftp_mkdir @ 800 ;\r
+ silc_sftp_rmdir @ 801 ;\r
+ silc_sftp_opendir @ 802 ;\r
+ silc_sftp_readdir @ 803 ;\r
+ silc_sftp_stat @ 804 ;\r
+ silc_sftp_lstat @ 805 ;\r
+ silc_sftp_fstat @ 806 ;\r
+ silc_sftp_setstat @ 807 ;\r
+ silc_sftp_fsetstat @ 808 ;\r
+ silc_sftp_readlink @ 809 ;\r
+ silc_sftp_symlink @ 810 ;\r
+ silc_sftp_realpath @ 811 ;\r
+ silc_sftp_extended @ 812 ;\r
+ silc_sftp_server_start @ 813 ;\r
+ silc_sftp_server_shutdown @ 814 ;\r
+ silc_sftp_server_receive_process @ 815 ;\r
+ silc_sftp_fs_memory @ 816 ;\r
+ silc_sftp_fs_memory_alloc @ 817 ;\r
+ silc_sftp_fs_memory_free @ 818 ;\r
+ silc_sftp_fs_memory_add_dir @ 819 ;\r
+ silc_sftp_fs_memory_del_dir @ 820 ;\r
+ silc_sftp_fs_memory_add_file @ 821 ;\r
+ silc_sftp_fs_memory_del_file @ 822 ;\r
+ silc_file_open @ 824 ;\r
+ silc_file_close @ 825 ;\r
+ silc_file_read @ 826 ;\r
+ silc_file_write @ 827 ;\r
+ silc_file_size @ 828 ;\r
+ silc_hmac_init @ 829 ;\r
+ silc_hmac_update @ 830 ;\r
+ silc_hmac_final @ 831 ;\r
+ silc_hmac_init_with_key @ 832 ;\r
+ silc_hmac_get_name @ 833 ;\r
+ silc_hmac_get_hash @ 834 ;\r
+ silc_net_localip @ 835 ;\r
+ silc_sftp_server_set_monitor @ 836 ;\r
+ silc_net_gethostbyname @ 837 ;\r
+ silc_net_gethostbyaddr @ 838 ;\r
+ silc_net_gethostbyname_async @ 839 ;\r
+ silc_net_gethostbyaddr_async @ 840 ;\r
+ silc_net_is_ip4 @ 841 ;\r
+ silc_net_is_ip6 @ 842 ;\r
+ silc_log_set_debug_string @ 843 ;\r
+ silc_log_reset_all @ 844 ;\r
+ silc_log_flush_all @ 845 ;\r
+ silc_log_get_file @ 846 ;\r
+ silc_log_quick @ 847 DATA ;\r
+ silc_log_flushdelay @ 848 DATA ;\r
+ silc_hash_table_list_reset @ 849 ;\r
+ silc_debug_hexdump @ 850 DATA ;\r
+ silc_memdup @ 851 ;\r
+ silc_command_get_status @ 852 ;\r
+ silc_utf8_encode @ 853 ;\r
+ silc_utf8_decode @ 854 ;\r
+ silc_utf8_encoded_len @ 855 ;\r
+ silc_utf8_valid @ 856 ;\r
+ silc_mime_parse @ 857 ;\r
+ silc_get_status_message @ 858 ;\r
+ silc_get_mode_list @ 859 ;\r
+ silc_hash_table_find_by_context @ 860 ;\r
+ silc_string_is_ascii @ 862 ;\r
+ silc_parse_version_string @ 863 ;\r
+ silc_version_to_num @ 864 ;\r
+ silc_fingerprint @ 865 ;\r
+ silc_get_packet_name @ 866 ;\r
+ silc_get_command_name @ 867 ;\r
+ silc_strncat @ 868 ;\r
+ silc_attribute_payload_parse @ 869 ;\r
+ silc_attribute_payload_encode @ 870 ;\r
+ silc_attribute_payload_alloc @ 871 ;\r
+ silc_attribute_payload_free @ 872 ;\r
+ silc_attribute_payload_list_free @ 873 ;\r
+ silc_attribute_payload_encode_data @ 874 ;\r
+ silc_attribute_get_attribute @ 875 ;\r
+ silc_attribute_get_data @ 876 ;\r
+ silc_attribute_get_object @ 877 ;\r
+ silc_attribute_get_flags @ 878 ;\r
+ silc_attribute_get_verify_data @ 879 ;\r
+ silc_hash_get_name @ 880 ;\r
+ silc_create_key_pair @ 881 ;\r
+ silc_load_key_pair @ 882 ;\r
+ silc_show_public_key @ 883 ;\r
+ silc_change_private_key_passphrase @ 884 ;\r
+ silc_argument_payload_encode_one @ 885 ; \r
+ silc_message_payload_decrypt @ 886 ; \r
+ silc_message_payload_parse @ 887 ; \r
+ silc_message_payload_encrypt @ 888 ; \r
+ silc_message_payload_encode @ 889 ; \r
+ silc_message_payload_free @ 890 ; \r
+ silc_message_get_flags @ 891 ; \r
+ silc_message_get_data @ 892 ; \r
+ silc_message_get_mac @ 893 ; \r
+ silc_message_get_iv @ 894 ; \r
+ silc_message_signed_payload_parse @ 895 ; \r
+ silc_message_signed_payload_encode @ 896 ; \r
+ silc_message_signed_payload_free @ 897 ; \r
+ silc_message_signed_verify @ 898 ; \r
+ silc_message_signed_get_public_key @ 899 ;\r
+ silc_hmac_unregister_all @ 900 ;\r
+ silc_hash_unregister_all @ 901 ;\r
+ silc_pkcs_unregister_all @ 902 ;\r
+ silc_cipher_unregister_all @ 903 ;\r
+ silc_rng_get_byte_fast @ 904 ;\r
+ silc_cipher_get_name @ 905 ;\r
+ silc_hmac_get_name @ 906 ;\r
+ silc_hash_get_name @ 907 ;\r
+ silc_pkcs_public_key_payload_encode @ 908 ;\r
+ silc_pkcs_public_key_payload_decode @ 909 ;\r
+\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\lib\silccore\silcnotify.c\r
+SOURCE=..\..\lib\silccore\silcmessage.c\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\lib\silccore\silcpacket.c\r
+SOURCE=..\..\lib\silccore\silcnotify.c\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\lib\silccore\silcprivate.c\r
+SOURCE=..\..\lib\silccore\silcpacket.c\r
# End Source File\r
# End Group\r
# Begin Group "silcske"\r
# PROP Default_Filter ""\r
# Begin Source File\r
\r
+SOURCE=..\..\lib\silcutil\silcapputil.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\lib\silcutil\silcbuffmt.c\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\lib\silccrypt\mars.c\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=..\..\lib\silccrypt\md5.c\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\lib\silccore\silcmode.h\r
+SOURCE=..\..\lib\silccore\silcmessage.h\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\lib\silccore\silcnotify.h\r
+SOURCE=..\..\lib\silccore\silcmode.h\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\lib\silccore\silcpacket.h\r
+SOURCE=..\..\lib\silccore\silcnotify.h\r
# End Source File\r
# Begin Source File\r
\r
# PROP Default_Filter ""\r
# Begin Source File\r
\r
+SOURCE=..\..\lib\silcutil\silcapputil.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\lib\silcutil\silcbuffer.h\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\lib\silccrypt\mars.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\lib\silccrypt\mars_internal.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=..\..\lib\silccrypt\md5.h\r
# End Source File\r
# Begin Source File\r
/* Native WIN32 compilation (-mno-cygwin GCC option) under cygwin, though
the code compiles with any native WIN32 compiler. */
+#ifndef SILC_WIN32
#define SILC_WIN32 1
+#endif
/* SILC distribution definitions (leave this at the end of file) */
#define SILC_DIST_TOOLKIT 1