Secure Names version 0.5 README
Securenames is a combination of a palace server plugin and stand alone name
encoding program which allows a server operator to control the screen names
people connecting with the Instant Palace client can use.
Installation
Installation requires user-provided changes to the web server's scripting to
encode the screen name and pass it to the instant palace client.  Very simple
samples are included in the distribution.
The plugin is installed following the usual plugin installation
conventions.  The
following installation instructions assume that the Palace server has been
installed in /usr/local/palace.
Securenames is a standard Palace server plugin.  It is installed by placing the
executable files, securenames.so and securenamesencode, in the palace binary
folder, /usr/local/palace/bin, and adding the following line to the plugin
configuration file, /usr/local/palace/<palace-name>/psdata/plugin.conf:
../bin/securenames.so <key-file> [-m <max-name-len>] [-w <time-window>]
The <key-file> is described below.  The switches are:
-m <max-name-len> - Specifies the maximum length of a valid screen name.
-w <time-window>  - Specifies the time window in seconds in which a name
will be
                    accepted.  For more information, see below.
Sample Web Scripting Files
The samples are:
signon.pl - Designed to go in the cgi-bin directory on the web server.
signon.html - Designed to go in the <palace-name> directory in the Palace
install.
Method of Operation
The server web scripting (CGI, Perl, JSP) decides what screen name the Instant
Palace user will have.  It may check the web site registration database, or use
any other technique that is appropriate to the rules of the particular
palace. It
then encodes the name using te securenamesencode program, and includes the
encoded name as the DefaultName parameter:
<PARAM name="DefaultName" value="<encoded-name>">
It then sends the Instant Palace web page to the user.
Instant Palace gets the encoded name from the DefaultName parameter and
sends it
to the Palace server.  The securenames plugin intercepts the name, decodes
it and
checks it for validity.  If it is valid, the login is continued using the
decoded
name.  Otherwise the login is forbidden, and an error message is sent to the
user.
The Time Window
The server operator may limit the time window in which an encoded name is valid
with the -w parameter.  The time window is implemented in units of 5 seconds.
The maximum value for the window is 600 seconds (10 minutes).  A value of zero
indicates that no window is in effect, and encoded names will remain valid
until
a new <key-file> is built.
If names are encoded on a different machine from the one running the palace
server, the clocks on the two machines must be synchronized well enough so
recently encoded screen names will be valid.  Network Time Protocol is a
possible
solution.
The Key File
Much of the security of Secure Names depends on the contents of the <key-file>.
The <key-file> should be protected so it can not be downloaded by the web
server.
The <key-file> must be generated by the user.  One way to generate it on Linux
is:
$ head -c 60 /dev/urandom > keyfile
Unless long-term encoded screen names are desired, it is reasonable to
regenerate
the <key-file> as part of the palace server startup script.
The Secure Names Encode program
The securenamesencode program encodes the screen name, and sends the
encoded name
to stdout.  It is called:
securenamesencode -w -k <key-file> <screen-name>
-w indicates that time information is to be included in the encoded name to
enforce a name validity window.  Note that if -w is specified, then a
non-zero -w
parameter must be specified for the securenames plugin.  If -w is not
specified,
then the -w parameter must be specified as zero for the securenames plugin.
(N.B. securenamesencode will perform the necessary web escaping for
characters in
the encoded screen name which need to be escaped.)
Valid Screen Name Characters
Secure names limits the valid characters in the user's screen name.  The valid
characters are the upper case alphabet (A-Z), the lower case alphabet
(a-z), the
digits 0-9, period, hyphen, and underscore.  All other characters are
invalid and
are used in validity checking the name.
Credits
Securenames uses an implementation of AES described as follows:
   Written by Mike Scott 21st April 1999
   mike@compapp.dcu.ie
   An alternative faster version is implemented in MIRACL
   ftp://ftp.compapp.dcu.ie/pub/crypto/miracl.zip
   Copyright (c) 1999 Mike Scott
   Permission for free direct or derivative use is granted subject
   to compliance with any conditions that the originators of the
   algorithm place on its exploitation.
   Inspiration from Brian Gladman's implementation is acknowledged.
Securenames uses an implementation of MD5 described as follows:
   **********************************************************************
   ** md5.c                                                            **
   ** RSA Data Security, Inc. MD5 Message Digest Algorithm             **
   ** Created: 2/17/90 RLR                                             **
   ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version                  **
   **                                                                  **
   **                                                                  **
   ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
   **                                                                  **
   ** License to copy and use this software is granted provided that   **
   ** it is identified as the "RSA Data Security, Inc. MD5 Message     **
   ** Digest Algorithm" in all material mentioning or referencing this **
   ** software or this function.                                       **
   **                                                                  **
   ** License is also granted to make and use derivative works         **
   ** provided that such works are identified as "derived from the RSA **
   ** Data Security, Inc. MD5 Message Digest Algorithm" in all         **
   ** material mentioning or referencing the derived work.             **
   **                                                                  **
   ** RSA Data Security, Inc. makes no representations concerning      **
   ** either the merchantability of this software or the suitability   **
   ** of this software for any particular purpose.  It is provided "as **
   ** is" without express or implied warranty of any kind.             **
   **                                                                  **
   ** These notices must be retained in any copies of any part of this **
   ** documentation and/or software.                                   **
   **********************************************************************
Geek Details for the Security Analyst
Securenames makes use of the fact that there are more characters (Ncs) that can
passed in an Instant Palace screen name than are included in the ones
considered
valid by secure names (Nv).  These "invalid" characters are used to detect
modification of a name or the use of an expired name.  Securenames uses
encryption to make it very difficult to change an encoded screen name without
introducing at least one invalid character in the decoded name.
The encoding is performed by converting the screen name to a number n.
Starting
with n=0, for each character c in the screen name, it calculates:
n = n*Ncs + index(c in valid_set)
It then encrypts the resulting number using the Advanced Encryption Standard
algorithm (AES) with cyphertext stealing for the two blocks.  (See Applied
Cryptography by Bruce Schneier for details on cyphertext stealing.)  The AES
encryption key is generated from the <key-file>, and if the -w parameter is
specified, the current time.
If -w parameter is specified, n is multiplied by the low order bits of the
encryption time giving nt.
Then nt is converted to a character string using the remainder from repeated
division by Ncs as in index in the passable screen name character set.  The
character string is written to stdout.
When the securenames plugin receives a login from an Instant Palace client, it
takes the screen name and converts it to a number.  If it is running with a
non-zero -w parameter, it divides out the low order bits of the encryption
time,
and uses the login time to compute the encryption time.  If there is an
encryption time within the window (and there will only be one), then the
computed
encryption time is used with the <key-file> to compute an AES decryption
key. (If
-w is zero, only the <key-file> is used to compute the key.)
Securenames decrypts the encrypted name recovering the value of n.  Then n is
converted to a character string using the remainder from repeated division
by Ncs
as in index in the valid screen name character set.  If any indexes are outside
the set, the login is rejected.