idnits 2.17.1 draft-ietf-lwig-ikev2-minimal-04.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (September 28, 2015) is 3123 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Missing Reference: 'CERTREQ' is mentioned on line 279, but not defined == Missing Reference: 'IPSECARCH' is mentioned on line 533, but not defined == Missing Reference: 'IDNA' is mentioned on line 1184, but not defined == Missing Reference: 'EAI' is mentioned on line 1189, but not defined == Missing Reference: 'PKCS1' is mentioned on line 1302, but not defined Summary: 0 errors (**), 0 flaws (~~), 7 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Light-Weight Implementation Guidance (lwig) T. Kivinen 3 Internet-Draft INSIDE Secure 4 Intended status: Informational September 28, 2015 5 Expires: March 31, 2016 7 Minimal IKEv2 Initiator Implementation 8 draft-ietf-lwig-ikev2-minimal-04.txt 10 Abstract 12 This document describes a minimal initiator version of the Internet 13 Key Exchange version 2 (IKEv2) protocol. IKEv2 is a component of 14 IPsec used for performing mutual authentication and establishing and 15 maintaining Security Associations (SAs). IKEv2 includes several 16 optional features, which are not needed in minimal implementations. 17 This document describes what is required from the minimal 18 implementation, and also describes various optimizations which can be 19 done. The protocol described here is interoperable with a full IKEv2 20 implementation using shared secret authentication (IKEv2 does not 21 require the use of certificate authentication). This minimal 22 initiator implementation can only talk to a full IKEv2 implementation 23 acting as responder, thus two minimal initiator implementations 24 cannot talk to each other. 26 This document does not update or modify RFC 7296, but provides more 27 compact description of the minimal version of the protocol. If this 28 document and RFC 7296 conflicts then RFC 7296 is the authoritative 29 description. 31 Status of This Memo 33 This Internet-Draft is submitted in full conformance with the 34 provisions of BCP 78 and BCP 79. 36 Internet-Drafts are working documents of the Internet Engineering 37 Task Force (IETF). Note that other groups may also distribute 38 working documents as Internet-Drafts. The list of current Internet- 39 Drafts is at http://datatracker.ietf.org/drafts/current/. 41 Internet-Drafts are draft documents valid for a maximum of six months 42 and may be updated, replaced, or obsoleted by other documents at any 43 time. It is inappropriate to use Internet-Drafts as reference 44 material or to cite them other than as "work in progress." 46 This Internet-Draft will expire on March 31, 2016. 48 Copyright Notice 50 Copyright (c) 2015 IETF Trust and the persons identified as the 51 document authors. All rights reserved. 53 This document is subject to BCP 78 and the IETF Trust's Legal 54 Provisions Relating to IETF Documents 55 (http://trustee.ietf.org/license-info) in effect on the date of 56 publication of this document. Please review these documents 57 carefully, as they describe your rights and restrictions with respect 58 to this document. Code Components extracted from this document must 59 include Simplified BSD License text as described in Section 4.e of 60 the Trust Legal Provisions and are provided without warranty as 61 described in the Simplified BSD License. 63 This document may contain material from IETF Documents or IETF 64 Contributions published or made publicly available before November 65 10, 2008. The person(s) controlling the copyright in some of this 66 material may not have granted the IETF Trust the right to allow 67 modifications of such material outside the IETF Standards Process. 68 Without obtaining an adequate license from the person(s) controlling 69 the copyright in such materials, this document may not be modified 70 outside the IETF Standards Process, and derivative works of it may 71 not be created outside the IETF Standards Process, except to format 72 it for publication as an RFC or to translate it into languages other 73 than English. 75 Table of Contents 77 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 78 1.1. Use Cases . . . . . . . . . . . . . . . . . . . . . . . . 4 79 2. Exchanges . . . . . . . . . . . . . . . . . . . . . . . . . . 5 80 2.1. Initial Exchange . . . . . . . . . . . . . . . . . . . . 5 81 2.2. Other Exchanges . . . . . . . . . . . . . . . . . . . . . 11 82 2.3. Generating Keying Material . . . . . . . . . . . . . . . 11 83 3. Conformance Requirements . . . . . . . . . . . . . . . . . . 12 84 4. Implementation Status . . . . . . . . . . . . . . . . . . . . 13 85 5. Security Considerations . . . . . . . . . . . . . . . . . . . 13 86 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 13 87 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 13 88 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 13 89 8.1. Normative References . . . . . . . . . . . . . . . . . . 13 90 8.2. Informative References . . . . . . . . . . . . . . . . . 14 91 Appendix A. Header and Payload Formats . . . . . . . . . . . . . 14 92 A.1. The IKE Header . . . . . . . . . . . . . . . . . . . . . 15 93 A.2. Generic Payload Header . . . . . . . . . . . . . . . . . 17 94 A.3. Security Association Payload . . . . . . . . . . . . . . 18 95 A.3.1. Proposal Substructure . . . . . . . . . . . . . . . . 20 96 A.3.2. Transform Substructure . . . . . . . . . . . . . . . 21 97 A.3.3. Valid Transform Types by Protocol . . . . . . . . . . 23 98 A.3.4. Transform Attributes . . . . . . . . . . . . . . . . 23 99 A.4. Key Exchange Payload . . . . . . . . . . . . . . . . . . 24 100 A.5. Identification Payloads . . . . . . . . . . . . . . . . . 25 101 A.6. Certificate Payload . . . . . . . . . . . . . . . . . . . 26 102 A.7. Certificate Request Payload . . . . . . . . . . . . . . . 27 103 A.8. Authentication Payload . . . . . . . . . . . . . . . . . 28 104 A.9. Nonce Payload . . . . . . . . . . . . . . . . . . . . . . 28 105 A.10. Notify Payload . . . . . . . . . . . . . . . . . . . . . 29 106 A.10.1. Notify Message Types . . . . . . . . . . . . . . . . 30 107 A.11. Traffic Selector Payload . . . . . . . . . . . . . . . . 31 108 A.11.1. Traffic Selector . . . . . . . . . . . . . . . . . . 33 109 A.12. Encrypted Payload . . . . . . . . . . . . . . . . . . . . 34 110 Appendix B. Useful Optional Features . . . . . . . . . . . . . . 36 111 B.1. IKE SA Delete Notification . . . . . . . . . . . . . . . 36 112 B.2. Raw Public Keys . . . . . . . . . . . . . . . . . . . . . 37 113 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 38 115 1. Introduction 117 This document describes a minimal IKEv2 implementation that is 118 interoperable with Internet Key Exchange Protocol Version 2 (IKEv2) 119 [RFC7296]. 121 A minimal IKEv2 implementation only supports the initiator end of the 122 protocol. It only supports the initial IKE_SA_INIT and IKE_AUTH 123 exchanges and does not initiate any other exchanges. It also replies 124 with empty (or error) message to all incoming requests. 126 This means that most of the optional features of IKEv2 are left out: 127 NAT Traversal, IKE SA rekey, Child SA Rekey, Multiple Child SAs, 128 Deleting Child / IKE SAs, Configuration payloads, EAP authentication, 129 COOKIEs etc. 131 Some optimizations can be done because of the limited set of 132 supported features, and this text should not be considered for 133 generic IKEv2 implementations (for example Message IDs can be done as 134 specified because minimal implementation is only sending out 135 IKE_SA_INIT and IKE_AUTH request, and do not send any other request). 137 This document is inteded to be stand-alone, meaning everything needed 138 to implement IKEv2 is copied here except the description of the 139 cryptographic algorithms. The IKEv2 specification has lots of 140 background information and rationale which has been omitted from this 141 document. 143 Numerous additional numeric values from IANA registries have been 144 omitted from this document, only those which are of interest for a 145 minimal implementation are listed in this document. 147 The main body of this document describes how to use the shared secret 148 authentication in IKEv2, as it is easiest to implement. In some 149 cases that is not enough and Appendix B.2 describes how to use Raw 150 Public keys instead of shared secret authentication. 152 For more information check the full IKEv2 specification in RFC 7296 153 [RFC7296] and [IKEV2IANA]. 155 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 156 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 157 document are to be interpreted as described in [RFC2119]. 159 1.1. Use Cases 161 One use case for this kind of minimal implementation is in small 162 devices doing machine-to-machine communication. In such environments 163 the node initiating connections can be very small and the other end 164 of the communication channel is some kind of larger device. 166 An example of the small initiating node could be a remote garage door 167 opener device, i.e., a device having buttons which open and close a 168 garage door, and which connects to the home area network server over 169 wireless link. 171 Another example of such a device is some kind of sensor device, for 172 example a room temperature sensor, which sends periodic temperature 173 data to some centralized node. 175 Those devices are usually sleeping for a long time, and only wake up 176 because of user interaction or periodically. The data transfer is 177 always initiated from that sleeping node when they wale up and after 178 they send packets there might be ACKs or other packets coming back 179 before they go back to sleep. If some data needs to be transferred 180 from a server node to the small device, it can be implemented by 181 polling, i.e. the small node periodically polls for the server to see 182 if it for example has some configuration changes or similar. While 183 the device is sleeping it will not maintain the IKEv2 SA. That is, 184 it will always create the IKEv2 SA again when it wakes up. This 185 means there is no need to do liveness checks for the server, as after 186 the device wakes up again the minimal implementation will start from 187 the beginning again. 189 2. Exchanges 191 2.1. Initial Exchange 193 All IKEv2 communications consist of pairs of messages: a request and 194 a response. The pair is called an "exchange", and is sometimes 195 called a "request/response pair". Every request requires a response. 197 For every pair of IKEv2 messages, the initiator is responsible for 198 retransmission in the event of a timeout. The responder MUST never 199 retransmit a response unless it receives a retransmission of the 200 request. 202 IKEv2 is a reliable protocol: the initiator MUST retransmit a request 203 until it either receives a corresponding response or deems the IKE SA 204 to have failed. A retransmission from the initiator MUST be bitwise 205 identical to the original request. Retransmission times MUST 206 increase exponentially. 208 IKEv2 is run over UDP port 500. All IKEv2 implementations MUST be 209 able to send, receive, and process IKEv2 messages that are up to 1280 210 octets long. An implementation MUST accept incoming requests even if 211 the source port is not 500, and MUST respond to the address and port 212 from which the request was received. 214 The minimal implementation of IKEv2 only uses the first two 215 exchanges, called IKE_SA_INIT and IKE_AUTH. These are used to create 216 the IKE SA and the first Child SA. In addition to those messages, a 217 minimal IKEv2 implementation needs to understand the CREATE_CHILD_SA 218 request enough to generate an CREATE_CHILD_SA response containing the 219 NO_ADDITIONAL_SAS error notify. It needs to understand the 220 INFORMATIONAL request enough to generate an empty INFORMATIONAL 221 response to it. There is no requirement to be able to respond to any 222 other requests. 224 All messages following the IKE_SA_INIT exchange are cryptographically 225 protected using the cryptographic algorithms and keys negotiated in 226 the IKE_SA_INIT exchange. 228 Every IKEv2 message contains a Message ID as part of its fixed 229 header. This Message ID is used to match up requests and responses, 230 and to identify retransmissions of messages. 232 Minimal implementations only need to support the role of initiator, 233 so so it typically only sends an IKE_SA_INIT request which, when 234 answered, is followed by an IKE_AUTH. As those messages have fixed 235 Message IDs (0 and 1) it does not need to keep track of its own 236 Message IDs for outgoing requests after that. 238 Minimal implementations can also optimize Message ID handling of the 239 incoming requests, as they do not need to protect incoming requests 240 against replays. This is possible because minimal implementations 241 will only return error or empty notification replies to incoming 242 requests. This means that any of those incoming requests do not have 243 any effect on the minimal implementation, thus processing them again 244 does not cause any harm. Because of this a minimal implementation 245 can always answer to request coming in, with the same Message ID than 246 what the request had and then forget the request/response pair 247 immediately. This means there is no need to keep track of Message 248 IDs of the incoming requests. 250 In the following descriptions, the payloads contained in the message 251 are indicated by the names listed below. 253 Notation Payload 254 ----------------------------------------- 255 AUTH Authentication 256 CERTREQ Certificate Request 257 D Delete 258 HDR IKE header (not a payload) 259 IDi Identification - Initiator 260 IDr Identification - Responder 261 KE Key Exchange 262 Ni, Nr Nonce 263 N Notify 264 SA Security Association 265 SK Encrypted and Authenticated 266 TSi Traffic Selector - Initiator 267 TSr Traffic Selector - Responder 269 The initial exchanges are as follows: 271 Initiator Responder 272 ------------------------------------------------------------------- 273 HDR(SPIi=xxx, SPIr=0, IKE_SA_INIT, 274 Flags: Initiator, Message ID=0), 275 SAi1, KEi, Ni --> 277 <-- HDR(SPIi=xxx, SPIr=yyy, IKE_SA_INIT, 278 Flags: Response, Message ID=0), 279 SAr1, KEr, Nr, [CERTREQ] 281 HDR contains the Security Parameter Indexes (SPIs), version numbers, 282 and flags of various sorts. Each endpoint chooses one of the two 283 SPIs and MUST choose them so as to be unique identifiers of an IKE 284 SA. An SPI value of zero is special: it indicates that the remote 285 SPI value is not yet known by the sender. 287 Incoming IKEv2 packets are mapped to an IKE SA using only the 288 packet's SPI, not using (for example) the source IP address of the 289 packet. 291 The SAi1 payload states the cryptographic algorithms the initiator 292 supports for the IKE SA. The KEi and KEr payload contain Diffie- 293 Hellman values and Ni and Nr are the nonces. The SAr1 contains the 294 chosen cryptographic suite from initiator's offered choices. A 295 minimal implementation using shared secrets will ignore the CERTREQ 296 payload. 298 Minimal implementation will most likely support exactly one set of 299 cryptographic algorithms, meaning the SAi1 payload will be static. 300 It needs to check that the SAr1 received matches the proposal it 301 sent. 303 At this point in the negotiation, each party can generate SKEYSEED, 304 from which all keys are derived for that IKE SA. 306 SKEYSEED = prf(Ni | Nr, g^ir) 308 {SK_d | SK_ai | SK_ar | SK_ei | SK_er | SK_pi | SK_pr } 309 = prf+ (SKEYSEED, Ni | Nr | SPIi | SPIr ) 311 prf+ (K,S) = T1 | T2 | T3 | T4 | ... 313 where: 314 T1 = prf (K, S | 0x01) 315 T2 = prf (K, T1 | S | 0x02) 316 T3 = prf (K, T2 | S | 0x03) 317 T4 = prf (K, T3 | S | 0x04) 318 ... 320 (indicating that the quantities SK_d, SK_ai, SK_ar, SK_ei, SK_er, 321 SK_pi, and SK_pr are taken in order from the generated bits of the 322 prf+). g^ir is the shared secret from the ephemeral Diffie-Hellman 323 exchange. g^ir is represented as a string of octets in big endian 324 order padded with zeros if necessary to make it the length of the 325 modulus. Ni and Nr are the nonces, stripped of any headers. 327 The SK_d is used for deriving new keys for the Child SAs. The SK_ai 328 and SK_ar are used as a key to the integrity protection algorithm for 329 authenticating the component messages of subsequent exchanges. The 330 SK_ei and SK_er are used for encrypting (and of course decrypting) 331 all subsequent exchanges. The SK_pi and SK_pr are used when 332 generating an AUTH payload. The lengths of SK_d, SK_pi, and SK_pr 333 MUST be the preferred key length of the PRF agreed upon. 335 A separate SK_e and SK_a is computed for each direction. The keys 336 used to protect messages from the original initiator are SK_ai and 337 SK_ei. The keys used to protect messages in the other direction are 338 SK_ar and SK_er. The notation SK { ... } indicates that these 339 payloads are encrypted and integrity protected using that direction's 340 SK_e and SK_a. 342 Initiator Responder 343 ------------------------------------------------------------------- 344 HDR(SPIi=xxx, SPIr=yyy, IKE_AUTH, 345 Flags: Initiator, Message ID=1), 346 SK {IDi, AUTH, SAi2, TSi, TSr, 347 N(INITIAL_CONTACT)} --> 349 <-- HDR(SPIi=xxx, SPIr=yyy, IKE_AUTH, Flags: 350 Response, Message ID=1), 351 SK {IDr, AUTH, SAr2, TSi, TSr} 353 The initiator asserts its identity with the IDi payload, proves 354 knowledge of the secret corresponding to IDi and integrity protects 355 the contents of the first message using the AUTH payload. The 356 responder asserts its identity with the IDr payload, authenticates 357 its identity and protects the integrity of the second message with 358 the AUTH payload. 360 As minimal implementation usually has only one host where it 361 connects, and that means it has only one shared secret. This means 362 it does not need to care about IDr payload that much. If the other 363 end sends AUTH payload which initiator can verify using the shared 364 secret it has, then it knows the other end is the peer it was 365 configured to talk to. 367 In the IKE_AUTH request, the initiator sends the SA offer(s) in the 368 SAi2 payload, and the proposed Traffic Selectors for the Child SA in 369 the TSi and TSr payloads. The responder replies with the accepted 370 offer in an SAr2 payload, and with the selected Traffic Selectors. 371 The selected Traffic Selectors may be a subset of what the initiator 372 proposed. 374 In the minimal implementation both SA payloads and TS payloads are 375 going to be mostly static. The SA payload will have the SPI value 376 used in the Encapsulating Security Payload (ESP), but the algorithms 377 are most likely going to be the one and only supported set. The TS 378 payloads on the initiator end will most likely say from any to any, 379 i.e. full wildcard ranges, or from the local IP to the remote IP. In 380 the wildcard case the responder quite often narrows the range down to 381 the one IP address pair. Using a single IP address pair as the 382 Traffic Selectors when sending the IKE_AUTH request will simplify 383 processing as the responder will either accept the IP address pair or 384 return an error. If wildcard ranges are used, there is a possibility 385 that the responder will narrow the Traffic Selector range to range 386 that is not acceptable by the initiator. 388 The IKE_AUTH (and IKE_SA_INIT) responses may contain multiple status 389 notification payloads which can be ignored by minimal 390 implementations. There can also be Vendor ID, Certificate, 391 Certificate Request or Configuration payloads, but any payload 392 unknown to minimal implementations can simply be skipped over 393 (response messages cannot have critical unsupported payloads). 395 The exchange above includes N(INITIAL_CONTACT) notification in the 396 request as that is quite commonly sent by a minimal implementation. 397 It indicates to the other end that the initiator does not have any 398 other IKE SAs between it and the responder, and if there is any left 399 from previous runs those can be deleted by the responder. As minimal 400 implementations delete IKE SAs without sending IKE SA delete 401 requests, this will help the responder to clean up leftover state. 403 When using shared secret authentication, the peers are authenticated 404 by having each calculating a MAC over a block of data: 406 For the initiator: 407 AUTH = prf( prf(Shared Secret, "Key Pad for IKEv2"), 408 ) 409 For the responder: 410 AUTH = prf( prf(Shared Secret, "Key Pad for IKEv2"), 411 ) 413 The string "Key Pad for IKEv2" is 17 ASCII characters without null 414 termination. The implementation can precalculate the inner prf and 415 only store the output of it. This is possible because a minimal 416 IKEv2 implementation usually only supports one PRF. 418 In following calculations, IDi' and IDr' are the entire ID payloads 419 excluding the fixed header and the Ni and Nr are only the value, not 420 the payload containing it. Note that neither the nonce Ni/Nr nor the 421 value prf(SK_pr, IDr')/prf(SK_pi, IDi') are transmitted. 423 The initiator signs the first message (IKE_SA_INIT request), starting 424 with the first octet of the first SPI in the header and ending with 425 the last octet of the last payload in that first message. Appended 426 to this (for purposes of computing the signature) are the responder's 427 nonce Nr, and the value prf(SK_pi, IDi'). 429 For the responder, the octets to be signed start with the first octet 430 of the first SPI in the header of the second message (IKE_SA_INIT 431 response) and end with the last octet of the last payload in that 432 second message. Appended to this are the initiator's nonce Ni, and 433 the value prf(SK_pr, IDr'). 435 The initiator's signed octets can be described as: 437 InitiatorSignedOctets = RealMessage1 | NonceRData | MACedIDForI 438 RealIKEHDR = SPIi | SPIr | . . . | Length 439 RealMessage1 = RealIKEHDR | RestOfMessage1 440 NonceRPayload = PayloadHeader | NonceRData 441 InitiatorIDPayload = PayloadHeader | RestOfInitIDPayload 442 RestOfInitIDPayload = IDType | RESERVED | InitIDData 443 MACedIDForI = prf(SK_pi, RestOfInitIDPayload) 445 The responder's signed octets can be described as: 447 ResponderSignedOctets = RealMessage2 | NonceIData | MACedIDForR 448 RealIKEHDR = SPIi | SPIr | . . . | Length 449 RealMessage2 = RealIKEHDR | RestOfMessage2 450 NonceIPayload = PayloadHeader | NonceIData 451 ResponderIDPayload = PayloadHeader | RestOfRespIDPayload 452 RestOfRespIDPayload = IDType | RESERVED | RespIDData 453 MACedIDForR = prf(SK_pr, RestOfRespIDPayload) 455 Note that all of the payloads inside the RestOfMessageX are included 456 under the signature, including any payload types not listed in this 457 document. 459 The initiator might also get an unauthenticated response back having 460 a notification payload with an error code inside. As that error code 461 will be unauthenticated and may be faked, there is no need to do 462 anything for those. A minimal implementation can simply ignore those 463 errors, and retransmit its request until it times out and if that 464 happens then the IKE SA (and Child SA) creation failed. 466 The responder might also reply with an IKE_AUTH response packet which 467 does not contain the payloads needed to set up a Child SA (SAr2, TSi 468 and TSr), but instead contain AUTH payload and an error. Minimal 469 implementation that do not support the CREATE_CHILD_SA exchange 470 cannot recover from this scenario. It can delete the IKE SA and 471 start over from the beginning (which might fail again if this is a 472 configuration error, or it might succeed if this was temporal 473 failure). 475 2.2. Other Exchanges 477 Minimal implementations MUST be able to reply to INFORMATIONAL 478 requests by sending back an empty INFORMATIONAL response: 480 Minimal implementation Other end 481 ------------------------------------------------------------------- 482 <-- HDR(SPIi=xxx, SPIr=yyy, INFORMATIONAL, 483 Flags: none, Message ID=m), 484 SK {...} 486 HDR(SPIi=xxx, SPIr=yyy, INFORMATIONAL, 487 Flags: Initiator | Response, 488 Message ID=m), 489 SK {} --> 491 Minimal implementations MUST be able to reply to incoming 492 CREATE_CHILD_SA requests. A typical implementation will reject the 493 CREATE_CHILD_SA exchanges by sending a NO_ADDITIONAL_SAS error notify 494 back: 496 Minimal implementation Other end 497 ------------------------------------------------------------------- 498 <-- HDR(SPIi=xxx, SPIy=yyy, CREATE_CHILD_SA, 499 Flags: none, Message ID=m), 500 SK {...} 502 HDR(SPIi=xxx, SPIr=yyy, CREATE_CHILD_SA, 503 Flags: Initiator | Response, Message ID=m), 504 SK {N(NO_ADDITIONAL_SAS)} --> 506 Note that INFORMATIONAL and CREATE_CHILD_SA requests might contain 507 unsupported critical payloads, in which case a compliant 508 implementation MUST ignore the request, and send a response message 509 back having the UNSUPPORTED_CRITICAL_PAYLOAD notification. That 510 notification payload data contains a one-octet payload type of the 511 unsupported critical payload. 513 2.3. Generating Keying Material 515 The keying material for the Child SA created by the IKE_AUTH exchange 516 is generated as follows: 518 KEYMAT = prf+(SK_d, Ni | Nr) 520 Where Ni and Nr are the nonces from the IKE_SA_INIT exchange. 522 A single CHILD_SA negotiation may result in multiple Security 523 Associations. ESP and AH SAs exist in pairs (one in each direction), 524 so two SAs are created in a single Child SA negotiation for them. 525 The keying material for each Child SA MUST be taken from the expanded 526 KEYMAT using the following rules: 528 o All keys for SAs carrying data from the initiator to the responder 529 are taken before SAs going from the responder to the initiator. 531 o If an IPsec protocol requires multiple keys, the order in which 532 they are taken from the SA's keying material needs to be described 533 in the protocol's specification. For ESP and AH, [IPSECARCH] 534 defines the order, namely: the encryption key (if any) MUST be 535 taken from the first bits and the integrity key (if any) MUST be 536 taken from the remaining bits. 538 Each cryptographic algorithm takes a fixed number of bits of keying 539 material specified as part of the algorithm, or negotiated in SA 540 payloads. 542 3. Conformance Requirements 544 For an implementation to be called conforming to RFC 7296 545 specification, it MUST be possible to configure it to accept the 546 following: 548 o Public Key Infrastructure using X.509 (PKIX) Certificates 549 containing and signed by RSA keys of size 1024 or 2048 bits, where 550 the ID passed is any of ID_KEY_ID, ID_FQDN, ID_RFC822_ADDR, or 551 ID_DER_ASN1_DN. 553 o Shared key authentication where the ID passed is any of ID_KEY_ID, 554 ID_FQDN, or ID_RFC822_ADDR. 556 o Authentication where the responder is authenticated using PKIX 557 Certificates and the initiator is authenticated using shared key 558 authentication. 560 This document only supports the second bullet, it does not support 561 PKIX certificates at all. As full RFC 7296 responders must also 562 support that shared key authentication, this allows a minimal 563 implementation to be able to interoperate with all RFC 7296 compliant 564 implementations. 566 PKIX certificates are left out from the minimal implementation as 567 those would add quite a lot of complexity to the implementation. The 568 actual code changes needed in the IKEv2 protocol are small, but the 569 certificate validation code would be more complex than the whole 570 minimal IKEv2 implementation itself. If public key based 571 authentication is needed for scalability reasons, then raw public 572 keys would probably be the best compromise (see Appendix B.2). 574 4. Implementation Status 576 This document describes minimal implementation written by the author 577 of this document. This minimal implementation supported the base 578 IKE_SA_INIT and IKE_AUTH exchanges, and successfully interoperated 579 with full IKEv2 server. This minimal implementation was presented in 580 the Interconnecting Smart Objects with Internet Workshop in Prague 581 March 2011 ([Kiv11]). This implementation was written as proof of 582 concept in perl. 584 There was also another proof of concept implementation written in 585 python, which also interoperated with full IKEv2 server. 587 Both implementations were written just for demonstration purposes, 588 and included fixed configuration built in to the code, and both also 589 implemented also ESP, ICMP and IP layers in the level that was needed 590 to send and receive one ICMP echo packet. Both implementations were 591 about 1000 lines of code excluding cryptographic libraries but 592 including ESP, ICMP and IP layers. 594 5. Security Considerations 596 As this implements same protocol as RFC 7296 this means all security 597 considerations from it also apply to this document. 599 6. IANA Considerations 601 There is no new IANA considerations in this document. 603 7. Acknowledgements 605 Most of the content of this document is copied from the RFC 7296. 607 8. References 609 8.1. Normative References 611 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 612 Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/ 613 RFC2119, March 1997, 614 . 616 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 617 Kivinen, "Internet Key Exchange Protocol Version 2 618 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 619 2014, . 621 8.2. Informative References 623 [I-D.ietf-ipsecme-oob-pubkey] 624 Kivinen, T., Wouters, P., and H. Tschofenig, "More Raw 625 Public Keys for IKEv2", draft-ietf-ipsecme-oob-pubkey-00 626 (work in progress), April 2013. 628 [IKEV2IANA] 629 "Internet Key Exchange Version 2 (IKEv2) Parameters", 630 . 632 [Kiv11] Kivinen, T., "IKEv2 and Smart Objects", March 2011, 633 . 636 [MODES] National Institute of Standards and Technology, U.S. 637 Department of Commerce, "Recommendation for Block Cipher 638 Modes of Operation", SP 800-38A, 2001. 640 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 641 Housley, R., and W. Polk, "Internet X.509 Public Key 642 Infrastructure Certificate and Certificate Revocation List 643 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 644 . 646 [RFC7619] Smyslov, V. and P. Wouters, "The NULL Authentication 647 Method in the Internet Key Exchange Protocol Version 2 648 (IKEv2)", RFC 7619, DOI 10.17487/RFC7619, August 2015, 649 . 651 Appendix A. Header and Payload Formats 653 This appendix describes actual packet payload formats. This is 654 required to make the document self contained. The descriptions are 655 mostly copied from the RFC7296 and more information can be found from 656 there. 658 Various payload contains RESERVED fields and those MUST be sent as 659 zero and MUST be ignored on receipt. 661 All multi-octet fields representing integers are laid out in big 662 endian order (also known as "most significant byte first", or 663 "network byte order"). 665 A.1. The IKE Header 667 Each IKEv2 message begins with the IKE header, denoted HDR in this 668 document. Following the header are one or more IKE payloads each 669 identified by a "Next Payload" field in the preceding payload. 670 Payloads are identified in the order in which they appear in an IKE 671 message by looking in the "Next Payload" field in the IKE header, and 672 subsequently according to the "Next Payload" field in the IKE payload 673 itself until a "Next Payload" field of zero indicates that no 674 payloads follow. If a payload of type "Encrypted" is found, that 675 payload is decrypted and its contents parsed as additional payloads. 676 An Encrypted payload MUST be the last payload in a packet and an 677 Encrypted payload MUST NOT contain another Encrypted payload. 679 The format of the IKE header is shown in Figure 1. 681 1 2 3 682 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 683 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 684 | IKE SA Initiator's SPI | 685 | | 686 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 687 | IKE SA Responder's SPI | 688 | | 689 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 690 | Next Payload | MjVer | MnVer | Exchange Type | Flags | 691 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 692 | Message ID | 693 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 694 | Length | 695 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 697 Figure 1: IKE Header Format 699 o Initiator's SPI (8 octets) - A value chosen by the initiator to 700 identify a unique IKE Security Association. This value MUST NOT 701 be zero. 703 o Responder's SPI (8 octets) - A value chosen by the responder to 704 identify a unique IKE Security Association. This value MUST be 705 zero in the first message of an IKE initial exchange. 707 o Next Payload (1 octet) - Indicates the type of payload that 708 immediately follows the header. The format and value of each 709 payload are defined below. 711 o Major Version (4 bits) - Indicates the major version of the IKE 712 protocol in use. Implementations based on this version of IKE 713 MUST set the major version to 2 and MUST drop the messages with a 714 higher major version number. 716 o Minor Version (4 bits) - Indicates the minor version of the IKE 717 protocol in use. Implementations based on this version of IKE 718 MUST set the minor version to 0. They MUST ignore the minor 719 version number of received messages. 721 o Exchange Type (1 octet) - Indicates the type of exchange being 722 used. This constrains the payloads sent in each message in an 723 exchange. 725 Exchange Type Value 726 ---------------------------------- 727 IKE_SA_INIT 34 728 IKE_AUTH 35 729 CREATE_CHILD_SA 36 730 INFORMATIONAL 37 732 o Flags (1 octet) - Indicates specific options that are set for the 733 message. Presence of options is indicated by the appropriate bit 734 in the flags field being set. The bits are as follows: 736 +-+-+-+-+-+-+-+-+ 737 |X|X|R|V|I|X|X|X| 738 +-+-+-+-+-+-+-+-+ 740 In the description below, a bit being 'set' means its value is 741 '1', while 'cleared' means its value is '0'. 'X' bits MUST be 742 cleared when sending and MUST be ignored on receipt. 744 * R (Response) - This bit indicates that this message is a 745 response to a message containing the same Message ID. This bit 746 MUST be cleared in all request messages and MUST be set in all 747 responses. An IKEv2 endpoint MUST NOT generate a response to a 748 message that is marked as being a response. 750 * V (Version) - This bit indicates that the transmitter is 751 capable of speaking a higher major version number of the 752 protocol than the one indicated in the major version number 753 field. Implementations of IKEv2 MUST clear this bit when 754 sending and MUST ignore it in incoming messages. 756 * I (Initiator) - This bit MUST be set in messages sent by the 757 original initiator of the IKE SA and MUST be cleared in 758 messages sent by the original responder. It is used by the 759 recipient to determine which eight octets of the SPI were 760 generated by the recipient. This bit changes to reflect who 761 initiated the last rekey of the IKE SA. 763 o Message ID (4 octets, unsigned integer) - Message identifier used 764 to control retransmission of lost packets and matching of requests 765 and responses. It is essential to the security of the protocol 766 because it is used to prevent message replay attacks. 768 o Length (4 octets, unsigned integer) - Length of the total message 769 (header + payloads) in octets. 771 A.2. Generic Payload Header 773 Each IKE payload begins with a generic payload header, shown in 774 Figure 2. Figures for each payload below will include the generic 775 payload header, but for brevity, the description of each field will 776 be omitted. 778 1 2 3 779 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 780 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 781 | Next Payload |C| RESERVED | Payload Length | 782 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 784 Figure 2: Generic Payload Header 786 The Generic Payload Header fields are defined as follows: 788 o Next Payload (1 octet) - Identifier for the payload type of the 789 next payload in the message. If the current payload is the last 790 in the message, then this field will be 0. This field provides a 791 "chaining" capability whereby additional payloads can be added to 792 a message by appending each one to the end of the message and 793 setting the "Next Payload" field of the preceding payload to 794 indicate the new payload's type. An Encrypted payload, which must 795 always be the last payload of a message, is an exception. It 796 contains data structures in the format of additional payloads. In 797 the header of an Encrypted payload, the Next Payload field is set 798 to the payload type of the first contained payload (instead of 0); 799 conversely, the Next Payload field of the last contained payload 800 is set to zero). The payload type values needed for minimal 801 implementations are listed here. 803 Next Payload Type Notation Value 804 -------------------------------------------------- 805 No Next Payload 0 806 Security Association SA 33 807 Key Exchange KE 34 808 Identification - Initiator IDi 35 809 Identification - Responder IDr 36 810 Certificate CERT 37 811 Certificate Request CERTREQ 38 812 Authentication AUTH 39 813 Nonce Ni, Nr 40 814 Notify N 41 815 Delete D 42 816 Traffic Selector - Initiator TSi 44 817 Traffic Selector - Responder TSr 45 818 Encrypted and Authenticated SK 46 820 o Critical (1 bit) - MUST be set to zero if the sender wants the 821 recipient to skip this payload if it does not understand the 822 payload type code in the Next Payload field of the previous 823 payload. MUST be set to one if the sender wants the recipient to 824 reject this entire message if it does not understand the payload 825 type. MUST be ignored by the recipient if the recipient 826 understands the payload type code. MUST be set to zero for 827 payload types defined in this document. Note that the critical 828 bit applies to the current payload rather than the "next" payload 829 whose type code appears in the first octet. 831 o Payload Length (2 octets, unsigned integer) - Length in octets of 832 the current payload, including the generic payload header. 834 A.3. Security Association Payload 836 The Security Association payload, denoted SA in this document, is 837 used to negotiate attributes of a Security Association. 839 An SA payload consists of one or more proposals. Each proposal 840 includes one protocol. Each protocol contains one or more transforms 841 -- each specifying a cryptographic algorithm. Each transform 842 contains zero or more attributes (attributes are needed only if the 843 Transform ID does not completely specify the cryptographic algorithm, 844 currently only attribute is key length attribute for variable length 845 ciphers, meaning there is exactly zero or one attribute). 847 The responder MUST choose a single suite, which may be any subset of 848 the SA proposal following the rules below. 850 Each proposal contains one protocol. If a proposal is accepted, the 851 SA response MUST contain the same protocol. Each IPsec protocol 852 proposal contains one or more transforms. Each transform contains a 853 Transform Type. The accepted cryptographic suite MUST contain 854 exactly one transform of each type included in the proposal. For 855 example: if an ESP proposal includes transforms ENCR_3DES, ENCR_AES 856 w/keysize 128, ENCR_AES w/keysize 256, AUTH_HMAC_MD5, and 857 AUTH_HMAC_SHA, the accepted suite MUST contain one of the ENCR_ 858 transforms and one of the AUTH_ transforms. Thus, six combinations 859 are acceptable. 861 Minimal implementation can create very simple SA proposal, i.e. 862 include one proposal, which contains exactly one transform for each 863 transform type. It is important to only include one Diffie-Hellman 864 group in proposal, so there is no need to do INVALID_KE_PAYLOAD 865 processing in responses. 867 When parsing an SA, an implementation MUST check that the total 868 Payload Length is consistent with the payload's internal lengths and 869 counts. Proposals, Transforms, and Attributes each have their own 870 variable-length encodings. They are nested such that the Payload 871 Length of an SA includes the combined contents of the SA, Proposal, 872 Transform, and Attribute information. The length of a Proposal 873 includes the lengths of all Transforms and Attributes it contains. 874 The length of a Transform includes the lengths of all Attributes it 875 contains. 877 Each Proposal/Protocol structure is followed by one or more transform 878 structures. The number of different transforms is generally 879 determined by the Protocol. AH generally has two transforms: 880 Extended Sequence Numbers (ESNs) and an integrity check algorithm. 881 ESP generally has three: ESN, an encryption algorithm, and an 882 integrity check algorithm. IKEv2 generally has four transforms: a 883 Diffie-Hellman group, an integrity check algorithm, a PRF algorithm, 884 and an encryption algorithm. For each Protocol, the set of 885 permissible transforms is assigned Transform ID numbers, which appear 886 in the header of each transform. 888 If there are multiple transforms with the same Transform Type, the 889 proposal is an OR of those transforms. If there are multiple 890 transforms with different Transform Types, the proposal is an AND of 891 the different groups. 893 A given transform MAY have one or more Attributes. Attributes are 894 necessary when the transform can be used in more than one way, as 895 when an encryption algorithm has a variable key size. The transform 896 would specify the algorithm and the attribute would specify the key 897 size. To propose alternate values for an attribute (for example, 898 multiple key sizes for the AES encryption algorithm), an 899 implementation MUST include multiple transforms with the same 900 Transform Type each with a single Attribute. 902 1 2 3 903 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 904 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 905 | Next Payload |C| RESERVED | Payload Length | 906 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 907 | | 908 ~ ~ 909 | | 910 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 912 Figure 3: Security Association Payload 914 o Proposals (variable) - One or more proposal substructures. 916 A.3.1. Proposal Substructure 918 1 2 3 919 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 920 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 921 | 0 (last) or 2 | RESERVED | Proposal Length | 922 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 923 | Proposal Num | Protocol ID | SPI Size |Num Transforms| 924 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 925 ~ SPI (variable) ~ 926 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 927 | | 928 ~ ~ 929 | | 930 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 932 Figure 4: Proposal Substructure 934 o 0 (last) or 2 (more) (1 octet) - Specifies whether this is the 935 last Proposal Substructure in the SA. 937 o Proposal Length (2 octets, unsigned integer) - Length of this 938 proposal, including all transforms and attributes that follow. 940 o Proposal Num (1 octet) - When a proposal is made, the first 941 proposal in an SA payload MUST be 1, and subsequent proposals MUST 942 be one more than the previous proposal. When a proposal is 943 accepted, the proposal number in the SA payload MUST match the 944 number on the proposal sent that was accepted. 946 o Protocol ID (1 octet) - Specifies the IPsec protocol identifier 947 for the current negotiation. 949 Protocol Protocol ID 950 ----------------------------------- 951 IKE 1 952 AH 2 953 ESP 3 955 o SPI Size (1 octet) - For an initial IKE SA negotiation, this field 956 MUST be zero; the SPI is obtained from the outer header. During 957 subsequent negotiations, it is equal to the size, in octets, of 958 the SPI of the corresponding protocol (8 for IKE, 4 for ESP and 959 AH). 961 o Num Transforms (1 octet) - Specifies the number of transforms in 962 this proposal. 964 o SPI (variable) - The sending entity's SPI. When the SPI Size 965 field is zero, this field is not present in the Security 966 Association payload. 968 o Transforms (variable) - One or more transform substructures. 970 A.3.2. Transform Substructure 972 1 2 3 973 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 974 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 975 | 0 (last) or 3 | RESERVED | Transform Length | 976 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 977 |Transform Type | RESERVED | Transform ID | 978 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 979 | | 980 ~ Transform Attributes ~ 981 | | 982 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 984 Figure 5: Transform Substructure 986 o 0 (last) or 3 (more) (1 octet) - Specifies whether this is the 987 last Transform Substructure in the Proposal. 989 o Transform Length - The length (in octets) of the Transform 990 Substructure including Header and Attributes. 992 o Transform Type (1 octet) - The type of transform being specified 993 in this transform. Different protocols support different 994 Transform Types. For some protocols, some of the transforms may 995 be optional. If a transform is optional and the initiator wishes 996 to propose that the transform be omitted, no transform of the 997 given type is included in the proposal. If the initiator wishes 998 to make use of the transform optional to the responder, it 999 includes a transform substructure with Transform ID = 0 as one of 1000 the options. 1002 o Transform ID (2 octets) - The specific instance of the Transform 1003 Type being proposed. 1005 The relevant Transform Type values are listed below. For more 1006 information see [RFC7296]. 1008 Description Trans. Used In 1009 Type 1010 ------------------------------------------------------------------ 1011 Encryption Algorithm (ENCR) 1 IKE and ESP 1012 Pseudorandom Function (PRF) 2 IKE 1013 Integrity Algorithm (INTEG) 3 IKE, AH, optional in ESP 1014 Diffie-Hellman group (D-H) 4 IKE, optional in AH & ESP 1015 Extended Sequence Numbers (ESN) 5 AH and ESP 1017 For Transform Type 1 (Encryption Algorithm), the relevant Transform 1018 IDs are listed below. 1020 Name Number 1021 --------------------------- 1022 ENCR_AES_CBC 12 1023 ENCR_AES-CCM_8 14 1025 For Transform Type 2 (Pseudorandom Function), the relevant Transform 1026 IDs are listed below. 1028 Name Number 1029 ---------------------------------- 1030 PRF_HMAC_SHA1 2 1032 For Transform Type 3 (Integrity Algorithm), relevant Transform IDs 1033 are listed below. 1035 Name Number 1036 --------------------------- 1037 AUTH_HMAC_SHA1_96 2 1038 AUTH_AES_XCBC_96 5 1040 For Transform Type 4 (Diffie-Hellman group), relevant Transform IDs 1041 are listed below. 1043 Name Number 1044 ------------------------- 1045 1536-bit MODP 5 1046 2048-bit MODP 14 1048 For Transform Type 5 (Extended Sequence Numbers), relevant Transform 1049 IDs are listed below. 1051 Name Number 1052 -------------------------------------------- 1053 No Extended Sequence Numbers 0 1054 Extended Sequence Numbers 1 1056 Note that an initiator who supports ESNs will usually include two ESN 1057 transforms, with values "0" and "1", in its proposals. A proposal 1058 containing a single ESN transform with value "1" means that using 1059 normal (non-extended) sequence numbers is not acceptable. 1061 A.3.3. Valid Transform Types by Protocol 1063 The number and type of transforms that accompany an SA payload are 1064 dependent on the protocol in the SA itself. An SA payload proposing 1065 the establishment of an SA has the following mandatory and optional 1066 Transform Types. A compliant implementation MUST understand all 1067 mandatory and optional types for each protocol it supports (though it 1068 need not accept proposals with unacceptable suites). A proposal MAY 1069 omit the optional types if the only value for them it will accept is 1070 NONE. 1072 Protocol Mandatory Types Optional Types 1073 --------------------------------------------------- 1074 IKE ENCR, PRF, INTEG, D-H 1075 ESP ENCR, ESN INTEG, D-H 1076 AH INTEG, ESN D-H 1078 A.3.4. Transform Attributes 1080 Transform type 1 (Encryption Algorithm) transforms might include one 1081 transform attribute: Key Length. 1083 1 2 3 1084 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 1085 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1086 |1| Attribute Type | Attribute Value | 1087 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1088 Figure 6: Data Attributes 1090 o Attribute Type (15 bits) - Unique identifier for each type of 1091 attribute (see below). 1093 o Attribute Value - Value of the attribute associated with the 1094 attribute type. 1096 Attribute Type Value 1097 ---------------------------- 1098 Key Length (in bits) 14 1100 The Key Length attribute specifies the key length in bits (MUST use 1101 network byte order) for certain transforms as follows: 1103 o The Key Length attribute MUST NOT be used with transforms that use 1104 a fixed-length key. 1106 o Some transforms specify that the Key Length attribute MUST be 1107 always included. For example ENCR_AES_CBC. 1109 A.4. Key Exchange Payload 1111 1 2 3 1112 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 1113 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1114 | Next Payload |C| RESERVED | Payload Length | 1115 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1116 | Diffie-Hellman Group Num | RESERVED | 1117 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1118 | | 1119 ~ Key Exchange Data ~ 1120 | | 1121 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1123 Figure 7: Key Exchange Payload Format 1125 A Key Exchange payload is constructed by copying one's Diffie-Hellman 1126 public value into the "Key Exchange Data" portion of the payload. 1127 The length of the Diffie-Hellman public value for modular 1128 exponentiation group (MODP) groups MUST be equal to the length of the 1129 prime modulus over which the exponentiation was performed, prepending 1130 zero bits to the value if necessary. 1132 The Diffie-Hellman Group Num identifies the Diffie-Hellman group in 1133 which the Key Exchange Data was computed. This Diffie-Hellman Group 1134 Num MUST match a Diffie-Hellman group specified in a proposal in the 1135 SA payload that is sent in the same message 1137 A.5. Identification Payloads 1139 The Identification payloads, denoted IDi and IDr in this document, 1140 allow peers to assert an identity to one another. When using the 1141 ID_IPV4_ADDR/ID_IPV6_ADDR identity types in IDi/IDr payloads, IKEv2 1142 does not require this address to match the address in the IP header 1143 of IKEv2 packets, or anything in the TSi/TSr payloads. The contents 1144 of IDi/IDr are used purely to fetch the policy and authentication 1145 data related to the other party. In minimal implementation it might 1146 be easiest to always use KEY_ID type. This allows the ID payload to 1147 be static. Using IP address has problems in environments where IP 1148 addresses are dynamically allocated. 1150 1 2 3 1151 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 1152 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1153 | Next Payload |C| RESERVED | Payload Length | 1154 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1155 | ID Type | RESERVED | 1156 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1157 | | 1158 ~ Identification Data ~ 1159 | | 1160 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1162 Figure 8: Identification Payload Format 1164 o ID Type (1 octet) - Specifies the type of Identification being 1165 used. 1167 o Identification Data (variable length) - Value, as indicated by the 1168 Identification Type. The length of the Identification Data is 1169 computed from the size in the ID payload header. 1171 The following table lists the assigned semantics for the 1172 Identification Type field. 1174 ID Type Value 1175 ------------------------------------------------------------------- 1176 ID_IPV4_ADDR 1 1177 A single four (4) octet IPv4 address. 1179 ID_FQDN 2 1180 A fully-qualified domain name string. An example of an ID_FQDN 1181 is "example.com". The string MUST NOT contain any terminators 1182 (e.g., NULL, CR, etc.). All characters in the ID_FQDN are ASCII; 1183 for an "internationalized domain name", the syntax is as defined 1184 in [IDNA], for example "xn--tmonesimerkki-bfbb.example.net". 1186 ID_RFC822_ADDR 3 1187 A fully-qualified RFC 822 email address string. An example of a 1188 ID_RFC822_ADDR is "jsmith@example.com". The string MUST NOT 1189 contain any terminators. Because of [EAI], implementations would 1190 be wise to treat this field as UTF-8 encoded text, not as 1191 pure ASCII. 1193 ID_IPV6_ADDR 5 1194 A single sixteen (16) octet IPv6 address. 1196 ID_KEY_ID 11 1197 An opaque octet stream that may be used to pass vendor- 1198 specific information necessary to do certain proprietary 1199 types of identification. Minimal implementation might use 1200 this type to send out serial number or similar device 1201 specific unique static identification data for the device. 1203 A.6. Certificate Payload 1205 1 2 3 1206 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 1207 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1208 | Next Payload |C| RESERVED | Payload Length | 1209 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1210 | Cert Encoding | | 1211 +-+-+-+-+-+-+-+-+ | 1212 ~ Certificate Data ~ 1213 | | 1214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1216 Figure 9: Certificate Payload Format 1218 o Certificate Encoding (1 octet) - This field indicates the type of 1219 certificate or certificate-related information contained in the 1220 Certificate Data field. 1222 Certificate Encoding Value 1223 ---------------------------------------------------- 1224 X.509 Certificate - Signature 4 1225 Raw Public Key TBD 1227 o Certificate Data (variable length) - Actual encoding of 1228 certificate data. The type of certificate is indicated by the 1229 Certificate Encoding field. 1231 The syntax of the types above are: 1233 o "X.509 Certificate - Signature" contains a DER-encoded X.509 1234 certificate whose public key is used to validate the sender's AUTH 1235 payload. Note that with this encoding, if a chain of certificates 1236 needs to be sent, multiple CERT payloads are used, only the first 1237 of which holds the public key used to validate the sender's AUTH 1238 payload. 1240 o "Raw Public Key" contains a raw public key. In essence the 1241 Certificate Payload contains the SubjectPublicKeyInfo part of the 1242 PKIX certificate (See Section 4.1.2.7 of [RFC5280]). This is 1243 quite simple ASN.1 object which contains mostly static parts 1244 before the actual public key values. See 1245 [I-D.ietf-ipsecme-oob-pubkey] for more information. 1247 A.7. Certificate Request Payload 1249 1 2 3 1250 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 1251 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1252 | Next Payload |C| RESERVED | Payload Length | 1253 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1254 | Cert Encoding | | 1255 +-+-+-+-+-+-+-+-+ | 1256 ~ Certification Authority ~ 1257 | | 1258 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1260 Figure 10: Certificate Request Payload Format 1262 o Certificate Encoding (1 octet) - Contains an encoding of the type 1263 or format of certificate requested. 1265 o Certification Authority (variable length) - Contains an encoding 1266 of an acceptable certification authority for the type of 1267 certificate requested. 1269 The Certificate Encoding field has the same values as those defined 1270 certificate payload. The Certification Authority field contains an 1271 indicator of trusted authorities for this certificate type. The 1272 Certification Authority value is a concatenated list of SHA-1 hashes 1273 of the public keys of trusted Certification Authorities (CAs). Each 1274 is encoded as the SHA-1 hash of the Subject Public Key Info element 1275 (see Section 4.1.2.7 of [RFC5280]) from each Trust Anchor 1276 certificate. The 20-octet hashes are concatenated and included with 1277 no other formatting. 1279 A.8. Authentication Payload 1281 1 2 3 1282 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 1283 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1284 | Next Payload |C| RESERVED | Payload Length | 1285 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1286 | Auth Method | RESERVED | 1287 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1288 | | 1289 ~ Authentication Data ~ 1290 | | 1291 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1293 Figure 11: Authentication Payload Format 1295 o Auth Method (1 octet) - Specifies the method of authentication 1296 used. 1298 Mechanism Value 1299 ----------------------------------------------------------------- 1300 RSA Digital Signature 1 1301 Using an RSA private key with RSASSA-PKCS1-v1_5 signature 1302 scheme specified in [PKCS1], see [RFC7296] Section 2.15 for 1303 details. 1305 Shared Key Message Integrity Code 2 1306 Computed as specified earlier using the shared key associated 1307 with the identity in the ID payload and the negotiated PRF. 1309 o Authentication Data (variable length) - see Section 2.1. 1311 A.9. Nonce Payload 1312 1 2 3 1313 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 1314 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1315 | Next Payload |C| RESERVED | Payload Length | 1316 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1317 | | 1318 ~ Nonce Data ~ 1319 | | 1320 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1322 Figure 12: Nonce Payload Format 1324 o Nonce Data (variable length) - Contains the random data generated 1325 by the transmitting entity. 1327 The size of the Nonce Data MUST be between 16 and 256 octets, 1328 inclusive. Nonce values MUST NOT be reused. 1330 A.10. Notify Payload 1332 The Notify payload, denoted N in this document, is used to transmit 1333 informational data, such as error conditions and state transitions, 1334 to an IKE peer. A Notify payload may appear in a response message 1335 (usually specifying why a request was rejected), in an INFORMATIONAL 1336 Exchange (to report an error not in an IKE request), or in any other 1337 message to indicate sender capabilities or to modify the meaning of 1338 the request. 1340 1 2 3 1341 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 1342 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1343 | Next Payload |C| RESERVED | Payload Length | 1344 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1345 | Protocol ID | SPI Size | Notify Message Type | 1346 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1347 | | 1348 ~ Security Parameter Index (SPI) ~ 1349 | | 1350 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1351 | | 1352 ~ Notification Data ~ 1353 | | 1354 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1356 Figure 13: Notify Payload Format 1358 o Protocol ID (1 octet) - If this notification concerns an existing 1359 SA whose SPI is given in the SPI field, this field indicates the 1360 type of that SA. If the SPI field is empty, this field MUST be 1361 sent as zero and MUST be ignored on receipt. 1363 o SPI Size (1 octet) - Length in octets of the SPI as defined by the 1364 IPsec protocol ID or zero if no SPI is applicable. For a 1365 notification concerning the IKE SA, the SPI Size MUST be zero and 1366 the field must be empty. 1368 o Notify Message Type (2 octets) - Specifies the type of 1369 notification message. 1371 o SPI (variable length) - Security Parameter Index. 1373 o Notification Data (variable length) - Status or error data 1374 transmitted in addition to the Notify Message Type. Values for 1375 this field are type specific. 1377 A.10.1. Notify Message Types 1379 Notification information can be error messages specifying why an SA 1380 could not be established. It can also be status data that a process 1381 managing an SA database wishes to communicate with a peer process. 1383 Types in the range 0 - 16383 are intended for reporting errors. An 1384 implementation receiving a Notify payload with one of these types 1385 that it does not recognize in a response MUST assume that the 1386 corresponding request has failed entirely. Unrecognized error types 1387 in a request and status types in a request or response MUST be 1388 ignored, and they should be logged. 1390 Notify payloads with status types MAY be added to any message and 1391 MUST be ignored if not recognized. They are intended to indicate 1392 capabilities, and as part of SA negotiation, are used to negotiate 1393 non-cryptographic parameters. 1395 NOTIFY messages: error types Value 1396 ------------------------------------------------------------------- 1397 UNSUPPORTED_CRITICAL_PAYLOAD 1 1398 Indicates that the one-octet payload type included in the 1399 Notification Data field is unknown. 1401 INVALID_SYNTAX 7 1402 Indicates the IKE message that was received was invalid because 1403 some type, length, or value was out of range or because the 1404 request was rejected for policy reasons. To avoid a DoS 1405 attack using forged messages, this status may only be 1406 returned for and in an encrypted packet if the Message ID and 1407 cryptographic checksum were valid. To avoid leaking information 1408 to someone probing a node, this status MUST be sent in response 1409 to any error not covered by one of the other status types. 1410 To aid debugging, more detailed error information should be 1411 written to a console or log. 1413 NO_PROPOSAL_CHOSEN 14 1414 None of the proposed crypto suites was acceptable. This can be 1415 sent in any case where the offered proposals are not acceptable 1416 for the responder. 1418 NO_ADDITIONAL_SAS 35 1419 Specifies that the node is unwilling to accept any more Child 1420 SAs. 1422 NOTIFY messages: status types Value 1423 ------------------------------------------------------------------- 1424 INITIAL_CONTACT 16384 1425 Asserts that this IKE SA is the only IKE SA currently active 1426 between the authenticated identities. 1428 A.11. Traffic Selector Payload 1430 Traffic Selector (TS) payloads allow endpoints to communicate some of 1431 the information from their SPD to their peers. TS payloads specify 1432 the selection criteria for packets that will be forwarded over the 1433 newly set up SA. 1435 1 2 3 1436 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 1437 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1438 | Next Payload |C| RESERVED | Payload Length | 1439 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1440 | Number of TSs | RESERVED | 1441 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1442 | | 1443 ~ ~ 1444 | | 1445 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1447 Figure 14: Traffic Selectors Payload Format 1449 o Number of TSs (1 octet) - Number of Traffic Selectors being 1450 provided. 1452 o Traffic Selectors (variable length) - One or more individual 1453 Traffic Selectors. 1455 The length of the Traffic Selector payload includes the TS header and 1456 all the Traffic Selectors. 1458 There is no requirement that TSi and TSr contain the same number of 1459 individual Traffic Selectors. Thus, they are interpreted as follows: 1460 a packet matches a given TSi/TSr if it matches at least one of the 1461 individual selectors in TSi, and at least one of the individual 1462 selectors in TSr. 1464 Two TS payloads appear in each of the messages in the exchange that 1465 creates a Child SA pair. Each TS payload contains one or more 1466 Traffic Selectors. Each Traffic Selector consists of an address 1467 range (IPv4 or IPv6), a port range, and an IP protocol ID. 1469 The first of the two TS payloads is known as TSi (Traffic Selector- 1470 initiator). The second is known as TSr (Traffic Selector-responder). 1471 TSi specifies the source address of traffic forwarded from (or the 1472 destination address of traffic forwarded to) the initiator of the 1473 Child SA pair. TSr specifies the destination address of the traffic 1474 forwarded to (or the source address of the traffic forwarded from) 1475 the responder of the Child SA pair. 1477 IKEv2 allows the responder to choose a subset of the traffic proposed 1478 by the initiator. 1480 When the responder chooses a subset of the traffic proposed by the 1481 initiator, it narrows the Traffic Selectors to some subset of the 1482 initiator's proposal (provided the set does not become the null set). 1484 If the type of Traffic Selector proposed is unknown, the responder 1485 ignores that Traffic Selector, so that the unknown type is not 1486 returned in the narrowed set. 1488 To enable the responder to choose the appropriate range, if the 1489 initiator has requested the SA due to a data packet, the initiator 1490 SHOULD include as the first Traffic Selector in each of TSi and TSr a 1491 very specific Traffic Selector including the addresses in the packet 1492 triggering the request. If the initiator creates the Child SA pair 1493 not in response to an arriving packet, but rather, say, upon startup, 1494 then there may be no specific addresses the initiator prefers for the 1495 initial tunnel over any other. In that case, the first values in TSi 1496 and TSr can be ranges rather than specific values. 1498 As minimal implementations might only support one SA, the traffic 1499 selectors will usually be from initiator's IP address to responders 1500 IP address (i.e. no port or protocol selectors and only one range). 1502 A.11.1. Traffic Selector 1504 1 2 3 1505 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 1506 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1507 | TS Type |IP Protocol ID | Selector Length | 1508 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1509 | Start Port | End Port | 1510 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1511 | | 1512 ~ Starting Address ~ 1513 | | 1514 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1515 | | 1516 ~ Ending Address ~ 1517 | | 1518 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1520 Figure 15: Traffic Selector 1522 o TS Type (one octet) - Specifies the type of Traffic Selector. 1524 o IP protocol ID (1 octet) - Value specifying an associated IP 1525 protocol ID (such as UDP, TCP, and ICMP). A value of zero means 1526 that the protocol ID is not relevant to this Traffic Selector -- 1527 the SA can carry all protocols. 1529 o Selector Length - Specifies the length of this Traffic Selector 1530 substructure including the header. 1532 o Start Port (2 octets, unsigned integer) - Value specifying the 1533 smallest port number allowed by this Traffic Selector. For 1534 protocols for which port is undefined (including protocol 0), or 1535 if all ports are allowed, this field MUST be zero. 1537 o End Port (2 octets, unsigned integer) - Value specifying the 1538 largest port number allowed by this Traffic Selector. For 1539 protocols for which port is undefined (including protocol 0), or 1540 if all ports are allowed, this field MUST be 65535. 1542 o Starting Address - The smallest address included in this Traffic 1543 Selector (length determined by TS Type). 1545 o Ending Address - The largest address included in this Traffic 1546 Selector (length determined by TS Type). 1548 The following table lists values for the Traffic Selector Type field 1549 and the corresponding Address Selector Data. 1551 TS Type Value 1552 ------------------------------------------------------------------- 1553 TS_IPV4_ADDR_RANGE 7 1555 A range of IPv4 addresses, represented by two four-octet 1556 values. The first value is the beginning IPv4 address 1557 (inclusive) and the second value is the ending IPv4 address 1558 (inclusive). All addresses falling between the two specified 1559 addresses are considered to be within the list. 1561 TS_IPV6_ADDR_RANGE 8 1563 A range of IPv6 addresses, represented by two sixteen-octet 1564 values. The first value is the beginning IPv6 address 1565 (inclusive) and the second value is the ending IPv6 address 1566 (inclusive). All addresses falling between the two specified 1567 addresses are considered to be within the list. 1569 A.12. Encrypted Payload 1571 The Encrypted payload, denoted SK{...} in this document, contains 1572 other payloads in encrypted form. 1574 1 2 3 1575 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 1576 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1577 | Next Payload |C| RESERVED | Payload Length | 1578 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1579 | Initialization Vector | 1580 | (length is block size for encryption algorithm) | 1581 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1582 ~ Encrypted IKE Payloads ~ 1583 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1584 | | Padding (0-255 octets) | 1585 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ 1586 | | Pad Length | 1587 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1588 ~ Integrity Checksum Data ~ 1589 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1591 Figure 16: Encrypted Payload Format 1593 o Next Payload - The payload type of the first embedded payload. 1594 Note that this is an exception in the standard header format, 1595 since the Encrypted payload is the last payload in the message and 1596 therefore the Next Payload field would normally be zero. But 1597 because the content of this payload is embedded payloads and there 1598 was no natural place to put the type of the first one, that type 1599 is placed here. 1601 o Payload Length - Includes the lengths of the header, 1602 initialization vector (IV), Encrypted IKE payloads, Padding, Pad 1603 Length, and Integrity Checksum Data. 1605 o Initialization Vector - For CBC mode ciphers, the length of the 1606 initialization vector (IV) is equal to the block length of the 1607 underlying encryption algorithm. Senders MUST select a new 1608 unpredictable IV for every message; recipients MUST accept any 1609 value. The reader is encouraged to consult [MODES] for advice on 1610 IV generation. In particular, using the final ciphertext block of 1611 the previous message is not considered unpredictable. For modes 1612 other than CBC, the IV format and processing is specified in the 1613 document specifying the encryption algorithm and mode. 1615 o IKE payloads are as specified earlier in this section. This field 1616 is encrypted with the negotiated cipher. 1618 o Padding MAY contain any value chosen by the sender, and MUST have 1619 a length that makes the combination of the payloads, the Padding, 1620 and the Pad Length to be a multiple of the encryption block size. 1621 This field is encrypted with the negotiated cipher. 1623 o Pad Length is the length of the Padding field. The sender SHOULD 1624 set the Pad Length to the minimum value that makes the combination 1625 of the payloads, the Padding, and the Pad Length a multiple of the 1626 block size, but the recipient MUST accept any length that results 1627 in proper alignment. This field is encrypted with the negotiated 1628 cipher. 1630 o Integrity Checksum Data is the cryptographic checksum of the 1631 entire message starting with the Fixed IKE header through the Pad 1632 Length. The checksum MUST be computed over the encrypted message. 1633 Its length is determined by the integrity algorithm negotiated. 1635 Appendix B. Useful Optional Features 1637 There are some optional features of IKEv2, which might be useful for 1638 minimal implementations in some scenarios. Such features include Raw 1639 public keys authentication, and sending IKE SA delete notification. 1641 B.1. IKE SA Delete Notification 1643 In some scenarios, a minimal implementation device creates an IKE SA, 1644 sends one or few packets, perhaps gets some packets back, and then 1645 the device goes back to sleep forgetting the IKE SA. In such 1646 scenarios it would be nice for the minimal implementation to send the 1647 IKE SA delete notification to tell the other end that the IKE SA is 1648 going away, so it can free the resources. 1650 Deleting the IKE SA can be done by sending one packet with a fixed 1651 Message ID, and with only one payload inside the encrypted payload. 1652 The other end will send back an empty response: 1654 Initiator Responder 1655 ------------------------------------------------------------------- 1656 HDR(SPIi=xxx, SPIr=yyy, INFORMATIONAL, 1657 Flags: Initiator, Message ID=2), 1658 SK {D} --> 1660 <-- HDR(SPIi=xxx, SPIr=yyy, INFORMATIONAL, 1661 Flags: Response, Message ID=2), 1662 SK {} 1664 The delete payload format is: 1666 1 2 3 1667 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 1668 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1669 | Next Payload |C| RESERVED | Payload Length | 1670 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1671 | Protocol ID | SPI Size | Num of SPIs | 1672 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1673 | | 1674 ~ Security Parameter Index(es) (SPI) ~ 1675 | | 1676 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1678 Figure 17: Delete Payload Format 1680 o Protocol ID (1 octet) - Must be 1 for an IKE SA. 1682 o SPI Size (1 octet) - Length in octets of the SPI as defined by the 1683 protocol ID. It MUST be zero for IKE (SPI is in message header). 1685 o Num of SPIs (2 octets, unsigned integer) - The number of SPIs 1686 contained in the Delete payload. This MUST be zero for IKE. 1688 o Security Parameter Index(es) (variable length) - Identifies the 1689 specific Security Association(s) to delete. The length of this 1690 field is determined by the SPI Size and Num of SPIs fields. This 1691 field is empty for the IKE SA delete. 1693 B.2. Raw Public Keys 1695 In some scenarios the shared secret authentication is not safe 1696 enough, as anybody who knows the secret can impersonate the server. 1697 If the shared secret is printed on the side of the device, then 1698 anybody who gets physical access to the device can read it. In such 1699 environments, public key authentication allows stronger 1700 authentication with minimal operational overhead. Certificate 1701 support is quite complex, and minimal implementations do not usually 1702 have need for them. Using Raw Public Keys is much simpler, and it 1703 scales similar to certificates. The fingerprint of the Raw Public 1704 Key can still be distributed by, for example, printing it on the side 1705 of the device allowing setup similar to using a shared secret. 1707 Raw Public Keys can also be used in a "leap of faith" or baby duck 1708 style initial setup, where the device imprints itself to the first 1709 device it sees when it boots up the first time. After that initial 1710 connection it stores the fingerprint of the Raw Public Key of the 1711 server in its own configuration and verifies that it never changes 1712 (unless a "reset to factory settings" or similar command is issued). 1714 This changes the initial IKE_AUTH payloads as follows: 1716 Initiator Responder 1717 ------------------------------------------------------------------- 1718 HDR(SPIi=xxx, SPIr=yyy, IKE_AUTH, 1719 Flags: Initiator, Message ID=1), 1720 SK {IDi, CERT, AUTH, SAi2, TSi, TSr, 1721 N(INITIAL_CONTACT)} --> 1723 <-- HDR(SPIi=xxx, SPIr=yyy, IKE_AUTH, Flags: 1724 Response, Message ID=1), 1725 SK {IDr, CERT, AUTH, SAr2, TSi, TSr} 1727 The CERT payloads contains the Raw Public Keys used to sign the hash 1728 of the InitiatorSignedOctects/ResponderSignedOctects when generating 1729 an AUTH payload. Minimal implementations should use SHA-1 as the 1730 hash function as that is the "SHOULD" support algorithm specified in 1731 RFC 7296, so it is the most likely one that is supported by all 1732 devices. 1734 Note, that RFC 7296 already obsoleted the old Raw RSA Key method, and 1735 More Raw Public Keys for IKEv2 ([I-D.ietf-ipsecme-oob-pubkey]) adds a 1736 new format to allow using any types of Raw Public Keys with IKEv2. 1737 This document only specifies how to use the new format. 1739 In these setups it might be possible that authenticating the server 1740 is not needed at all. If a minimal device is sending, for example, 1741 sensor information to the server, the server wants to verify that the 1742 sensor is who it claims to be using raw public keys, but the sensor 1743 does not really care who the server is. In such cases the NULL 1744 authentication method ([RFC7619]) would be useful, as it allows 1745 devices to do one-way authentication. 1747 Author's Address 1749 Tero Kivinen 1750 INSIDE Secure 1751 Eerikinkatu 28 1752 HELSINKI FI-00180 1753 FI 1755 Email: kivinen@iki.fi