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-sabin-esp-des3-lzs-md5-00.txt < prev    next >
Text File  |  1996-10-23  |  40KB  |  1,062 lines

  1.  
  2. Internet Draft                         October 1996 (Expires April 1997)
  3.  
  4.                                                     M. Sabin, Consultant
  5.                                                   R. Monsour, Hi/fn Inc.
  6.  
  7.  
  8.     Combined 3DES-CBC, LZS Compression, HMAC, and Replay Prevention
  9.                              ESP Transform
  10.                  <draft-sabin-esp-des3-lzs-md5-00.txt>
  11.  
  12.  
  13. Status of this Memo
  14.  
  15.    This document is an Internet-Draft.  Internet-Drafts are working
  16.    documents of the Internet Engineering Task Force (IETF), its areas,
  17.    and its working groups.  Note that other groups may also distribute
  18.    working documents as Internet-Drafts.
  19.  
  20.    Internet-Drafts are draft documents valid for a maximum of six months
  21.    and may be updated, replaced, or obsoleted by other documents at any
  22.    time.  It is inappropriate to use Internet-Drafts as reference
  23.    material or to cite them other than as "work in progress."
  24.  
  25.    To learn the current status of any Internet-Draft, please check the
  26.    "1id-abstracts.txt" listing contained in the Internet-Drafts Shadow
  27.    Directories on ftp.is.co.za (Africa), nic.nordu.net (Europe),
  28.    munnari.oz.au (Pacific Rim), ds.internic.net (US East Coast), or
  29.    ftp.isi.edu (US West Coast).
  30.  
  31.  
  32. Abstract
  33.  
  34.    This document proposes the "3DES-CBC-LZS-HMAC-Replay" security
  35.    transform for the IP Encapsulating Security Payload (ESP).  The
  36.    proposed transform combines triple-DES encryption, LZS compression,
  37.    HMAC authentication, and replay prevention into a single packet
  38.    format.  The transform is compatible with implementations that do not
  39.    support compression and with implementations that support only
  40.    single-DES encryption.  Compression is performed prior to encryption,
  41.    which has the side benefit of reducing the amount of data that must
  42.    be encrypted.
  43.  
  44.    This document is based on the IPsec Working Group's proposed
  45.    "Combined DES-CBC, HMAC, and Replay Prevention Security Transform,"
  46.    cited later in this document.
  47.  
  48.  
  49. Acknowledgments
  50.  
  51.    This memo is based on the document "Combined DES-CBC, HMAC, and
  52.    Replay Prevention Security Transform," by the IPsec Working Group, J.
  53.  
  54.  
  55.  
  56. Sabin, et al                                                   [Page  1]
  57.  
  58. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  59.  
  60.  
  61.    Hughes, editor [Hughes96].  Much of the text of that document is
  62.    repeated here, with details specific to LZS and triple-DES added.
  63.    The LZS details are similar to those in "PPP Stac LZS Compression
  64.    Protocol," by R.  Friend and W.  A.  Simpson [RFC-1974].
  65.  
  66.  
  67. Table of Contents
  68.  
  69.    1.  Introduction
  70.    2.  Packet Format
  71.    3.  Encode Procedure
  72.    4.  Decode Procedure
  73.    5.  Generating Key Material
  74.    6.  Security Considerations
  75.    7.  References
  76.    8.  Author's Addresses
  77.    9.  Appendix:  Guidelines for Resetting Compression History
  78.  
  79.  
  80. 1.  Introduction
  81.  
  82.    Encrypted data is random in nature and not compressible.  When an IP
  83.    packet is encrypted, the usual techniques for compressing it -- e.g.,
  84.    PPP compression -- do not work.  If both compression and encryption
  85.    are desired, compression must be performed first.
  86.  
  87.  
  88.    1.1  Compression with ESP
  89.  
  90.       ESP is well suited to combining compression with encryption, for a
  91.       variety of reasons:
  92.  
  93.          -  ESP is the place were encryption is applied to an IP packet.
  94.          It is straightforward to precede the encryption step by a
  95.          compression step.  A side benefit of compressing the data first
  96.          is that the amount of data which must be encrypted is reduced.
  97.          In some implementations, compression is done in hardware and
  98.          encryption in software, and this represents a significant
  99.          reduction in software processing.
  100.  
  101.          -  ESP supports routing of opaque data.  When a packet is
  102.          encrypted, intermediate nodes along a route are not able to
  103.          decrypt it.  Nevertheless, the encrypted packet can be routed,
  104.          because ESP has been designed with this in mind.  When a packet
  105.          is compressed within ESP, the situation is similar:
  106.          intermediate nodes are not able to decompress it (at least
  107.          without additional expense), but ESP ensures that the
  108.          compressed packet can be routed.
  109.  
  110.          -  ESP provides a security parameters index (SPI) that links a
  111.          packet to security parameters negotiated elsewhere.  A
  112.  
  113.  
  114.  
  115. Sabin, et al                                                   [Page  2]
  116.  
  117. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  118.  
  119.  
  120.          destination node uses the SPI to look up the ESP transform
  121.          needed to decode an incoming packet.  If compression details
  122.          are included in ESP transform specifications, a destination
  123.          node can also use the SPI to determine if a packet needs to be
  124.          decompressed, and if so, by what algorithm.  Source and
  125.          destination nodes can maintain multiple compression histories
  126.          (described in a later section), one history for each SPI.
  127.  
  128.  
  129.    1.2  Background of LZS Compression 
  130.  
  131.       The LZS algorithm is a lossless compression method that uses a
  132.       sliding window of 2,048 bytes.  During compression, redundant
  133.       sequences of data are replaced with tokens that represent those
  134.       sequences.  During decompression, the original sequences are
  135.       substituted for the tokens, in such a way that the original data
  136.       is exactly recovered.  LZS differs from lossy schemes, such as
  137.       those often used for video compression, that do not exactly
  138.       reproduce the original data.
  139.  
  140.       Details of LZS formatting can be found in [ANSI94].
  141.  
  142.       The efficiency of the LZS algorithm depends on the degree of
  143.       redundancy in the original data.  A typical compression ratio for
  144.       disk files is 2:1.  LZS achieves a compression ratio of 2.34:1 on
  145.       the University of Calgary Text Compression Corpus [Calgary].
  146.  
  147.       The LZS algorithm is stateful.  It maintains a "history" in which
  148.       compression information is stored.  The compression operation
  149.       requires a "compression history" and the decompression operation a
  150.       "decompression history." Each of these histories is initialized to
  151.       a start state before any data is processed.  Thereafter, as data
  152.       is compressed and decompressed, the two histories remain
  153.       synchronized, provided that the decompressor processes all the
  154.       data generated by the compressor, in the order in which it is
  155.       generated.
  156.  
  157.       An LZS compression/decompression history pair can be reset to the
  158.       start state at any time.  This can be used to restore
  159.       synchronization between compressor and decompressor when data
  160.       received by the decompressor has been lost or corrupted.  This is
  161.       particularly important in IP, where the delivery of individual
  162.       packets is not guaranteed.
  163.  
  164.       When LZS compression is applied to a block of data, it sometimes
  165.       happens that the "compressed" block is actually larger than the
  166.       original, uncompressed block.  In IP, it would be undesirable to
  167.       transmit a block that has expanded in this way.  Accordingly, when
  168.       LZS results in expansion, this specification calls for the
  169.       transmitter to send the uncompressed data instead of the
  170.       compressed data.  The packet format includes a bit to signal the
  171.  
  172.  
  173.  
  174. Sabin, et al                                                   [Page  3]
  175.  
  176. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  177.  
  178.  
  179.       receiver that the packet contents are not compressed.
  180.  
  181.       When the transmitter sends uncompressed data, it still updates its
  182.       compression history as if it had actually compressed the data.
  183.       This enhances its ability to compress future data.  When the
  184.       receiver receives uncompressed data, it updates its decompression
  185.       history using the uncompressed data.  This keeps the decompression
  186.       history in sync with the compression history.
  187.  
  188.       An application can maintain multiple compression and/or
  189.       decompression processes by maintaining multiple histories, one
  190.       history for each process.  Each process operates independently of
  191.       the others.  This is useful in IPsec, since it allows each
  192.       security association (as indexed by the SPI) to have its own
  193.       history.
  194.       
  195.  
  196.    1.3  Licensing
  197.  
  198.       Source and object licenses for LZS are available on a
  199.       non-discriminatory basis.  Hardware implementations are also
  200.       available.  For more information, contact Hi/fn at the address
  201.       listed with the authors' addresses.
  202.  
  203.  
  204.    1.4  3DES-CBC-LZS-HMAC-Replay ESP Transform
  205.  
  206.       The transform proposed in this memo combines triple-DES in CBC
  207.       mode (3DES-CBC), LZS compression, HMAC authentication, and replay
  208.       prevention.  The proposed transform is based heavily on the
  209.       transform presented in [Hughes96].  Much of the text from that
  210.       document has been repeated here.
  211.  
  212.       The goals of the transform are: privacy; compression;
  213.       authenticity; integrity; and defense against replay.
  214.  
  215.          - Privacy is provided by 3DES-CBC [RFC-1851], which is a
  216.          variant of conventional DES-CBC [FIPS-46] [FIPS-46-1] [FIPS-74]
  217.          [FIPS-81].
  218.  
  219.          - Compression is provided by the LZS algorithm [ANSI94].
  220.  
  221.          - Integrity is provided by HMAC [Krawczyk96].
  222.  
  223.          - Authentication is provided since only the source and
  224.          destination know the HMAC key.  If the HMAC is correct, it
  225.          proves that it must have been added by the source.
  226.  
  227.          - Replay prevention is provided by the combination of a
  228.          constantly increasing count, the SPI and the HMAC key.
  229.          Integrity of the count is provided by the HMAC.
  230.  
  231.  
  232.  
  233. Sabin, et al                                                   [Page  4]
  234.  
  235. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  236.  
  237.  
  238.  
  239.    3DES-CBC encryption uses a double-length key (112 bits) or a
  240.    triple-length key (168 bits).  Triple-length is usually preferred for
  241.    security reasons, but some hardware devices only support
  242.    double-length.  Accordingly, this transform supports both
  243.    double-length and triple-length keys as a negotiated parameter.
  244.  
  245.    The transform also supports single-length keys (56 bits) as a
  246.    negotiated parameter.  This makes it compatible with implementations
  247.    that only support conventional (i.e., single) DES-CBC.
  248.  
  249.  
  250.    1.5  Requirements Terminology
  251.  
  252.       In this document, the words that are used to define the
  253.       significance of each particular requirement are usually
  254.       capitalized.  These words are:
  255.  
  256.          - MUST:  This word, or the adjective "REQUIRED," means that the
  257.          item is an absolute requirement of the specification.
  258.  
  259.          - SHOULD:  This word, or the adjective "RECOMMENDED," means
  260.          that there might exist valid reasons in particular
  261.          circumstances to ignore this item, but the full implications
  262.          should be understood and the case carefully weighed before
  263.          taking a different course.
  264.  
  265.          - MAY:  This word, or the adjective "OPTIONAL," means that the
  266.          item is truly optional.  One vendor might choose to include the
  267.          item because of a particular marketplace requirement or because
  268.          it enhances the product, while another vendor might omit the
  269.          item.
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292. Sabin, et al                                                   [Page  5]
  293.  
  294. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  295.  
  296.  
  297. 2. Packet Format
  298.  
  299.  
  300. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---
  301. |                Security Parameters Index (SPI)                | ^
  302. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 
  303. |                                                               | |
  304. |                Initialization Vector (optional)               | |
  305. |                                                               | |
  306. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |  ---
  307. |                 Replay Prevention Field (count)               | |   ^
  308. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |   |
  309. |                                                               |HMAC |
  310. |              Payload Data (compressed or uncompressed)        | |   |
  311. |                                                               | |   |
  312. |                                               +-+-+-+-+-+-+-+-| |   |
  313. |                                               |               | |   |
  314. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               | | 3DES
  315. |                         Padding (0-7 bytes)                   | |  CBC
  316. |               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |   |
  317. |               |  Pad Length   |      CC       | Payload Type  | v   |
  318. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---  |
  319. |                                                               |     |
  320. |                        HMAC digest                            |     |
  321. |                                                               |     v
  322. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    ---
  323.  
  324.  
  325.    2.1  Security Parameters Index
  326.  
  327.       This field contains a 32-bit value identifying the security
  328.       association for this packet.  The value is negotiated at key setup
  329.       and MUST NOT be 0.
  330.  
  331.  
  332.    2.2  Initialization Vector
  333.  
  334.       The use of an explicit initialization vector (IV) MAY be
  335.       negotiated.  The purpose of this mode is to support devices that
  336.       automatically generate IV's and cannot operate using a constant
  337.       IV_key_.
  338.  
  339.       This field is optional and is only used when an explicit IV is
  340.       negotiated during key exchange.  This field contains random data
  341.       or the last ciphertext block of the previous packet.
  342.  
  343.  
  344.    2.3  Replay Prevention
  345.  
  346.       This field contains an unsigned, 32-bit, incrementing counter.
  347.       The counter is initialized to a mutually agreed upon value (see
  348.  
  349.  
  350.  
  351. Sabin, et al                                                   [Page  6]
  352.  
  353. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  354.  
  355.  
  356.       the section on Generating Key Material).
  357.  
  358.  
  359.       2.3.1  Security Issues
  360.  
  361.          To defend against replay attacks, the receiver verifies that
  362.          received packets have non-repeating counter values.  The
  363.          simplest approach is for the receiver to reject any packet
  364.          whose counter has a value less than or equal to that of any
  365.          previously received packet.  A consequence of this simple
  366.          approach is that out-of-order packets will be rejected.
  367.          Alternatively, the receiver MAY choose to operate with a window
  368.          of acceptable counter values:  a packet will not be rejected if
  369.          its counter value is within some value M of the highest counter
  370.          value received so far, provided that the counter value has not
  371.          been seen before.  For an example implementation of such a
  372.          strategy, see [Hughes96].
  373.  
  374.          The counter is not allowed to cycle back to its starting value.
  375.          This requires that the key be changed before 2^32 packets have
  376.          been transmitted.  The receiver rejects any packet whose
  377.          counter value indicates cycling back through the starting
  378.          value.
  379.  
  380.  
  381.       2.3.2  Compression Issues
  382.  
  383.          In addition to defending against replay attacks, the counter
  384.          plays a role in the decompression of packets.  When a packet is
  385.          received out of order, the receiver detects the misordering
  386.          because of the counter value.  Because LZS is stateful, the
  387.          receiver may or may not be able to decompress the out-of-order
  388.          packet.  If the history was reset by the transmitter
  389.          immediately prior to compressing the packet, the receiver can
  390.          decompress it, because decompression does not depend on any
  391.          previous packets.  (The packet includes a flag in the CC field
  392.          that indicates whether or not the history was reset.)  But if
  393.          the history was not reset by the transmitter immediately prior
  394.          to compressing the packet, the receiver cannot decompress it.
  395.  
  396.          When a receiver is unable to decompress an out-of-order packet,
  397.          the simplest strategy for the receiver is to discard it.
  398.          Alternatively, a receiver MAY elect to use a windowing scheme
  399.          similar to that described in Section 2.3.1, in order to
  400.          accommodate a reasonable spread of out-of-order packets.  Note
  401.          that if the windowing scheme is used, the receiver must queue
  402.          all packets that fall within the window but are not yet
  403.          decompressible.  This makes it more expensive than the scheme
  404.          previously described, which only had to queue counter values.
  405.  
  406.          Decompressing out-of-order packets is only an issue for the
  407.  
  408.  
  409.  
  410. Sabin, et al                                                   [Page  7]
  411.  
  412. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  413.  
  414.  
  415.          final destination of a packet.  Intermediate nodes along a
  416.          route do not decompress packets and thus can handle packets in
  417.          any order.
  418.  
  419.  
  420.    2.4  Payload Data
  421.  
  422.       The payload data is either compressed or uncompressed.  The value
  423.       of the COMPRESSED bit of the CC field is set accordingly.  The
  424.       payload field is an integral number of bytes in length.
  425.  
  426.  
  427.    2.5  Padding
  428.  
  429.       The padding is used to align the subsequent "payload type" field
  430.       to end on a double-word boundary, counting from the start of the
  431.       replay field.  Padding bytes SHOULD contain random data.
  432.  
  433.       At a minimum, the number of padding bytes added must be enough to
  434.       align the payload type field on the next appropriate boundary.
  435.       However, the sender may choose to include additional padding, in
  436.       order to hide the actual length of the data.  In general, the
  437.       sender can use any number of padding bytes in the range of 0-255,
  438.       provided that the required alignment is achieved.
  439.  
  440.  
  441.    2.6  Pad Length
  442.  
  443.       This field indicates the number of padding bytes immediately
  444.       preceding it.  The range of valid values is 0-255, where a value
  445.       of zero indicates the byte immediately preceding the pad length
  446.       field is the last byte of payload.
  447.  
  448.  
  449.    2.7  Compression Control
  450.  
  451.       The Compression Control (CC) field is a single, bit-mapped byte.
  452.       The bits are numbered 7 (most significant) to 0 (least
  453.       significant).  The following bits are defined:
  454.  
  455.  
  456.       2.7.1  COMPRESSED (bit 7)
  457.  
  458.          This bit is set to 1 to indicate the payload is compressed.  It
  459.          is cleared to 0 to indicate the payload is not compressed.
  460.  
  461.          In implementations that do not support compression, this bit
  462.          is always cleard to 0.
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469. Sabin, et al                                                   [Page  8]
  470.  
  471. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  472.  
  473.  
  474.       2.7.2  HIST_RESET (bit 6)
  475.  
  476.          This bit is set to 1 to indicate that the compression history
  477.          associated with this packet's SPI was reset prior to processing
  478.          this packet's payload.  In such a case, the receiver must reset
  479.          the corresponding decompression history prior to processing the
  480.          payload.  If the payload is compressed, it can always be
  481.          decompressed, because compression is not based on any previous
  482.          history.
  483.  
  484.          This bit is cleared to 0 to indicate that the compression
  485.          history associated with this packet's SPI was not reset prior
  486.          to transmitting the payload.  If the payload is compressed, it
  487.          can only be decompressed if there have been no missed packets
  488.          since the last packet that had the bit set to 1.  A packet that
  489.          cannot be decompressed because of missing packets is either
  490.          rejected or, if the implementation supports it, queued in the
  491.          hope that it can be decompressed when the missing packets
  492.          arrive.
  493.  
  494.          The transmitter SHOULD adopt a policy of periodically resetting
  495.          the compression history and setting the HIST_RESET bit.  This
  496.          allows a receiver that has missed packets to resynchronize its
  497.          decompressor.  The details of such a policy are up to the
  498.          transmitter implementation.  An attached appendix gives
  499.          guidelines.
  500.  
  501.          The transmitter MUST flush the compressor each time it
  502.          transmits a compressed packet, regardless of whether or not it
  503.          resets the compression history.  Flushing means that all data
  504.          going into the compressor is included in the output, i.e., no
  505.          data is held back in the hope of achieving better compression.
  506.          Flushing is necessary to prevent a packet's data from spilling
  507.          over into a later packet.
  508.  
  509.  
  510.    2.8  Payload Type
  511.  
  512.       This field indicates the type of payload, using the IP
  513.       Protocol/Payload value.  Values are described in [RFC-1700].
  514.  
  515.  
  516.    2.9  HMAC Digest
  517.  
  518.       The HMAC digest is a 128-bit residue, calculated over the SPI,
  519.       replay, payload, padding, pad length, CC, and payload type.
  520.       Details of the calculation can be found in [Krawczyk96].
  521.  
  522.       HMAC is a keyed algorithm based on MD5.  It uses the HMAC key
  523.       described in the section on keys.
  524.  
  525.  
  526.  
  527.  
  528. Sabin, et al                                                   [Page  9]
  529.  
  530. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  531.  
  532.  
  533.  
  534. 3.  Encode Procedure
  535.  
  536.    For compression, the LZS algorithm is used.
  537.  
  538.    For encryption, CBC chaining is used.  The initialization vector is
  539.    either the contents of the IV field or the IV_key_:
  540.  
  541.  
  542.        IV or
  543.        IV_key_   count|x1             x2                x3
  544.           |         |                 |                 |
  545.           |--------(+)     ----------(+)     ----------(+)
  546.                     |      |          |      |          |
  547.                 ---------  |      ---------  |      ---------
  548.             k1--|  DES  |  |  k1--|  DES  |  |  k1--|  DES  |
  549.                 |encrypt|  |      |encrypt|  |      |encrypt|
  550.                 ---------  |      ---------  |      ---------
  551.                     |      |          |      |          |
  552.                 ---------  |      ---------  |      ---------
  553.             k2--|  DES  |  |  k2--|  DES  |  |  k2--|  DES  |
  554.                 |decrypt|  |      |decrypt|  |      |decrypt|
  555.                 ---------  |      ---------  |      ---------
  556.                     |      |          |      |          |
  557.                 ---------  |      ---------  |      ---------
  558.             k3--|  DES  |  |  k3--|  DES  |  |  k3--|  DES  |
  559.                 |encrypt|  |      |encrypt|  |      |encrypt|
  560.                 ---------  |      ---------  |      ---------
  561.                     |------|          |------|          |----...
  562.                     |                 |                 |
  563.                    y1                 y2                y3
  564.  
  565.  
  566.    In the figure:  count is the value in the replay prevention field;
  567.    x1, x2, x3 are the plaintext (x1 is 32 bits, all others are 64 bits);
  568.    y1, y2, y3 are the ciphertext; k1, k2, k3 are the 56-bit portions of
  569.    the triple-length key.  (When a double-length key is used, k3 = k1.
  570.    When a single-length key is used, k3 = k2 = k1.)
  571.  
  572.    The transform is carried out in the following steps:
  573.  
  574.       i)  If the transmitter chooses to reset the compression history,
  575.       it does so, and it sets the HIST_RESET bit of the CC field to 1.
  576.       Otherwise, it clears the HIST_RESET bit to 0.
  577.  
  578.       ii)  The transmitter decides whether or not to compress the
  579.       payload.
  580.  
  581.          - If the transmitter chooses to compress the payload, the LZS
  582.          algorithm is applied.  The resulting compressed data is
  583.          formatted according to [ANSI94].  The COMPRESSED bit of the CC
  584.  
  585.  
  586.  
  587. Sabin, et al                                                   [Page 10]
  588.  
  589. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  590.  
  591.  
  592.          field is set to 1.
  593.  
  594.          - If the transmitter chooses not to compress the payload, the
  595.          COMPRESSED bit of the CC field is set to 0.  The compression
  596.          history is updated with the uncompressed payload.
  597.  
  598.       iii)  The payload is encapsulated with the SPI, IV (if used),
  599.       replay, padding, pad length, CC, and payload type.  The padding
  600.       and pad length are appropriately adjusted.  The replay is
  601.       incremented by one from its previous value.
  602.  
  603.       iv)  The HMAC is calculated.  The calculation uses the HMAC_key_
  604.       and spans the SPI, IV (if used), replay, payload, padding, pad
  605.       length, CC, and payload type.  The result is placed in the HMAC
  606.       digest field.
  607.  
  608.       v)  The replay, payload, padding, pad length, CC, payload type,
  609.       and HMAC digest are encrypted using 3DES-CBC with the appropriate
  610.       DES_key_.  The initialization vector is the IV field, if used, or
  611.       the appropriate IV_key_.
  612.  
  613.    An implementation SHOULD monitor the results of the payload
  614.    compression operation and reject the operation if it results in
  615.    expansion.  In such a case, the uncompressed payload SHOULD be
  616.    transmitted.
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646. Sabin, et al                                                   [Page 11]
  647.  
  648. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  649.  
  650.  
  651. 4.  Decode Procedure
  652.  
  653.    For decryption, CBC chaining is used:
  654.  
  655.  
  656.        IV or
  657.        IV_key_      y1                y2                y3
  658.          |          |                 |                 |
  659.          |          |-------          |-------          |----...
  660.          |          |      |          |      |          |
  661.          |      ---------  |      ---------  |      ---------
  662.          |  k3--|  DES  |  |  k3--|  DES  |  |  k3--|  DES  |
  663.          |      |decrypt|  |      |decrypt|  |      |decrypt|
  664.          |      ---------  |      ---------  |      ---------
  665.          |          |      |          |      |          |
  666.          |      ---------  |      ---------  |      ---------
  667.          |  k2--|  DES  |  |  k2--|  DES  |  |  k2--|  DES  |
  668.          |      |encrypt|  |      |encrypt|  |      |encrypt|
  669.          |      ---------  |      ---------  |      ---------
  670.          |          |      |          |      |          |
  671.          |      ---------  |      ---------  |      ---------
  672.          |  k1--|  DES  |  |  k1--|  DES  |  |  k1--|  DES  |
  673.          |      |decrypt|  |      |decrypt|  |      |decrypt|
  674.          |      ---------  |      ---------  |      ---------
  675.          |          |      |          |      |          |
  676.          |---------(+)     |---------(+)     |---------(+)
  677.                     |                 |                 |
  678.                (count|x1)             x2                x3
  679.  
  680.  
  681.    For decompression, the LZS algorithm is used.  The decompression
  682.    maintains a state variable "expected_count," which tracks the value
  683.    of count expected in the next packet.  Expected_count is initialized
  684.    to the starting value of the replay count; this value was mutually
  685.    agreed upon, as described in the section on Generating Key Material.
  686.  
  687.    In the procedure described here, it is assumed that out-of-order
  688.    packets are not queued for the purposes of decompression.  Compressed
  689.    packets that cannot be immediately decompressed are discarded.
  690.    Implementations MAY choose a scheme that queues packets, allowing
  691.    some spread of out-of-order packets to be decompressed; this was
  692.    discussed in Section 2.3.2.
  693.  
  694.    The transform is carried out in the following steps:
  695.  
  696.       i)  The replay, payload, padding, pad length, CC, payload type,
  697.       and HMAC digest are decrypted using 3DES-CBC and the appropriate
  698.       DES_key_.  The initialization vector is the IV field, if used, or
  699.       the appropriate IV_key_.
  700.  
  701.       ii)  The count is checked for replay attack using the window
  702.  
  703.  
  704.  
  705. Sabin, et al                                                   [Page 12]
  706.  
  707. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  708.  
  709.  
  710.       algorithm discussed in Section 2.3.1.  If the packet is duplicate
  711.       or too old, the packet is discarded.
  712.  
  713.       iii)  The HMAC is calculated.  The calculation uses the HMAC_key_
  714.       and spans the SPI, IV (if used), replay, payload, padding, pad
  715.       length, CC, and payload type.  The calculated digest is compared
  716.       against the decrypted digest at the end of the packet.  If the two
  717.       do not match, the packet is discarded.
  718.  
  719.       iv)  The HIST_RESET bit of the CC is checked.
  720.  
  721.          - If HIST_RESET = 1, the decompression history is reset, and
  722.          expected_count is set to (count + 1).
  723.  
  724.          - If HIST_RESET = 0, the value of count is compared to
  725.          expected_count.  If the two match, expected_count is set to
  726.          (count + 1).  If the two do not match, expected_count is
  727.          unchanged; and if COMPRESSED = 1, the packet is discarded.
  728.          (Queuing out-of-order packets is not considered here, but an
  729.          implementation MAY choose to implement queuing instead of
  730.          immediate discard, as discussed in Section 2.3.2.)
  731.  
  732.       v)  The COMPRESSED bit of the CC is checked.  If COMPRESSED = 1,
  733.       decompression is applied to the payload data.  If COMPRESSED = 0,
  734.       decompression is not applied, and the decompression history is
  735.       updated with the uncompressed data.
  736.  
  737.    An implementation MAY choose to perform a "sanity check" prior to the
  738.    above procedure.  In the sanity check, the first block of data is
  739.    decrypted using the appropriate DES_key_ and IV_key_, and the
  740.    decrypted value of the replay count is checked.  If the count is way
  741.    out of range -- e.g., more than 2^16 away from the expected value --
  742.    the packet is discarded as non-authentic.  This helps defend against
  743.    clogging attacks, in which an attacker tries to tie up the receiver's
  744.    resources by having it decrypt meaningless packets.  Note that if the
  745.    sanity check passes, the above procedure MUST still be performed.
  746.  
  747.  
  748. 5.  Generating Key Material
  749.  
  750.    The key management layer provides several negotiated parameters:
  751.  
  752.       - The master secret K.
  753.  
  754.       - The length of the DES symmetric keys:  triple length (168 bits),
  755.       double length (112 bits), or single length (56 bits).
  756.  
  757.       - Compression support: yes or no. 
  758.  
  759.    The master secret K is used to derive the following symmetric keys:
  760.  
  761.  
  762.  
  763.  
  764. Sabin, et al                                                   [Page 13]
  765.  
  766. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  767.  
  768.  
  769.       DES_Key_I1, DES_Key_I2, and DES_Key_I3 are the three parts of the
  770.       triple-length DES key for traffic from the initiator -> responder.
  771.       When a double-length key is used, DES_Key_I3 = DES_Key_I1.
  772.      When a single-length key is used, DES_Key_I3 = DES_KEY_I2 =
  773.      DES_Key_I1.
  774.  
  775.       DES_Key_R1, DES_Key_R2, and DES_Key_R3 are the three parts of the
  776.       triple-length DES key for traffic from the responder -> initiator.
  777.       When a double-length key is used, DES_Key_R3 = DES_Key_R1.
  778.      When a single-length key is used, DES_Key_R3 = DES_KEY_R2 =
  779.      DES_Key_R1.
  780.  
  781.       HMAC_Key_I is the key for the HMAC Algorithm for traffic from the
  782.       initiator -> responder.
  783.  
  784.       HMAC_Key_R is the key for the HMAC Algorithm for traffic from the
  785.       responder -> initiator.
  786.  
  787.       IV_key_I is used to stop code book attacks on the first block for
  788.       traffic from the initiator -> responder.
  789.  
  790.       IV_key_R is used to stop code book attacks on the first block for
  791.       traffic from the responder -> initiator.
  792.  
  793.       RP_key_I is the initial value and wrap point for the replay
  794.       prevention field for traffic from the initiator -> responder.
  795.  
  796.       RP_key_R is the initial value and wrap point for the replay
  797.       prevention field for traffic from the responder -> initiator.
  798.  
  799.    The vertical bar symbol "|" is used to denote concatenation of bit
  800.    strings.
  801.  
  802.    MD5(x|y) denotes the result of applying the MD5 function to the
  803.    concatenated bit strings x and y.
  804.  
  805.    Truncate(x,n) denotes the result of truncating x to its first n bits.
  806.  
  807.       IV_Key_I    = Truncate(MD5( I_Pad_I  | K ),64)
  808.       IV_Key_R    = Truncate(MD5( I_Pad_R  | K ),64)
  809.       HMAC_Key_I  =          MD5( H_Pad_I  | K )
  810.       HMAC_Key_R  =          MD5( H_Pad_R  | K )
  811.       RP_Key_I    = Truncate(MD5( R_Pad_I  | K ),32)
  812.       RP_Key_R    = Truncate(MD5( R_Pad_R  | K ),32)
  813.  
  814.    For triple-length DES keys:
  815.  
  816.       DES_Key_I1  = Truncate(MD5( D_Pad_I1 | K ),64)
  817.       DES_Key_I2  = Truncate(MD5( D_Pad_I2 | K ),64)
  818.       DES_Key_I3  = Truncate(MD5( D_Pad_I3 | K ),64) 
  819.       DES_Key_R1  = Truncate(MD5( D_Pad_R1 | K ),64)
  820.  
  821.  
  822.  
  823. Sabin, et al                                                   [Page 14]
  824.  
  825. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  826.  
  827.  
  828.       DES_Key_R2  = Truncate(MD5( D_Pad_R2 | K ),64)
  829.       DES_Key_R3  = Truncate(MD5( D_Pad_R3 | K ),64)
  830.  
  831.    For double-length DES keys:
  832.  
  833.       DES_Key_I1  = Truncate(MD5( D_Pad_I1 | K ),64)
  834.       DES_Key_I2  = Truncate(MD5( D_Pad_I2 | K ),64)
  835.       DES_Key_I3  = DES_Key_I1
  836.       DES_Key_R1  = Truncate(MD5( D_Pad_R1 | K ),64)
  837.       DES_Key_R2  = Truncate(MD5( D_Pad_R2 | K ),64)
  838.       DES_Key_R3  = DES_Key_R1
  839.  
  840.    For single-length DES keys:
  841.  
  842.       DES_Key_I1  = Truncate(MD5( D_Pad_I1 | K ),64)
  843.       DES_Key_I3  = DES_Key_I2 = DES_Key_I1
  844.       DES_Key_R1  = Truncate(MD5( D_Pad_R1 | K ),64)
  845.       DES_Key_R3  = DES_Key_R2 = DES_Key_R1
  846.  
  847.    Note:  Each DES_Key_ is in the usual "7 bits plus parity" format,
  848.    which is why the above procedure generates 64 bits instead of 56
  849.    bits.  The values of the parity bits in each DES_Key_ should either
  850.    be corrected or ignored.
  851.  
  852.    Each _Pad_is a 512 bit string, as follows:
  853.  
  854.       D_Pad_I1 = 0x5C repeated 64 times
  855.       D_Pad_I2 = 0xA3 repeated 64 times
  856.       D_Pad_I3 = 0xCA repeated 64 times
  857.       D_Pad_R1 = 0x3A repeated 64 times
  858.       D_Pad_R2 = 0xA5 repeated 64 times
  859.       D_Pad_R3 = 0xC3 repeated 64 times
  860.       I_Pad_I  = 0xAC repeated 64 times
  861.       I_Pad_R  = 0x55 repeated 64 times
  862.       H_Pad_I  = 0x53 repeated 64 times
  863.       H_Pad_R  = 0x3C repeated 64 times
  864.       R_Pad_I  = 0x35 repeated 64 times
  865.       R_Pad_R  = 0xCC repeated 64 times
  866.  
  867.    (Implementation note: The 16 byte intermediate residuals can be
  868.    precalculated from these constants and stored to reduce processing
  869.    overhead.)
  870.  
  871.  
  872. 6.  Security Considerations
  873.  
  874.    The transform described in this draft is immune to the [Bellovin96]
  875.    attacks.
  876.  
  877.    The implications of the size of K can be found in [Blaze96].
  878.  
  879.  
  880.  
  881.  
  882. Sabin, et al                                                   [Page 15]
  883.  
  884. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  885.  
  886.  
  887.  
  888. 7.  References
  889.  
  890.    [ANSI94] American National Standards Institute, Inc., "Data
  891.       Compression Method for Information Systems," ANSI X3.241-1994,
  892.       August 1994.
  893.  
  894.    [Blaze96] Blaze, M., Diffie, W., Rivest, R., Schneir, B., Shimomura,
  895.       T., Thompson, E., Wiener, M., "Minimal Key Lengths for Symmetric
  896.       Ciphers to Provide Adequate Commercial Security,"
  897.       http://theory.lcs.mit.edu/~rivest/bsa-final-report.ascii, January
  898.       1996.
  899.  
  900.    [Calgary]  Text Compression Corpus, University of Calgary, available
  901.       at
  902.       ftp://ftp.cpsc.ucalgary.ca/pub/projects/text.compression.corpus.
  903.  
  904.    [FIPS-46] US National Bureau of Standards, "Data Encryption
  905.       Standard," Federal Information Processing Standard (FIPS)
  906.       Publication 46, January 1977.
  907.  
  908.    [FIPS-46-1] US National Bureau of Standards, "Data Encryption
  909.       Standard," Federal Information Processing Standard (FIPS)
  910.       Publication 46-1, January 1988.
  911.  
  912.    [FIPS-74] US National Bureau of Standards, "Guidelines for
  913.       Implementing and Using the Data Encryption Standard," Federal
  914.       Information Processing Standard (FIPS) Publication 74, April 1981.
  915.  
  916.    [FIPS-81] US National Bureau of Standards, "DES Modes of Operation,"
  917.       Federal Information Processing Standard (FIPS) Publication 81,
  918.       December 1980.
  919.  
  920.    [Hughes96] Hughes, J.  editor, "Combined DES-CBC, HMAC, and Replay
  921.       Prevention Security Transform," work-in-progress, available from
  922.       ftp://ds.internic.net/internet-drafts
  923.       /draft-ietf-ipsec-esp-des-md5-03.txt.
  924.  
  925.    [Krawczyk96]  Krawczyk, H., Bellare, M., Canetti, R., "HMAC-MD5:
  926.       Keyed-MD5 for Message Authentication," work-in-progress, available
  927.       from
  928.       ftp://ds.internic.net/internet-drafts
  929.       /draft-ietf-ipsec-hmac-md5-00.txt.
  930.  
  931.    [RFC-1700] Reynolds, J., and Postel, J., "Assigned Numbers," STD 2,
  932.       RFC-1700, UCS/Information Sciences Institute, October 1994.
  933.  
  934.    [RFC-1974] Friend, R., and Simpson, W.A., "PPP Stac LZS Compression
  935.       Protocol," RFC-1974, Stac Electronics, August 1996.
  936.  
  937.    [RFC-1851] Karn, P., Metzger, P., and Simpson, W., "The ESP Triple
  938.  
  939.  
  940.  
  941. Sabin, et al                                                   [Page 16]
  942.  
  943. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  944.  
  945.  
  946.       DES Transform," RFC-1851, Qualcomm, September 1995.
  947.  
  948.  
  949. 8.  Authors' Addresses
  950.  
  951.    Michael Sabin
  952.    883 Mango Avenue
  953.    Sunnyvale, CA  94087
  954.    Email:  mike.sabin@worldnet.att.net
  955.  
  956.    Robert Monsour
  957.    Hi/fn Inc.
  958.    12636 High Bluff Drive
  959.    San Diego, CA  92130
  960.    Email: rmonsour@hifn.com
  961.  
  962.  
  963. 9.  Appendix:  Guidelines for Resetting Compression Histories
  964.  
  965.    The following table offers some guidance on how frequently an LZS
  966.    compression history can be reset.  The table considers two
  967.    parameters: "payload_bytes," the number of bytes in each payload; and
  968.    "reset_bytes," the number of bytes between history resets.
  969.    Reset_bytes is a multiple of payload_bytes, since an integer number
  970.    of payloads is processed between resets.  Each entry in the table
  971.    shows the compression ratio that was achieved when compressing a test
  972.    file with the corresponding values of payload_bytes and reset_bytes.
  973.  
  974.    The test file was the University of Calgary Text Compression Corpus
  975.    [Calgary].  The length of the file prior to compression was 3,278,000
  976.    bytes.  When the entire file was compressed as a single payload, a
  977.    compression ratio of 2.34 resulted.
  978.  
  979.  
  980.                |                    reset_bytes                      
  981.                |   64   128   256   512  1024  2048  4096  8192 16384 
  982.    ------------+-----------------------------------------------------
  983.    packet_bytes|
  984.           64   | 1.18  1.26  1.37  1.48  1.61  1.74  1.84  1.89  1.92
  985.          128   |       1.28  1.40  1.53  1.67  1.82  1.93  1.99  2.03
  986.          256   |             1.43  1.56  1.71  1.86  1.98  2.05  2.08
  987.          512   |                   1.58  1.73  1.89  2.01  2.08  2.11
  988.         1024   |                         1.74  1.90  2.02  2.09  2.13
  989.         2048   |                               1.91  2.03  2.10  2.14
  990.         4096   |                                     2.04  2.10  2.14
  991.         8192   |                                           2.11  2.14
  992.        16384   |                                                 2.14
  993.  
  994.  
  995.    The table suggests that not there is not much degradation in
  996.    compression ratio if the compression history is reset after several
  997.  
  998.  
  999.  
  1000. Sabin, et al                                                   [Page 17]
  1001.  
  1002. INTERNET DRAFT        3DES-CBC-LZS-HMAC-Replay ESP          October 1996
  1003.  
  1004.  
  1005.    thousand bytes have been processed.  Resetting after less than 1,000
  1006.    bytes is probably too soon -- the compression ratio degrades
  1007.    significantly.  But waiting longer than about 8,000 bytes gains
  1008.    little -- the compression ratio does not increase much.
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059. Sabin, et al                                                   [Page 18]
  1060.  
  1061.  
  1062.