home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / drafts / draft_s_z / draft-thayer-cipher-01.txt < prev    next >
Text File  |  1997-04-17  |  14KB  |  498 lines

  1.  
  2.  
  3.           Network Working Group                              R. Thayer
  4.           Expires in six months 
  5.           Internet Draft                                    April 1997
  6.  
  7.  
  8.                         A Stream Cipher Encryption Algorithm
  9.                             <draft-thayer-cipher-01.txt>
  10.  
  11.  
  12.           Status of this Memo
  13.  
  14.           This document is an Internet-Draft.  Internet-Drafts are working
  15.           documents of the Internet Engineering Task Force (IETF), its
  16.           areas, and its working groups.  Note that other groups may also
  17.           distribute working documents as Internet-Drafts.
  18.  
  19.           Internet-Drafts are draft documents valid for a maximum of six
  20.           months and may be updated, replaced, or obsoleted by other
  21.           documents at any time.  It is inappropriate to use Internet-
  22.           Drafts as reference material or to cite them other than as ``work
  23.           in progress.''
  24.  
  25.           To learn the current status of any Internet-Draft, please check
  26.           the ``1id-abstracts.txt'' listing contained in the Internet-
  27.           Drafts Shadow Directories on ftp.is.co.za (Africa), nic.nordu.net
  28.           (Europe), munnari.oz.au (Pacific Rim), ds.internic.net (US East
  29.           Coast), or ftp.isi.edu (US West Coast).
  30.  
  31.           Abstract
  32.  
  33.           There is a need in the Internet community for an encryption
  34.           algorithm that provides interoperable operation with existing
  35.           deployed commercial cryptographic applications.  This
  36.           interoperability will allow for a smoother transition to
  37.           protocols that have been developed through the IETF standards
  38.           process.  This document describes an existing algorithm that
  39.           satisifies this requirement.
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.           Thayer                                              [Page 1]
  56.  
  57.  
  58.  
  59.  
  60.           Internet Draft    An Encryption Algorithm         April 1997
  61.  
  62.  
  63.  
  64.  
  65.           TABLE OF CONTENTS
  66.  
  67.  
  68.           STATUS OF THIS MEMO.............................................1
  69.  
  70.  
  71.           ABSTRACT........................................................1
  72.  
  73.  
  74.           1. INTRODUCTION.................................................3
  75.  
  76.  
  77.           2. REQUIREMENTS FOR THIS ENCRYPTION ALGORITHM...................3
  78.  
  79.  
  80.           3. DESCRIPTION OF ALGORITHM.....................................4
  81.  
  82.  
  83.           4. INTELLECTUAL PROPERTY CONSIDERATIONS.........................5
  84.  
  85.  
  86.           5. ACKNOWLEDGEMENTS.............................................5
  87.  
  88.  
  89.           6. SECURITY CONSIDERATIONS......................................5
  90.  
  91.  
  92.           7. REFERENCES...................................................5
  93.  
  94.  
  95.           8. AUTHOR'S ADDRESS.............................................6
  96.  
  97.  
  98.           APPENDIX........................................................7
  99.  
  100.           A. TEST VECTORS.................................................7
  101.           B. SAMPLE CODE..................................................8
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.           Thayer                                              [Page 2]
  111.  
  112.  
  113.  
  114.  
  115.           Internet Draft    An Encryption Algorithm         April 1997
  116.  
  117.  
  118.  
  119.           1. Introduction
  120.  
  121.           There is a need in the Internet community for an encryption
  122.           algorithm that provides interoperable operation with existing
  123.           deployed commercial cryptographic applications.  This
  124.           interoperability allows for a smoother transition to protocols
  125.           that have been developed through the IETF standards process.
  126.           This document describes an existing algorithm that satisifies
  127.           this requirement.
  128.  
  129.           There is a large body of experience in developing and deploying
  130.           encryption applications, especially in the HTTP/HTML
  131.           browser/server markets.  These browsers typically implement an
  132.           encryption algorithm provided by [RSA].  It would be beneficial
  133.           for the IETF standards processes to produce protocols that can be
  134.           deployed into existing Internet environments.  This would allow
  135.           gracefull addition of new (IETF-developed) protocols. It would
  136.           allow less disruption of existing users, since there would be
  137.           more interoperability between pre-exisiting protocols and IETF-
  138.           based protocols.
  139.  
  140.           2. Requirements for this Encryption Algorithm
  141.  
  142.           The algorithm described here has been chosen because it is
  143.           compatible with one of the most popular encryption algorithms in
  144.           the browser market.  It is potentially useful in several
  145.           environments, including TLS [TLS] and IPSEC [IPSEC].  There are
  146.           existing Internet Drafts that describe how it can be applied, see
  147.           [TLS] and [Caronni].
  148.  
  149.           The algorithm can be used with a variety of key lengths.  It
  150.           specifically can be operated with 40-bit keys and with 128-bit
  151.           keys.  See the Security Considerations section for comments on
  152.           use of 40-bit keys.
  153.  
  154.           Compatability of the algorithm with commercial algorithms is
  155.           determined by comparing the encrypted data that is produced by
  156.           the test vectors listed in the appendix to this document.
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.           Thayer                                              [Page 3]
  166.  
  167.  
  168.  
  169.  
  170.           Internet Draft    An Encryption Algorithm         April 1997
  171.  
  172.  
  173.  
  174.  
  175.           3. Description of Algorithm
  176.  
  177.           The algorithm itself is documented in [Schneier], page 397-398,
  178.           in the chapter entitled "Other Stream Ciphers and Real Random-
  179.           Sequence Generators".
  180.  
  181.           1. Allocate an array of 8 by 8 8 bit counters as an S-box, label
  182.           it
  183.              S [0] .. S [255].
  184.  
  185.           2. Initialize the S-box.  Fill each entry first with it's index:
  186.  
  187.              S [0] = 0; S [1] = 1; etc. up to S [255] = 255;
  188.  
  189.           3. Fill another array of the same size (256) with the key,
  190.              repeating bytes as necessary.
  191.  
  192.              S2 [0] = key [0]; S2 [1] = key [1]; ...
  193.  
  194.           4. Initialize the S-box from it's preloaded value and the key.
  195.              Set j to zero and perform this:
  196.  
  197.              for (i=0; i<256; i=i+1)
  198.              {
  199.                j = (j + S [i] + S2 [i]) % 256;
  200.                temp = S [i];
  201.                S [i] = S [j];
  202.                S [j] = temp;
  203.              };
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.           Thayer                                              [Page 4]
  221.  
  222.  
  223.  
  224.  
  225.           Internet Draft    An Encryption Algorithm         April 1997
  226.  
  227.  
  228.  
  229.           5. For either encryption or decryption, the input text is
  230.              processed one byte at a time.  A 'random' byte k is generated:
  231.              Initialize i to zero; initialize j to zero.
  232.  
  233.               i = (i+1) % 256;
  234.               j = (j + S[i]) % 256;
  235.               temp = S [i];
  236.               S [i] = S [j];
  237.               S [j] = temp;
  238.               t = (S [i] + S [j]) % 256;
  239.               K = S [t];
  240.  
  241.           To encrypt, XOR the value K with the next byte of the plaintext.
  242.           To decrypt, XOR the value K with the next byte of the ciphertext.
  243.  
  244.           4. Intellectual Property Considerations
  245.  
  246.           This document does not address Intellectual Property issues.  No
  247.           claim is made as to who owns this algorithm.
  248.  
  249.           5. Acknowledgements
  250.  
  251.           This work was based on conversations with several collegues
  252.           within the IETF.
  253.  
  254.           6. Security Considerations
  255.  
  256.           This algorithm can be operated with several different key sizes.
  257.           If the key is 128 bits in length then this algorithm is believed
  258.           to be robust.  If the key length is significantly shorter,
  259.           specifically 40 bits, then there are known attacts that have been
  260.           successfully applied.  For this algorithm to be operated in a
  261.           cryptographicall sound manner it is believed that a key length of
  262.           128 bits should be used.
  263.  
  264.           On the other hand, the 40-bit version of this algorithm is
  265.           specifically regulated by the U.S. Government.  This means that
  266.           deployment of 40-bit implementations may be easier to export then
  267.           alternative algorithms.  The experience that can be gained by
  268.           developing a full implementation and deploying it may provide
  269.           sufficient benefit that 40-bit "weak" encryption is appropriate.
  270.           There are examples in the commercial environment where this logic
  271.           has been successfully applied.
  272.  
  273.  
  274.  
  275.           Thayer                                              [Page 5]
  276.  
  277.  
  278.  
  279.  
  280.           Internet Draft    An Encryption Algorithm         April 1997
  281.  
  282.  
  283.  
  284.           7. References
  285.  
  286.           [Caronni] Caronni, G., Waldvogel, M.  "The ESP Stream Transform",
  287.           ftp://ds.internic.net/internet-drafts/draft-caronni-esp-stream-
  288.           01.txt, September, 1996.
  289.  
  290.           [COMMERCE] Test vectors issued by United States Department of
  291.           Commerce, Bureau of Export Administration, Office of Strategic
  292.           Trade and Foreign Policy, Strategic Trade Controls Division.
  293.  
  294.           [CRYPTLIB] Gutmann, P, Young, E., Plumb, C.  "Cryptlib, A
  295.           Portable Encryption Library", Version 2.00.
  296.           http://www.cs.auckland.ac.nz/~pgut001/cryptlib.html, 1996.
  297.  
  298.           [IPSEC] Atkinson, R, "Security Architecture for the Internet
  299.           Protocol", ftp://ds.internic.net/rfc/rfc1825.txt, August 1995.
  300.  
  301.           [RSA] RSA Data Security, Inc., http://www.rsa.com, Address: RSA
  302.           Data Security, Inc.  100 Marine Parkway, Suite 500, Redwood City,
  303.           CA 94065-1031.
  304.  
  305.           [SCHNEIER] Schneier, B. "Applied Cryptography", Second Edition,
  306.           http://www.counterpane.com.  Published by John Wiley & Sons, Inc.
  307.           ISBN 0-471-11709-9, 1996.
  308.  
  309.           [TLS] Freier, A., Karlton, P., Kocher, P., Dierks, T., " The TLS
  310.           Protocol", ftp://ds.internic.net/internet-drafts/draft-ietf-tls-
  311.           protocol-00.txt, December, 1996.
  312.  
  313.           8. Author's Address
  314.  
  315.           Rodney Thayer
  316.           Sable Technology Corporation
  317.           246 Walnut Street
  318.           Newton Massachusetts 02160
  319.           rodney@sabletech.com
  320.           +1 617 332 7292
  321.           Fax +1 617 332 7970
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.           Thayer                                              [Page 6]
  331.  
  332.  
  333.  
  334.  
  335.           Internet Draft    An Encryption Algorithm         April 1997
  336.  
  337.  
  338.  
  339.  
  340.           Appendix
  341.  
  342.           A. Test Vectors
  343.  
  344.           1. Test Vectors from [CRYPTLIB]:
  345.                Plain Text:
  346.                     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  347.                Key:
  348.                     0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
  349.  
  350.                Cipher Text:
  351.                     0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79
  352.  
  353.           2. Test Vectors from [COMMERCE]:
  354.                Plain Text:
  355.                     0xdc, 0xee, 0x4c, 0xf9, 0x2c
  356.                Key:
  357.                     0x61, 0x8a, 0x63, 0xd2, 0xfb
  358.                Cipher Text:
  359.                     0xf1, 0x38, 0x29, 0xc9, 0xde
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.           Thayer                                              [Page 7]
  386.  
  387.  
  388.  
  389.  
  390.           Internet Draft    An Encryption Algorithm         April 1997
  391.  
  392.  
  393.  
  394.  
  395.           B. Sample Code
  396.  
  397.           /*
  398.             this code fragment illustrates the encryption case for RC4.
  399.           */
  400.           #define UINT16  unsigned short int
  401.           #define UINT8   unsigned char
  402.           #define EQUALS  ==
  403.  
  404.           UINT8   box2 [256];
  405.           UINT8   clear_text [] =
  406.                     { 0xdc, 0xee, 0x4c, 0xf9, 0x2c};
  407.           UINT8   encrypted_text [1024];
  408.           UINT8   key [] =
  409.                     { 0x61, 0x8a, 0x63, 0xd2, 0xfb };
  410.           UINT16  key_length;
  411.           UINT8   s [256];
  412.  
  413.           int encrypt (UINT8 * key, UINT16 key_length,
  414.                 UINT8 * clear_text, UINT8 * encrypted_text, UINT16 *
  415.           length)
  416.  
  417.           { /* encrypt */
  418.  
  419.             int   i;
  420.             int   idx;
  421.             int   idx2;
  422.             int   idx_text;
  423.             int   j;
  424.             int   k;
  425.             int   status;
  426.             UINT8 t;
  427.             UINT8 temp;
  428.  
  429.  
  430.             status = 0;
  431.             /*
  432.               pre-load the S-box with a ramp (0,1,2,3...)
  433.             */
  434.             for (idx=0; idx<256; idx=idx+1)
  435.               s [idx] = idx;
  436.             /*
  437.  
  438.  
  439.  
  440.           Thayer                                              [Page 8]
  441.  
  442.  
  443.  
  444.  
  445.           Internet Draft    An Encryption Algorithm         April 1997
  446.  
  447.  
  448.  
  449.               initialize second box with repeated key material
  450.             */
  451.             idx2 = 0;
  452.             for (idx=0; idx<256; idx=idx+1)
  453.             {
  454.               box2 [idx] = key [idx2];
  455.               idx2 = idx2 + 1;
  456.               if (idx2 EQUALS (int)key_length)
  457.                 idx2 = 0;
  458.             };
  459.             /*
  460.               initialize the S-box from it's pre-loaded value and the key
  461.             */
  462.             j = 0;
  463.             for (i=0; i<256; i=i+1)
  464.             {
  465.               j = 0xff & (j + s[i] + box2[i]);
  466.               temp = s[i];
  467.               s[i] = s[j];
  468.               s[j] = temp;
  469.             };
  470.             /*
  471.               encrypt the text
  472.             */
  473.             i = 0;
  474.             j = 0;
  475.             idx_text = 0;
  476.             while (idx_text < (int)(*length))
  477.             {
  478.               i = 0xff & (i+1);
  479.               j = 0xff & (j + s[i]);
  480.               temp = s[i];
  481.               s[i] = s[j];
  482.               s[j] = temp;
  483.               t = 0xff & (s[i] + s [j]);
  484.               k = s[t];
  485.               encrypted_text [idx_text] = clear_text [idx_text] ^ k;
  486.               idx_text = idx_text + 1;
  487.             };
  488.             return (status);
  489.  
  490.           } /* encrypt */
  491.  
  492.  
  493.  
  494.  
  495.           Thayer                                              [Page 9]
  496.  
  497.  
  498.