                       Oper Challenge and Response System

   $Id: challenge.txt,v 1.9 2002/07/17 23:31:11 leeh Exp $

   Copyright (c) 2001 by ircd-hybrid team

     ----------------------------------------------------------------------

   ircd-hybrid

   In an effort to reduce the damage caused to a network by a hacked O-line,
   Hybrid supports an OpenSSL based challenge-response system. This new
   system allows the admin to remove all oper block passwords from the conf
   file. Authentication is done through a public/private key.

     ----------------------------------------------------------------------

                                  Requirements

   The ircd must be compiled with the --enable-openssl option to configure .
   If configure detects a working openssl library, --enable-openssl is
   implicitly enabled.

   oper {} blocks should not have normal passwords, but should contain the
   the name of the private key file. However it is possible for the user to
   use both challenge and normal passwords, but this would defeat the purpose
   of the challenge system.

   m_challenge.so must be loaded.

   The oper has their private key file and an implementation of the RSA
   Respond tool available to be run.

     ----------------------------------------------------------------------

                                    Process

   Each oper should have a private key file and a public key file. The keys
   can be generated with the mkkeypair utility provided in tools/. The keys
   are compatible with cryptlink keys.

   The oper keeps their private key file in a safe place, and gives their
   public key file to their admin(s).

   The admin will place an entry for the public key file into a field called
   rsa_public_key_file of each oper's oper {} block in the conf file.

   The oper wishes to obtain their operator status, and issues the CHALLENGE
   command.

   The server will print out a long hexadecimal string, that needs to be fed
   to the respond utility provided in tools/rsa_respond.

   The respond program will generate an answer that is fed back to the
   CHALLENGE command.

     ----------------------------------------------------------------------

                            Generating the Key Files

   The keys can be generated with the openssl command as follows:

       openssl genrsa -des3(1) -out rsa.key 1024(2)
       openssl rsa -in rsa.key -pubout -out rsa.pub
   

   (1)
           The -des3 must be included in order to create a key with a
           passphrase. Omitting this option will create a non protected key.
   (2)
           The key size must be 1024 or below. The challenge sent for a
           longer keysize will be too long to fit into the ircd's 512 byte
           line constraint.

   It is highly recommended that you set a password on your private key.

   The tools/mkkeypair utility cannot be used to create a key suitable for
   use in CHALLENGE.

     ----------------------------------------------------------------------

                          Using CHALLENGE and respond

     Note: All examples assume the use of the stock respond client included
     with the Hybrid 7 source, run on a UNIX(c) platform.

   The administrator of the server you oper on should remove the password in
   your oper {} block and replace it with an entry for your public key, so
   that /oper will be disabled.

     Note: The public key is a VERY long string.

   The oper will issue /challenge oper_nick, and see something like below:

 *** 56F1FDAE4C590C524CF758917E62C2A2A1376CB9C4C2E7D411BB0AD9C4A
 605A2D05A94E7254197E9D71438B5FB565B6FD35465E462305F35F4A2D45311
 F983B3E062F635912FA155B4B1E18EAA782CC107F4C9DA83092658D16A2E88A
 6BCF9820F5A044A29CDD4C062F05BF509CA3B561375CBC4179BD1CF6026BDE9
 60E52C6B

     Note: The challenge is all on one line.

     Note: With some clients, the oper will have to issue /quote CHALLENGE
     instead of /challenge.

   The oper will then have to feed that challenge to the respond program.

   +------------------------------------------------------------------+
   | The respond utility's syntax is:                                 |
   |                                                                  |
   |$ ./respond private_key_file challenge_from_server                |
   |                                                                  |
   |                                                                  |
   | Example:                                                         |
   |                                                                  |
   |wcampbel@botbay (rsa_respond): ./respond hwy.key \                |
   |56F1FDAE4C590C524CF758917E62C2A2A1376CB9C4C2E7D411BB0AD9C4A605A2D0|
   |5A94E7254197E9D71438B5FB565B6FD35465E462305F35F4A2D45311F983B3E062|
   |F635912FA155B4B1E18EAA782CC107F4C9DA83092658D16A2E88A6BCF9820F5A04|
   |4A29CDD4C062F05BF509CA3B561375CBC4179BD1CF6026BDE960E52C6B        |
   |Keyphrase:                                                        |
   |6B882932DD00F86123869E401F7334B9B0D0018A60F1DE244E90E47246AA87C7  |
   |                                                                  |
   |   Note: The challenge parameter must be on one line.             |
   +------------------------------------------------------------------+

   The keyphrase must be entered properly to get the response. The bottom
   line is the response that must be sent back to the server.

   The oper will issue the following command in order to obtain operator
   status:

   /challenge
   +6B882932DD00F86123869E401F7334B9B0D0018A60F1DE244E90E47246AA87C7

     Note: The '+' is needed

   If successful, the oper will obtain operator status on the server.

   +------------------------------------------------------------------------+
   |                                Warning                                 |
   |------------------------------------------------------------------------|
   | If the CHALLENGE fails, and you use ircII, EPIC, or BX, you may get    |
   | disconnected with the client asking for the server password. This is a |
   | client bug, not an ircd bug.                                           |
   +------------------------------------------------------------------------+

     ----------------------------------------------------------------------

                                RSA Respond Tool

   The RSA Respond tool is a vital part of challenge/response system. In
   order to function, the operator must have must have a way to quickly issue
   the respond command, and to copy and paste data to and from the IRC
   client.

   The respond source code is included with the Hybrid 7 source, in the
   tools/rsa_respond directory. A distributable tar file can easily be
   created by issuing make rsa_respond in the root of the source tree. The
   file rsa_respond.tar.gz will be created in the root of the source tree.

   rsa_respond.tar.gz should compile with little or no modifications[1] on
   most UNIX(c) and UNIX-like platforms[2]. The README in the tar archive
   gives more information.

   A copy of the source tar file is available on
   http://ircd.botbay.net/pub/hybrid/rsa/rsa_respond.tar.gz.

   For Windows platforms, there are two available RSA Respond tools. One is a
   text only port of the stock tool. The binary is available from
   http://ircd.botbay.net/pub/hybrid/rsa/rsa_respond-bin.tar.gz. The other
   tool is a GUI enabled version[3]. The source tree[4] is available from
   http://ircd.botbay.net/pub/hybrid/rsa/winrespond-src.tar.gz. A binary
   distribution is available from
   http://ircd.botbay.net/pub/hybrid/rsa/winrespond-bin.tar.gz.

   With the appropriate version of the RSA Respond tool, any operator can
   protect their privileged access to the server, with little additional
   effort over using standard operator passwords.

     ----------------------------------------------------------------------

                                    Benefits

   The greatest benefit of using the challenge/response system is that there
   are no passwords sent over the network in plaintext. There are also no
   credentials left on the server side, as only public keys are kept in the
   conf. The use of public/private key encryption provides far greater
   security over having a single password, and may (if the key is kept
   secure, and has a good passphrase) virtually eliminate hacked O-lines.

     ----------------------------------------------------------------------

                                  A. Numerics

 :server 381 user :You have entered... the Twilight Zone!.
 :server 386 user :challenge-text
 :server 464 user :Password Incorrect
 :server 491 user :Only few of mere mortals may try to enter the twilight zone
   

     Note: The text used can be changed by the server administrator.

     ----------------------------------------------------------------------

                                  B. Scripting

   The following script is for EPIC 4 only. It was written by Greg Prosser,
   xyst <gregp@blackened.net>.

   Please note that passphrase protected keys cannot be used in conjunction
   with this script.

   BEGIN challenge.irc

      

      
 # challenge.irc -- authenticate to a hybrid-7 server with challenge response
 #                  oper authentication.  --gnp (xyst)
 # note: this is almost gauranteed to not work if your key needs a passphrase
 #
 # credit goes to hop for pipe from the default script archive, which doesn't
 # work, but gave me a framework for execing stuff and getting the response.

 # For Hybrid's cvs...
 # $Id: challenge.txt,v 1.9 2002/07/17 23:31:11 leeh Exp $

 xecho ... Loading challenge.irc by xyst, feer.

 # you might want to change these..

 @challenge.path=[~/.irc/respond]
 @challenge.key=[~/.irc/challenge.identity]
 @challenge.num=0
 @challenge.response=[]
 @challenge.savepath=[~/.irc/challenge.config]

 alias rsaconfig {
     if ([$0])
     {
         switch ($tolower($0))
         {
             (resppath)
             {
                 if ([$1])
                 {
                     @challenge.resp=[$1]
                     xecho $G Challenge -- resppath is now: $1
                 } {
                     xecho $G Challenge -- resppath: $challenge.path
                 }
             }
             (keypath)
             {
                 if ([$1])
                 {
                     @challenge.key=[$1]
                     xecho $G Challenge -- keypath is now: $1
                 } {
                     xecho $G Challenge -- keypath: $challenge.key
                 }
             }
             (save)
             {
                 @unlink($challenge.savepath)
                 @fd=open($challenge.savepath W)
                 @write($fd @challenge.path=[$challenge.path])
                 @write($fd @challenge.key=[$challenge.key])
                 @close($fd)
                 xecho $G Challenge -- saved settings.
             }
             (*)
             {
                 xecho $G Usage: /rsaconfig <resppath|keypath> [value]
             }
         }
     } {
         xecho $G Current settings for challenge.irc:
         rsaconfig resppath
         rsaconfig keypath
         xecho $G Type /rsaconfig <resppath|keypath> <value> to change these, /rsaconfig save saves them.
     }
 }

 alias challenge {
     if ([$0])
     {
         ^quote challenge $0
     } {
         xecho $G Usage: /challenge <username>
     }
 }

 on ^386 * {
     xecho $G Got oper-challenge from server, sending response..
     @challenge.num++
     ^on ^exec "chall$challenge.num *" {
         @challenge.response=[$1]
     }
     ^exec -name chall$challenge.num $challenge.path $challenge.key $1
     ^wait %chall$challenge.num
     ^on exec -"chall$challenge.num *"
     ^stack push on raw_irc
     ^stack push on 381
     ^on ^raw_irc "$S 464 *" { xecho $G Challenge incorrect.  Check your key.;^stack pop on raw_irc;^stack pop on 381 }
     ^on -381 * { ^stack pop on 381;^stack pop on raw_irc }
     ^quote challenge +$challenge.response
 }

 if ([$fexist($challenge.savepath)] > 0)
 {
     xecho $G Loading settings from $challenge.savepath ..
     ^load $challenge.savepath
 } {
     xecho $G Config file not found, try /rsaconfig save\; using defaults.
 }

 rsaconfig

      
   

  Notes

   [1] Some platforms may require Makefile changes in order to link in the    
       OpenSSL library. This may change in the future.                        
   [2] Platforms known to function include: Linux, FreeBSD, Solaris, and      
       Cygwin.                                                                
   [3] A screenshot of the program is available on                            
       http://kabel.pp.ru/sgml/winrespond.png .                               
   [4] The winrespond source depends on a working, up to date, Cygwin         
       installation.                                                          
