home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / encrypt.doc < prev    next >
Text File  |  2001-03-27  |  19KB  |  461 lines

  1. 13 December 1999. Daniel Hellerstein (danieh@crosslink.net)
  2.  
  3.        The SRE-http encryption facility.     
  4.  
  5. Abstract:
  6.    SRE-http provides several encryption tools for both
  7.    returning contents to clients, and for recieving
  8.    encrypted requests from clients.  This document
  9.    describe these options.
  10.  
  11.                         ------------------
  12.  
  13. Contents:
  14.    I    Introduction
  15.   II    Using SRE-http encryption
  16.   II.1    Enabling Encryption
  17.   II.2    Assigning a shared-secret
  18.   II.3    Selecting which responses to encrypt.
  19.   II.4    Providing client-side decryption tools
  20.   II.4a     SRE_A and SRE_B commonalities
  21.   II.4b     SRE_A
  22.   II.4c     SRE_B
  23.   II.4d     SRE_BF and SRE_BFC
  24.  III.   Custom encryption
  25.   IV.   Client-side encrpytion of FORM requests
  26.    V.   Comparing the default encryption algorithims
  27.   VI.   Notes
  28.  
  29.      
  30.                         ------------------
  31.  
  32. I. Introduction
  33.  
  34. Ideally, SRE-http would be SSL compliant. Unfortunately,
  35. the licensing and registration requirements for the 
  36. public-key procedures used by SSL are overwhelming
  37. (at least in the USA).  But given the open nature of the
  38. Internet, some form of encryption is sometimes necessary,
  39.  
  40. SRE-http provides a solution to this problem, using a "shared
  41. secret" form of encryption.  Basically, this requires
  42. that a client be "registered" with your site, that she have a 
  43. username and password stored on your server. Although this
  44. is not as convenient as SSL, in many cases it will be sufficient.
  45.  
  46. The encryption algorithim used by SRE-http is flexible -- you can
  47. use one of the default methods provided (SRE_A, SRE_B, SRE_BF or SRE_BFC), 
  48. or you can install your own, customized algorithim.  
  49.  
  50.   * The SRE_A and SRE_B default methods use "40 bit" keys, and are
  51.     based on a simple randomization of  a message, using  an MD5 hash 
  52.     of a password as a random number seed. 
  53.     Decryption of this method is accomplished with a 
  54.     javascript program run within your browser (SRE_B), or a rexx program
  55.     installed as a plug-in launched by your browser (SRE_A).
  56.  
  57.   * The SRE_BF and SRE_BFC use the BlowFish encryptor. Since BlowFish
  58.     is a strong (128 bit, and above) encryption algorithim, we 
  59.     can not include the BlowFish executable with SRE-http 
  60.      -- you'll have to find them on the net. You can try 
  61.         http://hobbes.nmsu.edu, search  for BLOWFISH, or 
  62.         http://www.counterpane.com/blowfish.html
  63.  
  64.       * You can fairly easily install and specify your own encryption scheme:
  65.        as long as it can be called by SRE-http as an external rexx
  66.        procedure, it probably can be used.  
  67.  
  68. Note: 
  69.   In many cases, where access control is more important then the actual 
  70.   contents of a response, encryption of a user's password is sufficient.
  71.   This can be accomplished using http/1.1 "digest authentication".  
  72.   Alternatively, since it may be a few years before digest authentication is 
  73.   fully suported by commonly used browsers, one can use SRE-http's 
  74.   "dynamic password" procedure  to simluate "digest authentication" (see 
  75.   DYNPWD.DOC for further discussion).
  76.   
  77.  
  78.                         -------------------------------
  79.  
  80. II) Using SRE-http encryption
  81.  
  82. To use SRE-http's encryption, you need to:
  83.  
  84.   ** 1) enable encryption
  85.   ** 2) assign a "shared secret" to all users who may need to download 
  86.         encrypted responses
  87.   ** 3) indicate which selectors are to be encrypted by SRE-http, and which
  88.         encryption algorithim to use
  89.   ** 4) depending on the encryption algorithim used, you may need to provide 
  90.         tools to clients, tools that can be used to decrypt the encrypted 
  91.         response.
  92.  
  93. The following describes these steps.
  94.  
  95. ** II.1) Enabling Encryption with the ENABLE_ENCRYPTION and DEFAULT_ENCRYPTION
  96.       paramaters
  97.  
  98. The ENABLE_ENCRYPTION parameter (set in INI_STA.80) is used to enable 
  99. SRE-http's encryption facility. It can take the following values:
  100.  
  101.   0 = Disable the sre-http encryption facility
  102.  
  103.   1 = Check for a !ENCRYPT "modifier", and encrypt if the response
  104.      is a file, or an "encrypt aware" addon
  105.  
  106.   2 = Same as 1, but handles more cases (i.e.; addons that let
  107.       sref_gos return results)
  108.  
  109.   3 = Encrypt everything
  110.  
  111. The DEFAULT_ENCRYPTION parameter (also set in INIT_STA.80) parameter specifies 
  112. what algorithim to use by default.  As described in step 3 below, when
  113. designating which "selectors" should be encrypted, one can specify
  114. the method, or use the "default". DEFAULT_ENCRYPTION specifies what
  115. this default method should be.
  116.  
  117. Examples:
  118.     DEFAULT_ENCRYPTION='SRE_A'
  119.     DEFAULT_ENCRYPTION='SRE_B'
  120.     DEFAULT_ENCRYPTION='MY_METHOD'
  121.  
  122.  
  123. Technical notes:
  124.  
  125.  i) The SRE-http encryption facility is invoked by the SREF_GOS procedure.
  126.     SREF_GOS is used by SREFILTR.80, and by most addons. However, some older
  127.     addons directly return results to the client, and bypass SREF_GOS.
  128.     For these "older" addons, encryption (unless explicitily invoked) will
  129.     NOT be attempted.
  130.  
  131.     Addon authors should read the description (in SREFPRC.DOC) of
  132.     how to specify encryption when using SREF_GOS.
  133.  
  134.  ii) ENABLE_ENCRYPTION=1 is a subset of ENABLE_ENCRYPTION=2.
  135.      If you use ENABLE_ENCRYPTION=1, then calls to SREF_GOS
  136.      must explicitily include an "encryption" option.  SREFILTR.80,
  137.      and a few of the more commonly used SRE-http utilities, have been 
  138.      modified to send this "explicit encryption" command when calling 
  139.      SREF_GOS.  Most addons have NOT been modified.
  140.  
  141.      In contrast, ENABLE_ENCRYPTION=2 instructs SREF_GOS to also check the 
  142.      "request specific" environment for an !ENCRYPT  flag.  Thus, addons 
  143.      that use SREF_GOS can have their output encrypted, even if they
  144.      don't explicitly tell SREF_GOS to encrypt.
  145.  
  146.      ENABLE_ENCRYPTION=2 is the more risk free choice, but it is a bit
  147.      slower. So, if you know what will be encrypted (say, a small
  148.      set of static documents), you can speed things up a bit by using
  149.      ENABLE_ENCRYPTION=1
  150.  
  151.  iii) If ENABLE_ENCRYPTION=3, then all responses (that are handled by SREF_GOS)
  152.       will be encrypted, using the default algorithim. This is not
  153.       recommended for general purposes, but may be useful for special secure
  154.       servers.
  155.  
  156.  
  157. ** II.2) Assigning a shared-secret
  158.  
  159. The default SRE-http encryption algorithims require a "shared-secret". 
  160. The "shared secret" is is a special "password" that is known only by
  161. you (the server) and the  user (the client). When SRE-http needs to encrypt
  162. a file, the shared-secret is used to scramble the contents.  Furthemore, when
  163. the client needs to decrypt the response, she'll need to provide this 
  164. same shared-secret to the decryption software (see 4 below for more 
  165. on decryption).
  166.  
  167. SRE-http uses client-specific "secret privileges" to assign this "shared-
  168. secret".  In particular, you could add the following to entries in the 
  169. USERS.IN file:
  170.    ?ENCRYPT:a_secret
  171. where  a_secret is this case-insensitive user's shared secret.
  172.  
  173. *** Although it weakens security a bit, shared-secrets are case insensitive.
  174.     In other words; SRE-http converts "shared-secrets" to upper case.
  175.  
  176. For example: assuming a user JOE, with password COLD. and a "shared-secret" 
  177. of MOLX4; the entry (in USERS.IN) could be:
  178.    JOE COLD ?ENCRYPT:MOLX4
  179.  
  180. or, if you want to also assign a  few other privileges, you could use:
  181.    JOE COLD USER5 ?ENCRYPT:MOLX4 ?MANAGER:ZXI3
  182.  
  183. Notes:
  184.  * "secret privileges" MUST always start with a ?
  185.  * Secret privileges should NEVER be reported by any SRE-http application.
  186.  * the SRE-http manual, and the sample USERS.IN file, contain further 
  187.    discussions of secret-privileges
  188.  * the shared-secret is case insensitive.
  189.  * Although it's not recommended, you can use the USER_PRIVS parameter (in
  190.    INITFILT.80) to assign a generic  shared-secret to all clients. For example:
  191.       USER_PRIVS='USER  ?ENCRYPT:users1q'
  192.   If you do this, you won't be able to assign "client specific" shared secrets.
  193.  
  194. ** II.3) Selecting which responses to encrypt.
  195.  
  196.   There are two ways to indicate which resources should be encrypted,
  197.   by prepending an !ENCRYPT to the selector, or by using an advanced option.
  198.  
  199.  a) Prepending !ENCRYPT
  200.  
  201.   SRE-http looks for a !ENCRYPT "special modifier" in the selector.
  202.   This modifier can take two forms:
  203.  
  204.      !ENCRYPT/selector  
  205.            encrypt using the "default"  algorithim (as specified by the
  206.            DEFAULT_ENCRYPTION parameter).
  207.      !ENCRYPT_method/selector
  208.            encrypt using the "method" algorithim
  209.  
  210.  For example:
  211.    !ENCRYPT/private/guests.txt
  212.    !ENCRYPT_SRE_A/sales/order123.rcp
  213.    !ENCRYPT_CUSTOM_XYZ/employees/jhm/timesheet.499
  214.  
  215.    Note that !ENCRYPT/ will invoke the algorithim specified by the 
  216.    DEFAULT_ENCRYPTION parameter (specified in section 1).
  217.  
  218.  
  219.  b) Using an advanced option
  220.     Set an advanced option of:
  221.       SET ENCRYPT method
  222.           or
  223.       SET ENCRYPT 0     (to override any !ENCRYPT special directive)
  224.  
  225.    For example:
  226.         SET ENCRYPT SRE_BFC
  227.  
  228.    If you do not specify a method, then the default method (as specified by
  229.    the DEFAULT_ENCRYPTION parameter) will be used.
  230.  
  231.    Note that the "advanced option" may be for a "wildcarded selector"
  232.    (say, from a wildcarded entry in ACCESS.IN) Please see ADV_OPTS.DOC
  233.    for further dicussion of advanced options.
  234.   
  235.  
  236. Note: for a discussion of how to specify a custom algorithim, 
  237.          please see section III.
  238.  
  239.  
  240. ** II.4) Providing client-side decryption tools
  241.  
  242. After the server sends the encrypted response, the client has to
  243. have some way of decrypting it.  The default methods offer different 
  244. means for accomplishing this decryption.
  245.  
  246. II.4a) SRE_A and SRE_B 
  247.  
  248. The SRE_A and SRE_B methods use a similar "randomization" technique:
  249.  
  250. a) SRE-http generates a "nonce", consisting of the time and the client's
  251.    ip address.
  252. b) The client's "shared-secret" password is appended to this nonce -- the
  253.    result is the "encryption key" (this assumes that that client has 
  254.    a ?ENCRYPT:password "secret privilege")
  255. c) An MD5 hash is generated from this encryption key.  A verifier is
  256.    extracted from this hash. In addition, a random number seed
  257.    is also extracted from the hash.
  258. d) The random number seed is used to generate a series of random numbers.
  259.    These are used to randomize the response.
  260. e) This randomized response is sent to the client.
  261.  
  262. To decrypt the response, the client must replicate these steps, using
  263. the nonce (which is included in the response), and her shared-secret password,
  264. to generate an MD5 hash from which the random number seed is extracted.
  265.  
  266. SRE_A and SRE_B use different strategies to enable this client side
  267. decryption:
  268.  
  269.   SRE_A)  An external program is run, which decrypts the response
  270.           and either writes the decrypted response to a file, or
  271.           displays it in a new browser window
  272.   SRE_B)  The encrypted response is embedded in an html document containing 
  273.           a javascript program. This javascript program will ask the
  274.           client for her password, decrypt the file, and then
  275.           display this decrypted response in a new window.
  276.  
  277.  
  278. II.4b) SRE_A
  279.  
  280. SRE_A requires an external program. In particular, the DE_SREA.CMD program
  281. (which is installed in the GoServe data directory) can be used by clients
  282. who have rexx interpreters on their machine -- basically, OS/2
  283. clients who are using NetScape.  
  284.  
  285. Although it can be run in a stand-alone mode, DE_SREA.CMD should be 
  286. installed as a NetScape helper application. DE_SREA.CMD contains 
  287. detailed installation instructions on how to do this.
  288. Basically, the client should:
  289.  a) copy DE_SREA.CMD to an applications directory; say, D:\OS2\APPS
  290.  b) add a helper-app to netscape, using:
  291.      mimetype: application/x-encrypt_SRE_A
  292.      application: cmd.exe /c "D:\OS2\APPS\DE_SREA.CMD PWD:my_secret"
  293.         where my_secret is the client's "shared-secret"
  294.  
  295. After this installation, NetScape will call DE_SREA whenever a response has 
  296. the mimetype of application/x-encrypt_SRE_A.  DE_SREA will display some 
  297. info on the response, decrypt it, and then ask whether the response 
  298. should be displayed in a new NetScape window or whether it should be saved 
  299. to a file.
  300.  
  301. II.4c) SRE_B
  302. SRE_B requires a javascript capable browser.  
  303. SRE_B has the advantage of simplicity -- you do NOT need to distribute (and
  304. instruct clients in the installation) of an operating system specific plug-in.
  305. The disadvantage is that it is much slower then SRE_A (about 10x slower).
  306. SRE_B uses the ENC_SREB.RSP file (which should be located in the, possibly
  307. host-specific, default data directory) to create this javascript containing 
  308. response. 
  309.    You can customize this "response" file, just be careful about 
  310.    non-changeable code!
  311.  
  312.  
  313. II.4d) SRE_BF and SRE_BFC
  314.  
  315. The SRE_BF and SRE_BFC "BlowFish" methods require that the client have
  316. some kind of BlowFish executable.  There may be plugins for NetScape, IE,
  317. etc. that will run BlowFish for the client.  Lacking that, the DE_SREBF.CMD
  318. REXX program can be used to facilitate (on OS/2, or other REXX capable
  319. machines) the use of BlowFish.
  320.  
  321. For details on DE_SREBF.CMD, please see the comments in DE_SREBF.CMD.
  322.  
  323.                         ------------------
  324.  
  325. III) Custom encryption
  326.  
  327. If desired, you can write your own encryption procedure (say, a Java based
  328. procedure based on PGP). To incorporate this into SRE-http, the following
  329. step are required:
  330.  
  331. a) Create (and load) a macrospace procecdure named SREF_CUSTOM_ENCRYPT. 
  332.    If you are implementing more then one custom procecure, SREF_CUSTOM_ENCRYPT
  333.    will need to implement all the various encryption algoritims (or call an
  334.    appropriate set of procedures).
  335.  
  336. b) This procedure should return the following (seperated by '0d0a'x):
  337.     i) the mime-type
  338.    ii) the content encoding
  339.   iii) the encrypted response
  340.  
  341.   That is, the following will be used to parse the reponse:
  342.        parse var stuff mimetype (crlf) content_encoding (crlf) stuff
  343.  
  344.   For example, SRE_A returns:
  345.         'application/x-encrypt_SRE_A'||crlf||'Encrypt_SRE_A'||crlf||response
  346.  where:
  347.       cflf='0a0a'x
  348.       response is the encrypted response (which might contain many crlfs)
  349.  
  350. c) You'll need to arrange a mechanism (i.e.; a seperate helper application, 
  351.    or embedded code) that will help the client decrypt the response.
  352.  
  353.  
  354.                         ------------------
  355.  
  356.  
  357. IV) Encrpyting FORMS submitted by clients.
  358.  
  359. In order to allow clients to submit encrypted information, SRE-http
  360. provides a javascript based procedure that will encrypt elements in
  361. an HTML form. These encrypted elements will be then be sent to
  362. the server, and the server will then decrypt them for further
  363. processing.
  364.  
  365. This is a several step process:
  366.    1) Include (using an INCLUDE ssi) the ENC_RESP.RSP javascript procedures
  367.       in an HTML document that contains a FORM (with elements you wish
  368.       to encrypt).
  369.    2) specify a hidden element with name="nonce"
  370.       and a hidden element with name="verify"     
  371.    3) Using a TEXT element, get a "shared-secret" password, and then 
  372.       call the comp_md5 javascript procedure to generate an encryption key
  373.    4) Specify some hidden elements that will contain the encrypted variables
  374.    5) Include some non-hidden form elements (such as TEXT, TEXTAREA, and SELECT), 
  375.       and encrypt their values using  do_encrypt javascript procedure
  376.    6) clear the raw (unencrypted) variables (that is, the raw versions
  377.       of the variables you encrypted in step 5) using the clear_fields
  378.       javascript procedure
  379.    7) Submit the form -- the script on the server will have to
  380.       decrypt (using SREF_FORM_DECRYPT) the encrypted
  381.       variables (that were set in 4 and 5)
  382.  
  383. ENC_TEST.RSP contains further details on each of these steps.
  384.  
  385. Notes:
  386.  
  387.   *  ENC_TEST.HTM and ENC_TEST.CMD demonstrate SRE-http's 
  388.      client-side encryption of form elements.
  389.  
  390.   *  The encryption algorithim used is essentially the same as SRE_B --
  391.      it uses a 40 bit key, hence can not be considered secure against
  392.      sophisicated attack.
  393.  
  394.                         ------------------
  395.  
  396. V) Comparing the default encryption algorithims
  397.  
  398. None of the several encryption algorithims are perfect. The
  399. following lists their strengths and weaknesses. Note that in
  400. all cases, clients requesting encyrpted resources must be
  401. "registered" -- which will require some parallel means of
  402. communicating passwords and other client-specific attributes.
  403.  
  404. SRE_A:
  405.    Speed: Moderate -- adequate for responses less then 25k.
  406.    Security: Moderate (40 bit) -- will not stop determined/well-equipped
  407.              crackers
  408.    Limitations: None
  409.    Client-side ease of use: Somewhat demanding.
  410.                    Client must obtain and install the DE_SREA.CMD
  411.                    program; which requires REXX. 
  412.    Recommendation: best used when you know your clients are OS/2 users.
  413.         
  414. SRE_B:
  415.    Speed: Slow  -- adequate for responses less then 5k.
  416.    Security: Moderate (40 bit) -- will not stop determined/well-equipped
  417.              crackers
  418.    Limitations: None
  419.    Client-side ease of use: Fairly easy.  Client has to have a 
  420.                    javascript enabled browser.
  421.    Recommendation: best used to return short responses to a variety
  422.                    of cients.
  423.  
  424. SRE_BF and SRE_BFC:
  425.    Speed: Fast  -- large (>100k) responses are quickly encrypted and
  426.                    decrypted
  427.    Security: Stronge (128+ bit) -- with adequately long "shared-secrets"
  428.              (say, 10 or so characters), will probably stop all but the
  429.              most sophisticated crackers.
  430.    Limitations: Export restrictions mean that both servers and clients
  431.                 are responsible for obtaining blowfish executables. 
  432.                 Howver, this is not difficult to do, they can readily be
  433.                 found on the WWW.
  434.    Client-side ease of use: Mediocre. Client must obtain an operating
  435.                             system specific version of BlowFish, and be 
  436.                             satisified with saving responses to a disk file.
  437.                             However, 
  438.                               * BlowFish is gaining acceptance, and there may be
  439.                                 BlowFish capable plug-ins for the major
  440.                                 browsers in the near future. Also,
  441.                               * the DE_SREBF program can be used (by clients
  442.                                 with REXX capable machines) to decrypt & display
  443.                                 SRE_BF and SRE_BFC encrypted files.
  444.    Recommendation: best used when security is important, and clients
  445.                    are capable of obtaining and using BlowFish executables.
  446.                    
  447.    Note: SRE_BF and SRE_BFC differ only in that SRE_BFC will compress
  448.          before encrypting. This is a very nice feature, but
  449.          may not be supported by all implementations of BlowFish.
  450.  
  451.  
  452. Vi) Notes
  453.  
  454.   * PUBLIC_URLS are NEVER encrypted.
  455.  
  456.   * For more information on BlowFish, see 
  457.         http://www.counterpane.com/blowfish.html
  458.     
  459.   
  460.  
  461.