home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / drafts / draft_ietf_i / draft-ietf-ipsec-esp-v2-00.txt < prev    next >
Text File  |  1997-07-22  |  47KB  |  1,064 lines

  1.  
  2. Network Working Group                             Stephen Kent, BBN Corp
  3. Internet Draft                           Randall Atkinson, @Home Network
  4. draft-ietf-ipsec-esp-v2-00.txt                              21 July 1997
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.                 IP Encapsulating Security Payload (ESP)
  12.  
  13.  
  14.  
  15.  
  16. Status of This Memo
  17.  
  18.    This document is an Internet Draft. Internet Drafts are working
  19.    documents of the Internet Engineering Task Force (IETF), its Areas,
  20.    and its working groups. Note that other groups may also distribute
  21.    working documents as Internet Drafts.
  22.  
  23.    Internet Drafts are draft documents valid for a maximum of 6 months.
  24.    Internet Drafts may be updated, replaced, or obsoleted by other
  25.    documents at any time. It is not appropriate to use Internet Drafts
  26.    as reference material or to cite them other than as "work in
  27.    progress".
  28.  
  29.    This particular Internet Draft is a product of the IETF's IPsec
  30.    working group. It is intended that a future version of this draft be
  31.    submitted to the IPng Area Directors and the IESG for possible
  32.    publication as a standards-track protocol.
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. Kent, Atkinson                                                  [Page 1]
  56.  
  57.  
  58. Internet Draft              IP Encapsulating                21 July 1997
  59.                          Security Payload (ESP)
  60.  
  61.  
  62. Table of Contents
  63.  
  64.    1. Introduction......................................................3
  65.    2. Encapsulating Security Payload Packet Format......................4
  66.       2.1  Security Parameters Index....................................5
  67.       2.2  Sequence Number .............................................5
  68.       2.3  Payload Data.................................................5
  69.       2.4  Padding (for Encryption).....................................6
  70.       2.5  Pad Length...................................................7
  71.       2.6  Next Header..................................................7
  72.       2.7  Authentication Data..........................................7
  73.    3. Encapsulating Security Protocol Processing........................7
  74.       3.1  ESP Header Location..........................................7
  75.       3.2  Outbound Packet Processing..................................10
  76.          3.2.1  Security Association Lookup............................10
  77.          3.2.2  Sequence Number Generation.............................10
  78.          3.2.3  Packet Encryption......................................10
  79.             3.2.3.1 Scope of Encryption................................10
  80.             3.2.3.2 Encryption Algorithms..............................11
  81.          3.2.4  Integrity Check Value Calculation......................11
  82.             3.2.4.1  Scope of Authentication Protection................11
  83.             3.2.4.2  Authentication Padding............................11
  84.             3.2.4.3  Authentication Algorithms.........................12
  85.          3.2.5  Fragmentation..........................................12
  86.       3.3  Inbound Packet Processing...................................12
  87.          3.3.1  Pre-ESP Processing Overview............................12
  88.          3.3.2  Security Association Lookup............................12
  89.          3.3.3  Sequence Number Verification...........................13
  90.          3.3.4  Integrity Check Value Verification.....................14
  91.          3.3.5  Packet Decryption......................................15
  92.    4. Auditing.........................................................15
  93.    5. Conformance Requirements.........................................16
  94.    6. Security Considerations..........................................16
  95.    7. Differences from RFC 1827........................................16
  96.    Acknowledgements....................................................17
  97.    References..........................................................17
  98.    Disclaimer..........................................................19
  99.    Author Information..................................................19
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. Kent, Atkinson                                                  [Page 2]
  112.  
  113.  
  114. Internet Draft              IP Encapsulating                21 July 1997
  115.                          Security Payload (ESP)
  116.  
  117.  
  118. 1.  Introduction
  119.  
  120.    The Encapsulating Security Payload (ESP) header is designed to
  121.    provide a mix of security services in IPv4 and IPv6.  ESP may be
  122.    applied alone, in combination with the IP Authentication Header (AH)
  123.    [KA97b], or in a nested fashion, e.g., through the use of tunnel mode
  124.    (see "Security Architecture for the Internet Protocol" [KA97a],
  125.    hereafter referred to as the Security Architecture document).
  126.    Security services can be provided between a pair of communicating
  127.    hosts, between a pair of communicating security gateways, or between
  128.    a security gateway and a host.  For more details on how to use ESP
  129.    and AH in various network environments, see the Security Architecture
  130.    document [KA97a].
  131.  
  132.    The ESP header is inserted after the IP header and before the upper
  133.    layer protocol header (transport mode) or before  an encapsulated IP
  134.    header (tunnel mode).  These modes are described in more detail
  135.    below.
  136.  
  137.    ESP is used to provide confidentiality, data origin authentication,
  138.    connectionless integrity, an anti-replay service (a form of partial
  139.    sequence integrity), and limited traffic flow confidentiality.  The
  140.    set of services provided depends on options selected at the time of
  141.    Security Association establishment and on the placement of the
  142.    implementation.  Confidentiality may be selected independent of all
  143.    other services.  However, use of confidentiality without
  144.    integrity/authentication (either in ESP or separately in AH) may
  145.    subject traffic to certain forms of active attacks that could
  146.    undermine the confidentiality service (see [Bel96].  Data origin
  147.    authentication and connectionless integrity are joint services
  148.    (hereafter referred to jointly as "authentication) and are offered as
  149.    an option in conjunction with confidentiality.  The anti-replay
  150.    service may be selected only if data origin authentication is
  151.    selected, and its election is solely at the discretion of the
  152.    receiver.  Traffic flow confidentiality requires selection of tunnel
  153.    mode, and is most effective if implemented at a security gateway,
  154.    where traffic aggregation may be able to mask true source-destination
  155.    patterns.
  156.  
  157.    It is assumed that the reader is familiar with the terms and concepts
  158.    described in the Security Architecture document.  In particular, the
  159.    reader should be familiar with the definitions of security services
  160.    offered by ESP and AH, the concept of Security Associations, the ways
  161.    in which ESP can be used in conjunction with the Authentication
  162.    Header (AH), and the different key management options available for
  163.    ESP and AH.  (With regard to the last topic, the current key
  164.    management options required for both AH and ESP are manual keying and
  165.  
  166.  
  167. Kent, Atkinson                                                  [Page 3]
  168.  
  169.  
  170. Internet Draft              IP Encapsulating                21 July 1997
  171.                          Security Payload (ESP)
  172.  
  173.  
  174.    automated keying via Oakley/ISAKMP.)
  175.  
  176. 2.  Encapsulating Security Payload Packet Format
  177.  
  178.  
  179.    The protocol header (IPv4, IPv6, or Extension) immediately preceding the
  180.    ESP header will contain the value 50 in its Protocol (IPv4) or Next
  181.    Header (IPv6, Extension) field [STD-2].
  182.  
  183.     0                   1                   2                   3
  184.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  185.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ----
  186.    |               Security Parameters Index (SPI)                 | ^
  187.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Auth.
  188.    |                      Sequence Number                          | |Coverage
  189.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | -----
  190.    |                    Payload Data* (variable)                   | |   ^
  191.    ~                                                               ~ |   |
  192.    |                                                               | |   |
  193.    +               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Confid.
  194.    |               |     Padding (0-255 bytes)                     | |Coverage*
  195.    +-+-+-+-+-+-+-+-+               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |   |
  196.    |                               |  Pad Length   | Next Header   | v   v
  197.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -------
  198.    |                 Authentication Data (variable)                |
  199.    ~                                                               ~
  200.    |                                                               |
  201.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  202.  
  203.         * If included in the Payload field, cryptographic synchronization
  204.           data, e.g., an IV, usually is not encrypted per se, although it
  205.           often is referred to as being part of the ciphertext.
  206.  
  207.  
  208.  
  209.  
  210.    The following subsections define the fields in the header format.
  211.    "Optional" means that the field is omitted if the option is not
  212.    selected, i.e., it is present in neither the packet as transmitted
  213.    nor as formatted for computation of an ICV.  Whether or not an option
  214.    is selected is defined as part of Security Association (SA)
  215.    establishment.  Thus the format of ESP packets for a given SA is
  216.    fixed, for the duration of the SA.  In contrast, "mandatory" fields
  217.    are always present in the ESP packet format, for all SAs.
  218.  
  219.  
  220.  
  221.  
  222.  
  223. Kent, Atkinson                                                  [Page 4]
  224.  
  225.  
  226. Internet Draft              IP Encapsulating                21 July 1997
  227.                          Security Payload (ESP)
  228.  
  229.  
  230. 2.1  Security Parameters Index
  231.  
  232.    The SPI is an arbitrary 32-bit value that uniquely identifies the
  233.    Security Association for this datagram, relative to the destination
  234.    IP address contained in the IP header (with which this security
  235.    header is associated) and relative to the security protocol employed.
  236.    The set of SPI values in the range 1 through 255 are reserved by the
  237.    Internet Assigned Numbers Authority (IANA) for future use; a reserved
  238.    SPI value will not normally be assigned by IANA unless the use of the
  239.    assigned SPI value is specified in an RFC.  It is ordinarily selected
  240.    by the destination system upon establishment of an SA (see the
  241.    Security Architecture document for more details).  (A zero value may
  242.    be used within an ESP implementation for local debugging purposes,
  243.    but no ESP packets should be transmitted with a zero SPI value.)  The
  244.    SPI field is mandatory.
  245.  
  246. 2.2  Sequence Number
  247.  
  248.    This unsigned 32-bit field contains a monotonically increasing
  249.    counter value (sequence number).  The sender's counter and the
  250.    receiver's counter are initialized to 0 when an SA is established.
  251.    (The first packet sent using a given SA will have a Sequence Number
  252.    of 1; see Section 3.2.2 for more details on how the Sequence Number
  253.    is generated.) The transmitted Sequence Number must never be allowed
  254.    to cycle.  Thus, the sender's counter and the receiver's counter MUST
  255.    be reset (by establishing a new SA and thus a new key) prior to the
  256.    transmission of 2^32nd packet on an SA.
  257.  
  258.    The Sequence Number is mandatory.  It is always included in an ESP
  259.    packet, to ensure alignment of the Payload field on an 8-byte
  260.    boundary (in support of IPv6).  Even if authentication is not
  261.    selected as a security service for the SA, or if ESP is employed in
  262.    an IPv4 environment, this field MUST be present.
  263.  
  264.    Processing of the Sequence Number field is at the discretion of the
  265.    receiver, i.e., the sender MUST always transmit this field, but the
  266.    receiver need not act upon it (see the discussion of Sequence Number
  267.    Verification in the "Inbound Processing" section below).
  268.  
  269.  
  270. 2.3  Payload Data
  271.  
  272.    Payload Data is a variable-length field containing data described by
  273.    the Next Header field. The Payload Data field is mandatory and is an
  274.    integral number of bytes in length.  If the algorithm used to encrypt
  275.    the payload requires cryptographic synchronization data, e.g., an
  276.    Initialization Vector (IV), then this data MAY be carried explicitly
  277.  
  278.  
  279. Kent, Atkinson                                                  [Page 5]
  280.  
  281.  
  282. Internet Draft              IP Encapsulating                21 July 1997
  283.                          Security Payload (ESP)
  284.  
  285.  
  286.    in the Payload field.  Any encryption algorithm that requires such
  287.    explicit, per-packet synchronization data MUST indicate the length,
  288.    any structure for such data, and the location of this data as part of
  289.    an RFC specifying how the algorithm is used with ESP.  If such
  290.    synchronization data is implicit, the algorithm for deriving the data
  291.    MUST be part of the RFC.
  292.  
  293. 2.4  Padding (for Encryption)
  294.  
  295.    Several factors require or motivate use of the Padding field.
  296.  
  297.  
  298.              If an encryption algorithm is employed that requires the
  299.              plaintext to be a multiple of some number of bytes, e.g., the
  300.              block size of a block cipher, the Padding field is used to fill
  301.              the plaintext (consisting of the Payload Data, Pad Length and
  302.              Next Header fields, as well as the Padding) to the size required
  303.              by the algorithm.
  304.  
  305.              Padding also may be required, irrespective of encryption
  306.              algorithm requirements, to ensure that the resulting ciphertext
  307.              terminates on a 4-byte boundary. Specifically, the Pad Length
  308.              and Next Header fields must be right aligned within a 4-byte
  309.              word, as illustrated in the ESP packet format figure above.
  310.  
  311.              Padding beyond that required for the algorithm or alignment
  312.              reasons cited above, may be used to conceal the actual length of
  313.              the payload, in support of (partial) traffic flow
  314.              confidentiality.  However, inclusion of such additional padding
  315.              has adverse bandwidth implications and thus its use should be
  316.              undertaken with care.
  317.  
  318.  
  319.    The transmitter MAY add 0-255 bytes of padding.  Inclusion of the
  320.    Padding field in an ESP packet is optional, but all implementations
  321.    MUST support generation and consumption of padding.
  322.  
  323.    As a default, the Padding bytes are initialized with a series of
  324.    (unsigned, 1-byte) integer values.  The first padding byte appended
  325.    to the plaintext is numbered 1, with subsequent padding bytes making
  326.    up a monotonically increasing sequence: 1, 2, 3, ...  When this
  327.    padding scheme is employed, the receiver SHOULD inspect the Padding
  328.    field.  (This scheme was selected because of its relative simplicity,
  329.    ease of implementation in hardware, and because it offers limited
  330.    protection against certain forms of "cut and paste" attacks in the
  331.    absence of other integrity measures, if the receiver checks the
  332.    padding values upon decryption.)
  333.  
  334.  
  335. Kent, Atkinson                                                  [Page 6]
  336.  
  337.  
  338. Internet Draft              IP Encapsulating                21 July 1997
  339.                          Security Payload (ESP)
  340.  
  341.  
  342.    Any encryption algorithm that requires Padding other than the default
  343.    described above, MUST define the Padding contents (e.g., zeros or
  344.    random data) and any required receiver processing of these Padding
  345.    bytes in an RFC specifying how the algorithm is used with ESP.  In
  346.    such circumstances, the content of the Padding field will be
  347.    determined by the encryption algorithm and mode selected and defined
  348.    in the corresponding algorithm RFC.  The relevant algorithm RFC MAY
  349.    specify that a receiver MUST inspect the Padding field or that a
  350.    receiver MUST inform senders of how the receiver will handle the
  351.    Padding field.
  352.  
  353. 2.5  Pad Length
  354.  
  355.    The Pad Length field indicates the number of pad bytes immediately
  356.    preceding it.  The range of valid values is 0-255, where a value of
  357.    zero indicates that no Padding bytes are present.  The Pad Length
  358.    field is mandatory.
  359.  
  360. 2.6  Next Header
  361.  
  362.    The Next Header is an 8-bit field that identifies the type of data
  363.    contained in the Payload Data field, e.g., an extension header in
  364.    IPv6 or an upper layer protocol identifier.  The value of this field
  365.    is chosen from the set of IP Protocol Numbers defined in the most
  366.    recent "Assigned Numbers" [STD-2] RFC from the Internet Assigned
  367.    Numbers Authority (IANA).  The Next Header field is mandatory.
  368.  
  369. 2.7  Authentication Data
  370.  
  371.    The Authentication Data is a variable-length field containing an
  372.    Integrity Check Value (ICV) computed over the ESP packet minus the
  373.    Authentication Data.  The length of the field depends upon the
  374.    authentication function selected.  The mandatory-to-implement
  375.    authentication algorithms, HMAC with MD5 or SHA-1, both yield 96-bit
  376.    ICV's because of the truncation convention (see Section 3.2.4.3)
  377.    adopted for use in IPsec.  The Authentication Data field is optional,
  378.    and is included only if the authentication service has been selected
  379.    for the SA in question.
  380.  
  381. 3.  Encapsulating Security Protocol Processing
  382.  
  383.    3.1 ESP Header Location
  384.  
  385.    Like AH, ESP may be employed in two ways: transport mode or tunnel
  386.    mode.  The former mode is applicable only to host implementations and
  387.    provides protection for upper layer protocols, but not the IP header.
  388.    (In this mode, note that for "bump-in-the-stack" or "bump-in-the-
  389.  
  390.  
  391. Kent, Atkinson                                                  [Page 7]
  392.  
  393.  
  394. Internet Draft              IP Encapsulating                21 July 1997
  395.                          Security Payload (ESP)
  396.  
  397.  
  398.    wire" implementations, as defined in the Security Architecture
  399.    document, inbound and outbound IP fragments may require an IPsec
  400.    implementation to perform extra IP reassembly/fragmentation in order
  401.    to both conform to this specification and provide transparent IPsec
  402.    support.  Special care is required to perform such operations within
  403.    these implementations when multiple interfaces are in use.)
  404.  
  405.    In transport mode, ESP is inserted after the IP header and before an
  406.    upper layer protocol, e.g., TCP, UDP, ICMP, etc.  or before any other
  407.    IPsec headers that have already been inserted, e.g., AH.  In the
  408.    context of IPv4, this translates to placing ESP after the IP header
  409.    (and any options that it contains), but before the upper layer
  410.    protocol.  (Note that the term "transport" mode should not be
  411.    misconstrued as restricting its use to TCP and UDP. For example, an
  412.    ICMP message MAY be sent using either "transport" mode or "tunnel"
  413.    mode.)  The following diagram illustrates ESP transport mode
  414.    positioning for a typical IPv4 packet, on a "before and after" basis.
  415.    (The "ESP trailer" encompasses any Padding, plus the Pad Length, and
  416.    Next Header fields.)
  417.  
  418.                  BEFORE APPLYING ESP
  419.             ----------------------------
  420.       IPv4  |orig IP hdr  |     |      |
  421.             |(any options)| TCP | Data |
  422.             ----------------------------
  423.  
  424.                  AFTER APPLYING ESP
  425.             -------------------------------------------------
  426.       IPv4  |orig IP hdr  | ESP |     |      |   ESP   | ESP|
  427.             |(any options)| Hdr | TCP | Data | Trailer |Auth|
  428.             -------------------------------------------------
  429.                                 |<----- encrypted ---->|
  430.                           |<------ authenticated ----->|
  431.  
  432.  
  433.    In the IPv6 context, ESP is viewed as an end-to-end payload, and thus
  434.    should appear after hop-by-hop, routing, and fragmentation extension
  435.    headers.  The destination options extension header(s) could appear
  436.    either before or after the ESP header depending on the semantics
  437.    desired.  However, since ESP protects only fields after the ESP
  438.    header, it generally may be desirable to place the destination
  439.    options header(s) after the ESP header.  The following diagram
  440.    illustrates ESP transport mode positioning for a typical IPv6 packet.
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447. Kent, Atkinson                                                  [Page 8]
  448.  
  449.  
  450. Internet Draft              IP Encapsulating                21 July 1997
  451.                          Security Payload (ESP)
  452.  
  453.  
  454.                      BEFORE APPLYING ESP
  455.             ---------------------------------------
  456.       IPv6  |             | ext hdrs |     |      |
  457.             | orig IP hdr |if present| TCP | Data |
  458.             ---------------------------------------
  459.  
  460.  
  461.                      AFTER APPLYING ESP
  462.             ---------------------------------------------------------
  463.       IPv6  | orig |hxh,rtg,frag|dest|ESP|dest|   |    | ESP   | ESP|
  464.             |IP hdr|if present**|opt*|Hdr|opt*|TCP|Data|Trailer|Auth|
  465.             ---------------------------------------------------------
  466.                                          |<---- encrypted ---->|
  467.                                      |<---- authenticated ---->|
  468.  
  469.                 * = if present, could be before ESP, after ESP, or both
  470.                ** = hop by hop, routing, fragmentation headers
  471.  
  472.    Tunnel mode ESP may be employed in either hosts or security gateways.
  473.    When ESP is implemented in a security gateway (to protect subscriber
  474.    transit traffic), tunnel mode must be used.  In tunnel mode, the
  475.    "inner" IP header carries the ultimate source and destination
  476.    addresses, while an "outer" IP header may contain distinct IP
  477.    addresses, e.g., addresses of security gateways.  In tunnel mode, ESP
  478.    protects the entire inner IP packet, including the entire inner IP
  479.    header. The position of ESP in tunnel mode, relative to the outer IP
  480.    header, is the same as for ESP in transport mode.  The following
  481.    diagram illustrates ESP tunnel mode positioning for typical IPv4 and
  482.    IPv6 packets.
  483.  
  484.             -----------------------------------------------------------
  485.       IPv4  | new IP hdr* |     | orig IP hdr*  |   |    | ESP   | ESP|
  486.             |(any options)| ESP | (any options) |TCP|Data|Trailer|Auth|
  487.             -----------------------------------------------------------
  488.                                 |<--------- encrypted ---------->|
  489.                           |<----------- authenticated ---------->|
  490.  
  491.             ---------------------------------------------------------------
  492.       IPv6  | new* | ext hdrs*|   | orig*| ext hdrs*|   |    | ESP   | ESP|
  493.             |IP hdr|if present|ESP|IP hdr|if present|TCP|Data|Trailer|Auth|
  494.             ---------------------------------------------------------------
  495.                                   |<---------- encrypted ----------->|
  496.                               |<----------- authenticated ---------->|
  497.  
  498.                * = construction of outer IP hdr/extensions and modification
  499.                       of inner IP hdr/extensions is discussed below.
  500.  
  501.  
  502.  
  503. Kent, Atkinson                                                  [Page 9]
  504.  
  505.  
  506. Internet Draft              IP Encapsulating                21 July 1997
  507.                          Security Payload (ESP)
  508.  
  509.  
  510. 3.2  Outbound Packet Processing
  511.  
  512.    In transport mode, the transmitter encapsulates the upper layer
  513.    protocol information in the ESP header/trailer, and retains the
  514.    specified IP header (and any IP extension headers in the IPv6
  515.    context).  In tunnel mode, the outer and inner IP header/extensions
  516.    can be inter-related in a variety of ways.  The construction of the
  517.    outer IP header/extensions during the encapsulation process is
  518.    described in the Security Architecture document.
  519.  
  520. 3.2.1  Security Association Lookup
  521.  
  522.    ESP is applied to an outbound packet only after an IPsec
  523.    implementation determines that the packet is associated with an SA
  524.    that calls for ESP processing.  The process of determining what, if
  525.    any, IPsec processing is applied to outbound traffic is described in
  526.    the Security Architecture document.
  527.  
  528. 3.2.2  Sequence Number Generation
  529.  
  530.    As noted in Section 2.2, the Sequence Number field is always included
  531.    in ESP packets, even if the anti-replay service, or the
  532.    authentication service, have not been enabled for the SA.  The
  533.    sender's counter is initialized to 0 when an SA is established.  The
  534.    transmitter increments the Sequence Number for this SA, checks to
  535.    ensure that the counter has not cycled, and inserts the new value
  536.    into the Sequence Number field.  Thus the first packet sent using a
  537.    given SA will have a Sequence Number of 1.  A transmitter MUST NOT
  538.    send a packet on an SA if doing so would cause the Sequence Number to
  539.    cycle.  An attempt to transmit a packet that would result in sequence
  540.    number overflow is an auditable event.  (Note that this approach to
  541.    Sequence Number management does not require use of modular
  542.    arithmetic.)
  543.  
  544. 3.2.3  Packet Encryption
  545.  
  546. 3.2.3.1 Scope of Encryption
  547.  
  548.    In transport mode, the transmitter encapsulates the original upper
  549.    layer protocol information into the ESP payload field, adds any
  550.    necessary padding, and encrypts the result (Payload Data, Padding,
  551.    Pad Length, and Next Header) using the key, encryption algorithm, and
  552.    algorithm mode indicated by the SA.  In tunnel mode, the transmitter
  553.    encapsulates and encrypts the entire original IP datagram (plus the
  554.    Padding, Pad Length, and Next Header).
  555.  
  556.    If authentication is selected, encryption is performed first, before
  557.  
  558.  
  559. Kent, Atkinson                                                 [Page 10]
  560.  
  561.  
  562. Internet Draft              IP Encapsulating                21 July 1997
  563.                          Security Payload (ESP)
  564.  
  565.  
  566.    the authentication, and the encryption does not encompass the
  567.    Authentication Data field.  This order of processing facilitates
  568.    rapid detection and rejection of replayed or bogus packets by the
  569.    receiver, prior to decrypting the packet, hence potentially reducing
  570.    the impact of denial of service attacks.  It also allows for the
  571.    possibility of parallel processing of packets at the receiver, i.e.,
  572.    decryption can take place in parallel with authentication.  Note that
  573.    since the Authentication Data is not protected by encryption, a keyed
  574.    authentication algorithm must be employed to compute the ICV.
  575.  
  576. 3.2.3.2 Encryption Algorithms
  577.  
  578. The encryption algorithm employed is specified by the SA.  ESP is
  579. designed for use with symmetric encryption algorithms.  Because IP
  580. packets may arrive out of order, each packet must carry any data
  581. required to allow the receiver to establish cryptographic
  582. synchronization for decryption.  This data may be carried explicitly in
  583. the payload field, e.g., as an IV (as described above), or the data may
  584. be derived from the packet header.  Since ESP makes provision for
  585. padding of the plaintext, encryption algorithms employed with ESP may
  586. exhibit either block or stream mode characteristics.
  587.  
  588. At the time of writing, one mandatory-to-implement encryption algorithm
  589. and mode has been defined for ESP.  It is based on the Data Encryption
  590. Standard (DES) [NIST77] in Cipher Block Chaining Mode [NIST80].  Details
  591. of use of this mode are contained in [MS97].
  592.  
  593.  
  594. 3.2.4  Integrity Check Value Calculation
  595.  
  596. 3.2.4.1  Scope of Authentication Protection
  597.  
  598.    If authentication is selected for the SA, the transmitter computes
  599.    the ICV over the ESP packet minus the Authentication Data.  Thus the
  600.    SPI, Sequence Number, Payload Data, Padding (if present), Pad Length,
  601.    and Next Header are all encompassed by the ICV computation.  Note
  602.    that the last 4 fields will be in ciphertext form, since encryption
  603.    is performed prior to authentication.
  604.  
  605. 3.2.4.2  Authentication Padding
  606.  
  607.    For some authentication algorithms, the byte string over which the
  608.    ICV computation is performed must be a multiple of a blocksize
  609.    specified by the algorithm.  If the length of this byte string does
  610.    not match the blocksize requirements for the algorithm, implicit
  611.    padding MUST be appended to the end of the ESP packet, prior to ICV
  612.    computation.  The padding octets MUST have a value of zero.  The
  613.  
  614.  
  615. Kent, Atkinson                                                 [Page 11]
  616.  
  617.  
  618. Internet Draft              IP Encapsulating                21 July 1997
  619.                          Security Payload (ESP)
  620.  
  621.  
  622.    blocksize (and hence the length of the padding) is specified by the
  623.    algorithm specification.  This padding is not transmitted with the
  624.    packet.
  625.  
  626. 3.2.4.3  Authentication Algorithms
  627.  
  628.    The authentication algorithm employed for the ICV computation is
  629.    specified by the SA.  For point-to-point communication, suitable
  630.    authentication algorithms include keyed Message Authentication Codes
  631.    (MACs) based on symmetric encryption algorithms (e.g., DES) or on
  632.    one-way hash functions (e.g., MD5 or SHA-1).  For multicast
  633.    communication, one-way hash algorithms combined with asymmetric
  634.    signature algorithms are suitable.  As of this writing, the
  635.    mandatory-to-implement authentication algorithms are based on the
  636.    former class, i.e., HMAC [KBC97] with SHA-1 [SHA] or HMAC with MD5
  637.    [Riv92].  The output of the HMAC computation is truncated to the
  638.    leftmost 96 bits.  Other algorithms, possibly with different ICV
  639.    lengths, MAY be supported.
  640.  
  641. 3.2.5  Fragmentation
  642.  
  643.    If necessary, fragmentation is performed after ESP processing within
  644.    an IPsec implementation.  Thus, transport mode ESP is applied only to
  645.    whole IP datagrams (not to IP fragments).  An IP packet to which ESP
  646.    has been applied may itself be fragmented by routers en route, and
  647.    such fragments must be reassembled prior to ESP processing at a
  648.    receiver.  In tunnel mode, ESP is applied to an IP packet, the
  649.    payload of which may be a fragmented IP packet.  For example, a
  650.    security gateway or a "bump-in-the-stack" or "bump-in-the-wire" IPsec
  651.    implementation (as defined in the Security Architecture document) may
  652.    apply tunnel mode ESP to such fragments.
  653.  
  654. 3.3  Inbound Packet Processing
  655.  
  656. 3.3.1  Pre-ESP Processing Overview
  657.  
  658.    If required, reassembly is performed prior to ESP processing.
  659.  
  660. 3.3.2  Security Association Lookup
  661.  
  662.    Upon receipt of a (reassembled) packet containing an ESP Header, the
  663.    receiver determines the appropriate (unidirectional) SA, based on the
  664.    destination IP address and the SPI.  (This process is described in
  665.    more detail in the Security Architecture document.)  The SA indicates
  666.    whether the Authentication Data field should be present, and it will
  667.    specify the algorithms and keys to be employed for decryption and ICV
  668.    computations (if applicable).
  669.  
  670.  
  671. Kent, Atkinson                                                 [Page 12]
  672.  
  673.  
  674. Internet Draft              IP Encapsulating                21 July 1997
  675.                          Security Payload (ESP)
  676.  
  677.  
  678.    If no valid Security Association exists for this session (for
  679.    example, the receiver has no key), the receiver MUST discard the
  680.    packet; this is an auditable event.  The audit log entry for this
  681.    event SHOULD include the SPI value, date/time, Source Address,
  682.    Destination Address, and (in IPv6) the cleartext Flow ID.
  683.  
  684. 3.3.3  Sequence Number Verification
  685.  
  686.    All ESP implementations MUST support the anti-replay service, though
  687.    its use may be enabled or disabled on a per-SA basis.  This service
  688.    MUST NOT be enabled unless the authentication service also is enabled
  689.    for the SA, since otherwise the Sequence Number field has not been
  690.    integrity protected.  (Note that there are no provisions for managing
  691.    transmitted Sequence Number values among multiple senders directing
  692.    traffic to a single, multicast SA.  Thus the anti-replay service
  693.    SHOULD NOT be used in a multi-sender multicast environment that
  694.    employs a single, multicast SA.)  If an SA establishment protocol
  695.    such as Oakley/ISAKMP is employed, then the receiver SHOULD notify
  696.    the transmitter, during SA establishment, if the receiver will
  697.    provide anti-replay protection and SHOULD inform the transmitter of
  698.    the window size.
  699.  
  700.    If the receiver enables the anti-replay service for this SA, the
  701.    receive packet counter for the SA MUST be initialized to zero when
  702.    the SA is established.  For each received packet, the receiver MUST
  703.    verify that the packet contains a Sequence Number that does not
  704.    duplicate the Sequence Number of any other packets received during
  705.    the life of this SA.  This SHOULD be the first ESP check applied to a
  706.    packet after it has been matched to an SA, to speed rejection of
  707.    duplicate packets.
  708.  
  709.    Duplicates are rejected through the use of a sliding receive window.
  710.    (How the window is implemented is a local matter, but the following
  711.    text describes the functionality that the implementation must
  712.    exhibit.)  A MINIMUM window size of 32 MUST be supported; but a
  713.    window size of 64 is preferred and SHOULD be employed as the default.
  714.    A window size of 64 or larger MAY be chosen by the receiver.  If a
  715.    larger window size is chosen, it MUST be a multiple of 32.  If any
  716.    window size other than the default of 64 is employed by the receiver,
  717.    it MUST be reported to the transmitter during SA negotiation.
  718.  
  719.    The "right" edge of the window represents the highest, validated
  720.    Sequence Number value received on this SA.  Packets that contain
  721.    Sequence Numbers lower than the "left" edge of the window are
  722.    rejected.  Packets falling within the window are checked against a
  723.    list of received packets within the window.  An efficient means for
  724.    performing this check, based on the use of a bit mask, is described
  725.  
  726.  
  727. Kent, Atkinson                                                 [Page 13]
  728.  
  729.  
  730. Internet Draft              IP Encapsulating                21 July 1997
  731.                          Security Payload (ESP)
  732.  
  733.  
  734.    in the Security Architecture document.
  735.  
  736.    If the received packet falls within the window and is new, or if the
  737.    packet is to the right of the window, then the receiver proceeds to
  738.    ICV verification.  If the ICV validation fails, the receiver MUST
  739.    discard the received IP datagram as invalid; this is an auditable
  740.    event.  The audit log entry for this event SHOULD include the SPI
  741.    value, date/time, Source Address, Destination Address, the Sequence
  742.    Number, and (in IPv6) the Flow ID.  The receive window is updated
  743.    only if the ICV verification succeeds.
  744.  
  745.    DISCUSSION:
  746.  
  747.       Note that if the packet is either inside the window and new, or is
  748.       outside the window on the "right" side, the receiver MUST
  749.       authenticate the packet before updating the Sequence Number window
  750.       data.
  751.  
  752. 3.3.4  Integrity Check Value Verification
  753.  
  754.    If authentication has been selected, the receiver computes the ICV
  755.    over the ESP packet minus the Authentication Data using the specified
  756.    authentication algorithm and verifies that it is the same as the ICV
  757.    included in the Authentication Data field of the packet.  Details of
  758.    the computation are provided below.
  759.  
  760.    If the computed and received ICV's match, then the datagram is valid,
  761.    and it is accepted.  If the test fails, then the receiver MUST
  762.    discard the received IP datagram as invalid; this is an auditable
  763.    event.  The log data SHOULD include the SPI value, date/time
  764.    received, Source Address, Destination Address, and (in IPv6) the
  765.    cleartext Flow ID.
  766.  
  767.    DISCUSSION:
  768.  
  769.       Begin by removing and saving the ICV value (Authentication Data
  770.       field).  Next check the overall length of the ESP packet minus the
  771.       Authentication Data.  If implicit padding is required, based on
  772.       the blocksize of the authentication algorithm, append zero-filled
  773.       bytes to the end of the ESP packet directly after the Next Header
  774.       field.  Perform the ICV computation and compare the result with
  775.       the saved value.  (For the mandatory-to-implement authentication
  776.       algorithms, HMAC [KBC97] with SHA-1 [SHA] or HMAC with MD5
  777.       [Riv92], the output of the HMAC computation is truncated to the
  778.       leftmost 96 bits.  Other algorithms may have different ICV
  779.       lengths.) (If a digital signature and one-way hash are used for
  780.       the ICV computation, the matching process is more complex and will
  781.  
  782.  
  783. Kent, Atkinson                                                 [Page 14]
  784.  
  785.  
  786. Internet Draft              IP Encapsulating                21 July 1997
  787.                          Security Payload (ESP)
  788.  
  789.  
  790.       be described in the algorithm specification.)
  791.  
  792.  
  793. 3.3.5  Packet Decryption
  794.  
  795.    The receiver decrypts the ESP Payload Data, Padding, Pad Length, and
  796.    Next Header using the session key that has been established for this
  797.    traffic.  If an explicit IV is present in the Payload Field, it is
  798.    input to the decryption algorithm as per the algorithm specification.
  799.    If an implicit IV is employed, a local version of the IV is
  800.    constructed and input to the decryption algorithm as per the
  801.    algorithm specification.  (Decryption may take place in parallel with
  802.    authentication, but care must be taken to avoid possible race
  803.    conditions with regard to packet access and reconstruction of the
  804.    decrypted packet.)
  805.  
  806.    After decryption, the original IP datagram is reconstructed and
  807.    processed per the normal IP protocol specification.  The exact steps
  808.    for reconstructing the original datagram depend on the mode (tunnel
  809.    vs transport) and are described in the Security Architecture
  810.    document.  At a minimum, in an IPv6 context, the receiver SHOULD
  811.    ensure that the decrypted data is 8-byte aligned, to facilitate
  812.    processing by the protocol identified in the Next Header field.
  813.  
  814.    Note that there are two ways in which the decryption can "fail".  The
  815.    selected SA may not be correct or the encrypted ESP packet could be
  816.    corrupted.  (The latter case would be detected if authentication is
  817.    selected for the SA, as would tampering with the SPI.  However, an SA
  818.    mismatch might still occur due to tampering with the IP Destination
  819.    Address.)  In either case, the erroneous result of the decryption
  820.    operation (an invalid IP datagram or transport-layer frame) will not
  821.    necessarily be detected by IPsec, and is the responsibility of later
  822.    protocol processing.
  823.  
  824.  
  825. 4. Auditing
  826.  
  827.    Not all systems that implement ESP will implement auditing.  However,
  828.    if ESP is incorporated into a system that supports auditing, then the
  829.    ESP implementation MUST also support auditing and MUST allow a system
  830.    administrator to enable or disable auditing for ESP.  For the most
  831.    part, the granularity of auditing is a local matter.  However,
  832.    several auditable events are identified in this specification and for
  833.    each of these events a minimum set of information that SHOULD be
  834.    included in an audit log is defined.  Additional information also MAY
  835.    be included in the audit log for each of these events, and additional
  836.    events, not explicitly called out in this specification, also MAY
  837.  
  838.  
  839. Kent, Atkinson                                                 [Page 15]
  840.  
  841.  
  842. Internet Draft              IP Encapsulating                21 July 1997
  843.                          Security Payload (ESP)
  844.  
  845.  
  846.    result in audit log entries.  There is no requirement for the
  847.    receiver to transmit any message to the purported transmitter in
  848.    response to the detection of an auditable event, because of the
  849.    potential to induce denial of service via such action.
  850.  
  851. 5.  Conformance Requirements
  852.  
  853.    Implementations that claim conformance or compliance with this
  854.    specification MUST implement the ESP syntax and processing described
  855.    here and MUST comply with all requirements of the Security
  856.    Architecture document.  If the key used to compute an ICV is manually
  857.    distributed, correct provision of the anti-replay service would
  858.    require correct maintenance of the counter state at the transmitter,
  859.    until the key is replaced, and there likely would be no automated
  860.    recovery provision if counter overflow were imminent.  Thus a
  861.    compliant implementation SHOULD NOT provide this service in
  862.    conjunction with SAs that are manually keyed.  A compliant ESP
  863.    implementation MUST support the following mandatory-to-implement
  864.    algorithms (specified in [KBC97] and in [MS97].
  865.  
  866.              - DES in CBC mode
  867.              - HMAC with MD5
  868.              - HMAC with SHA-1
  869.  
  870.  
  871.  
  872. 6.  Security Considerations
  873.  
  874.    Security is central to the design of this protocol, and this security
  875.    considerations permeate the specification.  Additional security-
  876.    relevant aspects of using IPsec protocol are discussed in the
  877.    Security Architecture document.
  878.  
  879.  
  880. 7. Differences from RFC 1827
  881.  
  882.    This document differs from RFC 1827 [ATK95] in several significant
  883.    ways.  The major difference is that, this document attempts to
  884.    specify a complete framework and context for ESP, whereas RFC 1827
  885.    provided a "shell" that was completed through the definition of
  886.    transforms.  The combinatorial growth of transforms motivated the
  887.    reformulation of the ESP specification as a more complete document,
  888.    with options for security services that may be offered in the context
  889.    of ESP.  Thus, fields previously defined in transform documents are
  890.    now part of this base ESP specification.  For example, the fields
  891.    necessary to support authentication (and anti-replay) are now defined
  892.    here, even though the provision of this service is an option.  The
  893.  
  894.  
  895. Kent, Atkinson                                                 [Page 16]
  896.  
  897.  
  898. Internet Draft              IP Encapsulating                21 July 1997
  899.                          Security Payload (ESP)
  900.  
  901.  
  902.    fields used to support padding for encryption, and for next protocol
  903.    identification, are now defined here as well.  Packet processing
  904.    consistent with the definition of these fields also is included in
  905.    the document.
  906.  
  907.  
  908. Acknowledgements
  909.  
  910.    Many of the concepts embodied in this specification were derived from
  911.    or influenced by the US Government's SP3 security protocol, ISO/IEC's
  912.    NLSP, or from the proposed swIPe security protocol.  [SDNS89, ISO92
  913.    IB93].
  914.  
  915.    For over 2 years, this document has evolved through multiple versions
  916.    and iterations.  During this time, many people have contributed
  917.    significant ideas and energy to the process and the documents
  918.    themselves.  The authors would like to thank Karen Seo for providing
  919.    extensive help in the review, editing, background research, and
  920.    coordination for this version of the specification.  The authors
  921.    would also like to thank the members of the IPSEC and IPng working
  922.    groups, with special mention of the efforts of (in alphabetic order):
  923.    Steve Bellovin, Steve Deering, Phil Karn, Perry Metzger, David
  924.    Mihelcic, Hilarie Orman, William Simpson and Nina Yuan.
  925.  
  926. References
  927.  
  928.  
  929.    [ATK95]   R. Atkinson, "IP Encapsulating Security Payload (ESP)", RFC
  930.              1827, August 1997.
  931.  
  932.    [Bel89]   Steven M. Bellovin, "Security Problems in the TCP/IP
  933.              Protocol Suite", ACM Computer Communications Review, Vol.
  934.              19, No. 2, March 1989.
  935.  
  936.    [Bel96]   Steven M. Bellovin, "Problem Areas for the IP Security
  937.              Protocols", Proceedings of the Sixth Usenix Unix Security
  938.              Symposium, July, 1996.
  939.  
  940.    [CERT95]  Computer Emergency Response Team (CERT), "IP Spoofing
  941.              Attacks and Hijacked Terminal Connections", CA-95:01,
  942.              January 1995.  Available via anonymous ftp from
  943.              info.cert.org.
  944.  
  945.    [DH95]    Steve Deering & Robert Hinden, Internet Protocol Version 6
  946.              (Ipv6)  Specification, RFC 1883, December 1995.
  947.  
  948.    [IB93]    John Ioannidis & Matt Blaze, "Architecture and
  949.  
  950.  
  951. Kent, Atkinson                                                 [Page 17]
  952.  
  953.  
  954. Internet Draft              IP Encapsulating                21 July 1997
  955.                          Security Payload (ESP)
  956.  
  957.  
  958.              Implementation of Network-layer Security Under Unix",
  959.              Proceedings of the USENIX Security Symposium, Santa Clara,
  960.              CA, October 1993.
  961.  
  962.    [ISO92]   ISO/IEC JTC1/SC6, Network Layer Security Protocol, ISO-IEC
  963.              DIS 11577, International Standards Organisation, Geneva,
  964.              Switzerland, 29 November 1992.
  965.  
  966.    [KA97a]   Steve Kent, Randall Atkinson, "Security Architecture for
  967.              the Internet Protocol", Internet Draft, ?? 1997.
  968.  
  969.    [KA97b]   Steve Kent, Randall Atkinson, "IP Authentication Header",
  970.              Internet Draft, ?? 1997.
  971.  
  972.    [KBC97]   Hugo Krawczyk, Mihir Bellare, and Ran Canetti, "HMAC:
  973.              Keyed-Hashing for Message Authentication", RFC-2104,
  974.              February 1997.
  975.  
  976.    [Ken91]   Steve Kent, "US DoD Security Options for the Internet
  977.              Protocol (IPSO)", RFC-1108, November 1991.
  978.  
  979.    [MS97]    Perry Metzger & W.A. Simpson, "The ESP DES-CBC Transform",
  980.              RFC-xxxx, August 1997.
  981.  
  982.    [NIST77]  US National Bureau of Standards, "Data Encryption
  983.              Standard", Federal Information Processing Standard (FIPS)
  984.              Publication 46, January 1977.
  985.  
  986.    [NIST80]  US National Bureau of Standards, "DES Modes of Operation"
  987.              Federal Information Processing Standard (FIPS) Publication
  988.              81, December 1980.
  989.  
  990.    [NIST81]  US National Bureau of Standards, "Guidelines for
  991.              Implementing and Using the Data Encryption Standard",
  992.              Federal Information Processing Standard (FIPS) Publication
  993.              74, April 1981.
  994.  
  995.    [NIST88]  US National Bureau of Standards, "Data Encryption
  996.              Standard", Federal Information Processing Standard (FIPS)
  997.              Publication 46-1, January 1988.
  998.  
  999.    [Riv92]   Ronald Rivest, "The MD5 Message Digest Algorithm," RFC-
  1000.              1321, April 1992.
  1001.  
  1002.    [SHA]     NIST, FIPS PUB 180-1: Secure Hash Standard, April 1995
  1003.  
  1004.    [STD-2]   J. Reynolds and J. Postel, "Assigned Numbers", STD-2, 20
  1005.  
  1006.  
  1007. Kent, Atkinson                                                 [Page 18]
  1008.  
  1009.  
  1010. Internet Draft              IP Encapsulating                21 July 1997
  1011.                          Security Payload (ESP)
  1012.  
  1013.  
  1014.              October 1994.
  1015.  
  1016.    [Sch94]   Bruce Schneier, Applied Cryptography, John Wiley & Sons,
  1017.              New York, NY, 1994. ISBN 0-471-59756-2
  1018.  
  1019.    [SDNS89]  SDNS Secure Data Network System, Security Protocol 3, SP3,
  1020.              Document SDN.301, Revision 1.5, 15 May 1989, as published
  1021.              in NIST Publication NIST-IR-90-4250, February 1990.
  1022.  
  1023.  
  1024. Disclaimer
  1025.  
  1026.    The views and specification here are those of the authors and are not
  1027.    necessarily those of their employers.  The authors and their
  1028.    employers specifically disclaim responsibility for any problems
  1029.    arising from correct or incorrect implementation or use of this
  1030.    specification.
  1031.  
  1032.  
  1033.  
  1034. Author Information
  1035.  
  1036.    Stephen Kent
  1037.    BBN Corporation
  1038.    70 Fawcett Street
  1039.    Cambridge, MA  02140
  1040.    USA
  1041.    E-mail: kent@bbn.com
  1042.    Telephone: +1 (617) 873-3988
  1043.  
  1044.    Randall Atkinson
  1045.    @Home Network
  1046.    385 Ravendale Drive
  1047.    Mountain View, CA 94043
  1048.    USA
  1049.    E-mail: rja@inet.org
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063. Kent, Atkinson                                                 [Page 19]
  1064.