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-oakley-02.txt < prev    next >
Text File  |  1997-07-25  |  106KB  |  2,828 lines

  1.  
  2. IPSEC Working Group                                          H. K. Orman
  3. INTERNET-DRAFT               Dept. of Computer Science, Univ. of Arizona
  4. draft-ietf-ipsec-oakley-02.txt
  5.  
  6.  
  7.                  The OAKLEY Key Determination Protocol
  8.  
  9.  
  10.               This document describes a protocol, named OAKLEY,
  11.       by which two authenticated parties can agree on secure and secret
  12.       keying material.  The basic mechanism is the Diffie-Hellman key
  13.       exchange algorithm.
  14.  
  15.       The OAKLEY protocol supports Perfect Forward Secrecy,
  16.       compatibility with the ISAKMP protocol for managing security
  17.       associations, user-defined abstract group structures for use with
  18.       the Diffie-Hellman algorithm, key updates, and incorporation of
  19.       keys distributed via out-of-band mechanisms.
  20.  
  21.  
  22.  
  23.  
  24. Status of this Memo
  25.  
  26.    This RFC is being distributed to members of the Internet community in
  27.    order to explain the basis for the Internet keying protocol.
  28.  
  29.  
  30.    Distribution of this memo is unlimited.
  31.  
  32.  
  33.  
  34. 1. INTRODUCTION
  35.  
  36.    Key establishment is the heart of data protection that relies on
  37.    cryptography, and it is an essential component of the packet
  38.    protection mechanisms described in [RFC1825], for example.  A
  39.    scalable and secure key distribution mechanism for the Internet is a
  40.    necessity.  The goal of this protocol is to provide that mechanism,
  41.    coupled with a great deal of cryptographic strength.
  42.  
  43.    The Diffie-Hellman key exchange algorithm provides such a mechanism.
  44.    It allows two parties to agree on a shared value without requiring
  45.    encryption.  The shared value is immediately available for use in
  46.    encrypting subsequent conversation, e.g. data transmission and/or
  47.    authentication.  The STS protocol [STS] provides a demonstration of
  48.    how to embed the algorithm in a secure protocol, one that ensures
  49.    that in addition to securely sharing a secret, the two parties can be
  50.    sure of each other's identities, even when an active attacker exists.
  51.  
  52.    Because OAKLEY is a generic key exchange protocol, and because the
  53.    keys that it generates might be used for encrypting data with a long
  54.    privacy lifetime, 20 years or more, it is important that the
  55.    algorithms underlying the protocol be able to ensure the security of
  56.    the keys for that period of time, based on the best prediction
  57.    capabilities available for seeing into the mathematical future.  The
  58.    protocol therefore has two options for adding to the difficulties
  59.    faced by an attacker who has a large amount of recorded key exchange
  60.    traffic at his disposal (a passive attacker).  These options are
  61.    useful for deriving keys which will be used for encryption.
  62.  
  63.    The OAKLEY protocol is related to STS, sharing the similarity of
  64.    authenticating the Diffie-Hellman exponentials and using them for
  65.    determining a shared key, and also of achieving Perfect Forward
  66.    Secrecy for the shared key, but it differs from the STS protocol in
  67.    several ways.
  68.  
  69.       mechanism ("cookies", described by Phil Karn in the Photuris key
  70.       exchange protocol draft) to help avoid denial of service attacks.
  71.  
  72.       The second extension is to allow the two parties to select
  73.       mutually agreeable supporting algorithms for the protocol: the
  74.       encryption method, the key derivation method, and the
  75.       authentication method.
  76.  
  77.       Thirdly, the authentication does not depend on encryption using
  78.       the Diffie-Hellman exponentials; instead, the authentication
  79.       validates the binding of the exponentials to the identities of the
  80.       parties.
  81.  
  82.       The protocol does not require the two parties compute the shared
  83.       exponentials prior to authentication.
  84.  
  85.       This protocol adds additional security to the derivation of keys
  86.       meant for use with encryption (as opposed to authentication) by
  87.       including a dependence on an additional algorithm.  The derivation
  88.       of keys for encryption is made to depend not only on the Diffie-
  89.       Hellman algorithm, but also on the cryptographic method used to
  90.       securely authenticate the communicating parties to each other.
  91.  
  92.       Finally, this protocol explicitly defines how the two parties can
  93.       select the mathematical structures (group representation and
  94.       operation) for performing the Diffie-Hellman algorithm; they can
  95.       use standard groups or define their own.  User-defined groups
  96.       provide an additional degree of long-term security.
  97.  
  98.  
  99.    OAKLEY has several options for distributing keys.  In addition to the
  100.    classic Diffie-Hellman exchange, this protocol can be used to derive
  101.    a new key from an existing key and to distribute an externally
  102.    derived key by encrypting it.
  103.  
  104.    The protocol allows two parties to use all or some of the anti-
  105.    clogging and perfect forward secrecy features.  It also permits the
  106.    use of authentication based on symmetric encryption or non-encryption
  107.    algorithms.  This flexibility is included in order to allow the
  108.    parties to use the features that are best suited to their security
  109.    and performance requirements.
  110.  
  111.    This document draws extensively in spirit and approach from the
  112.    Photuris draft by Karn and Simpson (and from discussions with the
  113.    authors), specifics of the ISAKMP draft by Schertler et al. the
  114.    ISAKMP protocol draft, and it was also influenced by papers by Paul
  115.    van Oorschot and Hugo Krawcyzk.
  116.  
  117. 2. The Protocol Outline
  118.  
  119.  
  120.  
  121.  
  122. 2.1  General Remarks
  123.  
  124.    The OAKLEY protocol is used to establish a shared key with an
  125.    assigned identifier and associated authenticated identities for the
  126.    two parties.  The name of the key can be used later to derive
  127.    security associations for the RFC1826 and RFC1827 protocols (AH and
  128.    ESP) or to achieve other network security goals.
  129.  
  130.    Each key is associated with algorithms that are used for
  131.    authentication, privacy, and one-way functions.  These are ancillary
  132.    algorithms for OAKLEY; their appearance in subsequent security
  133.    association definitions derived with other protocols is neither
  134.    required nor prohibited.
  135.  
  136.    The specification of the details of how to apply an algorithm to data
  137.    is called a transform.  This document does not supply the transform
  138.    definitions; they will be in separate RFC's.
  139.  
  140.    The anti-clogging tokens, or "cookies", provide a weak form of source
  141.    address identification for both parties; the cookie exchange can be
  142.    completed before they perform the computationally expensive part of
  143.    the protocol (large integer exponentiations).
  144.  
  145.    It is important to note that OAKLEY uses the cookies for two
  146.    purposes:  anti-clogging and key naming.  The two parties to the
  147.    protocol each contribute one cookie at the initiation of key
  148.    establishment; the pair of cookies becomes the key identifier
  149.    (KEYID), a reusable name for the keying material.  Because of this
  150.    dual role, we will use the notation for the concatenation of the
  151.    cookies ("COOKIE-I, COOKIE-R") interchangeably with the symbol
  152.    "KEYID".
  153.  
  154.    OAKLEY is designed to be a compatible component of the ISAKMP
  155.    protocol [ISAKMP], which runs over the UDP protocol using a well-
  156.    known port (see the RFC on port assignments, STD02-RFC-1700).  The
  157.    only technical requirement for the protocol environment is that the
  158.    underlying protocol stack must be able to supply the Internet address
  159.    of the remote party for each message.  Thus, OAKLEY could, in theory,
  160.    be used directly over the IP protocol or over UDP, if suitable
  161.    protocol or port number assignments were available.
  162.  
  163.    The machine running OAKLEY must provide a good random number
  164.    generator, as described in [RANDOM], as the source of random numbers
  165.    required in this protocol description.  Any mention of a "nonce"
  166.    implies that the nonce value is generated by such a generator.  The
  167.    same is true for "pseudorandom" values.
  168.  
  169. 2.2  Notation
  170.    The section describes the notation used in this document for message
  171.    sequences and content.
  172.  
  173. 2.2.1  Message descriptions
  174.  
  175.    The protocol exchanges below are written in an abbreviated notation
  176.    that is intended to convey the essential elements of the exchange in
  177.    a clear manner.  A brief guide to the notation follows.  The detailed
  178.    formats and assigned values are given in the appendices.
  179.  
  180.    In order to represent message exchanges succinctly, this document
  181.    uses an abbreviated notation that describes each message in terms of
  182.    its source and destination and relevant fields.
  183.  
  184.    Arrows ("->") indicate whether the message is sent from the initiator
  185.    to the responder, or vice versa ("<-").
  186.  
  187.    The fields in the message are named and comma separated.  The
  188.    protocol uses the convention that the first several fields constitute
  189.    a fixed header format for all messages.
  190.  
  191.    For example, consider a HYPOTHETICAL exchange of messages involving a
  192.    fixed format message, the four fixed fields being two "cookies", the
  193.    third field being a message type name, the fourth field being a
  194.    multi-precision integer representing a power of a number:
  195.  
  196.         Initiator                                       Responder
  197.             ->    Cookie-I, 0, OK_KEYX, g^x                    ->
  198.             <-    Cookie-R, Cookie-I, OK_KEYX, g^y            <-
  199.  
  200.    The notation describes a two message sequence.  The initiator begins
  201.    by sending a message with 4 fields to the responder; the first field
  202.    has the unspecified value "Cookie-I", second field has the numeric
  203.    value 0, the third field indicates the message type is OK_KEYX, the
  204.    fourth value is an abstract group element g to the x'th power.
  205.  
  206.    The second line indicates that the responder replies with value
  207.    "Cookie-R" in the first field, a copy of the "Cookie-I" value in the
  208.    second field, message type OK_KEYX, and the number g raised to the
  209.    y'th power.
  210.  
  211.    The value OK_KEYX is in capitals to indicate that it is a unique
  212.    constant (constants are defined in the appendices).
  213.  
  214.    Variable precision integers with length zero are null values for the
  215.    protocol.
  216.  
  217.    Sometimes the protocol will indicate that an entire payload (usually
  218.    the Key Exchange Payload) has null values.  The payload is still
  219.    present in the message, for the purpose of simplifying parsing.
  220.  
  221. 2.2.2 Guide to symbols
  222.  
  223.    Cookie-I and Cookie-R (or CKY-I and CKY-R) are 64-bit pseudo-random
  224.    numbers.  The generation method must ensure with high probability
  225.    that the numbers used for each IP remote address are unique over some
  226.    time period, such as one hour.
  227.  
  228.    KEYID is the concatenation of the initiator and responder cookies and
  229.    the domain of interpretation; it is the name of keying material.
  230.  
  231.    sKEYID is used to denote the keying material named by the KEYID.  It
  232.    is never transmitted, but it is used in various calculations
  233.    performed by the two parties.
  234.  
  235.    OK_KEYX and OK_NEWGRP are distinct message types.
  236.  
  237.    IDP is a bit indicating whether or not material after the encryption
  238.    boundary (see appendix B), is encrypted.  NIDP means not encrypted.
  239.  
  240.    g^x and g^y are encodings of group elements, where g is a special
  241.    group element indicated in the group description (see Appendix A) and
  242.    g^x indicates that element raised to the x'th power.  The type of the
  243.    encoding is either a variable precision integer or a pair of such
  244.    integers, as indicated in the group operation in the group
  245.    description.  Note that we will write g^xy as a short-hand for
  246.    g^(xy).  See Appendix F for references that describe implementing
  247.    large integer computations and the relationship between various group
  248.    definitions and basic arithmetic operations.
  249.  
  250.    EHAO is a list of encryption/hash/authentication choices.  Each item
  251.    is a pair of values: a class name and an algorithm name.
  252.  
  253.    EHAS is a set of three items selected from the EHAO list, one from
  254.    each of the classes for encryption, hash, authentication.
  255.  
  256.    GRP is a name (32-bit value) for the group and its relevant
  257.    parameters: the size of the integers, the arithmetic operation, and
  258.    the generator element.  There are a few pre-defined GRP's (for 768
  259.    bit modular exponentiation groups, 1024 bit modexp, 2048 bit modexp,
  260.    155-bit and 210-bit elliptic curves, see Appendix E), but
  261.    participants can share other group descriptions in a later protocol
  262.    stage (see the section NEW GROUP).  It is important to separate
  263.    notion of the GRP from the group descriptor (Appendix A); the former
  264.    is a name for the latter.
  265.  
  266.    The symbol vertical bar "|" is used to denote concatenation of bit
  267.    strings.  Fields are concatenated using their encoded form as they
  268.    appear in their payload.
  269.  
  270.    Ni and Nr are nonces selected by the initiator and responder,
  271.    respectively.
  272.  
  273.    ID(I) and ID(R) are the identities to be used in authenticating the
  274.    initiator and responder respectively.
  275.  
  276.    E{x}Ki indicates the encryption of x using the public key of the
  277.    initiator.  Encryption is done using the algorithm associated with
  278.    the authentication method; usually this will be RSA.
  279.  
  280.    S{x}Ki indicates the signature over x using the private key (signing
  281.    key) of the initiator.  Signing is done using the algorithm
  282.    associated with the authentication method; usually this will be RSA
  283.    or DSS.
  284.  
  285.    prf(a, b) denotes the result of applying pseudo-random function "a"
  286.    to data "b".  One may think of "a" as a key or as a value that
  287.    characterizes the function prf; in the latter case it is the index
  288.    into a family of functions.  Each function in the family provides a
  289.    "hash" or one-way mixing of the input.
  290.  
  291.    prf(0, b) denotes the application of a one-way function to data "b".
  292.    The similarity with the previous notation is deliberate and indicates
  293.    that a single algorithm, e.g. MD5, might will used for both purposes.
  294.    In the first case a "keyed" MD5 transform would be used with key "a";
  295.    in the second case the transform would have the fixed key value zero,
  296.    resulting in a one-way function.
  297.  
  298.    The term "transform" is used to refer to functions defined in
  299.    auxiliary RFC's.  The transform RFC's will be drawn from those
  300.    defined for IPSEC AH and ESP (see RFC1825 for the overall
  301.    architecture encompassing these protocols).
  302.  
  303.  
  304. 2.3 The Key Exchange Message Overview
  305.  
  306.  
  307.    The goal of key exchange processing is the secure establishment of
  308.    common keying information state in the two parties.  This state
  309.    information is a key name, secret keying material, the identification
  310.    of the two parties, and three algorithms for use during
  311.    authentication: encryption (for privacy of the identities of the two
  312.    parties), hashing (a pseudorandom function for protecting the
  313.    integrity of the messages and for authenticating message fields), and
  314.    authentication (the algorithm on which the mutual authentication of
  315.    the two parties is based).  The encodings and meanings for these
  316.    choices are presented in Appendix B.
  317.  
  318.    The main mode exchange has five optional features: stateless cookie
  319.    exchange, perfect forward secrecy for the keying material, secrecy
  320.    for the identities, perfect forward secrecy for identity secrecy, use
  321.    of signatures (for non-repudiation).  The two parties can use any
  322.    combination of these features.
  323.  
  324.    The general outline of processing is that the Initiator of the
  325.    exchange begins by specifying as much information as he wishes in his
  326.    first message.  The Responder replies, supplying as much information
  327.    as he wishes.  The two sides exchange messages, supplying more
  328.    information each time, until their requirements are satisfied.
  329.  
  330.    The choice of how much information to include in each message depends
  331.    on which options are desirable.  For example, if stateless cookies
  332.    are not a requirement, and identity secrecy and perfect forward
  333.    secrecy for the keying material are not requirements, and if non-
  334.    repudiatable signatures are acceptable, then the exchange can be
  335.    completed in three messages.
  336.  
  337.    Additional features may increase the number of roundtrips needed for
  338.    the keying material determination.
  339.  
  340.    ISAKMP provides fields for specifying the security association
  341.    parameters for use with the AH and ESP protocols.  These security
  342.    association payload types are specified in the ISAKMP draft; the
  343.    payload types can be protected with OAKLEY keying material and
  344.    algorithms, but this document does not discuss their use.
  345.  
  346.  
  347. 2.3.1 The Essential Key Exchange Message Fields
  348.  
  349.  
  350.    There are 12 fields in an OAKLEY key exchange message.  Not all the
  351.    fields are relevant in every message; if a field is not relevant it
  352.    can have a null value or not be present (no payload).
  353.  
  354.       CKY-I            originator cookie.
  355.       CKY-R            responder cookie.
  356.       MSGTYPE          for key exchange, will be ISA_KE&AUTH_REQ or ISA_KE&AUTH_REP;
  357.                        for new group definitions, will be ISA_NEW_GROUP_REQ
  358.                        or ISA_NEW_GROUP_REP
  359.       GRP              the name of the Diffie-Hellman group used for the exchange
  360.       g^x (or g^y)     variable length integer representing a power of
  361.                        group generator
  362.       EHAO or EHAS     encryption, hash, authentication functions, offered
  363.                        and selectedj, respectively
  364.       IDP              an indicator as to whether or not encryption with
  365.                        g^xy follows (perfect forward secrecy for ID's)
  366.       ID(I)            the identity for the Initiator
  367.       ID(R)            the identity for the Responder
  368.       Ni               nonce supplied by the Initiator
  369.       Nr               nonce supplied by the Responder
  370.  
  371.    The construction of the cookies is implementation dependent.  Phil
  372.    Karn has recommended making them the result of a one-way function
  373.    applied to a secret value (changed periodically), the local and
  374.    remote IP address, and the local and remote UDP port.  In this way,
  375.    the cookies remain stateless and expire periodically.  Note that with
  376.    OAKLEY, this would cause the KEYID's derived from the secret value to
  377.    also expire, necessitating the removal of any state information
  378.    associated with it.
  379.  
  380.    In order to support pre-distributed keys, we recommend that
  381.    implementations reserve some portion of their cookie space to
  382.    permanent keys.  The encoding of these depends only on the local
  383.    implementation.
  384.  
  385.    The encryption functions used with OAKLEY must be cryptographic
  386.    transforms which guarantee privacy and integrity for the message
  387.    data.  Merely using DES in CBC mode is not permissible.  The
  388.    MANDATORY and OPTIONAL transforms will include any that satisfy this
  389.    criteria and are defined for use with RFC1827 (ESP).
  390.  
  391.    The one-way (hash) functions used with OAKLEY must be cryptographic
  392.    transforms which can be used as either keyed hash (pseudo-random) or
  393.    non-keyed transforms.  The MANDATORY and OPTIONAL transforms will
  394.    include any that are defined for use with RFC1826 (AH).
  395.  
  396.    Where nonces are indicated, they will be variable precision integers
  397.    with an entropy value that matches the "strength" attribute of the
  398.    GRP used with the exchange.  If no GRP is indicated, the nonces must
  399.    be at least 90 bits long.  The pseudo-random generator for the nonce
  400.    material should start with initial data that has at least 90 bits of
  401.    entropy; see RFC1750.
  402.  
  403. 2.3.1.1 Exponent Advice
  404.  
  405.    Ideally, the exponents will have at least 180 bits of entropy for
  406.    every key exchange.  This ensures complete independence of keying
  407.    material between two exchanges (note that this applies if only one of
  408.    the parties chooses a random exponent).  In practice, implementors
  409.    may wish to base several key exchanges on a single base value with
  410.    180 bits of entropy and use one-way hash functions to guarantee that
  411.    exposure of one key will not compromise others.  In this case, a good
  412.    recommendation is to keep the base values for nonces and cookies
  413.    separate from the base value for exponents, and to replace the base
  414.    value with a full 180 bits of entropy as frequently as possible.
  415.  
  416.    The values 0 and p-1 should not be used as exponent values;
  417.    implementors should be sure to check for these values, and they
  418.    should also refuse to accept the values 1 and p-1 from remote parties
  419.    (where p is the prime used to define a modular exponentiation group).
  420.  
  421.  
  422. 2.3.2 Mapping to ISAKMP Message Structures
  423.  
  424.  
  425.    All the OAKLEY message fields correspond to ISAKMP message payloads
  426.    or payload components.  The relevant payload fields are the SA
  427.    payload, the AUTH payload, the Certificate Payload, the Key Exchange
  428.    Payload.  The ISAKMP protocol framwork is a work in progress at this
  429.    time, and the exact mapping of Oakley message fields to ISAKMP
  430.    payloads is also in progress (to be known as the Resolution
  431.    document).
  432.  
  433.    Some of the ISAKMP header and payload fields will have constant
  434.    values when used with OAKLEY.  The exact values to be used will be
  435.    published in a Domain of Interpretation document accompanying the
  436.    Resolution document.
  437.  
  438.    In the following we indicate where each OAKLEY field appears in the
  439.    ISAKMP message structure.  These are recommended only; the Resolution
  440.    document will be the final authority on this mapping.
  441.       CKY-I            ISAKMP header
  442.       CKY-R            ISAKMP header
  443.       MSGTYPE          Message Type in ISAKMP header
  444.       GRP              SA payload, Proposal section
  445.       g^x (or g^y)     Key Exchange Payload, encoded as a variable precision integer
  446.       EHAO and EHAS    SA payload, Proposal section
  447.       IDP              A bit in the RESERVED field in the AUTH header
  448.       ID(I)            AUTH payload, Identity field
  449.       ID(R)            AUTH payload, Identity field
  450.       Ni               AUTH payload, Nonce Field
  451.       Nr               AUTH payload, Nonce Field
  452.       S{...}Kx         AUTH payload, Data Field
  453.       prf{K,...}       AUTH payload, Data Field
  454.  
  455.  
  456. 2.4 The Key Exchange Protocol
  457.  
  458.    The exact number and content of messages exchanged during an OAKLEY
  459.    key exchange depends on which options the Initiator and Responder
  460.    want to use.  A key exchange can be completed with three or more
  461.    messages, depending on those options.
  462.  
  463.    The three components of the key determination protocol are the
  464.       1. cookie exchange (optionally stateless)
  465.       2. Diffie-Hellman half-key exchange (optional, but essential for
  466.          perfect forward secrecy)
  467.       3. authentication (options: privacy for ID's, privacy for ID's with PFS,
  468.          non-repudiatable)
  469.  
  470.    The initiator can supply as little information as a bare exchange
  471.    request, carrying no additional information.  On the other hand the
  472.    initiator can begin by supplying all of the information necessary for
  473.    the responder to authenticate the request and complete the key
  474.    determination quickly, if the responder chooses to accept this
  475.    method.  If not, the responder can reply with a minimal amount of
  476.    information (at the minimum, a cookie).
  477.  
  478.    The method of authentication can be digital signatures, public key
  479.    encryption, or an out-of-band symmetric key.  The three different
  480.    methods lead to slight variations in the messages, and the variations
  481.    are illustrated by examples in this section.
  482.  
  483.    The Initiator is responsible for retransmitting messages if the
  484.    protocol does not terminate in a timely fashion.  The Responder must
  485.    therefore avoid discarding reply information until it is acknowledged
  486.    by Initiator in the course of continuing the protocol.
  487.  
  488.    The remainder of this section contains examples demonstrating how to
  489.    use OAKLEY options.
  490.  
  491. 2.4.1 An Aggressive Example
  492.  
  493.  
  494.    The following example indicates how two parties can complete a key
  495.    exchange in three messages.  The identities are not secret, the
  496.    derived keying material is protected by PFS.
  497.  
  498.    By using digital signatures, the two parties will have a proof of
  499.    communication that can be recorded and presented later to a third
  500.    party.
  501.  
  502.    The keying material implied by the group exponentials is not needed
  503.    for completing the exchange.  If it is desirable to defer the
  504.    computation, the implementation can save the "x" and "g^y" values and
  505.    mark the keying material as "uncomputed".  It can be computed from
  506.    this information later.
  507.  
  508.  
  509.    Initiator                                                   Responder
  510.    ---------                                                   ---------
  511.      -> CKY-I, 0,     OK_KEYX, GRP, g^x, EHAO, NIDP,               ->
  512.         ID(I), ID(R), Ni, 0,
  513.         S{ID(I) | ID(R) | Ni | 0 | GRP | g^x | 0 | EHAO}Ki
  514.     <-  CKY-R, CKY-I, OK_KEYX, GRP, g^y, EHAS, NIDP,
  515.         ID(R), ID(I), Nr, Ni,
  516.         S{ID(R) | ID(I) | Nr | Ni | GRP | g^y | g^x | EHAS}Kr            <-
  517.      -> CKY-I, CKY-R, OK_KEYX, GRP, g^x, EHAS, NIDP,                ->
  518.         ID(I), ID(R), Ni, Nr,
  519.         S{ID(I) | ID(R) | Ni | Nr | GRP | g^x | g^y | EHAS}Ki
  520.  
  521.    NB "NIDP" means that the PFS option for hiding identities is not used.
  522.       i.e., the identities are not encrypted using a key based on g^xy
  523.  
  524.    NB Fields are shown separated by commas in this document; they are concatenated
  525.    in the actual protocol messages using their encoded forms as
  526.    specified in the ISAKMP/Oakley Resolution document.
  527.  
  528.    The result of this exchange is a key with KEYID = CKY-I|CKY-R and
  529.    value
  530.  
  531.    sKEYID = prf(Ni | Nr, g^xy | CKY-I | CKY-R).
  532.  
  533.    The processing outline for this exchange is as follows:
  534.  
  535.    Initiation
  536.  
  537.       The Initiator generates a unique cookie and associates it with the
  538.       expected IP address of the responder, and its chosen state
  539.       information: GRP (the group identifier), a pseudo-randomly
  540.       selected exponent x, g^x, EHAO list, nonce, identities.  The first
  541.       authentication choice in the EHAO list is an algorithm that
  542.       supports digital signatures, and this is used to sign the ID's and
  543.       the nonce and group id.  The initiator further
  544.  
  545.       notes that the key is in the initial state of "unauthenticated",
  546.       and
  547.  
  548.       sets a timer for possible retransmission and/or termination of the
  549.       request.
  550.  
  551.    When the Responder receives the message, he may choose to ignore all
  552.    the information and treat it as merely a request for a cookie,
  553.    creating no state.  If CKY-I is not already in use by the source
  554.    address in the IP header, the responder generates a unique cookie,
  555.    CKY-R.  The next steps depend on the Responder's preferences.  The
  556.    minimal required response is to reply with the first cookie field set
  557.    to zero and CKY-R in the second field.  For this example we will
  558.    assume that the responder is more aggressive (for the alternatives,
  559.    see section 6) and accepts the following:
  560.       group with identifier GRP,
  561.       first authentication choice (which must be the digital signature
  562.       method
  563.       used to sign the Initiator message),
  564.       lack of perfect forward secrecy for protecting the identities,
  565.       identity ID(I) and identity ID(R)
  566.  
  567.    In this example the Responder decides to accept all the information
  568.    offered by the initiator.  It validates the signature over the signed
  569.    portion of the message, and associate the pair (CKY-I, CKY-R) with
  570.    the following state information:
  571.  
  572.    the source and destination network addresses of the message
  573.  
  574.    key state of "unauthenticated"
  575.  
  576.    the first algorithm from the authentication offer
  577.  
  578.    group GRP, a "y" exponent value in group GRP, and g^x from the
  579.    message
  580.  
  581.    the nonce Ni and a pseudorandomly selected value Nr
  582.  
  583.    a timer for possible destruction of the state.
  584.  
  585.    The Responder computes g^y, forms the reply message, and then signs
  586.    the ID and nonce information with the private key of ID(R) and sends
  587.    it to the Initiator.  In all exchanges, each party should make sure
  588.    that he neither offers nor accepts 1 or g^(p-1) as an exponential.
  589.  
  590.    In this example, to expedite the protocol, the Responder implicitly
  591.    accepts the first algorithm in the Authentication class of the EHAO
  592.    list.  This because he cannot validate the Initiator signature
  593.    without accepting the algorithm for doing the signature.  The
  594.    Responder's EHAS list will also reflect his acceptance.
  595.  
  596.    The Initiator receives the reply message and
  597.       validates that CKY-I is a valid association for the network
  598.       address of the incoming message,
  599.  
  600.       adds the CKY-R value to the state for the pair (CKY-I, network
  601.       address), and associates all state information with the pair
  602.       (CKY-I, CKY-R),
  603.  
  604.       validates the signature of the responder over the state
  605.       information (should validation fail, the message is discarded)
  606.  
  607.       adds g^y to its state information,
  608.  
  609.       saves the EHA selections in the state,
  610.  
  611.       optionally computes (g^y)^x (= g^xy) (this can be deferred until
  612.       after sending the reply message),
  613.  
  614.       sends the reply message, signed with the public key of ID(I),
  615.  
  616.       marks the KEYID (CKY-I|CKY-R) as authenticated,
  617.  
  618.       and composes the reply message and signature.
  619.  
  620.  
  621.    When the Responder receives the Initiator message, and if the
  622.    signature is valid, it marks the key as being in the authenticated
  623.    state.  It should compute g^xy and associate it with the KEYID.
  624.  
  625.    Note that although PFS for identity protection is not used, PFS for
  626.    the derived keying material is still present because the Diffie-
  627.    Hellman half-keys g^x and g^y are exchanged.
  628.  
  629.    Even if the Responder only accepts some of the Initiator information,
  630.    the Initiator will consider the protocol to be progressing.  The
  631.    Initiator should assume that fields that were not accepted by the
  632.    Responder were not recorded by the Responder.
  633.  
  634.    If the Responder does not accept the aggressive exchange and selects
  635.    another algorithm for the A function, then the protocol will not
  636.    continue using the signature algorithm or the signature value from
  637.    the first message.
  638.  
  639. 2.4.1.1 Fields Not Present
  640.  
  641.    If the Responder does not accept all the fields offered by the
  642.    Initiator, he should include null values for those fields in his
  643.    response.  Section 6 has guidelines on how to select fields in a
  644.    "left-to-right" manner.  If a field is not accepted, then it and all
  645.    following fields must have null values.
  646.  
  647.    The Responder should not record any information that it does not
  648.    accept.  If the ID's and nonces have null values, there will not be a
  649.    signature over these null values.
  650.  
  651. 2.4.1.2 Signature via Pseudo-Random Functions
  652.  
  653.  
  654.    The aggressive example is written to suggest that public key
  655.    technology is used for the signatures.  However, a pseudorandom
  656.    function can be used, if the parties have previously agreed to such a
  657.    scheme and have a shared key.
  658.  
  659.    If the first proposal in the EHAO list is an "existing key" method,
  660.    then the KEYID named in that proposal will supply the keying material
  661.    for the "signature" which is computed using the "H" algorithm
  662.    associated with the KEYID.
  663.  
  664.    Suppose the first proposal in EHAO is
  665.               EXISTING-KEY, 32
  666.    and the "H" algorithm for KEYID 32 is MD5-HMAC, by prior negotiation.
  667.    The keying material is some string of bits, call it sK32.  Then in
  668.    the first message in the aggressive exchange, where the signature
  669.  
  670.            S{ID(I), ID(R), Ni, 0, GRP, g^x, EHAO}Ki
  671.  
  672.    is indicated, the signature computation would be performed by
  673.        MD5-HMAC_func(KEY=sK32, DATA = ID(I) | ID(R) | Ni | 0 | GRP | g^x
  674.       | g^y | EHAO)
  675.    (The exact definition of the algorithm corresponding to "MD5-HMAC-
  676.    func" will appear in the RFC defining that transform).
  677.  
  678.    The result of this computation appears in the Authentication payload.
  679.  
  680. 2.4.2 An Aggressive Example With Hidden Identities
  681.  
  682.  
  683.    The following example indicates how two parties can complete a key
  684.    exchange without using digital signatures.  Public key cryptography
  685.    hides the identities during authentication.  The group exponentials
  686.    are exchanged and authenticated, but the implied keying material
  687.    (g^xy) is not needed during the exchange.
  688.  
  689.    This exchange has an important difference from the previous signature
  690.    scheme --- in the first message, an identity for the responder is
  691.    indicated as cleartext: ID(R').  However, the identity hidden with
  692.    the public key cryptography is different: ID(R).  This happens
  693.    because the Initiator must somehow tell the Responder which
  694.    public/private key pair to use for the decryption, but at the same
  695.    time, the identity is hidden by encryption with that public key.
  696.  
  697.    The Initiator might elect to forgo secrecy of the Responder identity,
  698.    but this is undesirable.  Instead, if there is a well-known identity
  699.    for the Responder node, the public key for that identity can be used
  700.    to encrypt the actual Responder identity.
  701.  
  702.  
  703.    Initiator                                                   Responder
  704.    ---------                                                   ---------
  705.      -> CKY-I, 0,     OK_KEYX, GRP, g^x, EHAO, NIDP,                ->
  706.         ID(R'), E{ID(I), ID(R), E{Ni}Kr}Kr'
  707.     <-  CKY-R, CKY-I, OK_KEYX, GRP, g^y, EHAS, NIDP,
  708.         E{ID(R), ID(I), Nr}Ki,
  709.         prf(Kir, ID(R) | ID(I) | GRP | g^y | g^x | EHAS) <-
  710.      -> CKY-I, CKY-R, OK_KEYX, GRP, 0, 0, NIDP,
  711.         prf(Kir, ID(I) | ID(R) | GRP | g^x | g^y | EHAS)    ->
  712.  
  713.    Kir = prf(0, Ni | Nr)
  714.  
  715.    NB "NIDP" means that the PFS option for hiding identities is not used.
  716.  
  717.    NB  The ID(R') value is included in the Authentication payload as
  718.        described in Appendix B.
  719.  
  720.  
  721.    The result of this exchange is a key with KEYID = CKY-I|CKY-R and
  722.    value sKEYID = prf(Ni | Nr, g^xy | CKY-I | CKY-R).
  723.  
  724.    The processing outline for this exchange is as follows:
  725.  
  726.    Initiation
  727.       The Initiator generates a unique cookie and associates it with the
  728.       expected IP address of the responder, and its chosen state
  729.       information: GRP, g^x, EHAO list.  The first authentication choice
  730.       in the EHAO list is an algorithm that supports public key
  731.       encryption.  The Initiator also names the two identities to be
  732.       used for the connection and enters these into the state.  A well-
  733.       known identity for the responder machine is also chosen, and the
  734.       public key for this identity is used to encrypt the nonce Ni and
  735.       the two connection identities.  The Initiator further
  736.  
  737.       notes that the key is in the initial state of "unauthenticated",
  738.       and
  739.  
  740.       sets a timer for possible retransmission and/or termination of the
  741.       request.
  742.  
  743.    When the Responder receives the message, he may choose to ignore all
  744.    the information and treat it as merely a request for a cookie,
  745.    creating no state.
  746.  
  747.    If CKY-I is not already in use by the source address in the IP
  748.    header, the Responder generates a unique cookie, CKY-R.  As before,
  749.    the next steps depend on the responder's preferences.  The minimal
  750.    required response is a message with the first cookie field set to
  751.    zero and CKY-R in the second field.  For this example we will assume
  752.    that responder is more aggressive and accepts the following:
  753.       group GRP, first authentication choice (which must be the public key
  754.       encryption algorithm used to encrypt the payload), lack of perfect
  755.       forward secrecy for protecting the identities, identity ID(I),
  756.       identity ID(R)
  757.  
  758.    The Responder must decrypt the ID and nonce information, using the
  759.    private key for the R' ID.  After this, the private key for the R ID
  760.    will be used to decrypt the nonce field.
  761.  
  762.    The Responder now associates the pair (CKY-I, CKY-R) with the
  763.    following state information:
  764.  
  765.    the source and destination network addresses of the message
  766.  
  767.    key state of "unauthenticated"
  768.  
  769.    the first algorithm from each class in the EHAO (encryption-hash-
  770.    authentication algorithm offers) list
  771.  
  772.    group GRP and a y and g^y value in group GRP
  773.  
  774.    the nonce Ni and a pseudorandomly selected value Nr
  775.  
  776.    a timer for possible destruction of the state.
  777.  
  778.    The Responder then encrypts the state information with the public key
  779.    of ID(I), forms the prf value, and sends it to the Initiator.
  780.  
  781.    The Initiator receives the reply message and
  782.       validates that CKY-I is a valid association for the network
  783.       address of the incoming message,
  784.  
  785.       adds the CKY-R value to the state for the pair (CKY-I, network
  786.       address), and associates all state information with the pair
  787.       (CKY-I, CKY-R),
  788.  
  789.       decrypts the ID and nonce information
  790.  
  791.       checks the prf calculation (should this fail, the message is
  792.       discarded)
  793.  
  794.       adds g^y to its state information,
  795.  
  796.       saves the EHA selections in the state,
  797.  
  798.       optionally computes (g^x)^y (= g^xy) (this may be deferred), and
  799.  
  800.       sends the reply message, encrypted with the public key of ID(R),
  801.  
  802.       and marks the KEYID (CKY-I|CKY-R) as authenticated.
  803.  
  804.    When the Responder receives this message, it marks the key as being
  805.    in the authenticated state.  If it has not already done so, it should
  806.    compute g^xy and associate it with the KEYID.
  807.  
  808.    The secret keying material sKEYID = prf(Ni | Nr,  g^xy | CKY-I |
  809.    CKY-R)
  810.  
  811.    Note that although PFS for identity protection is not used, PFS for
  812.    the derived keying material is still present because the Diffie-
  813.    Hellman half-keys g^x and g^y are exchanged.
  814.  
  815. 2.4.3 An Aggressive Example With Private Identities and Without Diffie-
  816. Hellman
  817.  
  818.  
  819.    Considerable computational expense can be avoided if perfect forward
  820.    secrecy is not a requirement for the session key derivation.  The two
  821.    parties can exchange nonces and secret key parts to achieve the
  822.    authentication and derive keying material.  The long-term privacy of
  823.    data protected with derived keying material is dependent on the
  824.    private keys of each of the parties.
  825.  
  826.    In this exchange, the GRP has the value 0 and the field for the group
  827.    exponential is used to hold a nonce value instead.
  828.  
  829.    As in the previous section, the first proposed algorithm must be a
  830.    public key encryption system; by responding with a cookie and a non-
  831.    zero exponential field, the Responder implicitly accepts the first
  832.    proposal and the lack of perfect forward secrecy for the identities
  833.    and derived keying material.
  834.  
  835.  
  836.    Initiator                                                   Responder
  837.    ---------                                                   ---------
  838.      -> CKY-I, 0,     OK_KEYX, 0, 0, EHAO, NIDP,                  ->
  839.         ID(R'), E{ID(I), ID(R), sKi}Kr', Ni
  840.     <-  CKY-R, CKY-I, OK_KEYX, 0, 0, EHAS, NIDP,
  841.         E{ID(R), ID(I), sKr}Ki, Nr,
  842.         prf(Kir, ID(R) | ID(I) | Nr | Ni | EHAS)                 <-
  843.      -> CKY-I, CKY-R, OK_KEYX, EHAS, NIDP,
  844.         prf(Kir, ID(I) | ID(R) | Ni | Nr | EHAS)                  ->
  845.  
  846.    Kir = prf(0, sKi | sKr)
  847.  
  848.    NB  The sKi and sKr values go into the nonce fields.  The change in
  849.    notation is meant to emphasize that their entropy is critical to setting
  850.    the keying material.
  851.  
  852.    NB "NIDP" means that the PFS option for hiding identities is not used.
  853.  
  854.  
  855.    The result of this exchange is a key with KEYID = CKY-I|CKY-R and
  856.    value sKEYID = prf(Kir, CKY-I | CKY-R).
  857.  
  858. 2.4.3 A Conservative Example
  859.  
  860.  
  861.    In this example the two parties are minimally aggressive; they use
  862.    the cookie exchange to delay creation of state, and they use perfect
  863.    forward secrecy to protect the identities.  For this example, they
  864.    use public key encryption for authentication; digital signatures or
  865.    pre-shared keys can also be used, as illustrated previously.  The
  866.    conservative example here does not change the use of nonces, prf's,
  867.    etc., but it does change how much information is transmitted in each
  868.    message.
  869.  
  870.    The responder considers the ability of the initiator to repeat CKY-R
  871.    as weak evidence that the message originates from a "live"
  872.    correspondent on the network and the correspondent is associated with
  873.    the initiator's network address.  The initiator makes similar
  874.    assumptions when CKY-I is repeated to the initiator.
  875.  
  876.    All messages must have either valid cookies or at least one zero
  877.    cookie. If both cookies are zero, this indicates a request for a
  878.    cookie; if only the initiator cookie is zero, it is a response to a
  879.    cookie request.
  880.  
  881.    Information in messages violating the cookie rules cannot be used for
  882.    any OAKLEY operations.
  883.  
  884.    Note that the Initiator and Responder must agree on one set of EHA
  885.    algorithms; there is not one set for the Responder and one for the
  886.    Initiator.  The Initiator must include at least MD5 and DES in the
  887.    initial offer.
  888.  
  889.    Fields not indicated have null values.
  890.  
  891.    Initiator                                                   Responder
  892.    ---------                                                   ---------
  893.      ->     0, 0, OK_KEYX                                          ->
  894.     <-      0, CKY-R, OK_KEYX                                     <-
  895.      ->     CKY-I, CKY-R, OK_KEYX, GRP, g^x, EHAO                  ->
  896.     <-      CKY-R, CKY-I, OK_KEYX, GRP, g^y, EHAS                 <-
  897.      ->     CKY-I, CKY-R, OK_KEYX, GRP, g^x, IDP*,
  898.             ID(I), ID(R), E{Ni}Kr,                                 ->
  899.     <-      CKY-R, CKY-I, OK_KEYX, GRP, 0  , 0, IDP,              <-
  900.             E{Nr, Ni}Ki, ID(R), ID(I),
  901.             prf(Kir, ID(R) | ID(I) | GRP | g^y | g^x | EHAS )
  902.      ->     CKY-I, CKY-R, OK_KEYX, GRP, 0  , 0, IDP,
  903.             prf(Kir, ID(I) | ID(R) | GRP | g^x | g^y | EHAS ) ->
  904.  
  905.    Kir = prf(0, Ni | Nr)
  906.  
  907.    * when IDP is in effect, authentication payloads are encrypted with
  908.      the selected encryption algorithm using the keying material prf(0, g^xy).
  909.      (The transform defining the encryption algorithm will define
  910.      how to select key bits from the keying material.)
  911.      This encryption is in addition to and after any  public key encryption.
  912.      See Appendix B.
  913.  
  914.      Note that in the first messages, several fields are omitted from the
  915.      description.  These fields are present as null values.
  916.  
  917.    The first exchange allows the Responder to use stateless cookies; if
  918.    the responder generates cookies in a manner that allows him to
  919.    validate them without saving them, as in Photuris, then this is
  920.    possible.  Even if the Initiator includes a cookie in his initial
  921.    request, the responder can still use stateless cookies by merely
  922.    omitting the CKY-I from his reply and by declining to record the
  923.    Initiator cookie until it appears in a later message.
  924.  
  925.    After the exchange is complete, both parties compute the shared key
  926.    material sKEYID as
  927.    prf(Ni | Nr, g^xy | CKY-I | CKY-R)
  928.    where "prf" is the pseudo-random function in class "hash" selected in
  929.    the EHA list.
  930.  
  931.    As with the cookies, each party considers the ability of the remote
  932.    side to repeat the Ni or Nr value as a proof that Ka, the public key
  933.    of party a, speaks for the remote party and establishes its identity.
  934.  
  935.    In analyzing this exchange, it is important to note that although the
  936.    IDP option ensures that the identities are protected with an
  937.    ephemeral key g^xy, the authentication itself does not depend on
  938.    g^xy.  It is essential that the authentication steps validate the g^x
  939.    and g^y values, and it is thus imperative that the authentication not
  940.    involve a circular dependency on them.  A third party could intervene
  941.    with a "man-in-middle" scheme to convince the initiator and responder
  942.    to use different g^xy values; although such an attack might result in
  943.    revealing the identities to the eavesdropper, the authentication
  944.    would fail.
  945.  
  946. 2.4.4 Extra Strength for Protection of Encryption Keys
  947.  
  948.  
  949.    The nonces Ni and Nr are used to provide an extra dimension of
  950.    secrecy in deriving session keys.  This makes the secrecy of the key
  951.    depend on two different problems: the discrete logarithm problem in
  952.    the group G, and the problem of breaking the nonce encryption scheme.
  953.    If RSA encryption is used, then this second problem is roughly
  954.    equivalent to factoring the RSA public keys of both the initiator and
  955.    responder.
  956.  
  957.    For authentication, the key type, the validation method, and the
  958.    certification requirement must be indicated.
  959.  
  960.  
  961.    2.5 Identity and Authentication
  962.  
  963.    2.5.1 Identity
  964.  
  965.    In OAKLEY exchanges the Initiator offers Initiator and Responder ID's
  966.    -- the former is the claimed identity for the Initiator, and the
  967.    latter is the requested ID for the Responder.
  968.  
  969.    If neither ID is specified, the ID's are taken from the IP header
  970.    source and destination addresses.
  971.  
  972.    If the Initiator doesn't supply a responder ID, the Responder can
  973.    reply by naming any identity that the local policy allows.  The
  974.    Initiator can refuse acceptance by terminating the exchange.
  975.  
  976.    The Responder can also reply with a different ID than the Initiator
  977.    suggested; the Initiator can accept this implicitly by continuing the
  978.    exchange or refuse it by terminating (not replying).
  979.  
  980.    2.5.2 Authentication
  981.  
  982.    The authentication of principals to one another is at the heart of
  983.    any key exchange scheme.  The Internet community must decide on a
  984.    scalable standard for solving this problem, and OAKLEY must make use
  985.    of that standard.  At the time of this writing, there is no such
  986.    standard, though several are emerging.  This document attempts to
  987.    describe how a handful of standards could be incorporated into
  988.    OAKLEY, without attempting to pick and choose among them.
  989.  
  990.    The following methods can appear in OAKLEY offers:
  991.  
  992.    a. Pre-shared Keys
  993.       When two parties have arranged for a trusted method of
  994.       distributing secret keys for their mutual authentication, they can
  995.       be used for authentication.  This has obvious scaling problems for
  996.       large systems, but it is an acceptable interim solution for some
  997.       situations.  Support for pre-shared keys is REQUIRED.
  998.  
  999.       The encryption, hash, and authentication algorithm for use with a
  1000.       pre-shared key must be part of the state information distributed
  1001.       with the key itself.
  1002.  
  1003.       The pre-shared keys have a KEYID and keying material sKEYID; the
  1004.       KEYID is used in a pre-shared key authentication option offer.
  1005.       There can be more than one pre-shared key offer in a list.
  1006.  
  1007.       Because the KEYID persists over different invocations of OAKLEY
  1008.       (after a crash, etc.), it must occupy a reserved part of the KEYID
  1009.       space for the two parties.  A few bits can be set aside in each
  1010.       party's "cookie space" to accommodate this.
  1011.  
  1012.       There is no certification authority for pre-shared keys.  When a
  1013.       pre-shared key is used to generate an authentication payload, the
  1014.       certification authority is "None", the Authentication Type is
  1015.       "Preshared", and the payload contains
  1016.          the KEYID, encoded as two 64-bit quantities, and
  1017.  
  1018.          the result of applying the pseudorandom hash function to the
  1019.          message body with the sKEYID forming the key for the function
  1020.  
  1021.  
  1022.  
  1023.    b. DNS public keys
  1024.       Security extensions to the DNS protocol [DNSSEC] provide a
  1025.       convenient way to access public key information, especially for
  1026.       public keys associated with hosts.  RSA keys are a requirement for
  1027.       secure DNS implementations; extensions to allow optional DSS keys
  1028.       are a near-term possibility.
  1029.  
  1030.       DNS KEY records have associated SIG records that are signed by a
  1031.       zone authority, and a hierarchy of signatures back to the root
  1032.       server establishes a foundation for trust.  The SIG records
  1033.       indicate the algorithm used for forming the signature.
  1034.  
  1035.       OAKLEY implementations MUST support the use of DNS KEY and SIG
  1036.       records for authenticating with respect to IPv4 and IPv6 addresses
  1037.       and fully qualified domain names.  However, implementations are
  1038.       not required to support any particular algorithm (RSA, DSS, etc.).
  1039.  
  1040.  
  1041.    c. RSA public keys w/o certification authority signature
  1042.       PGP [Zimmerman] uses public keys with an informal method for
  1043.       establishing trust.  The format of PGP public keys and naming
  1044.       methods will be described in a separate RFC.  The RSA algorithm
  1045.       can be used with PGP keys for either signing or encryption; the
  1046.       authentication option should indicate either RSA-SIG or RSA-ENC,
  1047.       respectively.  Support for this is OPTIONAL.
  1048.  
  1049.    d.1 RSA public keys w/ certificates
  1050.       There are various formats and naming conventions for public keys
  1051.       that are signed by one or more certification authorities.  The
  1052.       Public Key Interchange Protocol discusses X.509 encodings and
  1053.       validation.  Support for this is OPTIONAL.
  1054.  
  1055.    d.2 DSS keys w/ certificates
  1056.       Encoding for the Digital Signature Standard with X.509 is
  1057.       described in draft-ietf-ipsec-dss-cert-00.txt.  Support for this
  1058.       is OPTIONAL; an ISAKMP Authentication Type will be assigned.
  1059.  
  1060.  
  1061. 2.5.3 Validating Authentication Keys
  1062.  
  1063.  
  1064.    The combination of the Authentication algorithm, the Authentication
  1065.    Authority, the Authentication Type, and a key (usually public) define
  1066.    how to validate the messages with respect to the claimed identity.
  1067.    The key information will be available either from a pre-shared key,
  1068.    or from some kind of certification authority.
  1069.  
  1070.    Generally the certification authority produces a certificate binding
  1071.    the entity name to a public key.  OAKLEY implementations must be
  1072.    prepared to fetch and validate certificates before using the public
  1073.    key for OAKLEY authentication purposes.
  1074.  
  1075.    The ISAKMP Authentication Payload defines the Authentication
  1076.    Authority field for specifying the authority that must be apparent in
  1077.    the trust hierarchy for authentication.
  1078.  
  1079.    Once an appropriate certificate is obtained (see 2.4.3), the
  1080.    validation method will depend on the Authentication Type; if it is
  1081.    PGP then the PGP signature validation routines can be called to
  1082.    satisfy the local web-of-trust predicates; if it is RSA with X.509
  1083.    certificates, the certificate must be examined to see if the
  1084.    certification authority signature can be validated, and if the
  1085.    hierarchy is recognized by the local policy.
  1086.  
  1087. 2.5.4 Fetching Identity Objects
  1088.  
  1089.    In addition to interpreting the certificate or other data structure
  1090.    that contains an identity, users of OAKLEY must face the task of
  1091.    retrieving certificates that bind a public key to an identifier and
  1092.    also retrieving auxiliary certificates for certifying authorities or
  1093.    co-signers (as in the PGP web of trust).
  1094.  
  1095.    The ISAKMP Credentials Payload can be used to attach useful
  1096.    certificates to OAKLEY messages.  The Credentials Payload is defined
  1097.    in Appendix B.
  1098.  
  1099.    Support for accessing and revoking public key certificates via the
  1100.    Secure DNS protocol [SECDNS] is MANDATORY for OAKLEY implementations.
  1101.    Other retrieval methods can be used when the AUTH class indicates a
  1102.    preference.
  1103.  
  1104.    The Public Key Interchange Protocol discusses a full protocol that
  1105.    might be used with X.509 encoded certificates.
  1106.  
  1107.  
  1108. 2.6 Interface to Cryptographic Transforms
  1109.  
  1110.  
  1111.    The keying material computed by the key exchange should have at least
  1112.    90 bits of entropy, which means that it must be at least 90 bits in
  1113.    length.  This may be more or less than is required for keying the
  1114.    encryption and/or pseudorandom function transforms.
  1115.  
  1116.    The transforms used with OAKLEY should have auxiliary algorithms
  1117.    which take a variable precision integer and turn it into keying
  1118.    material of the appropriate length.  For example, a DES algorithm
  1119.    could take the low order 56 bits, a triple DES algorithm might use
  1120.    the following:
  1121.               K1 = low 56 bits of md5(0|sKEYID)
  1122.               K2 = low 56 bits of md5(1|sKEYID)
  1123.               K3 = low 56 bits of md5(2|sKEYID)
  1124.  
  1125.    The transforms will be called with the keying material encoded as a
  1126.    variable precision integer, the length of the data, and the block of
  1127.    memory with the data.  Conversion of the keying material to a
  1128.    transform key is the responsibility of the transform.
  1129.  
  1130.  
  1131. 2.7 Retransmission, Timeouts, and Error Messages
  1132.  
  1133.  
  1134.    If a response from the Responder is not elicited in an appropriate
  1135.    amount of time, the message should be retransmitted by the Initiator.
  1136.    These retransmissions must be handled gracefully by both parties; the
  1137.    Responder must retain information for retransmitting until the
  1138.    Initiator moves to the next message in the protocol or completes the
  1139.    exchange.
  1140.  
  1141.    Informational error messages present a problem because they cannot be
  1142.    authenticated using only the information present in an incomplete
  1143.    exchange; for this reason, the parties may wish to establish a
  1144.    default key for OAKLEY error messages.  A possible method for
  1145.    establishing such a key is described in Appendix B, under the use of
  1146.    ISA_INIT message types.
  1147.  
  1148.    In the following the message type is OAKLEY Error, the KEYID supplies
  1149.    the H algorithm and key for authenticating the message contents; this
  1150.    value is carried in the Sig/Prf payload.
  1151.  
  1152.    The Error payload contains the error code and the contents of the
  1153.    rejected message.
  1154.  
  1155.  
  1156.                              1                   2                   3
  1157.          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
  1158.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1159.         !                                                               !
  1160.         ~                       Initiator-Cookie                        ~
  1161.      /  !                                                               !
  1162. KEYID   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1163.     \  !                                                               !
  1164.         ~                       Responder-Cookie                        ~
  1165.         !                                                               !
  1166.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1167.         !                  Domain of Interpretation                     !
  1168.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1169.         ! Message Type  ! Exch  ! Vers  !          Length               !
  1170.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1171.         !                 SPI (unused)                                  !
  1172.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1173.         !                 SPI (unused)                                  !
  1174.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1175.         !                 Error Payload                                 !
  1176.         ~                                                               ~
  1177.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1178.         !                 Sig/prf Payload
  1179.         ~                                                               ~
  1180.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1181.  
  1182.  
  1183.  
  1184.  
  1185. The error message will contain the cookies as presented in the offending
  1186. message, the message type OAKLEY_ERROR, and the reason for the error,
  1187. followed by the rejected message.
  1188.  
  1189. Error messages are informational only, and the correctness of the
  1190. protocol does not depend on them.
  1191.  
  1192. Error reasons:
  1193.  
  1194. TIMEOUT                         exchange has taken too long, state destroyed
  1195. AEH_ERROR                       an unknown algorithm appears in an offer
  1196. GROUP_NOT_SUPPORTED             GRP named is not supported
  1197. EXPONENTIAL_UNACCEPTABLE        exponential too large/small or is +-1
  1198. SELECTION_NOT_OFFERED           selection does not occur in offer
  1199. NO_ACCEPTABLE_OFFERS            no offer meets host requirements
  1200. AUTHENTICATION_FAILURE          signature or hash function fails
  1201. RESOURCE_EXCEEDED               too many exchanges or too much state info
  1202. NO_EXCHANGE_IN_PROGRESS         a reply received with no request in progress
  1203.  
  1204.  
  1205.  
  1206.  
  1207. 2.8 Additional Security for Privacy Keys: Private Groups
  1208.  
  1209.  
  1210.    If the two parties have need to use a Diffie-Hellman key
  1211.    determination scheme that does not depend on the standard group
  1212.    definitions, they have the option of establishing a private group.
  1213.    The authentication need not be repeated, because this stage of the
  1214.    protocol will be protected by a pre-existing authentication key.  As
  1215.    an extra security measure, the two parties will establish a private
  1216.    name for the shared keying material, so even if they use exactly the
  1217.    same group to communicate with other parties, the re-use will not be
  1218.    apparent to passive attackers.
  1219.  
  1220.    Private groups have the advantage of making a widespread passive
  1221.    attack much harder by increasing the number of groups that would have
  1222.    to be exhaustively analyzed in order to recover a large number of
  1223.    session keys.  This contrasts with the case when only one or two
  1224.    groups are ever used; in that case, one would expect that years and
  1225.    years of session keys would be compromised.
  1226.  
  1227.    There are two technical challenges to face: how can a particular user
  1228.    create a unique and appropriate group, and how can a second party
  1229.    assure himself that the proposed group is reasonably secure?
  1230.  
  1231.    The security of a modular exponentiation group depends on the largest
  1232.    prime factor of the group size.  In order to maximize this, one can
  1233.    choose "strong" or Sophie Germaine primes, P = 2Q + 1, where P and Q
  1234.    are prime.  However, if P = kQ + 1, where k is small, then the
  1235.    strength of the group is still considerable.  These groups are known
  1236.    as Schnorr subgroups, and they can be found with much less
  1237.    computational effort than Sophie-Germaine primes.
  1238.  
  1239.    Schnorr subgroups can also be validated efficiently by using probable
  1240.    prime tests.
  1241.  
  1242.    It is also fairly easy to find P, k, and Q such that the largest
  1243.    prime factor can be easily proven to be Q.
  1244.  
  1245.    We estimate that it would take about 10 minutes to find a new group
  1246.    of about 2^1024 elements, and this could be done once a day by a
  1247.    scheduled process; validating a group proposed by a remote party
  1248.    would take perhaps a minute on a 25 MHz RISC machine or a 66 MHz CISC
  1249.    machine.
  1250.  
  1251.    We note that validation is done only between previously mutually
  1252.    authenticated parties, and that a new group definition always follows
  1253.    and is protected by a key established using a well-known group.
  1254.    There are five points to keep in mind:
  1255.  
  1256.       a. The description and public identifier for the new group are
  1257.       protected by the well-known group.
  1258.  
  1259.       b. The responder can reject the attempt to establish the new
  1260.       group, either because he is too busy or because he cannot validate
  1261.       the largest prime factor as being sufficiently large.
  1262.  
  1263.       c. The new modulus and generator can be cached for long periods of
  1264.       time; they are not security critical and need not be associated
  1265.       with ongoing activity.
  1266.  
  1267.       d. Generating a new g^x value periodically will be more expensive
  1268.       if there are many groups cached; however, the importance of
  1269.       frequently generating new g^x values is reduced, so the time
  1270.       period can be lengthened correspondingly.
  1271.  
  1272.       e. All modular exponentiation groups have subgroups that are
  1273.       weaker than the main group.  For Sophie Germain primes, if the
  1274.       generator is a square, then there are only two elements in the
  1275.       subgroup: 1 and g^(-1) (same as g^(p-1)) which we have already
  1276.       recommended avoiding.  For Schnorr subgroups with k not equal to
  1277.       2, the subgroup can be avoided by checking that the exponential is
  1278.       not a kth root of 1 (e^k != 1 mod p).
  1279.  
  1280. 2.8.1 Defining a New Group
  1281.    This section describes how to define a new group.  The description of
  1282.    the group is hidden from eavesdroppers, and the identifier assigned
  1283.    to the group is unique to the two parties.  Use of the new group for
  1284.    Diffie-Hellman key exchanges is described in the next section.
  1285.  
  1286.    The secrecy of the description and the identifier increases the
  1287.    difficulty of a passive attack, because if the group descriptor is
  1288.    not known to the attacker, there is no straightforward and efficient
  1289.    way to gain information about keys calculated using the group.
  1290.  
  1291.    Only the description of the new group need be encrypted in this
  1292.    exchange.  The hash algorithm is implied by the OAKLEY session named
  1293.    by the group.  The encryption is the encryption function of the
  1294.    OAKLEY session.
  1295.  
  1296.    The descriptor of the new group is encoded in the new group payload.
  1297.    The nonces are encoded in the Authentication Payload.
  1298.  
  1299.    Data beyond the encryption boundary is encrypted using the transform
  1300.    named by the KEYID.
  1301.  
  1302.    The following messages use the ISAKMP Key Exchange Identifier OAKLEY
  1303.    New Group.
  1304.  
  1305.    To define a new modular exponentiation group:
  1306.     Initiator                                        Responder
  1307.     ---------                                       ----------
  1308.      ->   KEYID,                                        ->
  1309.           INEWGRP,
  1310.           Desc(New Group), Na
  1311.           prf(sKEYID, Desc(New Group) | Na)
  1312.  
  1313.      <-   KEYID,
  1314.           INEWGRPRS,
  1315.           Na, Nb
  1316.           prf(sKEYID, Na | Nb | Desc(New Group))       <-
  1317.  
  1318.       ->  KEYID,
  1319.           INEWGRPACK
  1320.           prf(sKEYID, Nb | Na | Desc(New Group))        ->
  1321.  
  1322.    These messages are encrypted at the encryption boundary using the key
  1323.    indicated.  The hash value is placed in the "digital signature" field
  1324.    (see Appendix B).
  1325.  
  1326.  
  1327.       New GRP identifier = trunc16(Na) | trunc16(Nb)
  1328.  
  1329.       (trunc16 indicates truncation to 16 bits; the initiator and
  1330.       responder must use nonces that have distinct upper bits from any
  1331.       used for current GRPID's)
  1332.  
  1333.       Desc(G) is the encoding of the descriptor for the group descriptor
  1334.       (see Appendix A for the format of a group descriptor)
  1335.  
  1336.    The two parties must store the mapping between the new group
  1337.    identifier GRP and the group descriptor Desc(New Group).  They must
  1338.    also note the identities used for the KEYID and copy these to the
  1339.    state for the new group.
  1340.  
  1341.    Note that one could have the same group descriptor associated with
  1342.    several KEYID's.   Pre-calculation of g^x values may be done based
  1343.    only on the group descriptor, not the private group name.
  1344.  
  1345. 2.8.2 Deriving a Key Using a Private Group
  1346.  
  1347.    Once a private group has been established, its group id can be used
  1348.    in the key exchange messages in the GRP position.  No changes to the
  1349.    protocol are required.
  1350.  
  1351.  
  1352. 2.9 Quick Mode: New Keys From Old,
  1353.  
  1354.    When an authenticated KEYID and associated keying material sKEYID
  1355.    already exist, it is easy to derive additional KEYID's and keys
  1356.    sharing similar attributes (GRP, EHA, etc.)  using only hashing
  1357.    functions.  The KEYID might be one that was derived in Main Mode, for
  1358.    example.
  1359.  
  1360.    On the other hand, the authenticated key may be a manually
  1361.    distributed key, one that is shared by the initiator and responder
  1362.    via some means external to OAKLEY.  If the distribution method has
  1363.    formed the KEYID using appropriately unique values for the two halves
  1364.    (CKY-I and CKY-R), then this method is applicable.
  1365.  
  1366.    In the following, the Key Exchange Identifier is OAKLEY Quick Mode.
  1367.    The nonces are carried in the Authentication Payload, and the prf
  1368.    value is carried in the Authentication Payload; the Authentication
  1369.    Authority is "None" and the type is "Pre-Shared".
  1370.  
  1371.    The protocol is:
  1372.  
  1373.      Initiator                                           Responder
  1374.      ---------                                           ---------
  1375.      -> KEYID, INEWKRQ, Ni, prf(sKEYID, Ni)                ->
  1376.     <-  KEYID, INEWKRS, Nr, prf(sKEYID, 1 | Nr | Ni)      <-
  1377.      -> KEYID, INEWKRP, 0, prf(sKEYID,  0 | Ni | Nr)       ->
  1378.  
  1379.    The New KEYID, NKEYID, is Ni | Nr
  1380.  
  1381.    sNKEYID = prf(sKEYID, Ni | Nr )
  1382.  
  1383.  
  1384.    The identities and EHA values associated with NKEYID are the same as
  1385.    those associated with KEYID.
  1386.  
  1387.    Each party must validate the hash values before using the new key for
  1388.    any purpose.
  1389.  
  1390.  
  1391. 2.10 Defining and Using Pre-Distributed Keys
  1392.  
  1393.  
  1394.    If a key and an associated key identifier and state information have
  1395.    been distributed manually, then the key can be used for any OAKLEY
  1396.    purpose.  The key must be associated with the usual state
  1397.    information:  ID's and EHA algorithms.
  1398.  
  1399.    Local policy dictates when a manual key can be included in the OAKLEY
  1400.    database.  For example, only privileged users would be permitted to
  1401.    introduce keys associated with privileged ID's, an unprivileged user
  1402.    could only introduce keys associated with her own ID.
  1403.  
  1404. 2.11 Distribution of an External Key
  1405.    Once an OAKLEY session key and ancillary algorithms are established,
  1406.    the keying material and the "H" algorithm can be used to distribute
  1407.    an externally generated key and to assign a KEYID to it.
  1408.  
  1409.    In the following, KEYID represents an existing, authenticated OAKLEY
  1410.    session key, and sNEWKEYID represents the externally generated keying
  1411.    material.
  1412.  
  1413.    In the following, the Key Exchange Identifier is OAKLEY External
  1414.    Mode.  The Key Exchange Payload contains the new key, which is
  1415.    protected
  1416.  
  1417.  
  1418.      Initiator                                                     Responder
  1419.      ---------                                                     ---------
  1420.      -> KEYID, IEXTKEY, Ni, prf(sKEYID, Ni)                               ->
  1421.     <-  KEYID, IEXTKEY, Nr, prf(sKEYID, 1 | Nr | Ni)                     <-
  1422.      -> KEYID, IEXTKEY, Kir xor sNEWKEYID*, prf(Kir, sNEWKEYID | Ni | Nr) ->
  1423.  
  1424.    Kir = prf(sKEYID, Ni | Nr)
  1425.  
  1426.    * this field is carried in the Key Exchange Payload.
  1427.  
  1428.  
  1429.    Each party must validate the hash values using the "H" function in
  1430.    the KEYID state before changing any key state information.
  1431.  
  1432.    The new key is recovered by the Responder by calculating the xor of
  1433.    the field in the Authentication Payload with the Kir value.
  1434.  
  1435.    The new key identifier, naming the keying material sNEWKEYID, is
  1436.    prf(sKEYID, 1 | Ni | Nr).
  1437.  
  1438.    Note that this exchange does not require encryption.  Hugo Krawcyzk
  1439.    suggested the method and noted its advantage.
  1440.  
  1441.  
  1442. 2.11.1 Cryptographic Strength Considerations
  1443.  
  1444.    The strength of the key used to distribute the external key must be
  1445.    at least equal to the strength of the external key.  Generally, this
  1446.    means that the length of the sKEYID material must be greater than or
  1447.    equal to the length of the sNEWKEYID material.
  1448.  
  1449.    The derivation of the external key, its strength or intended use are
  1450.    not addressed by this protocol; the parties using the key must have
  1451.    some other method for determining these properties.
  1452.  
  1453.    As of early 1996, it appears that for 90 bits of cryptographic
  1454.    strength, one should use a modular exponentiation group modulus of
  1455.    2000 bits.  For 128 bits of strength, a 3000 bit modulus is required.
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508. 3. Specifying and Deriving Security Associations
  1509.  
  1510.    When a security association is defined, only the KEYID need be given.
  1511.    The responder should be able to look up the state associated with the
  1512.    KEYID value and find the appropriate keying material, sKEYID.
  1513.  
  1514.    Deriving keys for use with IPSEC protocols such as ESP or AH is a
  1515.    subject covered in the ISAKMP/Oakley Resolution document.  That
  1516.    document also describes how to negotiate acceptable parameter sets
  1517.    and identifiers for ESP and AH, and how to exactly calculate the
  1518.    keying material for each instance of the protocols.  Because the
  1519.    basic keying material defined here (g^xy) may be used to derive keys
  1520.    for several instances of ESP and AH, the exact mechanics of using
  1521.    one-way functions to turn g^xy into several unique keys is essential
  1522.    to correct usage.
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574. 4. ISAKMP Compatibility
  1575.  
  1576.    OAKLEY uses ISAKMP header and payload formats, as described in the
  1577.    text and in Appendix B.  There are particular noteworthy extensions
  1578.    beyond the version 4 draft.
  1579.  
  1580. 4.1 Authentication with Existing Keys
  1581.  
  1582.    In the case that two parties do not have suitable public key
  1583.    mechanisms in place for authenticating each other, they can use keys
  1584.    that were distributed manually.  After establishment of these keys
  1585.    and their associated state in OAKLEY, they can be used for
  1586.    authentication modes that depend on signatures, e.g. Aggressive Mode.
  1587.  
  1588.    When an existing key is to appear in an offer list, it should be
  1589.    indicated with an Authentication Algorithm of ISAKMP_EXISTING.  This
  1590.    value will be assigned in the ISAKMP RFC.
  1591.  
  1592.    When the authentication method is ISAKMP_EXISTING, the authentication
  1593.    authority will have the value ISAKMP_AUTH_EXISTING; the value for
  1594.    this field must not conflict with any authentication authority
  1595.    registered with IANA and will be defined in the ISAKMP RFC.
  1596.  
  1597.    The authentication payload will have two parts:
  1598.  
  1599.        the KEYID for the pre-existing key
  1600.  
  1601.        the identifier for the party to be authenticated by the pre-
  1602.       existing key.
  1603.  
  1604.    The pseudo-random function "H" in the state information for that
  1605.    KEYID will be the signature algorithm, and it will use the keying
  1606.    material for that key (sKEYID) when generating or checking the
  1607.    validity of message data.
  1608.  
  1609.    E.g. if the existing key has an KEYID denoted by KID and 128 bits of
  1610.    keying material denoted by sKID and "H" algorithm a transform named
  1611.    HMAC, then to generate a "signature" for a data block, the output of
  1612.    HMAC(sKID, data)
  1613.    will be the corresponding signature payload.
  1614.  
  1615.    The KEYID state will have the identities of the local and remote
  1616.    parties for which the KEYID was assigned; it is up to the local
  1617.    policy implementation to decide when it is appropriate to use such a
  1618.    key for authenticating other parties.  For example, a key distributed
  1619.    for use between two Internet hosts A and B may be suitable for
  1620.    authenticating all identities of the form "alice@A" and "bob@B".
  1621.  
  1622.    4.2 Third Party Authentication
  1623.  
  1624.    A local security policy might restrict key negotiation to trusted
  1625.    parties.  For example, two OAKLEY daemons running with equal
  1626.    sensitivity labels on two machines might wish to be the sole arbiters
  1627.    of key exchanges between users with that same sensitivity label.  In
  1628.    this case, some way of authenticating the provenance of key exchange
  1629.    requests is needed.  I.e., the identities of the two daemons should
  1630.    be bound to a key, and that key will be used to form a "signature"
  1631.    for the key exchange messages.
  1632.  
  1633.    The Signature Payload, in Appendix B, is for this purpose.  This
  1634.    payload names a KEYID that is in existence before the start of the
  1635.    current exchange.  The "H" transform for that KEYID is used to
  1636.    calculate an integrity/authentication value for all payloads
  1637.    preceding the signature.
  1638.  
  1639.    Local policy can dictate which KEYID's are appropriate for signing
  1640.    further exchanges.
  1641.  
  1642.    4.3 New Group Mode
  1643.  
  1644.    OAKLEY uses a new KEI for the exchange that defines a new group.
  1645.  
  1646.  
  1647. 5. Security Implementation Notes
  1648.  
  1649.    Timing attacks that are capable of recovering the exponent value used
  1650.    in Diffie-Hellman calculations have been described by Paul Kocher
  1651.    [Kocher].  In order to nullify the attack, implementors must take
  1652.    pains to obscure the sequence of operations involved in carrying out
  1653.    modular exponentiations.
  1654.  
  1655.    A "blinding factor" can accomplish this goal.  A group element, r, is
  1656.    chosen at random.  When an exponent x is chosen, the value r^(-x) is
  1657.    also calculated.  Then, when calculating (g^y)^x, the implementation
  1658.    will calculate this sequence:
  1659.            A = (rg^y)
  1660.            B = A^x = (rg^y)^x = (r^x)(g^(xy))
  1661.            C = B*r^(-x) = (r^x)(r^-(x))(g^(xy)) = g^(xy)
  1662.  
  1663.    The blinding factor is only necessary if the exponent x is used more
  1664.    than 100 times (estimate by Richard Schroeppel).
  1665.  
  1666.  
  1667. 6. OAKLEY Parsing and State Machine
  1668.  
  1669.  
  1670.    There are many pathways through OAKLEY, but they follow a left-to-
  1671.    right parsing pattern of the message fields.
  1672.  
  1673.    The initiator decides on an initial message in the following order:
  1674.       1. Offer a cookie.  This is not necessary but it helps with
  1675.       aggressive exchanges.
  1676.  
  1677.       2. Pick a group.  The choices are the well-known groups or any
  1678.       private groups that may have been negotiated.  The very first
  1679.       exchange between two Oakley daemons with no common state must
  1680.       involve a well-known group (0, meaning no group, is a well-known
  1681.       group).  Note that the group identifier, not the group descriptor,
  1682.       is used in the message.
  1683.  
  1684.       If a non-null group will be used, it must be included with the
  1685.       first message specifying EHAO.  It need not be specified until
  1686.       then.
  1687.  
  1688.       3. If PFS will be used, pick an exponent x and present g^x.
  1689.  
  1690.       4. Offer Encryption, Hash, and Authentication lists.
  1691.  
  1692.       5. Use PFS for hiding the identities
  1693.  
  1694.       If identity hiding is not used, then the initiator has this
  1695.       option:
  1696.  
  1697.       6. Name the identities and include authentication information
  1698.  
  1699.    The information in the authentication section depends on the first
  1700.    authentication offer.  In this aggressive exchange, the Initiator
  1701.    hopes that the Responder will accept all the offered information and
  1702.    the first authentication method.  The authentication method
  1703.    determines the authentication payload as follows:
  1704.       1. Signing method.  The signature will be applied to all the
  1705.       offered information.
  1706.  
  1707.       2. A public key encryption method.  The algorithm will be used to
  1708.       encrypt a nonce in the public key of the requested Responder
  1709.       identity.  There are two cases possible, depending on whether or
  1710.       not identity hiding is used:
  1711.  
  1712.          a. No identity hiding.  The ID's will appear as plaintext.
  1713.          b. Identity hiding.  A well-known ID, call it R', will appear
  1714.       as
  1715.             plaintext in the authentication payload.  It will be
  1716.       followed
  1717.             by two ID's and a nonce; these will be encrypted using the
  1718.             public key for R'.
  1719.  
  1720.       3. A pre-existing key method.  The pre-existing key will be used
  1721.       to encrypt a nonce.  If identity hiding is used, the ID's will be
  1722.       encrypted in place in the payload, using the "E" algorithm
  1723.       associated with the pre-existing key.
  1724.    The Responder can accept all, part or none of the initial message.
  1725.  
  1726.    The Responder accepts as many of the fields as he wishes, using the
  1727.    same decision order as the initiator.  At any step he can stop,
  1728.    implicitly rejecting further fields (which will have null values in
  1729.    his response message).  The minimum response is a cookie and the GRP.
  1730.       1. Accept cookie.  The Responder may elect to record no state
  1731.       information until the Initiator successfully replies with a cookie
  1732.       chosen by the responder.  If so, the Responder replies with a
  1733.       cookie, the GRP, and no other information.
  1734.  
  1735.       2. Accept GRP.  If the group is not acceptable, the Responder will
  1736.       not reply.  The Responder may send an error message indicating the
  1737.       the group is not acceptable (modulus too small, unknown
  1738.       identifier, etc.)  Note that "no group" has two meanings during
  1739.       the protocol: it may mean the group is not yet specified, or it
  1740.       may mean that no group will be used (and thus PFS is not
  1741.       possible).
  1742.  
  1743.       3. Accept the g^x value.  The Responder indicates his acceptance
  1744.       of the g^x value by including his own g^y value in his reply.  He
  1745.       can postpone this by ignoring g^x and putting a zero length g^y
  1746.       value in his reply.  He can also reject the g^x value with an
  1747.       error message.
  1748.  
  1749.       4. Accept one element from each of the EHA lists.  The acceptance
  1750.       is indicated by a non-zero proposal.
  1751.  
  1752.       5. If PFS for identity hiding is requested, then no further data
  1753.       will follow.
  1754.  
  1755.       6. If the authentication payload is present, and if the first item
  1756.       in the offered authentication class is acceptable, then the
  1757.       Responder must validate/decrypt the information in the
  1758.       authentication payload and signature payload, if present. The
  1759.       Responder should choose a nonce and reply using the same
  1760.       authentication/hash algorithm as the Initiator used.
  1761.    The Initiator notes which information the Responder has accepted,
  1762.    validates/decrypts any signed, hashed, or encrypted fields, and if
  1763.    the data is acceptable, replies in accordance to the EHA methods
  1764.    selected by the Responder.  The Initiator replies are distinguished
  1765.    from his initial message by the presence of the non-zero value for
  1766.    the Responder cookie.
  1767.  
  1768.    The output of the signature or prf function will be encoded as a
  1769.    variable precision integer as described in Appendix C.  The KEYID
  1770.    will indicate KEYID that names keying material and the Hash or
  1771.    Signature function.
  1772.  
  1773.    7. The Credential Payload
  1774.  
  1775.    Useful certificates with public key information can be attached to
  1776.    OAKLEY messages using Credential Payloads as defined in the ISAKMP
  1777.    document.  It should be noted that the identity protection option
  1778.    applies to the credentials as well as the identities.
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838. APPENDIX A Group Descriptors
  1839.  
  1840.  
  1841.  
  1842.    Three distinct group representations can be used with OAKLEY.  Each
  1843.    group is defined by its group operation and the kind of underlying
  1844.    field used to represent group elements.  The three types are modular
  1845.    exponentiation groups (named MODP herein), elliptic curve groups
  1846.    over the field GF[2^N] (named EC2N herein), and elliptic curve groups
  1847.    over GF[P] (named ECP herein) For each representation, many distinct
  1848.    realizations are possible, depending on parameter selection.
  1849.  
  1850.    With a few exceptions, all the parameters are transmitted as if they
  1851.    were non-negative multi-precision integers, using the format defined
  1852.    in this appendix (note, this is distinct from the encoding in Appendix
  1853.    C).  Every multi-precision integer has a prefixed length field, even
  1854.    where this information is redundant.
  1855.  
  1856.    For the group type EC2N, the parameters are more properly thought of
  1857.    as very long bit fields, but they are represented as multi-precision
  1858.    integers, (with length fields, and right-justified).  This is the
  1859.    natural encoding.
  1860.  
  1861.    MODP means the classical modular exponentiation group, where the
  1862.    operation is to calculate G^X (mod P).  The group is defined by
  1863.    the numeric parameters P and G.  P must be a prime.  G is often 2,
  1864.    but may be a larger number.  2 <= G <= P-2.
  1865.  
  1866.    ECP is an elliptic curve group, modulo a prime number P.
  1867.    The defining equation for this kind of group is
  1868.     Y^2 = X^3 + AX + B
  1869.    The group operation is taking a multiple of an elliptic-curve point.
  1870.    The group is defined by 5 numeric parameters:  The prime P, two curve
  1871.    parameters A and B, and a generator (X,Y).  A,B,X,Y are all
  1872.    interpreted mod P, and must be (non-negative) integers less than P.
  1873.    They must satisfy the defining equation, modulo P.
  1874.  
  1875.    EC2N is an elliptic curve group, over the finite field F[2^N].  The
  1876.    defining equation for this kind of group is
  1877.     Y^2 + XY = X^3 + AX^2 + B
  1878.    (This equation differs slightly from the mod P case:  it has an XY
  1879.    term, and an AX^2 term instead of an AX term.)
  1880.  
  1881.    We must specify the field representation, and then the elliptic
  1882.    curve.  The field is specified by giving an irreducible polynomial
  1883.    (mod 2) of degree N.  This polynomial is represented as an integer of
  1884.    size between 2^N and 2^(N+1), as if the defining polynomial were
  1885.    evaluated at the value U=2.
  1886.  
  1887.    For example, the field defined by the polynomial
  1888.    U^155 + U^62 + 1
  1889.    is represented by the integer 2^155 + 2^62 + 1.  The group is defined
  1890.    by 4 more parameters, A,B,X,Y.  These parameters are elements of the
  1891.    field GF[2^N], and can be thought of as polynomials of degree < N,
  1892.    with (mod 2) coefficients.  They fit in N-bit fields, and are
  1893.    represented as integers < 2^N, as if the polynomial were evaluated at
  1894.    U=2.  For example, the field element U^2 + 1 would be represented by
  1895.    the integer 2^2+1, which is 5.  The two parameters A and B define the
  1896.    curve.  A is frequently 0.  B must not be 0.  The parameters X and Y
  1897.    select a point on the curve.  The parameters A,B,X,Y must satisfy the
  1898.    defining equation, modulo the defining polynomial, and mod 2.
  1899.  
  1900.    Group descriptor formats:
  1901.  
  1902.     Type of group: A two-byte field,
  1903.            assigned values for the types "MODP", "ECP", "EC2N"
  1904.            will be defined (see ISAKMP-04).
  1905.    Size of a field element, in bits.  This is either Ceiling(log2 P)
  1906.       or the degree of the irreducible polynomial: a 32-bit integer.
  1907.    The prime P or the irreducible field polynomial: a multi-precision integer.
  1908.    The generator: 1 or 2 values, multi-precision integers.
  1909.    EC only:  The parameters of the curve:  2 values, multi-precision integers.
  1910.  
  1911.    The following parameters are Optional (each of these may appear
  1912.    independently):
  1913.      a value of 0 may be used as a place-holder to represent an unspecified
  1914.      parameter; any number of the parameters may be sent, from 0 to 3.
  1915.  
  1916.    The largest prime factor: the encoded value that is the LPF of the group size,
  1917.      a multi-precision integer.
  1918.  
  1919.    EC only:  The order of the group: multi-precision integer.
  1920.      (The group size for MODP is always P-1.)
  1921.  
  1922.    Strength of group: 32-bit integer.
  1923.      The strength of the group is approximately the number of key-bits protected.
  1924.      It is determined by the log2 of the effort to attack the group.
  1925.      It may change as we learn more about cryptography.
  1926.  
  1927. This is a generic example for a "classic" modular exponentiation group:
  1928.       Group type: "MODP"
  1929.       Size of a field element in bits:  Log2 (P) rounded *up*.  A 32bit integer.
  1930.       Defining prime P: a multi-precision integer.
  1931.       Generator G: a multi-precision integer.  2 <= G <= P-2.
  1932.       <optional>
  1933.       Largest prime factor of P-1: the multi-precision integer Q
  1934.       Strength of group: a 32-bit integer.  We will specify a formula
  1935.         for calculating this number (TBD).
  1936.  
  1937.    This is a generic example for an elliptic curve group, mod P:
  1938.       Group type: "ECP"
  1939.       Size of a field element in bits:  Log2 (P) rounded *up*,
  1940.           a 32 bit integer.
  1941.       Defining prime P: a multi-precision integer.
  1942.       Generator (X,Y): 2 multi-precision integers, each < P.
  1943.       Parameters of the curve A,B: 2 multi-precision integers, each < P.
  1944.       <optional>
  1945.       Largest prime factor of the group order: a multi-precision integer.
  1946.       Order of the group: a multi-precision integer.
  1947.       Strength of group:  a 32-bit integer.  Formula TBD.
  1948.  
  1949.    This is a specific example for an elliptic curve group:
  1950.       Group type: "EC2N"
  1951.       Degree of the irreducible polynomial: 155
  1952.       Irreducible polynomial:  U^155 + U^62 + 1, represented as the
  1953.         multi-precision integer 2^155 + 2^62 + 1.
  1954.       Generator (X,Y) : represented as 2 multi-precision integers, each < 2^155.
  1955.         For our present curve, these are (decimal) 123 and 456.  Each is represented
  1956.         as a multi-precision integer.
  1957.       Parameters of the curve A,B: represented as 2 multi-precision
  1958.         integers,  each < 2^155.
  1959.         For our present curve these are 0 and (decimal) 471951, represented as two
  1960.         multi-precision integers.
  1961.  
  1962.       <optional>
  1963.       Largest prime factor of the group order:
  1964.  
  1965.        3805993847215893016155463826195386266397436443,
  1966.  
  1967.       represented as a multi-precision integer.
  1968.       The order of the group:
  1969.  
  1970.         45671926166590716193865565914344635196769237316
  1971.  
  1972.       represented as a multi-precision integer.
  1973.  
  1974.       Strength of group: 76, represented as a 32-bit integer.
  1975.  
  1976.    The variable precision integer encoding for group descriptor fields
  1977.    is the following.  This is a slight variation on the format defined
  1978.    in Appendix C in that a fixed 16-bit value is used first, and the
  1979.    length is limited to 16 bits.  However, the interpretation is
  1980.    otherwise identical.
  1981.  
  1982.                              1                   2                   3
  1983.          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
  1984.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1985.         !   Fixed value (TBD)           !             Length            !
  1986.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1987.         .                                                               .
  1988.         .                  Integer                                      .
  1989.         .                                                               .
  1990.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1991.  
  1992.  
  1993.    The format of a group descriptor is:
  1994.                              1                   2                   3
  1995.          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
  1996.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1997.         !1!1!     Group Description     !             MODP              !
  1998.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1999.         !1!0!        Field Size         !            Length             !
  2000.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2001.         !                              MPI                              !
  2002.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2003.         !1!0!          Prime            !            Length             !
  2004.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2005.         !                              MPI                              !
  2006.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2007.         !1!0!       Generator1          !            Length             !
  2008.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2009.         !                              MPI                              !
  2010.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2011.         !1!0!       Generator2          !            Length             !
  2012.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2013.         !                              MPI                              !
  2014.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2015.         !1!0!         Curve-p1          !            Length             !
  2016.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2017.         !                              MPI                              !
  2018.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2019.         !1!0!         Curve-p2          !            Length             !
  2020.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2021.         !                              MPI                              !
  2022.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2023.         !1!0!   Largest Prime Factor    !            Length             !
  2024.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2025.         !                              MPI                              !
  2026.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2027.         !1!0!      Order of Group       !            Length             !
  2028.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2029.         !                              MPI                              !
  2030.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2031.         !0!0!    Strength of Group      !            Length             !
  2032.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2033.         !                              MPI                              !
  2034.         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2035.  
  2036.  
  2037. APPENDIX B  Message formats
  2038.  
  2039.  
  2040.    The encodings of Oakley messages into ISAKMP payloads is deferred to
  2041.    the ISAKMP/Oakley Resolution document.
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102. APPENDIX C Encoding a variable precision integer.
  2103.  
  2104.  
  2105.    Variable precision integers will be encoded as a 32-bit length field
  2106.    followed by one or more 32-bit quantities containing the
  2107.    representation of the integer, aligned with the most significant bit
  2108.    in the first 32-bit item.
  2109.  
  2110.                                 1                   2                   3
  2111.             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
  2112.            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2113.            !    length                                                     !
  2114.            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2115.            !    first value word (most significant bits)                   !
  2116.            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2117.            !                                                               !
  2118.            ~     additional value words                                    ~
  2119.            !                                                               !
  2120.            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2121.  
  2122.  
  2123.    An example of such an encoding is given below, for a number with 51
  2124.    bits of significance.  The length field indicates that 2 32-bit
  2125.    quantities follow.  The most significant non-zero bit of the number
  2126.    is in bit 13 of the first 32-bit quantity, the low order bits are in
  2127.    the second 32-bit quantity.
  2128.  
  2129.                                 1                   2                   3
  2130.             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
  2131.            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2132.            !                                                            1 0!
  2133.            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2134.            !0 0 0 0 0 0 0 0 0 0 0 0 0 1 x x x x x x x x x x x x x x x x x x!
  2135.            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2136.            !x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x!
  2137.            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2138.  
  2139. APPENDIX D Cryptographic strengths
  2140.  
  2141.    The Diffie-Hellman algorithm is used to compute keys that will be
  2142.    used with symmetric algorithms.  It should be no easier to break the
  2143.    Diffie-Hellman computation than it is to do an exhaustive search over
  2144.    the symmetric key space.  A recent recommendation by an group of
  2145.    cryptographers [Blaze] has recommended a symmetric key size of 75
  2146.    bits for a practical level of security.  For 20 year security, they
  2147.    recommend 90 bits.
  2148.  
  2149.    Based on that report, a conservative strategy for OAKLEY users would
  2150.    be to ensure that their Diffie-Hellman computations were as secure as
  2151.    at least a 90-bit key space.  In order to accomplish this for modular
  2152.    exponentiation groups, the size of the largest prime factor of the
  2153.    modulus should be at least 180 bits, and the size of the modulus
  2154.    should be at least 1400 bits.  For elliptic curve groups, the LPF
  2155.    should be at least 180 bits.
  2156.  
  2157.    If long-term secrecy of the encryption key is not an issue, then the
  2158.    following parameters may be used for the modular exponentiation
  2159.    group: 150 bits for the LPF, 980 bits for the modulus size.
  2160.  
  2161.    The modulus size alone does not determine the strength of the
  2162.    Diffie-Hellman calculation; the size of the exponent used in
  2163.    computing powers within the group is also important.  The size of the
  2164.    exponent in bits should be at least twice the size of any symmetric
  2165.    key that will be derived from it.  We recommend that ISAKMP
  2166.    implementors use at least 180 bits of exponent (twice the size of a
  2167.    20-year symmetric key).
  2168.  
  2169.    The mathematical justification for these estimates can be found in
  2170.    texts that estimate the effort for solving the discrete log problem,
  2171.    a task that is strongly related to the efficiency of using the Number
  2172.    Field Sieve for factoring large integers.  Readers are referred to
  2173.    [Stinson] and [Schneier].
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235. APPENDIX E The Well-Known Groups
  2236.  
  2237.  
  2238.    The group identifiers:
  2239.  
  2240.       0   No group (used as a placeholder and for non-DH exchanges)
  2241.       1   A modular exponentiation group with a 768 bit modulus
  2242.       2   A modular exponentiation group with a 1024 bit modulus
  2243.       3   A modular exponentiation group with a 1536 bit modulus (TBD)
  2244.       4   An elliptic curve group over GF[2^155]
  2245.       5   An elliptic curve group over GF[2^185]
  2246.  
  2247.       values 2^31 and higher are used for private group identifiers
  2248.  
  2249.    Richard Schroeppel performed all the mathematical and computational
  2250.    work for this appendix.
  2251.  
  2252.    Classical Diffie-Hellman Modular Exponentiation Groups
  2253.  
  2254.    The primes for groups 1 and 2 were selected to have certain
  2255.    properties.  The high order 64 bits are forced to 1.  This helps the
  2256.    classical remainder algorithm, because the trial quotient digit can
  2257.    always be taken as the high order word of the dividend, possibly +1.
  2258.    The low order 64 bits are forced to 1.  This helps the Montgomery-
  2259.    style remainder algorithms, because the multiplier digit can always
  2260.    be taken to be the low order word of the dividend.  The middle bits
  2261.    are taken from the binary expansion of pi.  This guarantees that they
  2262.    are effectively random, while avoiding any suspicion that the primes
  2263.    have secretly been selected to be weak.
  2264.  
  2265.    Because both primes are based on pi, there is a large section of
  2266.    overlap in the hexadecimal representations of the two primes.  The
  2267.    primes are chosen to be Sophie Germain primes (i.e., (P-1)/2 is also
  2268.    prime), to have the maximum strength against the square-root attack
  2269.    on the discrete logarithm problem.
  2270.  
  2271.    The starting trial numbers were repeatedly incremented by 2^64 until
  2272.    suitable primes were located.
  2273.  
  2274.    Because these two primes are congruent to 7 (mod 8), 2 is a quadratic
  2275.    residue of each prime.  All powers of 2 will also be quadratic
  2276.    residues.  This prevents an opponent from learning the low order bit
  2277.    of the Diffie-Hellman exponent (AKA the subgroup confinement
  2278.    problem).  Using 2 as a generator is efficient for some modular
  2279.    exponentiation algorithms.  [Note that 2 is technically not a
  2280.    generator in the number theory sense, because it omits half of the
  2281.    possible residues mod P.  From a cryptographic viewpoint, this is a
  2282.    virtue.]
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301. E.1. Well-Known Group 1:  A 768 bit prime
  2302.  
  2303.    The prime is 2^768 - 2^704 - 1 + 2^64 * { [2^638 pi] + 149686 }.  Its
  2304.    decimal value is
  2305.           155251809230070893513091813125848175563133404943451431320235
  2306.           119490296623994910210725866945387659164244291000768028886422
  2307.           915080371891804634263272761303128298374438082089019628850917
  2308.           0691316593175367469551763119843371637221007210577919
  2309.  
  2310.    This has been rigorously verified as a prime.
  2311.  
  2312.    The representation of the group in OAKLEY is
  2313.  
  2314.       Type of group:                    "MODP"
  2315.       Size of field element (bits):      768
  2316.       Prime modulus:                     21 (decimal)
  2317.          Length (32 bit words):          24
  2318.          Data (hex):
  2319.             FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
  2320.             29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
  2321.             EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
  2322.             E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF
  2323.       Generator:                         22 (decimal)
  2324.          Length (32 bit words):          1
  2325.          Data (hex):                     2
  2326.  
  2327.       Optional Parameters:
  2328.       Group order largest prime factor:  24 (decimal)
  2329.          Length (32 bit words):          24
  2330.          Data (hex):
  2331.             7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68
  2332.             94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E
  2333.             F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122
  2334.             F242DABB 312F3F63 7A262174 D31D1B10 7FFFFFFF FFFFFFFF
  2335.       Strength of group:                 26 (decimal)
  2336.          Length (32 bit words)            1
  2337.          Data (hex):
  2338.             00000042
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366. E.2. Well-Known Group 2:  A 1024 bit prime
  2367.  
  2368.    The prime is 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 }.
  2369.    Its decimal value is
  2370.          179769313486231590770839156793787453197860296048756011706444
  2371.          423684197180216158519368947833795864925541502180565485980503
  2372.          646440548199239100050792877003355816639229553136239076508735
  2373.          759914822574862575007425302077447712589550957937778424442426
  2374.          617334727629299387668709205606050270810842907692932019128194
  2375.          467627007
  2376.  
  2377.    The primality of the number has been rigorously proven.
  2378.  
  2379.    The representation of the group in OAKLEY is
  2380.       Type of group:                    "MODP"
  2381.       Size of field element (bits):      1024
  2382.       Prime modulus:                     21 (decimal)
  2383.          Length (32 bit words):          32
  2384.          Data (hex):
  2385.             FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
  2386.             29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
  2387.             EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
  2388.             E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED
  2389.             EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381
  2390.             FFFFFFFF FFFFFFFF
  2391.       Generator:                         22 (decimal)
  2392.          Length (32 bit words):          1
  2393.          Data (hex):                     2
  2394.  
  2395.       Optional Parameters:
  2396.       Group order largest prime factor:  24 (decimal)
  2397.          Length (32 bit words):          32
  2398.          Data (hex):
  2399.             7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68
  2400.             94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E
  2401.             F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122
  2402.             F242DABB 312F3F63 7A262174 D31BF6B5 85FFAE5B 7A035BF6
  2403.             F71C35FD AD44CFD2 D74F9208 BE258FF3 24943328 F67329C0
  2404.             FFFFFFFF FFFFFFFF
  2405.       Strength of group:                 26 (decimal)
  2406.          Length (32 bit words)            1
  2407.          Data (hex):
  2408.             0000004D
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432. E.3. Well-Known Group 3:  An Elliptic Curve Group Definition
  2433.  
  2434.    The curve is based on the Galois field GF[2^155] with 2^155 field
  2435.    elements.  The irreducible polynomial for the field is u^155 + u^62 +
  2436.    1.  The equation for the elliptic curve is
  2437.  
  2438.    Y^2 + X Y = X^3 + A X + B
  2439.  
  2440.    X, Y, A, B are elements of the field.
  2441.  
  2442.    For the curve specified, A = 0 and
  2443.  
  2444.     B = u^18 + u^17 + u^16 + u^13 + u^12 + u^9 + u^8 + u^7 + u^3 + u^2 +
  2445.    u + 1.
  2446.  
  2447.    B is represented in binary as the bit string 1110011001110001111; in
  2448.    decimal this is 471951, and in hex 7338F.
  2449.  
  2450.    The generator is a point (X,Y) on the curve (satisfying the curve
  2451.    equation, mod 2 and modulo the field polynomial).
  2452.  
  2453.    X = u^6 + u^5 + u^4 + u^3 + u + 1
  2454.  
  2455.    and
  2456.  
  2457.    Y = u^8 + u^7 + u^6 + u^3.
  2458.  
  2459.    The binary bit strings for X and Y are 1111011 and 111001000; in
  2460.    decimal they are 123 and 456.
  2461.  
  2462.    The group order (the number of curve points) is
  2463.         45671926166590716193865565914344635196769237316
  2464.    which is 12 times the prime
  2465.  
  2466.          3805993847215893016155463826195386266397436443.
  2467.    (This prime has been rigorously proven.)  The generating point (X,Y)
  2468.    has order 4 times the prime; the generator is the triple of some
  2469.    curve point.
  2470.  
  2471.    OAKLEY representation of this group:
  2472.       Type of group:                    "EC2N"
  2473.       Size of field element (bits):      155
  2474.       Irreducible field polynomial:      21 (decimal)
  2475.          Length (32 bit words):          5
  2476.          Data (hex):
  2477.             08000000 00000000 00000000 40000000 00000001
  2478.       Generator:
  2479.          X coordinate:                   22 (decimal)
  2480.              Length (32 bit words):      1
  2481.              Data (hex):                 7B
  2482.          Y coordinate:                   22 (decimal)
  2483.              Length (32 bit words):      1
  2484.              Data (hex):                 1C8
  2485.       Elliptic curve parameters:
  2486.          A parameter:                    23 (decimal)
  2487.              Length (32 bit words):      1
  2488.              Data (hex):                 0
  2489.          B parameter:                    23 (decimal)
  2490.              Length (32 bit words):      1
  2491.              Data (hex):                 7338F
  2492.  
  2493.       Optional Parameters:
  2494.       Group order largest prime factor:  24 (decimal)
  2495.          Length (32 bit words):          5
  2496.          Data (hex):
  2497.             00AAAAAA AAAAAAAA AAAAB1FC F1E206F4 21A3EA1B
  2498.       Group order:                       25 (decimal)
  2499.          Length (32 bit words):          5
  2500.          Data (hex):
  2501.             08000000 00000000 000057DB 56985371 93AEF944
  2502.       Strength of group:                 26 (decimal)
  2503.          Length (32 bit words)            1
  2504.          Data (hex):
  2505.             0000004C
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565. E.4. Well-Known Group 4:  A Large Elliptic Curve Group Definition
  2566.  
  2567.    This curve is based on the Galois field GF[2^185] with 2^185 field
  2568.    elements.  The irreducible polynomial for the field is
  2569.  
  2570.    u^185 + u^69 + 1.
  2571.  
  2572.    The equation for the elliptic curve is
  2573.  
  2574.    Y^2 + X Y = X^3 + A X + B.
  2575.  
  2576.    X, Y, A, B are elements of the field.  For the curve specified, A = 0
  2577.    and
  2578.  
  2579.    B = u^12 + u^11 + u^10 + u^9 + u^7 + u^6 + u^5 + u^3 + 1.
  2580.  
  2581.    B is represented in binary as the bit string 1111011101001; in
  2582.    decimal this is 7913, and in hex 1EE9.
  2583.  
  2584.    The generator is a point (X,Y) on the curve (satisfying the curve
  2585.    equation, mod 2 and modulo the field polynomial);
  2586.  
  2587.    X = u^4 + u^3 and Y = u^3 + u^2 + 1.
  2588.  
  2589.    The binary bit strings for X and Y are 11000 and 1101; in decimal
  2590.    they are 24 and 13.  The group order (the number of curve points) is
  2591.  
  2592.         49039857307708443467467104857652682248052385001045053116,
  2593.  
  2594.    which is 4 times the prime
  2595.  
  2596.         12259964326927110866866776214413170562013096250261263279.
  2597.  
  2598.    (This prime has been rigorously proven.)
  2599.  
  2600.    The generating point (X,Y) has order 2 times the prime; the generator
  2601.    is the double of some curve point.
  2602.  
  2603.    OAKLEY representation of this group:
  2604.  
  2605.       Type of group:                    "EC2N"
  2606.       Size of field element (bits):      185
  2607.       Irreducible field polynomial:      21 (decimal)
  2608.          Length (32 bit words):          6
  2609.          Data (hex):
  2610.             02000000 00000000 00000000 00000020 00000000 00000001
  2611.       Generator:
  2612.          X coordinate:                   22 (decimal)
  2613.              Length (32 bit words):      1
  2614.              Data (hex):                 18
  2615.          Y coordinate:                   22 (decimal)
  2616.              Length (32 bit words):      1
  2617.              Data (hex):                 D
  2618.       Elliptic curve parameters:
  2619.          A parameter:                    23 (decimal)
  2620.              Length (32 bit words):      1
  2621.              Data (hex):                 0
  2622.          B parameter:                    23 (decimal)
  2623.              Length (32 bit words):      1
  2624.              Data (hex):                 1EE9
  2625.  
  2626.       Optional parameters:
  2627.       Group order largest prime factor:  24 (decimal)
  2628.          Length (32 bit words):          6
  2629.          Data (hex):
  2630.             007FFFFF FFFFFFFF FFFFFFFF F6FCBE22 6DCF9210 5D7E53AF
  2631.       Group order:                       25 (decimal)
  2632.          Length (32 bit words):          6
  2633.          Data (hex):
  2634.             01FFFFFF FFFFFFFF FFFFFFFF DBF2F889 B73E4841 75F94EBC
  2635.       Strength of group:                 26 (decimal)
  2636.          Length (32 bit words)            1
  2637.          Data (hex):
  2638.             0000005B
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696. Appendix F  Implementing Group Operations
  2697.  
  2698.  
  2699.    The group operation must be implemented as a sequence of arithmetic
  2700.    operations; the exact operations depend on the type of group.  For
  2701.    modular exponentiation groups, the operation is multi-precision
  2702.    integer multiplication and remainders by the group modulus.  See
  2703.    Knuth Vol. 2 [Knuth] for a discussion of how to implement these for
  2704.    large integers.  Implementation recommendations for elliptic curve
  2705.    group operations over GF[2^N] are described in [Schroeppel].
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762. BIBLIOGRAPHY
  2763.  
  2764.  
  2765.    [RFC1825] RFCs 1825-1827, R. Atkinson, "Security Architecture for the
  2766.    Internet Protocol", 08/09/1995; R. Atkinson, "IP Encapsulating
  2767.    Security Payload (ESP)", 08/09/1995; R. Atkinson, "IP Authentication
  2768.    Header", 08/09/1995
  2769.  
  2770.    [Blaze] Blaze, Matt et al., MINIMAL KEY LENGTHS FOR SYMMETRIC CIPHERS
  2771.    TO PROVIDE ADEQUATE COMMERCIAL
  2772.           SECURITY. A REPORT BY AN AD HOC GROUP OF CRYPTOGRAPHERS AND
  2773.    COMPUTER SCIENTISTS...
  2774.           --http://www.bsa.org/policy/encryption/cryptographers.html
  2775.  
  2776.    [STS] W. Diffie, P.C. Van Oorschot, and M.J. Wiener, "Authentication
  2777.    and Authenticated Key Exchanges," in Designs, Codes and Cryptography,
  2778.    Kluwer Academic Publishers, 1992, pp. 107
  2779.  
  2780.    [SECDNS] RFC2065, D. Eastlake, C. Kaufman, "Domain Name System
  2781.    Security Extensions", 01/03/1997
  2782.  
  2783.    [Random] RFC17150, D. Eastlake, S. Crocker, J. Schiller, "Randomness
  2784.    Recommendations for Security", 12/29/1994
  2785.  
  2786.    [Kocher] Kocher, Paul, Timing Attack,
  2787.    http://www.cryptography.com/timingattack.old/timingattack.html
  2788.  
  2789.    [Knuth] Knuth, Donald E., The Art of Computer Programming, Vol. 2,
  2790.    Seminumerical Algorithms, Addison Wesley, 1969.
  2791.  
  2792.    [Krawcyzk] Krawcyzk, Hugo, SKEME: A Versatile Secure Key Exchange
  2793.    Mechanism for Internet, ISOC Secure Networks and Distributed Systems
  2794.    Symposium, San Diego, 1996
  2795.  
  2796.    [Schneier] Schneier, Bruce, Applied cryptography: protocols,
  2797.    algorithms, and source code in C, Second edition, John Wiley & Sons,
  2798.    Inc. 1995, ISBN 0-471-12845-7, hardcover.  ISBN 0-471-11709-9,
  2799.    softcover.
  2800.  
  2801.    [Schroeppel] Schroeppel, Richard, et al.; Fast Key Exchange with
  2802.    Elliptic Curve Systems, Crypto '95, Santa Barbara, 1995.  Available
  2803.    on-line as ftp://ftp.cs.arizona.edu/reports/1995/TR95-03.ps (and .Z).
  2804.  
  2805.    [Stinson] Stinson, Douglas, Cryptography Theory and Practice. CRC
  2806.    Press, Inc., 2000, Corporate Blvd., Boca Raton, FL, 33431-9868, ISBN
  2807.    0-8493-8521-0, 1995
  2808.  
  2809.    [Zimmerman] Philip Zimmermann, The Official Pgp User's Guide,
  2810.    Published by MIT Press Trade, Publication date: June 1995, ISBN:
  2811.    0262740176
  2812.  
  2813.  
  2814.  
  2815.    Hilarie Orman DARPA orman@darpa.mil
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.