RFC 2412
The OAKLEY Key Determination Protocol
The OAKLEY Key Determination Protocol ๐ฆ
Okay bestie, this is RFC 2412 ๐ It's an Informational doc from the Network Working Group, written by H. Orman of the Department of Computer Science at the University of Arizona. It's dated November 1998. It doesn't obsolete or update anything, since the title block doesn't list any RFCs in either column โจ
Status of this Memo ๐ญ
Okay so this doc is just here to give the Internet some info ๐ It is not an Internet standard of any kind, and you're allowed to share it as much as you want ๐ซถ
Copyright Notice ยฉ๏ธ
Copyright (C) The Internet Society (1998). All Rights Reserved. Mine, theirs, everyone's ๐
Abstract ๐ธ
This doc describes a protocol called OAKLEY ๐ It's how two parties who have already authenticated each other can agree on secure, secret keying material. The core mechanism is the Diffie-Hellman key exchange algorithm, which is genuinely iconic ๐
OAKLEY is giving a lot. It supports Perfect Forward Secrecy ๐, works with the ISAKMP protocol for managing security associations ๐ค, lets you define your own abstract group structures for Diffie-Hellman ๐ง, handles key updates ๐, and can bring in keys that were distributed through out-of-band mechanisms ๐ฆ
1. INTRODUCTION โจ
Okay so key establishment is the heart of any data protection that uses cryptography ๐ It's an essential piece of the packet protection mechanisms in [RFC2401], for example. The Internet really needs a scalable and secure key distribution mechanism, and that's what this protocol is trying to be, with a whole lot of cryptographic strength ๐ช
Diffie-Hellman gives us exactly that kind of mechanism ๐ฆ It lets two parties agree on a shared value without needing encryption first, which is wild. That shared value is ready to go right away for encrypting whatever comes next, like data transmission and/or authentication ๐ฅ The STS protocol [STS] shows how to build the algorithm into a secure protocol. The best part is that it makes sure the two parties can trust each other's identities too, even when an active attacker is lurking ๐
OAKLEY is a generic key exchange protocol, and the keys it makes might be used to encrypt data with a long privacy lifetime, 20 years or more ๐ญ So the algorithms underneath it need to keep those keys secure for that whole time, based on the best predictions we have about the mathematical future ๐ฎ The protocol has two options to make life harder for an attacker who has tons of recorded key exchange traffic (a passive attacker) ๐ก๏ธ Both options are useful for deriving keys that will be used for encryption ๐
OAKLEY is related to STS ๐ They both authenticate the Diffie-Hellman exponentials and use them to figure out a shared key, and they both get Perfect Forward Secrecy for that shared key. But OAKLEY is different in a few ways, lowkey:
- The first is a weak address validation mechanism called "cookies" ๐ช Phil Karn described it in the Photuris key exchange protocol work in progress. It helps prevent denial of service attacks ๐ โโ๏ธ
- The second is that the two parties can pick mutually agreeable supporting algorithms for the protocol: the encryption method, the key derivation method, and the authentication method ๐งฉ
- The third is that the authentication does not depend on encryption using the Diffie-Hellman exponentials. Instead, it checks that the exponentials are bound to the identities of the parties ๐ชช
- The protocol doesn't require the two parties to compute the shared exponentials before authentication ๐
- This protocol adds extra security to keys meant for encryption (as opposed to authentication) by making them depend on one more algorithm. Keys for encryption depend not just on Diffie-Hellman, but also on the cryptographic method used to securely authenticate the communicating parties to each other ๐
- Finally, the protocol explicitly defines how the two parties can select the mathematical structures (group representation and operation) for Diffie-Hellman. They can use standard groups or define their own. User-defined groups give an extra degree of long-term security ๐
OAKLEY has several options for distributing keys ๐ Besides the classic Diffie-Hellman exchange, it can derive a new key from an existing key, and it can distribute an externally derived key by encrypting it.
The protocol lets two parties use all or some of the anti-clogging and perfect forward secrecy features ๐ It also allows authentication based on symmetric encryption or on non-encryption algorithms. This flexibility exists so the parties can use whatever features best fit their security and performance requirements ๐ง
This doc draws a lot in spirit and approach from the Photuris work in progress by Karn and Simpson (and from discussions with the authors) ๐ค It also draws from specifics of the ISAKMP document by Schertler et al., the ISAKMP protocol document, and papers by Paul van Oorschot and Hugo Krawcyzk ๐
2. The Protocol Outline ๐บ๏ธ
2.1 General Remarks โจ
OAKLEY is used to establish a shared key with an assigned identifier, plus associated authenticated identities for the two parties ๐ The name of the key can be used later to derive security associations for the RFC 2402 and RFC 2406 protocols (AH and ESP), or to reach other network security goals ๐ฏ
Each key is tied to algorithms used for authentication, privacy, and one-way functions. These are ancillary algorithms for OAKLEY. Whether they show up in security association definitions derived with other protocols is neither required nor prohibited ๐คทโโ๏ธ
The details of how to apply an algorithm to data are called a transform. This doc doesn't supply the transform definitions, because they'll be in separate RFC's ๐
The anti-clogging tokens, aka "cookies" ๐ช, give both parties a weak form of source address identification. The cookie exchange can be completed before they do the computationally expensive part of the protocol, which is the large integer exponentiations ๐งฎ
Here's the big deal: OAKLEY uses cookies for two purposes, anti-clogging and key naming ๐คฏ Each party contributes one cookie when key establishment starts, and the pair of cookies becomes the key identifier (KEYID), a reusable name for the keying material ๐ท๏ธ Because cookies have this dual role, the notation for the concatenated cookies ("COOKIE-I, COOKIE-R") can be used interchangeably with the symbol "KEYID" ๐
OAKLEY is designed to be a compatible component of the ISAKMP protocol [ISAKMP]. ISAKMP runs over UDP on a well-known port (see the RFC on port assignments, STD02-RFC-1700) ๐ The only technical requirement for the protocol environment is that the underlying protocol stack can supply the Internet address of the remote party for each message. So in theory, OAKLEY could be used directly over IP or over UDP, if suitable protocol or port number assignments were available ๐ธ
The machine running OAKLEY must have a good random number generator, as described in [RANDOM], to supply the random numbers this protocol needs ๐ฒ Anytime you see a "nonce," it means the nonce value was generated by that kind of generator. Same goes for "pseudorandom" values ๐
2.2 Notation ๐
This section describes the notation used in this doc for message sequences and content ๐งพ
2.2.1 Message descriptions ๐
The protocol exchanges below are written in an abbreviated notation, so the important stuff comes through clearly ๐ซถ A quick guide is below. The detailed formats and assigned values are in the appendices ๐
To keep message exchanges short, each message is described in terms of its source, its destination, and its relevant fields ๐ Arrows show the direction. "->" means the message goes from the initiator to the responder, and "<-" means it goes the other way ๐น
The fields in a message are named and separated by commas. The protocol uses the convention that the first several fields make up a fixed header format for all messages ๐
Here's a HYPOTHETICAL exchange of messages with a fixed format message. The four fixed fields are two "cookies," then a message type name, then a multi-precision integer that represents a power of a number ๐ง
Initiator Responder
-> Cookie-I, 0, OK_KEYX, g^x ->
<- Cookie-R, Cookie-I, OK_KEYX, g^y <-
So this is a two message sequence ๐ The initiator starts by sending a message with 4 fields to the responder. The first field has the unspecified value "Cookie-I", the second field has the numeric value 0, the third field says the message type is OK_KEYX, and the fourth value is an abstract group element g raised to the x'th power ๐ง
The second line shows the responder replying with "Cookie-R" in the first field, a copy of the "Cookie-I" value in the second field, message type OK_KEYX, and the number g raised to the y'th power ๐ฅฐ
OK_KEYX is in capitals because it's a unique constant. Constants are defined in the appendices ๐
Variable precision integers with length zero are null values for the protocol ๐ซฅ
Sometimes the protocol says that an entire payload (usually the Key Exchange Payload) has null values. The payload is still present in the message anyway, which makes parsing way easier ๐งโโ๏ธ โจ
2.2.2 Guide to symbols โจ
okay so Cookie-I and Cookie-R (or CKY-I and CKY-R) are 64-bit pseudo-random numbers ๐ The generation method must ensure, with high probability, that the numbers used for each IP remote address are unique over some time period, such as one hour ๐
KEYID is the concatenation of the initiator and responder cookies and the domain of interpretation. It's the name of the keying material ๐
sKEYID is used to denote the keying material named by the KEYID. It is never transmitted, but it gets used in various calculations performed by the two parties ๐คซ
OK_KEYX and OK_NEWGRP are distinct message types ๐
IDP is a bit that says whether or not material after the encryption boundary (see Appendix B) is encrypted. NIDP means not encrypted ๐ธ
g^x and g^y are encodings of group elements. g is a special group element indicated in the group description (see Appendix A), and g^x means that element raised to the x'th power ๐ฆ The type of the encoding is either a variable precision integer or a pair of such integers, as indicated in the group operation in the group description. Also, we'll write g^xy as a shorthand for g^(xy) ๐ See Appendix F for references that describe implementing large integer computations and how the different group definitions connect to basic arithmetic operations ๐
EHAO is a list of encryption/hash/authentication choices. Each item is a pair of values: a class name and an algorithm name ๐ง
EHAS is a set of three items picked from the EHAO list, one from each of the classes for encryption, hash, and authentication ๐
GRP is a name (a 32-bit value) for the group and its relevant parameters: the size of the integers, the arithmetic operation, and the generator element. There are a few pre-defined GRPs (for 768 bit modular exponentiation groups, 1024 bit modexp, 2048 bit modexp, and 155-bit and 210-bit elliptic curves, see Appendix E), but participants can share other group descriptions in a later protocol stage (see the section NEW GROUP). It's important to keep the notion of the GRP separate from the group descriptor (Appendix A). The former is just a name for the latter ๐ซถ
The symbol vertical bar "|" is used to denote concatenation of bit strings. Fields get concatenated using their encoded form, as they appear in their payload ๐
Ni and Nr are nonces picked by the initiator and responder, respectively ๐ฒ
ID(I) and ID(R) are the identities used to authenticate the initiator and responder, respectively ๐ชช
E{x}Ki indicates the encryption of x using the public key of the initiator. Encryption is done with the algorithm associated with the authentication method, which will usually be RSA ๐
S{x}Ki indicates the signature over x using the private key (signing key) of the initiator. Signing is done with the algorithm associated with the authentication method, which will usually be RSA or DSS โ๏ธ
prf(a, b) denotes the result of applying pseudo-random function "a" to data "b". You can think of "a" as a key, or as a value that characterizes the function prf. In the latter case, it's the index into a family of functions. Each function in the family provides a "hash", or one-way mixing, of the input ๐
prf(0, b) denotes the application of a one-way function to data "b" ๐ง
The similarity with the previous notation is deliberate. It shows that a single algorithm, e.g. MD5, might will be used for both purposes. In the first case, a "keyed" MD5 transform would be used with key "a". In the second case, the transform would have the fixed key value zero, which gives you a one-way function ๐ญ
The term "transform" refers to functions defined in auxiliary RFCs. The transform RFCs will be drawn from those defined for IPSEC AH and ESP (see RFC 2401 for the overall architecture that covers these protocols) ๐
2.3 The Key Exchange Message Overview ๐
The goal of key exchange processing is the secure establishment of common keying information state between the two parties. This state information is made up of a key name, secret keying material, the identification of the two parties, and three algorithms used during authentication: encryption (for privacy of the identities of the two parties), hashing (a pseudorandom function for protecting the integrity of the messages and for authenticating message fields), and authentication (the algorithm the mutual authentication of the two parties is based on). The encodings and meanings for these choices are presented in Appendix B ๐ฅ
The main mode exchange has five optional features: stateless cookie exchange, perfect forward secrecy for the keying material, secrecy for the identities, perfect forward secrecy for identity secrecy, and use of signatures (for non-repudiation). The two parties can use any combination of these features ๐
The general outline of processing is that the Initiator of the exchange starts by specifying as much information as they want in their first message. The Responder replies, supplying as much information as they want. The two sides keep exchanging messages, supplying more information each time, until their requirements are satisfied ๐ฌ
Choosing how much information to include in each message depends on which options are desirable. For example, if stateless cookies aren't a requirement, identity secrecy and perfect forward secrecy for the keying material aren't requirements, and non-repudiatable signatures are acceptable, then the exchange can be completed in three messages โญ
Additional features may increase the number of roundtrips needed for the keying material determination ๐ฃ๏ธ
ISAKMP provides fields for specifying the security association parameters used with the AH and ESP protocols. These security association payload types are specified in the ISAKMP memo. The payload types can be protected with OAKLEY keying material and algorithms, but this document doesn't discuss their use ๐ โโ๏ธ
2.3.1 The Essential Key Exchange Message Fields ๐งฉ
There are 12 fields in an OAKLEY key exchange message. Not all the fields are relevant in every message. If a field isn't relevant, it can have a null value or not be present (no payload) ๐ซง
CKY-I originator cookie.
CKY-R responder cookie.
MSGTYPE for key exchange, will be ISA_KE&AUTH_REQ or
ISA_KE&AUTH_REP; for new group definitions,
will be ISA_NEW_GROUP_REQ or ISA_NEW_GROUP_REP
GRP the name of the Diffie-Hellman group used for
the exchange
g^x (or g^y) variable length integer representing a power of
group generator
EHAO or EHAS encryption, hash, authentication functions,
offered and selectedj, respectively
IDP an indicator as to whether or not encryption with
g^xy follows (perfect forward secrecy for ID's)
ID(I) the identity for the Initiator
ID(R) the identity for the Responder
Ni nonce supplied by the Initiator
Nr nonce supplied by the Responder
The construction of the cookies is implementation dependent. Phil Karn has recommended making them the result of a one-way function applied to a secret value (changed periodically), the local and remote IP address, and the local and remote UDP port. That way, the cookies stay stateless and expire periodically. Note that with OAKLEY, this would also cause the KEYIDs derived from the secret value to expire, which means any state information associated with them has to be removed ๐งน
In order to support pre-distributed keys, we recommend that implementations reserve some portion of their cookie space for permanent keys. How these are encoded depends only on the local implementation ๐๏ธ
The encryption functions used with OAKLEY must be cryptographic transforms that guarantee privacy and integrity for the message data. Merely using DES in CBC mode is not permissible. The MANDATORY and OPTIONAL transforms will include any that satisfy this criteria and are defined for use with RFC 2406 (ESP).
The one-way (hash) functions used with OAKLEY must be cryptographic transforms that can be used as either keyed hash (pseudo-random) or non-keyed transforms. The MANDATORY and OPTIONAL transforms will include any that are defined for use with RFC 2406 (AH) ๐ก๏ธ
Wherever nonces are indicated, they'll be variable precision integers with an entropy value that matches the "strength" attribute of the GRP used with the exchange. If no GRP is indicated, the nonces must be at least 90 bits long. The pseudo-random generator for the nonce material should start with initial data that has at least 90 bits of entropy; see RFC 1750 ๐ฒโจ
2.3.1.1 Exponent Advice ๐ง
Ideally, the exponents will have at least 180 bits of entropy for every key exchange. This makes sure the keying material between two exchanges is completely independent (note that this applies even if only one of the parties chooses a random exponent) ๐ช
In practice, implementors may want to base several key exchanges on a single base value with 180 bits of entropy, and use one-way hash functions to guarantee that exposing one key won't compromise the others. In this case, a good recommendation is to keep the base values for nonces and cookies separate from the base value for exponents, and to replace the base value with a full 180 bits of entropy as often as possible ๐
The values 0 and p-1 should not be used as exponent values. Implementors should be sure to check for these values, and they should also refuse to accept the values 1 and p-1 from remote parties (where p is the prime used to define a modular exponentiation group) ๐ โโ๏ธ
2.3.2 Mapping to ISAKMP Message Structures ๐บ๏ธ
All the OAKLEY message fields correspond to ISAKMP message payloads or payload components. The relevant payload fields are the SA payload, the AUTH payload, the Certificate Payload, and the Key Exchange Payload. The ISAKMP protocol framework is a work in progress at this time, and the exact mapping of OAKLEY message fields to ISAKMP payloads is also in progress (to be known as the Resolution document) ๐ง
Some of the ISAKMP header and payload fields will have constant values when used with OAKLEY. The exact values to be used will be published in a Domain of Interpretation document that accompanies the Resolution document ๐
Below, we show where each OAKLEY field appears in the ISAKMP message structure. These are recommended only. The Resolution document will be the final authority on this mapping ๐ธ
CKY-I ISAKMP header
CKY-R ISAKMP header
MSGTYPE Message Type in ISAKMP header
GRP SA payload, Proposal section
g^x (or g^y) Key Exchange Payload, encoded as a variable
precision integer
EHAO and EHAS SA payload, Proposal section
IDP A bit in the RESERVED field in the AUTH header
ID(I) AUTH payload, Identity field
ID(R) AUTH payload, Identity field
Ni AUTH payload, Nonce Field
Nr AUTH payload, Nonce Field
S{...}Kx AUTH payload, Data Field
prf{K,...} AUTH payload, Data Field
2.4 The Key Exchange Protocol โจ
okay so the exact number and content of messages in an OAKLEY key exchange depends on which options the Initiator and Responder want to use ๐ a key exchange can be finished with three or more messages, depending on those options ๐
the three components of the key determination protocol are:
- 1. cookie exchange (optionally stateless) ๐
- 2. Diffie-Hellman half-key exchange (optional, but essential for perfect forward secrecy) ๐ฅ
- 3. authentication (options: privacy for ID's, privacy for ID's with PFS, non-repudiatable) ๐
the initiator can send as little as a bare exchange request, with no extra info attached ๐ฆ or, on the flip side, it can start by sending everything the responder needs to authenticate the request and finish key determination super fast, if the responder is down with that method ๐ if not, the responder can just reply with a minimal amount of info (at the very least, a cookie) ๐ง
the method of authentication can be digital signatures, public key encryption, or an out-of-band symmetric key ๐ these three methods cause slight variations in the messages, and the examples in this section show those variations ๐
the Initiator is responsible for retransmitting messages if the protocol does not terminate in a timely fashion ๐ญ so the Responder MUST avoid discarding reply information until the Initiator acknowledges it while the protocol continues ๐ซถ
the rest of this section has examples showing how to use OAKLEY options โจ
2.4.1 An Aggressive Example ๐ธ
this example shows how two parties can finish a key exchange in three messages ๐ the identities aren't secret, and the derived keying material is protected by PFS ๐
by using digital signatures, the two parties get a proof of communication that can be recorded and shown to a third party later on ๐
the keying material implied by the group exponentials isn't needed to complete the exchange ๐ if you want to put off the computation, the implementation can save the "x" and "g^y" values and mark the keying material as "uncomputed" ๐ง it can be computed from this info later on โญ
Initiator Responder
--------- ---------
-> CKY-I, 0, OK_KEYX, GRP, g^x, EHAO, NIDP, ->
ID(I), ID(R), Ni, 0,
S{ID(I) | ID(R) | Ni | 0 | GRP | g^x | 0 | EHAO}Ki
<- CKY-R, CKY-I, OK_KEYX, GRP, g^y, EHAS, NIDP,
ID(R), ID(I), Nr, Ni,
S{ID(R) | ID(I) | Nr | Ni | GRP | g^y | g^x | EHAS}Kr <-
-> CKY-I, CKY-R, OK_KEYX, GRP, g^x, EHAS, NIDP, ->
ID(I), ID(R), Ni, Nr,
S{ID(I) | ID(R) | Ni | Nr | GRP | g^x | g^y | EHAS}Ki
NB "NIDP" means that the PFS option for hiding identities is not used. i.e., the identities are not encrypted using a key based on g^xy
NB Fields are shown separated by commas in this document; they are concatenated in the actual protocol messages using their encoded forms as specified in the ISAKMP/Oakley Resolution document. ๐
the result of this exchange is a key with KEYID = CKY-I|CKY-R and value
sKEYID = prf(Ni | Nr, g^xy | CKY-I | CKY-R)
the processing outline for this exchange goes like this ๐บ๏ธ
Initiation ๐
the Initiator generates a unique cookie and ties it to the expected IP address of the responder, plus its chosen state info: GRP (the group identifier), a pseudo-randomly selected exponent x, g^x, EHAO list, nonce, identities ๐ the first authentication choice in the EHAO list is an algorithm that supports digital signatures, and this is what gets used to sign the ID's, the nonce and the group id โ๏ธ the Initiator also notes that the key is in the initial state of "unauthenticated" ๐ซฅ and sets a timer for possible retransmission and/or termination of the request โฐ
when the Responder gets the message, it can choose to ignore everything and treat it as just a request for a cookie, creating no state ๐ if CKY-I isn't already in use by the source address in the IP header, the responder generates a unique cookie, CKY-R ๐ช the next steps depend on the Responder's preferences ๐ญ the minimal required response is to reply with the first cookie field set to zero and CKY-R in the second field ๐ซถ for this example we'll assume the responder is more aggressive (for the alternatives, see section 6) and accepts the following:
- group with identifier GRP,
- first authentication choice (which MUST be the digital signature method used to sign the Initiator message),
- lack of perfect forward secrecy for protecting the identities,
- identity ID(I) and identity ID(R)
in this example the Responder decides to accept all the info the Initiator offered ๐ it validates the signature over the signed portion of the message, and associates the pair (CKY-I, CKY-R) with the following state info:
- the source and destination network addresses of the message
- key state of "unauthenticated"
- the first algorithm from the authentication offer
- group GRP, a "y" exponent value in group GRP, and g^x from the message
- the nonce Ni and a pseudorandomly selected value Nr
- a timer for possible destruction of the state
the Responder computes g^y, forms the reply message, signs the ID and nonce info with the private key of ID(R), and sends it to the Initiator ๐จ in all exchanges, each party SHOULD make sure that it neither offers nor accepts 1 or g^(p-1) as an exponential ๐ โโ๏ธ
in this example, to speed things up, the Responder implicitly accepts the first algorithm in the Authentication class of the EHAO list ๐โโ๏ธ this is because it can't validate the Initiator's signature without accepting the algorithm used to do the signature ๐ the Responder's EHAS list will also reflect that acceptance ๐
the Initiator receives the reply message and
- validates that CKY-I is a valid association for the network address of the incoming message,
- adds the CKY-R value to the state for the pair (CKY-I, network address), and associates all state info with the pair (CKY-I, CKY-R),
- validates the signature of the responder over the state info (if validation fails, the message is discarded),
- adds g^y to its state info,
- saves the EHA selections in the state,
- optionally computes (g^y)^x (= g^xy) (this can be deferred until after sending the reply message),
- sends the reply message, signed with the public key of ID(I),
- marks the KEYID (CKY-I|CKY-R) as authenticated,
- and composes the reply message and signature ๐ท
when the Responder gets the Initiator's message, and the signature is valid, it marks the key as being in the authenticated state ๐ฅฐ it SHOULD compute g^xy and associate it with the KEYID ๐ง
note that even though PFS for identity protection isn't used, PFS for the derived keying material is still there, because the Diffie-Hellman half-keys g^x and g^y are exchanged ๐
even if the Responder only accepts some of the Initiator's info, the Initiator will consider the protocol to be progressing ๐ the Initiator SHOULD assume that fields the Responder didn't accept were not recorded by the Responder ๐ซง
if the Responder doesn't accept the aggressive exchange and picks another algorithm for the A function, then the protocol won't continue using the signature algorithm or the signature value from the first message ๐
2.4.1.1 Fields Not Present ๐
if the Responder doesn't accept all the fields the Initiator offered, it SHOULD include null values for those fields in its response ๐ซ Section 6 has guidelines on how to select fields in a "left-to-right" manner ๐ if a field isn't accepted, then it and all following fields MUST have null values ๐ซ
the Responder SHOULD NOT record any info it doesn't accept ๐ if the ID's and nonces have null values, there won't be a signature over those null values ๐ซฅ
2.4.1.2 Signature via Pseudo-Random Functions ๐ฆ
the aggressive example is written to suggest that public key technology is used for the signatures ๐ however, a pseudorandom function can be used, if the parties have previously agreed to such a scheme and have a shared key ๐ค
if the first proposal in the EHAO list is an "existing key" method, then the KEYID named in that proposal will supply the keying material for the "signature", which is computed using the "H" algorithm associated with the KEYID ๐งช
suppose the first proposal in EHAO is
EXISTING-KEY, 32
and the "H" algorithm for KEYID 32 is MD5-HMAC, by prior negotiation ๐ค the keying material is some string of bits, call it sK32 ๐ then in the first message of the aggressive exchange, where the signature
S{ID(I), ID(R), Ni, 0, GRP, g^x, EHAO}Ki
is indicated, the signature computation would be performed by
MD5-HMAC_func(KEY=sK32, DATA = ID(I) | ID(R) | Ni | 0 | GRP | g^x
| g^y | EHAO)
(The exact definition of the algorithm corresponding to "MD5-HMAC- func" will appear in the RFC defining that transform ๐)
the result of this computation appears in the Authentication payload ๐
โจ that's the end of this part, bestie, more coming up next! โจ ๐
2.4.2 An Aggressive Example With Hidden Identities โจ
okay so this one shows how two parties can finish a key exchange without digital signatures ๐ public key crypto hides the identities during auth. the group exponentials get exchanged and authenticated, but the implied keying material (g^xy) isn't needed during the exchange ๐
this one is lowkey different from the signature version ๐ฆ in the first message, the responder's identity shows up in cleartext: ID(R'). but the identity that gets hidden by the public key crypto is a different one: ID(R). why? the Initiator has to tell the Responder which public/private key pair to use for decryption, but the identity also has to stay hidden behind encryption with that same public key. it's a whole thing ๐
The Initiator might choose to give up secrecy of the Responder identity, but that's undesirable ๐ instead, if there's a well-known identity for the responder node, its public key can be used to encrypt the actual Responder identity ๐
Initiator Responder
--------- ---------
-> CKY-I, 0, OK_KEYX, GRP, g^x, EHAO, NIDP, ->
ID(R'), E{ID(I), ID(R), E{Ni}Kr}Kr'
<- CKY-R, CKY-I, OK_KEYX, GRP, g^y, EHAS, NIDP,
E{ID(R), ID(I), Nr}Ki,
prf(Kir, ID(R) | ID(I) | GRP | g^y | g^x | EHAS) <-
-> CKY-I, CKY-R, OK_KEYX, GRP, 0, 0, NIDP,
prf(Kir, ID(I) | ID(R) | GRP | g^x | g^y | EHAS) ->
Kir = prf(0, Ni | Nr)
NB "NIDP" means that the PFS option for hiding identities is not used.
NB The ID(R') value is included in the Authentication payload as described in Appendix B.
The result of this exchange is a key with KEYID = CKY-I|CKY-R and value sKEYID = prf(Ni | Nr, g^xy | CKY-I | CKY-R).
Here's the processing outline, step by step ๐ง
- Initiation
- The Initiator generates a unique cookie and ties it to the expected IP address of the responder, plus its chosen state info: GRP, g^x, EHAO list. The first authentication choice in the EHAO list is an algorithm that supports public key encryption. The Initiator also names the two identities for the connection and puts them into the state. A well-known identity for the responder machine is also picked, and that identity's public key is used to encrypt the nonce Ni and the two connection identities. The Initiator further notes that the key is in the initial state of "unauthenticated", and sets a timer for possible retransmission and/or termination of the request.
When the Responder gets the message, they MAY choose to ignore all of it and treat it as just a request for a cookie, creating no state ๐ธ
If CKY-I isn't already in use by the source address in the IP header, the Responder generates a unique cookie, CKY-R. Next steps depend on the responder's preferences ๐ the minimal required response is a message with the first cookie field set to zero and CKY-R in the second field. for this example, the responder is more aggressive and accepts the following:
- group GRP
- first authentication choice (which MUST be the public key encryption algorithm used to encrypt the payload)
- lack of perfect forward secrecy for protecting the identities
- identity ID(I)
- identity ID(R)
The Responder MUST decrypt the ID and nonce information using the private key for the R' ID. After that, the private key for the R ID gets used to decrypt the nonce field ๐ฅ
The Responder now ties the pair (CKY-I, CKY-R) to this state info:
- the source and destination network addresses of the message
- key state of "unauthenticated"
- the first algorithm from each class in the EHAO (encryption-hash-authentication algorithm offers) list
- group GRP and a y and g^y value in group GRP
- the nonce Ni and a pseudorandomly selected value Nr
- a timer for possible destruction of the state
The Responder then encrypts the state info with the public key of ID(I), forms the prf value, and sends it to the Initiator ๐
The Initiator gets the reply and:
- validates that CKY-I is a valid association for the network address of the incoming message,
- adds the CKY-R value to the state for the pair (CKY-I, network address), and ties all state info to the pair (CKY-I, CKY-R),
- decrypts the ID and nonce information,
- checks the prf calculation (if this fails, the message SHOULD be discarded),
- adds g^y to its state info,
- saves the EHA selections in the state,
- optionally computes (g^x)^y (= g^xy) (this may be deferred), and
- sends the reply message, encrypted with the public key of ID(R),
- and marks the KEYID (CKY-I|CKY-R) as authenticated.
When the Responder gets this message, it marks the key as being in the authenticated state. If it hasn't already done so, it SHOULD compute g^xy and tie it to the KEYID ๐ฆ
The secret keying material is sKEYID = prf(Ni | Nr, g^xy | CKY-I | CKY-R)
sKEYID = prf(Ni | Nr, g^xy | CKY-I | CKY-R)
Note that even though PFS for identity protection isn't used, PFS for the derived keying material is still there, because the Diffie-Hellman half-keys g^x and g^y get exchanged. the vibes are immaculate ๐
2.4.3 An Aggressive Example With Private Identities and Without Diffie-Hellman
okay so if perfect forward secrecy isn't a requirement for session key derivation, you can skip a LOT of expensive computation ๐ค the two parties exchange nonces and secret key parts to get authentication and derive keying material. the long-term privacy of data protected with that keying material depends on each party's private keys ๐
in this exchange, GRP has the value 0, and the group exponential field holds a nonce value instead โจ
like in the previous section, the first proposed algorithm MUST be a public key encryption system. by responding with a cookie and a non-zero exponential field, the Responder implicitly accepts the first proposal, plus the lack of perfect forward secrecy for the identities and the derived keying material ๐
Initiator Responder
--------- ---------
-> CKY-I, 0, OK_KEYX, 0, 0, EHAO, NIDP, ->
ID(R'), E{ID(I), ID(R), sKi}Kr', Ni
<- CKY-R, CKY-I, OK_KEYX, 0, 0, EHAS, NIDP,
E{ID(R), ID(I), sKr}Ki, Nr,
prf(Kir, ID(R) | ID(I) | Nr | Ni | EHAS) <-
-> CKY-I, CKY-R, OK_KEYX, EHAS, NIDP,
prf(Kir, ID(I) | ID(R) | Ni | Nr | EHAS) ->
Kir = prf(0, sKi | sKr)
NB The sKi and sKr values go into the nonce fields. The change in notation is meant to emphasize that their entropy is critical to setting the keying material.
NB "NIDP" means that the PFS option for hiding identities is not used.
The result of this exchange is a key with KEYID = CKY-I|CKY-R and value sKEYID = prf(Kir, CKY-I | CKY-R). ๐
2.4.3 A Conservative Example
in this one, the two parties are minimally aggressive ๐ they use the cookie exchange to delay creating state, and they use perfect forward secrecy to protect the identities. for this example they use public key encryption for authentication, but digital signatures or pre-shared keys can also be used, like we saw before. the conservative example doesn't change how nonces, prf's, etc. work, but it does change how much info gets sent in each message ๐ง
the responder treats the initiator being able to repeat CKY-R as weak evidence that the message comes from a "live" correspondent on the network, and that the correspondent is tied to the initiator's network address. the initiator makes similar assumptions when CKY-I gets repeated back to it ๐ซถ
All messages MUST have either valid cookies or at least one zero cookie. If both cookies are zero, that means a request for a cookie. If only the initiator cookie is zero, it's a response to a cookie request ๐
Info in messages that break the cookie rules can't be used for any OAKLEY operations ๐ซ
Note that the Initiator and Responder MUST agree on one set of EHA algorithms. there isn't one set for the Responder and another for the Initiator. The Initiator MUST include at least MD5 and DES in the initial offer. ๐ฅ
Fields that aren't indicated have null values.
Initiator Responder
--------- ---------
-> 0, 0, OK_KEYX ->
<- 0, CKY-R, OK_KEYX <-
-> CKY-I, CKY-R, OK_KEYX, GRP, g^x, EHAO ->
<- CKY-R, CKY-I, OK_KEYX, GRP, g^y, EHAS <-
-> CKY-I, CKY-R, OK_KEYX, GRP, g^x, IDP*,
ID(I), ID(R), E{Ni}Kr, ->
<- CKY-R, CKY-I, OK_KEYX, GRP, 0 , 0, IDP, <-
E{Nr, Ni}Ki, ID(R), ID(I),
prf(Kir, ID(R) | ID(I) | GRP | g^y | g^x | EHAS )
-> CKY-I, CKY-R, OK_KEYX, GRP, 0 , 0, IDP,
prf(Kir, ID(I) | ID(R) | GRP | g^x | g^y | EHAS ) ->
Kir = prf(0, Ni | Nr)
* when IDP is in effect, authentication payloads are encrypted with the selected encryption algorithm using the keying material prf(0, g^xy). (The transform defining the encryption algorithm will define how to select key bits from the keying material.) This encryption is in addition to and after any public key encryption. See Appendix B.
Note that several fields are left out of the description in the first messages. These fields are present as null values. ๐ธ
The first exchange lets the Responder use stateless cookies ๐ง if the responder generates cookies in a way that lets it validate them without saving them, like in Photuris, then this is possible. Even if the Initiator includes a cookie in its initial request, the responder can still use stateless cookies by just leaving CKY-I out of its reply and by holding off on recording the Initiator cookie until it shows up in a later message.
After the exchange is done, both parties compute the shared key material sKEYID as prf(Ni | Nr, g^xy | CKY-I | CKY-R), where "prf" is the pseudo-random function in class "hash" selected in the EHA list.
Just like with the cookies, each party treats the remote side's ability to repeat the Ni or Nr value as proof that Ka, the public key of party a, speaks for the remote party and establishes its identity ๐
Here's the big thing to get: even though the IDP option makes sure the identities are protected with an ephemeral key g^xy, the authentication itself doesn't depend on g^xy ๐ง it's essential that the authentication steps validate the g^x and g^y values, so it's imperative that the authentication not have a circular dependency on them. a third party could try a "man-in-middle" trick to get the initiator and responder to use different g^xy values. that attack might reveal the identities to an eavesdropper, but the authentication would fail ๐
2.4.4 Extra Strength for Protection of Encryption Keys โจ
okay so the nonces Ni and Nr give your session keys an extra layer of secrecy ๐ bestie, which means the key's secrecy depends on TWO different problems: the discrete logarithm problem in the group G, AND breaking the nonce encryption scheme ๐ญ If RSA encryption is used, that second problem is roughly the same as factoring the RSA public keys of both the initiator and responder. literally so iconic ๐
For authentication, you have to indicate the key type, the validation method, and the certification requirement. no skipping!! ๐ซถ
2.5 Identity and Authentication ๐ฆ
2.5.1 Identity ๐
In OAKLEY exchanges, the Initiator offers Initiator and Responder ID's -- the former is the claimed identity for the Initiator, and the latter is the requested ID for the Responder. ๐
If neither ID is specified, the ID's are taken from the IP header source and destination addresses. so it's giving self-serve vibes ๐ธ
If the Initiator doesn't supply a responder ID, the Responder can reply by naming any identity that the local policy allows. The Initiator can refuse acceptance by terminating the exchange. ๐
The Responder can also reply with a different ID than the Initiator suggested. The Initiator can accept this implicitly by continuing the exchange, or refuse it by terminating (not replying). the way that the Initiator gets to decide is so main character ๐
2.5.2 Authentication ๐ฅ
The authentication of principals to one another is at the heart of any key exchange scheme. The Internet community must decide on a scalable standard for solving this problem, and OAKLEY must make use of that standard. At the time of this writing, there is no such standard, though several are emerging. This document attempts to describe how a handful of standards could be incorporated into OAKLEY, without attempting to pick and choose among them. ngl this is the big-picture drama ๐ญ
The following methods can appear in OAKLEY offers:
- a. Pre-shared Keys ๐ When two parties have arranged for a trusted method of distributing secret keys for their mutual authentication, they can be used for authentication. This has obvious scaling problems for large systems, but it is an acceptable interim solution for some situations. Support for pre-shared keys is REQUIRED.
The encryption, hash, and authentication algorithm for use with a pre-shared key must be part of the state information distributed with the key itself.
The pre-shared keys have a KEYID and keying material sKEYID. The KEYID is used in a pre-shared key authentication option offer. There can be more than one pre-shared key offer in a list.
Because the KEYID persists over different invocations of OAKLEY (after a crash, etc.), it must occupy a reserved part of the KEYID space for the two parties. A few bits can be set aside in each party's "cookie space" to accommodate this.
There is no certification authority for pre-shared keys. When a pre-shared key is used to generate an authentication payload, the certification authority is None, the Authentication Type is Preshared, and the payload contains:
the KEYID, encoded as two 64-bit quantities, and the result of
applying the pseudorandom hash function to the message body
with the sKEYID forming the key for the function
- b. DNS public keys ๐ง Security extensions to the DNS protocol [DNSSEC] provide a convenient way to access public key information, especially for public keys associated with hosts. RSA keys are a requirement for secure DNS implementations. Extensions to allow optional DSS keys are a near-term possibility.
DNS KEY records have associated SIG records that are signed by a zone authority, and a hierarchy of signatures back to the root server establishes a foundation for trust. The SIG records indicate the algorithm used for forming the signature.
OAKLEY implementations must support the use of DNS KEY and SIG records for authenticating with respect to IPv4 and IPv6 addresses and fully qualified domain names. However, implementations are not required to support any particular algorithm (RSA, DSS, etc.). ๐
- c. RSA public keys w/o certification authority signature PGP ๐ PGP [Zimmerman] uses public keys with an informal method for establishing trust. The format of PGP public keys and naming methods will be described in a separate RFC. The RSA algorithm can be used with PGP keys for either signing or encryption. The authentication option should indicate either
RSA-SIGorRSA-ENC, respectively. Support for this is OPTIONAL. - d.1 RSA public keys w/ certificates ๐ There are various formats and naming conventions for public keys that are signed by one or more certification authorities. The Public Key Interchange Protocol discusses X.509 encodings and validation. Support for this is OPTIONAL.
- d.2 DSS keys w/ certificates ๐ซง Encoding for the Digital Signature Standard with X.509 is described in draft-ietf-ipsec-dss-cert-00.txt. Support for this is OPTIONAL; an ISAKMP Authentication Type will be assigned.
2.5.3 Validating Authentication Keys โจ
The combination of the Authentication algorithm, the Authentication Authority, the Authentication Type, and a key (usually public) define how to validate the messages with respect to the claimed identity. The key information will be available either from a pre-shared key, or from some kind of certification authority. ๐
Generally, the certification authority produces a certificate binding the entity name to a public key. OAKLEY implementations must be prepared to fetch and validate certificates before using the public key for OAKLEY authentication purposes. no shortcuts, bestie ๐ โโ๏ธ
The ISAKMP Authentication Payload defines the Authentication Authority field for specifying the authority that must be apparent in the trust hierarchy for authentication.
Once an appropriate certificate is obtained (see 2.4.3), the validation method will depend on the Authentication Type. If it is PGP, then the PGP signature validation routines can be called to satisfy the local web-of-trust predicates. If it is RSA with X.509 certificates, the certificate must be examined to see if the certification authority signature can be validated, and if the hierarchy is recognized by the local policy. โ
2.5.4 Fetching Identity Objects ๐
In addition to interpreting the certificate or other data structure that contains an identity, users of OAKLEY must face the task of retrieving certificates that bind a public key to an identifier, and also retrieving auxiliary certificates for certifying authorities or co-signers (as in the PGP web of trust). it's a whole quest ๐บ๏ธ
The ISAKMP Credentials Payload can be used to attach useful certificates to OAKLEY messages. The Credentials Payload is defined in Appendix B.
Support for accessing and revoking public key certificates via the Secure DNS protocol [SECDNS] is MANDATORY for OAKLEY implementations. Other retrieval methods can be used when the AUTH class indicates a preference.
The Public Key Interchange Protocol discusses a full protocol that might be used with X.509 encoded certificates. ๐ธ
2.6 Interface to Cryptographic Transforms ๐ซ
The keying material computed by the key exchange should have at least 90 bits of entropy, which means that it must be at least 90 bits in length. This may be more or less than is required for keying the encryption and/or pseudorandom function transforms. ๐ฅ
The transforms used with OAKLEY should have auxiliary algorithms which take a variable precision integer and turn it into keying material of the appropriate length. For example, a DES algorithm could take the low order 56 bits, and a triple DES algorithm might use the following:
K1 = low 56 bits of md5(0|sKEYID)
K2 = low 56 bits of md5(1|sKEYID)
K3 = low 56 bits of md5(2|sKEYID)
The transforms will be called with the keying material encoded as a variable precision integer, the length of the data, and the block of memory with the data. Conversion of the keying material to a transform key is the responsibility of the transform. the transform does the heavy lifting, periodt ๐ โจ
2.7 Retransmission, Timeouts, and Error Messages โจ
okay bestie, so if the Responder doesn't reply in a reasonable amount of time, the Initiator should resend the message ๐. Both sides have to handle those retransmissions gracefully ๐ , so the Responder must keep the info it needs to resend stuff until the Initiator moves on to the next message or finishes the whole exchange. ๐ซถ
Informational error messages are kinda tricky ngl ๐ญ. They can't be authenticated using only the info in an incomplete exchange, so the parties may wanna set up a default key just for OAKLEY error messages. One way to do that is described in Appendix B, under the ISA_INIT message types ๐ธ.
Here's the deal for this one: the message type is OAKLEY Error. The KEYID brings the H algorithm and key for authenticating the message contents, and that value gets carried in the Sig/Prf payload ๐.
The Error payload holds the error code and the contents of the rejected message ๐.
1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! !
~ Initiator-Cookie ~
/ ! !
KEYID +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\ ! !
~ Responder-Cookie ~
! !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Domain of Interpretation !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Message Type ! Exch ! Vers ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! SPI (unused) !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! SPI (unused) !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Error Payload !
~ ~
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Sig/prf Payload
~ ~
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The error message will contain the cookies as they showed up in the offending message ๐ช, the message type OAKLEY_ERROR, and the reason for the error, followed by the rejected message. ๐
Error messages are informational only, so the correctness of the protocol doesn't depend on them. Not me being like "okay, but what if," because it's giving low-stakes ๐ฆ.
Error reasons:
TIMEOUT exchange has taken too long, state destroyed
AEH_ERROR an unknown algorithm appears in an offer
GROUP_NOT_SUPPORTED GRP named is not supported
EXPONENTIAL_UNACCEPTABLE exponential too large/small or is +-1
SELECTION_NOT_OFFERED selection does not occur in offer
NO_ACCEPTABLE_OFFERS no offer meets host requirements
AUTHENTICATION_FAILURE signature or hash function fails
RESOURCE_EXCEEDED too many exchanges or too much state info
NO_EXCHANGE_IN_PROGRESS a reply received with no request in progress
2.8 Additional Security for Privacy Keys: Private Groups ๐ฅ
okay so if the two parties need a Diffie-Hellman key determination scheme that doesn't depend on the standard group definitions, they've got the option of setting up a private group ๐. They don't have to redo the authentication, because this stage is already protected by a pre-existing authentication key ๐. As an extra layer, the two parties establish a private name for the shared keying material. So even if they use exactly the same group to talk to other people, the re-use won't be obvious to passive attackers ๐.
Private groups are iconic for this reason: they make a widespread passive attack way harder, since the attacker would have to exhaustively analyze way more groups to recover a bunch of session keys ๐. Compare that to when only one or two groups ever get used. In that case, you'd expect years and years of session keys to get compromised. Yikes ๐ญ.
There are two technical challenges to face. First, how can a particular user create a unique and appropriate group? Second, how can a second party assure himself that the proposed group is reasonably secure? ๐ง
The security of a modular exponentiation group depends on the largest prime factor of the group size. To maximize this, you can choose "strong" or Sophie Germaine primes, P = 2Q + 1, where P and Q are prime. However, if P = kQ + 1, where k is small, then the strength of the group is still considerable ๐ช. These groups are known as Schnorr subgroups, and they can be found with much less computational effort than Sophie-Germaine primes โจ.
Schnorr subgroups can also be validated efficiently by using probable prime tests ๐งช.
It's also fairly easy to find P, k, and Q such that the largest prime factor can be easily proven to be Q ๐ฆ.
We estimate that it would take about 10 minutes to find a new group of about 2^1024 elements, and this could be done once a day by a scheduled process โฐ. Validating a group proposed by a remote party would take perhaps a minute on a 25 MHz RISC machine or a 66 MHz CISC machine ๐ฅ๏ธ.
We note that validation is only done between previously mutually authenticated parties, and that a new group definition always follows and is protected by a key established using a well-known group ๐ซถ. There are five points to keep in mind:
a. The description and public identifier for the new group are protected by the well-known group.
b. The responder can reject the attempt to establish the new group, either because he is too busy or because he cannot validate the largest prime factor as being sufficiently large ๐ โโ๏ธ.
c. The new modulus and generator can be cached for long periods of time. They are not security critical and need not be associated with ongoing activity ๐.
d. Generating a new g^x value periodically will be more expensive if there are many groups cached. However, the importance of frequently generating new g^x values is reduced, so the time period can be lengthened correspondingly ๐.
e. All modular exponentiation groups have subgroups that are weaker than the main group. For Sophie Germain primes, if the generator is a square, then there are only two elements in the subgroup: 1 and g^(-1) (same as g^(p-1)), which we have already recommended avoiding. For Schnorr subgroups with k not equal to 2, the subgroup can be avoided by checking that the exponential is not a kth root of 1 (e^k != 1 mod p) ๐.
2.8.1 Defining a New Group ๐
This section describes how to define a new group. The description of the group is hidden from eavesdroppers, and the identifier assigned to the group is unique to the two parties ๐ต๏ธโโ๏ธ. Using the new group for Diffie-Hellman key exchanges is covered in the next section ๐.
The secrecy of the description and the identifier makes a passive attack harder. If the group descriptor isn't known to the attacker, there's no straightforward and efficient way to gain info about keys calculated using the group ๐.
Only the description of the new group needs to be encrypted in this exchange. The hash algorithm is implied by the OAKLEY session named by the group. The encryption is the encryption function of the OAKLEY session ๐ง.
The descriptor of the new group is encoded in the new group payload. The nonces are encoded in the Authentication Payload ๐ฆ.
Data beyond the encryption boundary is encrypted using the transform named by the KEYID ๐.
The following messages use the ISAKMP Key Exchange Identifier OAKLEY New Group ๐.
To define a new modular exponentiation group:
Initiator Responder
--------- ----------
-> KEYID, ->
INEWGRP,
Desc(New Group), Na
prf(sKEYID, Desc(New Group) | Na)
<- KEYID,
INEWGRPRS,
Na, Nb
prf(sKEYID, Na | Nb | Desc(New Group)) <-
-> KEYID,
INEWGRPACK
prf(sKEYID, Nb | Na | Desc(New Group)) ->
These messages are encrypted at the encryption boundary using the key indicated. The hash value is placed in the "digital signature" field (see Appendix B) ๐งพ.
New GRP identifier = trunc16(Na) | trunc16(Nb)
(trunc16 indicates truncation to 16 bits. The initiator and responder must use nonces that have distinct upper bits from any used for current GRPID's ๐.)
Desc(G) is the encoding of the descriptor for the group descriptor (see Appendix A for the format of a group descriptor) ๐.
The two parties must store the mapping between the new group identifier GRP and the group descriptor Desc(New Group). They must also note the identities used for the KEYID and copy these to the state for the new group ๐๏ธ.
Note that one could have the same group descriptor associated with several KEYID's. Pre-calculation of g^x values may be done based only on the group descriptor, not the private group name โจ.
2.8.2 Deriving a Key Using a Private Group ๐ฆ
Once a private group has been established, its group id can be used in the key exchange messages in the GRP position. No changes to the protocol are required ๐ .
2.9 Quick Mode: New Keys From Old, ๐
When an authenticated KEYID and its associated keying material sKEYID already exist, it's easy to derive additional KEYID's and keys that share similar attributes (GRP, EHA, etc.) using only hashing functions ๐ง. The KEYID might be one that was derived in Main Mode, for example ๐.
On the other hand, the authenticated key may be a manually distributed key, one that's shared by the initiator and responder through some means external to OAKLEY. If the distribution method formed the KEYID using appropriately unique values for the two halves (CKY-I and CKY-R), then this method applies ๐ซถ.
In the following, the Key Exchange Identifier is OAKLEY Quick Mode. The nonces are carried in the Authentication Payload, and the prf value is carried in the Authentication Payload too. The Authentication Authority is "None" and the type is "Pre-Shared" ๐.
The protocol is:
Initiator Responder
--------- ---------
-> KEYID, INEWKRQ, Ni, prf(sKEYID, Ni) ->
<- KEYID, INEWKRS, Nr, prf(sKEYID, 1 | Nr | Ni) <-
-> KEYID, INEWKRP, 0, prf(sKEYID, 0 | Ni | Nr) ->
The New KEYID, NKEYID, is Ni | Nr ๐.
sNKEYID = prf(sKEYID, Ni | Nr )
The identities and EHA values associated with NKEYID are the same as those associated with KEYID ๐.
Each party must validate the hash values before using the new key for any purpose ๐.
2.10 Defining and Using Pre-Distributed Keys ๐
okay so if a key, its key identifier, and its state info got passed around by hand (manually, bestie ๐ซถ), then that key is good to go for any OAKLEY purpose ๐ . It just has to come with the usual state info: the ID's and the EHA algorithms ๐.
Whether a manual key gets added to the OAKLEY database is up to local policy ๐. Like, only privileged users would be allowed to add keys tied to privileged ID's, while an unprivileged user could only add keys tied to her own ID ๐. ngl that's a very fair rule ๐ธ.
2.11 Distribution of an External Key ๐ฆ
Once an OAKLEY session key and its ancillary algorithms are set up, the keying material and the "H" algorithm can be used to distribute an externally generated key and assign a KEYID to it โจ.
Here's the setup: KEYID means an existing, authenticated OAKLEY session key, and sNEWKEYID means the externally generated keying material. The Key Exchange Identifier is OAKLEY External Mode, and the Key Exchange Payload contains the new key, which is protected
Initiator Responder
--------- ---------
-> KEYID, IEXTKEY, Ni, prf(sKEYID, Ni) ->
<- KEYID, IEXTKEY, Nr, prf(sKEYID, 1 | Nr | Ni) <-
-> KEYID, IEXTKEY, Kir xor sNEWKEYID*, prf(Kir, sNEWKEYID | Ni | Nr) ->
Kir = prf(sKEYID, Ni | Nr)
* this field is carried in the Key Exchange Payload.
Each party must validate the hash values using the "H" function in the KEYID state before changing any key state information ๐. The Responder recovers the new key by xor-ing the field in the Authentication Payload with the Kir value ๐งฉ. The new key identifier, which names the keying material sNEWKEYID, is prf(sKEYID, 1 | Ni | Nr) ๐.
Note that this exchange does not require encryption ๐. Hugo Krawcyzk suggested the method and noted its advantage ๐.
2.11.1 Cryptographic Strength Considerations ๐ช
The strength of the key used to distribute the external key must be at least equal to the strength of the external key. Generally, this means the length of the sKEYID material must be greater than or equal to the length of the sNEWKEYID material ๐.
The derivation of the external key, its strength, or its intended use isn't covered by this protocol ๐ . The parties using the key must have some other method for figuring those properties out ๐ซ .
As of early 1996, it looked like for 90 bits of cryptographic strength, you should use a modular exponentiation group modulus of 2000 bits. For 128 bits of strength, a 3000 bit modulus is required ๐ฅ.
3. Specifying and Deriving Security Associations ๐ง
When a security association is defined, only the KEYID needs to be given ๐. The responder should be able to look up the state associated with the KEYID value and find the right keying material, sKEYID ๐.
Deriving keys for use with IPSEC protocols like ESP or AH is covered in the ISAKMP/Oakley Resolution document ๐. That document also describes how to negotiate acceptable parameter sets and identifiers for ESP and AH, and how to exactly calculate the keying material for each instance of the protocols ๐งฎ. Because the basic keying material defined here (g^xy) can be used to derive keys for several instances of ESP and AH, the exact mechanics of using one-way functions to turn g^xy into several unique keys is essential to correct usage ๐
.
4. ISAKMP Compatibility ๐
OAKLEY uses ISAKMP header and payload formats, as described in the text and in Appendix B ๐. There are particular noteworthy extensions beyond the version 4 draft โจ.
4.1 Authentication with Existing Keys ๐๏ธ
In the case that two parties don't have suitable public key mechanisms in place for authenticating each other, they can use keys that were distributed manually ๐ค. After these keys and their associated state are established in OAKLEY, they can be used for authentication modes that depend on signatures, e.g. Aggressive Mode ๐ฆ.
When an existing key is going to appear in an offer list, it should be indicated with an Authentication Algorithm of ISAKMP_EXISTING. This value will be assigned in the ISAKMP RFC ๐.
When the authentication method is ISAKMP_EXISTING, the authentication authority will have the value ISAKMP_AUTH_EXISTING. The value for this field must not conflict with any authentication authority registered with IANA, and it is defined in the ISAKMP RFC ๐
โโ๏ธ.
The authentication payload has two parts ๐งฉ:
- the KEYID for the pre-existing key
- the identifier for the party to be authenticated by the pre-existing key
The pseudo-random function "H" in the state information for that KEYID will be the signature algorithm ๐๏ธ. It uses the keying material for that key (sKEYID) when generating or checking the validity of message data ๐.
E.g. say the existing key has a KEYID called KID, 128 bits of keying material called sKID, and an "H" algorithm that's a transform named HMAC ๐. Then, to generate a "signature" for a data block, the output of HMAC(sKID, data) becomes the signature payload ๐.
The KEYID state will have the identities of the local and remote parties the KEYID was assigned to. It's up to the local policy implementation to decide when it's appropriate to use such a key for authenticating other parties ๐. For example, a key distributed for use between two Internet hosts A and B might be suitable for authenticating all identities of the form "alice@A" and "bob@B" ๐.
4.2 Third Party Authentication ๐ต๏ธโโ๏ธ
A local security policy might restrict key negotiation to trusted parties ๐. For example, two OAKLEY daemons running with equal sensitivity labels on two machines might want to be the sole arbiters of key exchanges between users with that same sensitivity label ๐ซถ. In this case, some way of authenticating where key exchange requests come from is needed. I.e., the identities of the two daemons should be bound to a key, and that key is used to form a "signature" for the key exchange messages ๐.
The Signature Payload, in Appendix B, is for this purpose ๐ฏ. This payload names a KEYID that already exists before the start of the current exchange. The "H" transform for that KEYID is used to calculate an integrity/authentication value for all payloads that come before the signature ๐งพ.
Local policy can dictate which KEYID's are appropriate for signing further exchanges ๐ .
4.3 New Group Mode ๐ธ
OAKLEY uses a new KEI for the exchange that defines a new group โจ.
5. Security Implementation Notes ๐จ
Timing attacks that can recover the exponent value used in Diffie-Hellman calculations have been described by Paul Kocher [Kocher] ๐ญ. To nullify the attack, implementors must take pains to obscure the sequence of operations involved in carrying out modular exponentiations ๐ซฃ.
A "blinding factor" can accomplish this goal ๐ฆ. A group element, r, is chosen at random. When an exponent x is chosen, the value r^(-x) is also calculated. Then, when calculating (g^y)^x, the implementation calculates this sequence ๐ง :
A = (rg^y)
B = A^x = (rg^y)^x = (r^x)(g^(xy))
C = B*r^(-x) = (r^x)(r^-(x))(g^(xy)) = g^(xy)
The blinding factor is only necessary if the exponent x is used more than 100 times (estimate by Richard Schroeppel) ๐.
6. OAKLEY Parsing and State Machine โจ
okay so there are a bunch of pathways through OAKLEY ๐ but they all read the message fields left to right, like scrolling a group chat from top to bottom ๐ฆ
The initiator builds the opening message in this order ๐:
- Offer a cookie. This isn't required, but it helps a lot with aggressive exchanges ๐
- Pick a group. The choices are the well-known groups or any private groups that may have been negotiated. The very first exchange between two Oakley daemons with no common state must involve a well-known group (0, meaning no group, counts as a well-known group โจ). Note that the group identifier, not the group descriptor, is what goes in the message.
If a non-null group will be used, it must be included with the first message specifying EHAO. It doesn't need to be specified until then.
- If PFS will be used, pick an exponent x and present
g^x๐ฅ - Offer Encryption, Hash, and Authentication lists ๐
- Use PFS for hiding the identities ๐
If identity hiding isn't used, then the initiator gets this option:
- Name the identities and include authentication information ๐ซถ
The information in the authentication section depends on the first authentication offer. In this aggressive exchange, the Initiator is hoping the Responder accepts everything offered and the first authentication method ๐ค. The authentication method decides what the authentication payload looks like:
- Signing method. The signature gets applied to all the offered information.
- A public key encryption method. The algorithm is used to encrypt a nonce under the public key of the requested Responder identity. There are two cases, depending on whether identity hiding is used:
- a. No identity hiding. The ID's appear as plaintext.
- b. Identity hiding. A well-known ID, called
R', appears as plaintext in the authentication payload. It's followed by two ID's and a nonce, and those get encrypted using the public key forR'๐
- A pre-existing key method. The pre-existing key is used to encrypt a nonce. If identity hiding is used, the ID's get encrypted in place in the payload, using the
"E"algorithm associated with the pre-existing key.
The Responder can accept all, part, or none of the initial message ๐. They accept as many fields as they want, using the same decision order as the initiator. At any step they can stop, which implicitly rejects the remaining fields (those come back with null values in the response). The bare minimum response is a cookie and the GRP.
- Accept cookie. The Responder may choose to record no state information until the Initiator successfully replies with a cookie chosen by the responder. If so, the Responder replies with a cookie, the GRP, and nothing else ๐ง
- Accept GRP. If the group isn't acceptable, the Responder won't reply. The Responder may send an error message saying the group isn't acceptable (modulus too small, unknown identifier, etc.). Heads up: "no group" means two different things in this protocol. It can mean the group isn't specified yet, or it can mean no group will be used, which means PFS isn't possible ๐ฌ
- Accept the
g^xvalue. The Responder shows they acceptg^xby including their owng^yvalue in the reply. They can postpone this by ignoringg^xand putting a zero-lengthg^yvalue in the reply. They can also reject theg^xvalue with an error message. - Accept one element from each of the EHA lists. Acceptance is shown by a non-zero proposal ๐
- If PFS for identity hiding is requested, then no further data will follow.
- If the authentication payload is present, and the first item in the offered authentication class is acceptable, then the Responder must validate/decrypt the information in the authentication payload and the signature payload, if present. The Responder should pick a nonce and reply using the same authentication/hash algorithm the Initiator used ๐ธ
The Initiator checks which info the Responder accepted, validates/decrypts any signed, hashed, or encrypted fields, and if the data is acceptable, replies according to the EHA methods the Responder picked ๐ฆ. The Initiator's replies are told apart from their initial message by the presence of a non-zero Responder cookie. That's the giveaway ๐
The output of the signature or prf function gets encoded as a variable precision integer, as described in Appendix C. The KEYID indicates which KEYID names the keying material and the Hash or Signature function โจ
7. The Credential Payload
Useful certificates with public key information can be attached to OAKLEY messages using Credential Payloads, as defined in the ISAKMP document ๐. Important: the identity protection option applies to the credentials too, not just the identities ๐๐
Security Considerations
The focus of this document is security, so security considerations permeate this memo. ๐ญ๐ฅ Basically, security is the whole vibe here, and every part of this spec is built around it. Read everything with that in mind ๐
Author's Address
Hilarie K. Orman
Department of Computer Science
University of Arizona
EMail: ho@darpa.mil ๐
APPENDIX A Group Descriptors โจ
okay bestie, so OAKLEY can use three different group representations ๐ฆ Each group is defined by its group operation AND the kind of underlying field used to represent its group elements. The three types are modular exponentiation groups (called MODP in here ๐ ), elliptic curve groups over the field GF[2^N] (called EC2N in here), and elliptic curve groups over GF[P] (called ECP in here). For each representation there are loads of distinct realizations, depending on which parameters you pick ๐
With a few exceptions, all the parameters are sent as if they were non-negative multi-precision integers, using the format defined in this appendix. (Note, this is distinct from the encoding in Appendix C.) Every multi-precision integer has a prefixed length field, even where that info is redundant ๐
For the group type EC2N, the parameters are more properly thought of as very long bit fields. They get represented as multi-precision integers anyway, with length fields and right-justified. This is the natural encoding ๐ง
MODP means the classic modular exponentiation group, where the operation is to calculate G^X (mod P). The group is defined by the numeric parameters P and G. P must be a prime. G is often 2, but may be a larger number. 2 <= G <= P-2.
ECP is an elliptic curve group, modulo a prime number P. The defining equation for this kind of group is:
Y^2 = X^3 + AX + B
The group operation is taking a multiple of an elliptic-curve point. The group is defined by 5 numeric parameters: the prime P, two curve parameters A and B, and a generator (X,Y). A, B, X, and Y are all interpreted mod P, and must be (non-negative) integers less than P. They must satisfy the defining equation, modulo P ๐ฅ
EC2N is an elliptic curve group over the finite field F[2^N]. The defining equation for this kind of group is:
Y^2 + XY = X^3 + AX^2 + B
(This equation differs slightly from the mod P case: it has an XY term, and an AX^2 term instead of an AX term. Lowkey a glow-up ๐)
We must specify the field representation, and then the elliptic curve. The field is specified by giving an irreducible polynomial (mod 2) of degree N. This polynomial is represented as an integer of size between 2^N and 2^(N+1), as if the defining polynomial were evaluated at the value U=2.
For example, the field defined by the polynomial U^155 + U^62 + 1 is represented by the integer 2^155 + 2^62 + 1. The group is defined by 4 more parameters, A, B, X, and Y. These parameters are elements of the field GF[2^N], and can be thought of as polynomials of degree < N, with (mod 2) coefficients. They fit in N-bit fields, and are represented as integers < 2^N, as if the polynomial were evaluated at U=2. For example, the field element U^2 + 1 would be represented by the integer 2^2+1, which is 5 ๐
The two parameters A and B define the curve. A is frequently 0. B must not be 0. The parameters X and Y select a point on the curve. The parameters A, B, X, and Y must satisfy the defining equation, modulo the defining polynomial, and mod 2.
Group descriptor formats:
- Type of group: a two-byte field. Assigned values for the types
"MODP","ECP", and"EC2N"will be defined (see ISAKMP-04). - Size of a field element, in bits. This is either
Ceiling(log2 P)or the degree of the irreducible polynomial: a 32-bit integer. - The prime
Por the irreducible field polynomial: a multi-precision integer. - The generator: 1 or 2 values, multi-precision integers.
- EC only: the parameters of the curve: 2 values, multi-precision integers.
The following parameters are Optional (each of these may appear independently). A value of 0 may be used as a place-holder to represent an unspecified parameter. Any number of the parameters may be sent, from 0 to 3.
- The largest prime factor: the encoded value that is the LPF of the group size, a multi-precision integer.
- EC only: the order of the group: a multi-precision integer. (The group size for MODP is always
P-1.) - Strength of group: a 32-bit integer. The strength of the group is approximately the number of key-bits protected. It is determined by the log2 of the effort to attack the group. It may change as we learn more about cryptography ๐ง
This is a generic example for a "classic" modular exponentiation group:
- Group type:
"MODP" - Size of a field element in bits:
Log2 (P)rounded up. A 32-bit integer. - Defining prime
P: a multi-precision integer. - Generator
G: a multi-precision integer.2 <= G <= P-2. - Optional:
- Largest prime factor of
P-1: the multi-precision integerQ - Strength of group: a 32-bit integer. We will specify a formula for calculating this number (TBD).
- Largest prime factor of
This is a generic example for an elliptic curve group, mod P:
- Group type:
"ECP" - Size of a field element in bits:
Log2 (P)rounded up, a 32-bit integer. - Defining prime
P: a multi-precision integer. - Generator
(X,Y): 2 multi-precision integers, each< P. - Parameters of the curve
A,B: 2 multi-precision integers, each< P. - Optional:
- Largest prime factor of the group order: a multi-precision integer.
- Order of the group: a multi-precision integer.
- Strength of group: a 32-bit integer. Formula TBD.
This is a specific example for an elliptic curve group:
- Group type:
"EC2N" - Degree of the irreducible polynomial: 155
- Irreducible polynomial:
U^155 + U^62 + 1, represented as the multi-precision integer2^155 + 2^62 + 1. - Generator
(X,Y): represented as 2 multi-precision integers, each< 2^155. For our present curve, these are (decimal) 123 and 456. Each is represented as a multi-precision integer. - Parameters of the curve
A,B: represented as 2 multi-precision integers, each< 2^155. For our present curve these are 0 and (decimal) 471951, represented as two multi-precision integers. - Optional:
- Largest prime factor of the group order:
3805993847215893016155463826195386266397436443
represented as a multi-precision integer.
- The order of the group:
45671926166590716193865565914344635196769237316
represented as a multi-precision integer.
- Strength of group: 76, represented as a 32-bit integer.
The variable precision integer encoding for group descriptor fields is the following. This is a slight variation on the format defined in Appendix C in that a fixed 16-bit value is used first, and the length is limited to 16 bits. However, the interpretation is otherwise identical ๐
1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Fixed value (TBD) ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
. .
. Integer .
. .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The format of a group descriptor is:
1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!1! Group Description ! MODP !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!0! Field Size ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!0! Prime ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!0! Generator1 ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!0! Generator2 ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!0! Curve-p1 ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!0! Curve-p2 ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!0! Largest Prime Factor ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!1!0! Order of Group ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!0!0! Strength of Group ! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! MPI !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
APPENDIX B Message formats ๐
The encodings of Oakley messages into ISAKMP payloads is deferred to the ISAKMP/Oakley Resolution document. ๐ซถ
APPENDIX C Encoding a variable precision integer โจ
Okay, so variable precision integers get encoded as a 32-bit length field ๐, followed by one or more 32-bit quantities that hold the representation of the integer. The first 32-bit item is aligned with the most significant bit, so the big bits always come first ๐
1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! first value word (most significant bits) !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! !
~ additional value words ~
! !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Let's do a worked example, because this part is so satisfying ๐ฆ. It's for a number with 51 bits of significance. The length field says 2 32-bit quantities follow. The most significant non-zero bit of the number is in bit 13 of the first 32-bit quantity, and the low order bits sit in the second 32-bit quantity.
1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! 1 0!
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!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!
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!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!
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
APPENDIX D Cryptographic strengths ๐ฅ
Diffie-Hellman is used to compute keys that get used with symmetric algorithms, so it should be no easier to break the Diffie-Hellman computation than it is to do an exhaustive search over the symmetric key space ๐ญ. A recent recommendation from a group of cryptographers [Blaze] suggests a symmetric key size of 75 bits for a practical level of security. For 20-year security, they recommend 90 bits.
Based on that report, a conservative plan for OAKLEY users is to make sure their Diffie-Hellman computations are at least as secure as a 90-bit key space. For modular exponentiation groups, the size of the largest prime factor of the modulus should be at least 180 bits, and the size of the modulus should be at least 1400 bits. For elliptic curve groups, the LPF should be at least 180 bits.
If long-term secrecy of the encryption key isn't a concern, the following parameters may be used for the modular exponentiation group: 150 bits for the LPF and 980 bits for the modulus size ๐ธ
The modulus size alone doesn't decide how strong the Diffie-Hellman calculation is. The size of the exponent used when computing powers within the group matters too ๐ The size of the exponent in bits should be at least twice the size of any symmetric key that will be derived from it. We recommend that ISAKMP implementors use at least 180 bits of exponent, which is twice the size of a 20-year symmetric key ๐
The math behind these estimates is in texts about the effort needed to solve the discrete log problem. That's a task strongly related to how efficient the Number Field Sieve is for factoring large integers. Readers are referred to [Stinson] and [Schneier] ๐ง
APPENDIX E The Well-Known Groups ๐
The group identifiers are:
0 No group (used as a placeholder and for non-DH exchanges)
1 A modular exponentiation group with a 768 bit modulus
2 A modular exponentiation group with a 1024 bit modulus
3 A modular exponentiation group with a 1536 bit modulus (TBD)
4 An elliptic curve group over GF[2^155]
5 An elliptic curve group over GF[2^185]
values 2^31 and higher are used for private group identifiers
Richard Schroeppel did all the mathematical and computational work for this appendix, so a huge shoutout to him ๐
Classical Diffie-Hellman Modular Exponentiation Groups
The primes for groups 1 and 2 were picked to have certain properties ๐ The high order 64 bits are forced to 1. This helps the classical remainder algorithm, because the trial quotient digit can always be taken as the high order word of the dividend, possibly +1. The low order 64 bits are also forced to 1. This helps the Montgomery-style remainder algorithms, because the multiplier digit can always be taken to be the low order word of the dividend. The middle bits come from the binary expansion of pi. That makes them effectively random, and it avoids any suspicion that the primes were secretly picked to be weak ๐ซถ
Because both primes are based on pi, the hexadecimal representations of the two primes overlap in a big section. The primes are chosen to be Sophie Germain primes (meaning (P-1)/2 is also prime), so they have the maximum strength against the square-root attack on the discrete logarithm problem ๐
The starting trial numbers were repeatedly incremented by 2^64 until suitable primes turned up.
Because these two primes are congruent to 7 (mod 8), 2 is a quadratic residue of each prime. All powers of 2 are quadratic residues too. This stops an opponent from learning the low order bit of the Diffie-Hellman exponent, which is also called the subgroup confinement problem. Using 2 as a generator is efficient for some modular exponentiation algorithms. [Note that 2 is technically not a generator in the number theory sense, because it omits half of the possible residues mod P. From a cryptographic viewpoint, this is a virtue.] Iconic behaviour ๐ญโจ
E.1. Well-Known Group 1: A 768 bit prime
The prime is 2^768 - 2^704 - 1 + 2^64 * { [2^638 pi] + 149686 }. Its decimal value is:
155251809230070893513091813125848175563133404943451431320235
119490296623994910210725866945387659164244291000768028886422
915080371891804634263272761303128298374438082089019628850917
0691316593175367469551763119843371637221007210577919
This has been rigorously verified as a prime ๐ฆ
The representation of the group in OAKLEY is:
Type of group: "MODP"
Size of field element (bits): 768
Prime modulus: 21 (decimal)
Length (32 bit words): 24
Data (hex):
FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF
Generator: 22 (decimal)
Length (32 bit words): 1
Data (hex): 2
Optional Parameters:
Group order largest prime factor: 24 (decimal)
Length (32 bit words): 24
Data (hex):
7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68
94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E
F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122
F242DABB 312F3F63 7A262174 D31D1B10 7FFFFFFF FFFFFFFF
Strength of group: 26 (decimal)
Length (32 bit words) 1
Data (hex):
00000042
E.2. Well-Known Group 2: A 1024 bit prime
The prime is 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 }. Its decimal value is:
179769313486231590770839156793787453197860296048756011706444
423684197180216158519368947833795864925541502180565485980503
646440548199239100050792877003355816639229553136239076508735
759914822574862575007425302077447712589550957937778424442426
617334727629299387668709205606050270810842907692932019128194
467627007
The primality of this number has been rigorously proven ๐
The representation of the group in OAKLEY is:
Type of group: "MODP"
Size of field element (bits): 1024
Prime modulus: 21 (decimal)
Length (32 bit words): 32
Data (hex):
FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED
EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381
FFFFFFFF FFFFFFFF
Generator: 22 (decimal)
Length (32 bit words): 1
Data (hex): 2
Optional Parameters:
Group order largest prime factor: 24 (decimal)
Length (32 bit words): 32
Data (hex):
7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68
94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E
F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122
F242DABB 312F3F63 7A262174 D31BF6B5 85FFAE5B 7A035BF6
F71C35FD AD44CFD2 D74F9208 BE258FF3 24943328 F67329C0
FFFFFFFF FFFFFFFF
Strength of group: 26 (decimal)
Length (32 bit words) 1
Data (hex):
0000004D
E.3. Well-Known Group 3: An Elliptic Curve Group Definition โจ
Okay bestie, this one is an elliptic curve group ๐ฆ and it lives in the Galois field GF[2^155], so there are 2^155 field elements. The irreducible polynomial that defines the field is:
u^155 + u^62 + 1
The curve equation is:
Y^2 + X Y = X^3 + A X + B
X, Y, A, B are all elements of the field ๐
For this curve, A = 0 and B is:
B = u^18 + u^17 + u^16 + u^13 + u^12 + u^9 + u^8 + u^7 + u^3 + u^2 +
u + 1
In binary, B is the bit string 1110011001110001111. In decimal that's 471951, and in hex it's 7338F ๐ฅ
The generator is a point (X,Y) on the curve. It has to satisfy the curve equation, mod 2 and modulo the field polynomial, so no cheating ๐
X and Y are:
X = u^6 + u^5 + u^4 + u^3 + u + 1
Y = u^8 + u^7 + u^6 + u^3
Their binary bit strings are 1111011 and 111001000, and in decimal they're 123 and 456 ๐ธ
The group order (the number of curve points) is:
45671926166590716193865565914344635196769237316
That's 12 times this prime:
3805993847215893016155463826195386266397436443
The prime has been rigorously proven โจ The generating point (X,Y) has order 4 times the prime, so the generator is the triple of some curve point. Main character energy ๐
Here's how this group is represented in OAKLEY:
Type of group: "EC2N"
Size of field element (bits): 155
Irreducible field polynomial: 21 (decimal)
Length (32 bit words): 5
Data (hex):
08000000 00000000 00000000 40000000 00000001
Generator:
X coordinate: 22 (decimal)
Length (32 bit words): 1
Data (hex): 7B
Y coordinate: 22 (decimal)
Length (32 bit words): 1
Data (hex): 1C8
Elliptic curve parameters:
A parameter: 23 (decimal)
Length (32 bit words): 1
Data (hex): 0
B parameter: 23 (decimal)
Length (32 bit words): 1
Data (hex): 7338F
Optional Parameters:
Group order largest prime factor: 24 (decimal)
Length (32 bit words): 5
Data (hex):
00AAAAAA AAAAAAAA AAAAB1FC F1E206F4 21A3EA1B
Group order: 25 (decimal)
Length (32 bit words): 5
Data (hex):
08000000 00000000 000057DB 56985371 93AEF944
Strength of group: 26 (decimal)
Length (32 bit words) 1
Data (hex):
0000004C
E.4. Well-Known Group 4: A Large Elliptic Curve Group Definition ๐
This one is another elliptic curve, but it's bigger ๐ค It's based on the Galois field GF[2^185], which has 2^185 field elements. The irreducible polynomial for the field is:
u^185 + u^69 + 1
The curve equation is:
Y^2 + X Y = X^3 + A X + B
X, Y, A, B are elements of the field. For this curve, A = 0 and B is:
B = u^12 + u^11 + u^10 + u^9 + u^7 + u^6 + u^5 + u^3 + 1
In binary, B is 1111011101001. In decimal that's 7913, and in hex it's 1EE9 ๐
The generator is a point (X,Y) on the curve, satisfying the curve equation, mod 2 and modulo the field polynomial:
X = u^4 + u^3
Y = u^3 + u^2 + 1
Their binary bit strings are 11000 and 1101, and in decimal they're 24 and 13 ๐
The group order (the number of curve points) is:
49039857307708443467467104857652682248052385001045053116
which is 4 times this prime:
12259964326927110866866776214413170562013096250261263279
The prime has been rigorously proven ๐ฅ The generating point (X,Y) has order 2 times the prime, so the generator is the double of some curve point.
OAKLEY representation of this group:
Type of group: "EC2N"
Size of field element (bits): 185
Irreducible field polynomial: 21 (decimal)
Length (32 bit words): 6
Data (hex):
02000000 00000000 00000000 00000020 00000000 00000001
Generator:
X coordinate: 22 (decimal)
Length (32 bit words): 1
Data (hex): 18
Y coordinate: 22 (decimal)
Length (32 bit words): 1
Data (hex): D
Elliptic curve parameters:
A parameter: 23 (decimal)
Length (32 bit words): 1
Data (hex): 0
B parameter: 23 (decimal)
Length (32 bit words): 1
Data (hex): 1EE9
Optional parameters:
Group order largest prime factor: 24 (decimal)
Length (32 bit words): 6
Data (hex):
007FFFFF FFFFFFFF FFFFFFFF F6FCBE22 6DCF9210 5D7E53AF
Group order: 25 (decimal)
Length (32 bit words): 6
Data (hex):
01FFFFFF FFFFFFFF FFFFFFFF DBF2F889 B73E4841 75F94EBC
Strength of group: 26 (decimal)
Length (32 bit words) 1
Data (hex):
0000005B
E.5. Well-Known Group 5: A 1536 bit prime ๐
This is a big prime group, 1536 bits of pure vibes โจ The prime is defined as:
2^1536 - 2^1472 - 1 + 2^64 * { [2^1406 pi] + 741804 }
Its decimal value is:
241031242692103258855207602219756607485695054850245994265411
694195810883168261222889009385826134161467322714147790401219
650364895705058263194273070680500922306273474534107340669624
601458936165977404102716924945320037872943417032584377865919
814376319377685986952408894019557734611984354530154704374720
774996976375008430892633929555996888245787241299381012913029
459299994792636526405928464720973038494721168143446471443848
8520940127459844288859336526896320919633919
The primality of the number has been rigorously proven ๐ญ
Here's how the group is represented in OAKLEY:
Type of group: "MODP"
Size of field element (bits): 1536
Prime modulus: 21 (decimal)
Length (32 bit words): 48
Data (hex):
FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED
EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D
C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F
83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D
670C354E 4ABC9804 F1746C08 CA237327 FFFFFFFF FFFFFFFF
Generator: 22 (decimal)
Length (32 bit words): 1
Data (hex): 2
Optional Parameters:
Group order largest prime factor: 24 (decimal)
Length (32 bit words): 48
Data (hex):
7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68
94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E
F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122
F242DABB 312F3F63 7A262174 D31BF6B5 85FFAE5B 7A035BF6
F71C35FD AD44CFD2 D74F9208 BE258FF3 24943328 F6722D9E
E1003E5C 50B1DF82 CC6D241B 0E2AE9CD 348B1FD4 7E9267AF
C1B2AE91 EE51D6CB 0E3179AB 1042A95D CF6A9483 B84B4B36
B3861AA7 255E4C02 78BA3604 6511B993 FFFFFFFF FFFFFFFF
Strength of group: 26 (decimal)
Length (32 bit words) 1
Data (hex):
0000005B
Appendix F Implementing Group Operations ๐ง
Okay so the group operation has to be built as a sequence of arithmetic operations, and the exact operations depend on what type of group you're using. For modular exponentiation groups, the operation is multi-precision integer multiplication plus remainders by the group modulus. If you want to know how to do these for large integers, check out Knuth Vol. 2 [Knuth] ๐ Implementation recommendations for elliptic curve group operations over GF[2^N] are described in [Schroeppel] โจ
BIBLIOGRAPHY ๐
[RFC2401]Atkinson, R., "Security Architecture for the Internet Protocol", RFC 2401, November 1998.[RFC2406]Atkinson, R., "IP Encapsulating Security Payload (ESP)", RFC 2406, November 1998.[RFC2402]Atkinson, R., "IP Authentication Header", RFC 2402, November 1998.[Blaze]Blaze, Matt et al., MINIMAL KEY LENGTHS FOR SYMMETRIC CIPHERS TO PROVIDE ADEQUATE COMMERCIAL SECURITY. A REPORT BY AN AD HOC GROUP OF CRYPTOGRAPHERS AND COMPUTER SCIENTISTS... --http://www.bsa.org/policy/encryption/cryptographers.html[STS]W. Diffie, P.C. Van Oorschot, and M.J. Wiener, "Authentication and Authenticated Key Exchanges," in Designs, Codes and Cryptography, Kluwer Academic Publishers, 1992, pp. 107[SECDNS]Eastlake, D. and C. Kaufman, "Domain Name System Security Extensions", RFC 2065, January 1997.[Random]Eastlake, D., Crocker, S. and J. Schiller, "Randomness Recommendations for Security", RFC 1750, December 1994.[Kocher]Kocher, Paul, Timing Attack,http://www.cryptography.com/timingattack.old/timingattack.html[Knuth]Knuth, Donald E., The Art of Computer Programming, Vol. 2, Seminumerical Algorithms, Addison Wesley, 1969.[Krawcyzk]Krawcyzk, Hugo, SKEME: A Versatile Secure Key Exchange Mechanism for Internet, ISOC Secure Networks and Distributed Systems Symposium, San Diego, 1996[Schneier]Schneier, Bruce, Applied cryptography: protocols, algorithms, and source code in C, Second edition, John Wiley & Sons, Inc. 1995, ISBN 0-471-12845-7, hardcover. ISBN 0-471-11709-9, softcover.[Schroeppel]Schroeppel, Richard, et al.; Fast Key Exchange with Elliptic Curve Systems, Crypto '95, Santa Barbara, 1995. Available on-line asftp://ftp.cs.arizona.edu/reports/1995/TR95-03.ps(and .Z).[Stinson]Stinson, Douglas, Cryptography Theory and Practice. CRC Press, Inc., 2000, Corporate Blvd., Boca Raton, FL, 33431-9868, ISBN 0-8493-8521-0, 1995[Zimmerman]Philip Zimmermann, The Official Pgp User's Guide, Published by MIT Press Trade, Publication date: June 1995, ISBN: 0262740176
Full Copyright Statement โจ
Okay bestie, let's talk about the legal stuff ๐ It's not the most exciting part, but it's important, so read it closely ๐ซถ
Copyright (C) The Internet Society (1998). All Rights Reserved. ๐ธ
So this document and translations of it can be copied and shared with others ๐ฆ You can also make derivative works that comment on or explain it, or that help people implement it, and you can prepare, copy, publish, and distribute those too, in whole or in part, with no restrictions of any kind. The one condition is that the copyright notice and this paragraph have to be included on every copy and derivative work. โจ
The original document itself, though, can't be modified in any way. You can't remove the copyright notice or the references to the Internet Society or other Internet organizations. There are two exceptions. First, you can do it when it's needed for developing Internet standards, but then you have to follow the copyright procedures defined in the Internet Standards process. Second, you can do it to translate it into languages other than English. ๐
The permissions above are perpetual, meaning they will never be revoked by the Internet Society or its successors or assigns. Forever and ever, bestie ๐
Now the disclaimer, which is kind of dramatic ๐ญ This document and the information in it are provided on an "AS IS" basis, and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. No cap, that's the whole vibe ๐
๐ฆ where this page comes from
- ietf: rfc2412 1998-11
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms