document.) The SAD entry for the SA also indicates whether the
Sequence Number field will be checked, whether 32- or 64-bit sequence
numbers are employed for the SA, and whether the (explicit) ICV field
should be present (and if so, its size). Also, the SAD entry will
specify the algorithms and keys to be employed for decryption and ICV
computation (if applicable).
If no valid Security Association exists for this packet, the receiver
MUST discard the packet; this is an auditable event. The audit log
entry for this event SHOULD include the SPI value, date/time
received, Source Address, Destination Address, Sequence Number, and
(in IPv6) the cleartext Flow ID.
(Note that SA management traffic, such as IKE packets, does not need
to be processed based on SPI, i.e., one can demultiplex this traffic
separately based on Next Protocol and Port fields, for example.)
3.4.3. Sequence Number Verification
All ESP implementations MUST support the anti-replay service, though
its use may be enabled or disabled by the receiver on a per-SA basis.
This service MUST NOT be enabled unless the ESP integrity service
also is enabled for the SA, because otherwise the Sequence Number
field has not been integrity protected. Anti-replay is applicable to
unicast as well as multicast SAs. However, this standard specifies
no mechanisms for providing anti-replay for a multi-sender SA
(unicast or multicast). In the absence of negotiation (or manual
configuration) of an anti-replay mechanism for such an SA, it is
recommended that sender and receiver checking of the sequence number
for the SA be disabled (via negotiation or manual configuration), as
noted below.
If the receiver does not enable anti-replay for an SA, no inbound
checks are performed on the Sequence Number. However, from the
perspective of the sender, the default is to assume that anti-replay
is enabled at the receiver. To avoid having the sender do
unnecessary sequence number monitoring and SA setup (see section
3.3.3), if an SA establishment protocol is employed, the receiver
SHOULD notify the sender, during SA establishment, if the receiver
will not provide anti-replay protection.
If the receiver has enabled the anti-replay service for this SA, the
receive packet counter for the SA MUST be initialized to zero when
the SA is established. For each received packet, the receiver MUST
verify that the packet contains a Sequence Number that does not
duplicate the Sequence Number of any other packets received during
the life of this SA. This SHOULD be the first ESP check applied to a
packet after it has been matched to an SA, to speed rejection of
duplicate packets.
ESP permits two-stage verification of packet sequence numbers. This
capability is important whenever an ESP implementation (typically the
cryptographic module portion thereof) is not capable of performing
decryption and/or integrity checking at the same rate as the
interface(s) to unprotected networks. If the implementation is
capable of such "line rate" operation, then it is not necessary to
perform the preliminary verification stage described below.
The preliminary Sequence Number check is effected utilizing the
Sequence Number value in the ESP Header and is performed prior to
integrity checking and decryption. If this preliminary check fails,
the packet is discarded, thus avoiding the need for any cryptographic
operations by the receiver. If the preliminary check is successful,
the receiver cannot yet modify its local counter, because the
integrity of the Sequence Number has not been verified at this point.
Duplicates are rejected through the use of a sliding receive window.
How the window is implemented is a local matter, but the following
text describes the functionality that the implementation must
exhibit.
The "right" edge of the window represents the highest, validated
Sequence Number value received on this SA. Packets that contain
sequence numbers lower than the "left" edge of the window are
rejected. Packets falling within the window are checked against a
list of received packets within the window. If the ESN option is
selected for an SA, only the low-order 32 bits of the sequence number
are explicitly transmitted, but the receiver employs the full
sequence number computed using the high-order 32 bits for the
indicated SA (from his local counter) when checking the received
Sequence Number against the receive window. In constructing the full
sequence number, if the low-order 32 bits carried in the packet are
lower in value than the low-order 32 bits of the receiver’s sequence
number, the receiver assumes that the high-order 32 bits have been
incremented, moving to a new sequence number subspace. (This
algorithm accommodates gaps in reception for a single SA as large as
2**32-1 packets. If a larger gap occurs, additional, heuristic
checks for re-synchronization of the receiver sequence number counter
MAY be employed, as described in the Appendix.)
If the received packet falls within the window and is not a
duplicate, or if the packet is to the right of the window, and if a
separate integrity algorithm is employed, then the receiver proceeds
to integrity verification. If a combined mode algorithm is employed,
the integrity check is performed along with decryption. In either
case, if the integrity check fails, the receiver MUST discard the
received IP datagram as invalid; this is an auditable event. The
audit log entry for this event SHOULD include the SPI value,
date/time received, Source Address, Destination Address, the Sequence
Number, and (in IPv6) the Flow ID. The receive window is updated
only if the integrity verification succeeds. (If a combined mode
algorithm is being used, then the integrity protected Sequence Number
must also match the Sequence Number used for anti-replay protection.)
A minimum window size of 32 packets MUST be supported when 32-bit
sequence numbers are employed; a window size of 64 is preferred and
SHOULD be employed as the default. Another window size (larger than
the minimum) MAY be chosen by the receiver. (The receiver does NOT
notify the sender of the window size.) The receive window size
should be increased for higher-speed environments, irrespective of
assurance issues. Values for minimum and recommended receive window
sizes for very high-speed (e.g., multi-gigabit/second) devices are
not specified by this standard.
3.4.4. Integrity Check Value Verification
As with outbound processing, there are several options for inbound
processing, based on features of the algorithms employed.
3.4.4.1. Separate Confidentiality and Integrity Algorithms
If separate confidentiality and integrity algorithms are employed
processing proceeds as follows:
1. If integrity has been selected, the receiver computes the
ICV over the ESP packet minus the ICV, using the specified
integrity algorithm and verifies that it is the same as the
ICV carried in the packet. Details of the computation are
provided below.
If the computed and received ICVs match, then the datagram
is valid, and it is accepted. If the test fails, then the
receiver MUST discard the received IP datagram as invalid;
this is an auditable event. The log data SHOULD include the
SPI value, date/time received, Source Address, Destination
Address, the Sequence Number, and (for IPv6) the cleartext
Flow ID.
Implementation Note:
Implementations can use any set of steps that results in the
same result as the following set of steps. Begin by
removing and saving the ICV field. Next check the overall
length of the ESP packet minus the ICV field. If implicit
padding is required, based on the block size of the
integrity algorithm, append zero-filled bytes to the end of
the ESP packet directly after the Next Header field, or
after the high-order 32 bits of the sequence number if ESN
is selected. Perform the ICV computation and compare the
result with the saved value, using the comparison rules
defined by the algorithm specification.
2. The receiver decrypts the ESP Payload Data, Padding, Pad
Length, and Next Header using the key, encryption algorithm,
algorithm mode, and cryptographic synchronization data (if
any), indicated by the SA. As in Section 3.3.2, we speak
here in terms of encryption always being applied because of
the formatting implications. This is done with the
understanding that "no confidentiality" is offered by using
the NULL encryption algorithm (RFC 2410).
- If explicit cryptographic synchronization data, e.g.,
an IV, is indicated, it is taken from the Payload
field and input to the decryption algorithm as per
the algorithm specification.
- If implicit cryptographic synchronization data is
indicated, a local version of the IV is constructed
and input to the decryption algorithm as per the
algorithm specification.
3. The receiver processes any Padding as specified in the
encryption algorithm specification. If the default padding
scheme (see Section 2.4) has been employed, the receiver
SHOULD inspect the Padding field before removing the padding
prior to passing the decrypted data to the next layer.
4. The receiver checks the Next Header field. If the value is
"59" (no next header), the (dummy) packet is discarded
without further processing.
5. The receiver reconstructs the original IP datagram from:
- for transport mode -- outer IP header plus the
original next layer protocol information in the ESP
Payload field
- for tunnel mode -- the entire IP datagram in the ESP
Payload field.
The exact steps for reconstructing the original datagram
depend on the mode (transport or tunnel) and are described
in the Security Architecture document. At a minimum, in an
IPv6 context, the receiver SHOULD ensure that the decrypted
data is 8-byte aligned, to facilitate processing by the
protocol identified in the Next Header field. This
processing "discards" any (optional) TFC padding that has
been added for traffic flow confidentiality. (If present,
this will have been inserted after the IP datagram (or
transport-layer frame) and before the Padding field (see
Section 2.4).)
If integrity checking and encryption are performed in parallel,
integrity checking MUST be completed before the decrypted packet is
passed on for further processing. This order of processing
facilitates rapid detection and rejection of replayed or bogus
packets by the receiver, prior to decrypting the packet, hence
potentially reducing the impact of denial of service attacks.
Note: If the receiver performs decryption in parallel with integrity
checking, care must be taken to avoid possible race conditions with
regard to packet access and extraction of the decrypted packet.
3.4.4.2. Combined Confidentiality and Integrity Algorithms
If a combined confidentiality and integrity algorithm is employed,
then the receiver proceeds as follows:
1. Decrypts and integrity checks the ESP Payload Data, Padding,
Pad Length, and Next Header, using the key, algorithm,
algorithm mode, and cryptographic synchronization data (if
any), indicated by the SA. The SPI from the ESP header, and
the (receiver) packet counter value (adjusted as required
from the processing described in Section 3.4.3) are inputs
to this algorithm, as they are required for the integrity
check.
- If explicit cryptographic synchronization data, e.g.,
an IV, is indicated, it is taken from the Payload
field and input to the decryption algorithm as per
the algorithm specification.
- If implicit cryptographic synchronization data, e.g.,
an IV, is indicated, a local version of the IV is
constructed and input to the decryption algorithm as
per the algorithm specification.
2. If the integrity check performed by the combined mode
algorithm fails, the receiver MUST discard the received IP
datagram as invalid; this is an auditable event. The log
data SHOULD include the SPI value, date/time received,
Source Address, Destination Address, the Sequence Number,
and (in IPv6) the cleartext Flow ID.
3. Process any Padding as specified in the encryption algorithm
specification, if the algorithm has not already done so.
4. The receiver checks the Next Header field. If the value is
"59" (no next header), the (dummy) packet is discarded
without further processing.
5. Extract the original IP datagram (tunnel mode) or
transport-layer frame (transport mode) from the ESP Payload
Data field. This implicitly discards any (optional) padding
that has been added for traffic flow confidentiality. (If
present, the TFC padding will have been inserted after the
IP payload and before the Padding field (see Section 2.4).)
4. Auditing
Not all systems that implement ESP will implement auditing. However,
if ESP is incorporated into a system that supports auditing, then the
ESP implementation MUST also support auditing and MUST allow a system
administrator to enable or disable auditing for ESP. For the most
part, the granularity of auditing is a local matter. However,
several auditable events are identified in this specification and for
each of these events a minimum set of information that SHOULD be
included in an audit log is defined.
- No valid Security Association exists for a session. The
audit log entry for this event SHOULD include the SPI value,
date/time received, Source Address, Destination Address,
Sequence Number, and (for IPv6) the cleartext Flow ID.
- A packet offered to ESP for processing appears to be an IP
fragment, i.e., the OFFSET field is non-zero or the MORE
FRAGMENTS flag is set. The audit log entry for this event
SHOULD include the SPI value, date/time received, Source
Address, Destination Address, Sequence Number, and (in IPv6)
the Flow ID.
- Attempt to transmit a packet that would result in Sequence
Number overflow. The audit log entry for this event SHOULD
include the SPI value, current date/time, Source Address,
Destination Address, Sequence Number, and (for IPv6) the
cleartext Flow ID.
- The received packet fails the anti-replay checks. The audit
log entry for this event SHOULD include the SPI value,
date/time received, Source Address, Destination Address, the
Sequence Number, and (in IPv6) the Flow ID.
- The integrity check fails. The audit log entry for this
event SHOULD include the SPI value, date/time received,
Source Address, Destination Address, the Sequence Number, and
(for IPv6) the Flow ID.
Additional information also MAY be included in the audit log for each
of these events, and additional events, not explicitly called out in
this specification, also MAY result in audit log entries. There is
no requirement for the receiver to transmit any message to the
purported sender in response to the detection of an auditable event,
because of the potential to induce denial of service via such action.
5. Conformance Requirements
Implementations that claim conformance or compliance with this
specification MUST implement the ESP syntax and processing described
here for unicast traffic, and MUST comply with all additional packet
processing requirements levied by the Security Architecture document
[Ken-Arch]. Additionally, if an implementation claims to support
multicast traffic, it MUST comply with the additional requirements
specified for support of such traffic. If the key used to compute an
ICV is manually distributed, correct provision of the anti-replay
service requires correct maintenance of the counter state at the
sender (across local reboots, etc.), until the key is replaced, and
there likely would be no automated recovery provision if counter
overflow were imminent. Thus, a compliant implementation SHOULD NOT
provide anti-replay service in conjunction with SAs that are manually
keyed.
The mandatory-to-implement algorithms for use with ESP are described
in a separate document [Eas04], to facilitate updating the algorithm
requirements independently from the protocol per se. Additional
algorithms, beyond those mandated for ESP, MAY be supported.
Because use of encryption in ESP is optional, support for the "NULL"
encryption algorithm also is required to maintain consistency with
the way ESP services are negotiated. Support for the
confidentiality-only service version of ESP is optional. If an
implementation offers this service, it MUST also support the
negotiation of the "NULL" integrity algorithm. NOTE that although
integrity and encryption may each be "NULL" under the circumstances
noted above, they MUST NOT both be "NULL".
6. Security Considerations
Security is central to the design of this protocol, and thus security
considerations permeate the specification. Additional security-
relevant aspects of using the IPsec protocol are discussed in the
Security Architecture document.
7. Differences from RFC 2406
This document differs from RFC 2406 in a number of significant ways.
o Confidentiality-only service -- now a MAY, not a MUST.
o SPI -- modified to specify a uniform algorithm for SAD lookup
for unicast and multicast SAs, covering a wider range of
multicast technologies. For unicast, the SPI may be used
alone to select an SA, or may be combined with the protocol,
at the option of the receiver. For multicast SAs, the SPI is
combined with the destination address, and optionally the
source address, to select an SA.
o Extended Sequence Number -- added a new option for a 64-bit
sequence number for very high-speed communications. Clarified
sender and receiver processing requirements for multicast SAs
and multi-sender SAs.
o Payload data -- broadened model to accommodate combined mode
algorithms.
o Padding for improved traffic flow confidentiality -- added
requirement to be able to add bytes after the end of the IP
Payload, prior to the beginning of the Padding field.
o Next Header -- added requirement to be able to generate and
discard dummy padding packets (Next Header = 59)
o ICV -- broadened model to accommodate combined mode
algorithms.
o Algorithms -- Added combined confidentiality mode algorithms.
o Moved references to mandatory algorithms to a separate
document.
o Inbound and Outbound packet processing -- there are now two
paths: (1) separate confidentiality and integrity
algorithms and (2) combined confidentiality mode
algorithms. Because of the addition of combined mode
algorithms, the encryption/decryption and integrity sections
have been combined for both inbound and outbound packet
processing.
8. Backward-Compatibility Considerations
There is no version number in ESP and no mechanism enabling IPsec
peers to discover or negotiate which version of ESP each is using or
should use. This section discusses consequent backward-compatibility
issues.
First, if none of the new features available in ESP v3 are employed,
then the format of an ESP packet is identical in ESP v2 and v3. If a
combined mode encryption algorithm is employed, a feature supported
only in ESP v3, then the resulting packet format may differ from the
ESP v2 spec. However, a peer who implements only ESP v2 would never
negotiate such an algorithm, as they are defined for use only in the
ESP v3 context.
Extended Sequence Number (ESN) negotiation is supported by IKE v2 and
has been addressed for IKE v1 by the ESN Addendum to the IKE v1
Domain of Interpretation (DOI).
In the new ESP (v3), we make two provisions to better support traffic
flow confidentiality (TFC):
- arbitrary padding after the end of an IP packet
- a discard convention using Next Header = 59
The first feature is one that should not cause problems for a
receiver, since the IP total length field indicates where the IP
packet ends. Thus, any TFC padding bytes after the end of the packet
should be removed at some point during IP packet processing, after
ESP processing, even if the IPsec software does not remove such
padding. Thus, this is an ESP v3 feature that a sender can employ
irrespective of whether a receiver implements ESP v2 or ESP v3.
The second feature allows a sender to send a payload that is an
arbitrary string of bytes that do not necessarily constitute a well-
formed IP packet, inside of a tunnel, for TFC purposes. It is an
open question as to what an ESP v2 receiver will do when the Next
Header field in an ESP packet contains the value "59". It might
discard the packet when it finds an ill-formed IP header, and log
this event, but it certainly ought not to crash, because such
behavior would constitute a DoS vulnerability relative to traffic
received from authenticated peers. Thus this feature is an