idnits 2.17.1 draft-bradley-dnssd-private-discovery-02.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 date (October 18, 2019) is 1651 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) ** Downref: Normative reference to an Informational RFC: RFC 5869 ** Obsolete normative reference: RFC 7539 (Obsoleted by RFC 8439) ** Downref: Normative reference to an Informational RFC: RFC 7748 ** Downref: Normative reference to an Informational RFC: RFC 8032 Summary: 4 errors (**), 0 flaws (~~), 1 warning (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Internet Engineering Task Force B. Bradley 3 Internet-Draft Apple Inc. 4 Intended status: Standards Track October 18, 2019 5 Expires: April 20, 2020 7 Private Discovery 8 draft-bradley-dnssd-private-discovery-02 10 Abstract 12 This document specifies a mechanism for advertising and discovering 13 in a private manner. 15 Status of This Memo 17 This Internet-Draft is submitted in full conformance with the 18 provisions of BCP 78 and BCP 79. 20 Internet-Drafts are working documents of the Internet Engineering 21 Task Force (IETF). Note that other groups may also distribute 22 working documents as Internet-Drafts. The list of current Internet- 23 Drafts is at https://datatracker.ietf.org/drafts/current/. 25 Internet-Drafts are draft documents valid for a maximum of six months 26 and may be updated, replaced, or obsoleted by other documents at any 27 time. It is inappropriate to use Internet-Drafts as reference 28 material or to cite them other than as "work in progress." 30 This Internet-Draft will expire on April 20, 2020. 32 Copyright Notice 34 Copyright (c) 2019 IETF Trust and the persons identified as the 35 document authors. All rights reserved. 37 This document is subject to BCP 78 and the IETF Trust's Legal 38 Provisions Relating to IETF Documents 39 (https://trustee.ietf.org/license-info) in effect on the date of 40 publication of this document. Please review these documents 41 carefully, as they describe your rights and restrictions with respect 42 to this document. Code Components extracted from this document must 43 include Simplified BSD License text as described in Section 4.e of 44 the Trust Legal Provisions and are provided without warranty as 45 described in the Simplified BSD License. 47 Table of Contents 49 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 50 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 3 51 3. Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . 4 52 3.1. Probe . . . . . . . . . . . . . . . . . . . . . . . . . . 4 53 3.2. Response . . . . . . . . . . . . . . . . . . . . . . . . 4 54 3.3. Announcement . . . . . . . . . . . . . . . . . . . . . . 5 55 3.4. Query . . . . . . . . . . . . . . . . . . . . . . . . . . 6 56 3.5. Answer . . . . . . . . . . . . . . . . . . . . . . . . . 6 57 4. Timestamps . . . . . . . . . . . . . . . . . . . . . . . . . 7 58 5. Implicit Nonces . . . . . . . . . . . . . . . . . . . . . . . 7 59 6. Re-keying and Limits . . . . . . . . . . . . . . . . . . . . 7 60 7. Message Formats . . . . . . . . . . . . . . . . . . . . . . . 8 61 7.1. TLV Structure . . . . . . . . . . . . . . . . . . . . . . 8 62 7.2. TLV Items . . . . . . . . . . . . . . . . . . . . . . . . 8 63 7.3. Message Types . . . . . . . . . . . . . . . . . . . . . . 9 64 8. Security Considerations . . . . . . . . . . . . . . . . . . . 9 65 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10 66 10. To Do . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 67 11. Normative References . . . . . . . . . . . . . . . . . . . . 11 68 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 11 70 1. Introduction 72 Advertising and discovering devices and services on the network can 73 leak a lot of information about a device or person, such as their 74 name, the types of services they provide or use, and persistent 75 identifiers. This information can be used to identify and track a 76 person's location and daily routine (e.g. buys coffee every morning 77 at 8 AM at Starbucks on Main Street). It can also reveal intimate 78 details about a person's behavior and medical conditions, such as 79 discovery requests for a glucose monitor, possibly indicating 80 diabetes. 82 This document specifies a system for advertising and discovery of 83 devices and services while preserving privacy and confidentiality. 85 This document does not specify how keys are provisioned. 86 Provisioning keys is complex enough to justify its own document(s). 87 This document assumes each peer has a long-term asymmetric key pair 88 (LTPK and LTSK) and communicating peers have each other's long-term 89 asymmetric public key (LTPK). 91 2. Conventions and Terminology 93 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 94 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 95 document are to be interpreted as described in [RFC2119]. 97 "Friend" 98 A peer you have a cryptographic relationship with. Specifically, 99 that you have the peer's LTPK. 101 "Probe" 102 Unsolicited multicast message sent to find friends on the network. 104 "Announcement" 105 Unsolicited multicast message sent to inform friends on the 106 network that you have become available or have updated data. 108 "Response" 109 Solicited unicast message sent in response to a probe or 110 announcement. 112 "Query" 113 Unsolicited unicast message sent to get specific info from a peer. 115 "Answer" 116 Solicited unicast message sent in response to a query to provide 117 info or indicate the lack of info. 119 "Multicast" 120 This term is used in the generic sense of sending a message that 121 targets 0 or more peers. It's not strictly required to be a UDP 122 packet with a multicast destination address. It could be sent via 123 TCP or some other transport to a router that repeats the message 124 via unicast to each peer. 126 "Unicast" 127 This term is used in the generic sense of sending a message that 128 targets a single peer. It's not strictly required to be a UDP 129 packet with a unicast destination address. 131 Multi-byte values are encoded from the most significant byte to the 132 least significant byte (big endian). 134 When multiple items are concatenated together, the symbol "||" 135 (without quotes) between each item is used to indicate this. For 136 example, a combined item of A followed by B followed by C would be 137 written as "A || B || C". 139 3. Protocol 141 There are two techniques used to preserve privacy and provide 142 confidentiality in this document. The first is announcing, probing, 143 and responding with only enough info to allow a peer with your public 144 key to detect that it's you while hiding your identity from peers 145 without your public key. This technique uses a fresh random signed 146 with your private key using a signature algorithm that doesn't reveal 147 your public key. The second technique is to query and answer in a 148 way that only a specific friend can read the data. This uses 149 ephemeral key exchange and symmetric encryption and authentication. 151 The general flow of the protocol is a device sends multicast probes 152 to discover friend devices on the network. If friend devices are 153 found, it directly communicates with them via unicast queries and 154 answers. Announcements are sent to report availability and when 155 services are added or removed. 157 3.1. Probe 159 A probe is sent via multicast to discover friends on the network. A 160 probe contains a fresh, ephemeral public key (EPK1), a timestamp 161 (TS1), and a signature (SIG1). This provides enough for a friend to 162 identify the source, but doesn't allow non-friends to identify it. 164 Probe Fields: 166 o EPK1 (Ephemeral Public Key 1). 168 o TS1 (Timestamp 1). See Timestamps Section 4. 170 o SIG1 (Signature of "Probe" || EPK1 || TS1 || "End"). 172 When a peer receives a probe, it verifies TS1. If TS1 is outside the 173 time window then it SHOULD be ignored. It then attempts to verify 174 SIG1 with the public key of each of its friends. If verification 175 fails for all public keys then it ignores the probe. If a 176 verification succeeds for a public key then it knows which friend 177 sent the probe. It SHOULD send a response to the friend. 179 3.2. Response 181 A response contains a fresh, ephemeral public key (EPK2) and a 182 symmetrically encrypted signature (ESIG2). The encryption key is 183 derived by first generating a fresh ephemeral public key (EPK2) and 184 its corresponding secret key (ESK2) and performing Diffie-Hellman 185 (DH) using EPK1 and ESK2 to compute a shared secret. The shared 186 secret is used to derive a symmetric session key (SSK2). A signature 187 of the payload is generated (SIG2) using the responder's long-term 188 secret key (LTSK2). The signature is encrypted with SSK2 (ESIG2). 189 The nonce for ESIG2 is 1 and is not included in the response. The 190 response is sent via unicast to the sender of the probe. 192 When the friend that sent the probe receives the response, it 193 performs DH, symmetrically verifies ESIG2 and, if successful, 194 decrypts it to reveal SIG2. It then tries to verify SIG2 with the 195 public keys of all of its friends. If a verification succeeds for a 196 public key then it knows which friend sent the response. If any 197 steps fail, the response is ignored. If all steps succeed, it 198 derives a session key (SSK1). Both session keys (SSK1 and SSK2) are 199 remembered for subsequent communication with the friend. 201 Response Fields: 203 o EPK2 (Ephemeral Public Key 2). 205 o ESIG2 (Encrypted Signature of "Response" || EPK2 || EPK1 || TS1 || 206 "End"). 208 Key Derivation values: 210 o SSK1: HKDF-SHA-512 with Salt = "SSK1-Salt", Info = "SSK1-Info", 211 Output size = 32 bytes. 213 o SSK2: HKDF-SHA-512 with Salt = "SSK2-Salt", Info = "SSK2-Info", 214 Output size = 32 bytes. 216 3.3. Announcement 218 An announcement indicates availability to friends on the network or 219 if it has update(s). It is sent whenever a device joins a network 220 (e.g. joins WiFi, plugged into Ethernet, etc.), its IP address 221 changes, or when it has an update for one or more of its services. 222 Announcements are sent via multicast. 224 Announcement Fields: 226 o EPK1 (Ephemeral Public Key 1). 228 o TS1 (Timestamp 1). See Timestamps Section 4. 230 o SIG1 (Signature of "Announcement" || EPK1 || TS1 || "End"). 232 When a peer receives an announcement, it verifies TS1. If TS1 is 233 outside the time window then it SHOULD be ignored. It then attempts 234 to verify SIG1 with the public key of each of its friends. If 235 verification fails for all public keys then it ignores the probe. If 236 a verification succeeds for a public key then it knows which friend 237 sent the announcement. 239 3.4. Query 241 A query is sent via unicast to request specific info from a friend. 242 The query data (MSG1) is encrypted with the symmetric session key 243 (SSK1 for the original prober or SSK2 for the original responder) for 244 the target friend previously generated via the probe/response 245 exchange. This encrypted field is EMSG1. The nonce for EMSG1 is 1 246 larger than the last nonce used with this symmetric key and is not 247 included in the query. For example, if this is the first message 248 sent to this friend after the probe/response then the nonce would be 249 2. The query is sent via unicast to the friend. 251 When the friend receives a query, it symmetrically verifies EMSG1 252 against every active session's key and, if one is successful (which 253 also identifies the friend), it decrypts the field. If verification 254 fails, the query is ignored, If verification succeeds, the query is 255 processed. 257 Query Fields: 259 o EMSG1 (Encrypted query data). 261 3.5. Answer 263 An answer is sent via unicast in response to a query from a friend. 264 The answer data (MSG2) is encrypted with the symmetric session key of 265 the destination friend (SSK1 it was the original prober or SSK2 if it 266 was the original responder from the previous probe/response 267 exchange). This encrypted field is EMSG2. The nonce for EMSG2 is 1 268 larger than the last nonce used with this symmetric key and is not 269 included in the answer. For example, if this is the first message 270 sent to this friend after the probe/response then the nonce would be 271 2. The answer is sent via unicast to the friend. 273 When the friend receives an answer, it symmetrically verifies EMSG2 274 against every active session's key and, if one is successful (which 275 also identifies the friend), it decrypts the field. If verification 276 fails, the answer is ignored, If verification succeeds, the answer is 277 processed. 279 Answer Fields: 281 o EMSG2 (Encrypted answer data). 283 4. Timestamps 285 A timestamp in this document is the number of seconds since 286 2001-01-01 00:00:00 UTC. Timestamps sent in messages SHOULD be 287 randomized by +/- 30 seconds to reduce the fingerprinting ability of 288 observers. A timestamp of 0 means the sender doesn't know the 289 current time (e.g. lacks a battery-backed RTC and access to an NTP 290 server). Receivers MAY use a timestamp of 0 to decide whether to 291 enforce time window restrictions. This can allow discovery in 292 situations where one or more devices don't know the current time 293 (e.g. location without Internet access). 295 A timestamp is considered valid if it's within N seconds of the 296 current time of the receiver. The RECOMMENDED value of N is 900 297 seconds (15 minutes) to allow peers to remain discoverable even after 298 a large amount of clock drift. 300 5. Implicit Nonces 302 The nonces in this document are integers that increment by 1 for each 303 encryption. Nonces are never included in any message. Including 304 nonces in messages would enable transactions to be easily tracked by 305 following nonce 1, 2, 3, etc. This may seem futile if other layers 306 of the system also leak trackable identifiers, such as IP addresses, 307 but those problems can be solved by other documents. Random nonces 308 could avoid tracking, but make replay protection difficult by 309 requiring the receiver to remember previously received messages to 310 detect a replay. 312 One issue with implicit nonces and replay protection in general is 313 handling lost messages. Message loss and reordering is expected and 314 shouldn't cause complete failure. Accepting nonces within N of the 315 expected nonce enables recovery from some loss and reordering. When 316 a message is received, the expected nonce is checked first and then 317 nonce + 1, nonce - 1, up to nonce +/- N. The RECOMMENDED value of N 318 is 8 as a balance between privacy, robustness, and performance. 320 6. Re-keying and Limits 322 Re-keying is a hedge against key compromise. The underlying 323 algorithms have limits that far exceed reasonable usage (e.g. 96-bit 324 nonces), but if a key was revealed then we want to reduce the damage 325 by periodically re-keying. 327 Probes are periodically re-sent with a new ephemeral public key in 328 case the previous key pair was compromised. The RECOMMENDED maximum 329 probe ephemeral public key lifetime is 20 hours. This is close to 1 330 day since people often repeat actions on a daily basis, but with some 331 leeway for natural variations. If a probe ephemeral public key is 332 re-generated for other reasons, such as joining a WiFi network, the 333 refresh timer is reset. 335 Session keys are periodically re-key'd in case a symmetric key was 336 compromised. The RECOMMENDED maximum session key lifetime is 20 337 hours or 1000 messages, whichever comes first. This uses the same 338 close-to-a-day reasoning as probes, but adds a maximum number of 339 messages to reduce the potential for exposure when many messages are 340 being exchanged. Responses SHOULD be throttled if it appears that a 341 peer is making an excessive number of requests since this may 342 indicate the peer is probing for weaknesses (e.g. timing attacks, 343 ChopChop-style attacks). 345 7. Message Formats 347 Messages defined by this document are use Type-Length-Value (TLV) 348 payloads with an 8-bit type and a 16-bit length (TLV8x16). It has 349 the following format. 351 7.1. TLV Structure 353 +--------+-------------+--------------------------------------------+ 354 | Field | Size | Description | 355 | | (bytes) | | 356 +--------+-------------+--------------------------------------------+ 357 | Type | 1 | Identifies a value type as defined in | 358 | | | Section 7.2. | 359 | Length | 1 or 2 | Length of the value field in bytes. | 360 | Value | Variable | Value formatted based on the type field. | 361 +--------+-------------+--------------------------------------------+ 363 7.2. TLV Items 365 The following lists the TLV items defined by this document. 367 +-----------+----------+--------------------------------------------+ 368 | Type | Name | Description | 369 +-----------+----------+--------------------------------------------+ 370 | 0x00 | Reserved | Reserved to protect against accidental | 371 | | | zeroing. | 372 | 0x01 | Type | Type of message. See Section 7.3. | 373 | 0x02 | EPK | Ephemeral Public Key. 32-byte Curve25519 | 374 | | | public key. | 375 | 0x03 | TS | Timestamp. 4-byte timestamp. See | 376 | | | Timestamps Section 4. | 377 | 0x04 | SIG | Signature. 64-byte Ed25519 signature. | 378 | 0x05 | ESIG | Encrypted signature. Ed25519 signature | 379 | | | encrypted with ChaCha20-Poly1305. | 380 | | | Formatted as the 64-byte encrypted portion | 381 | | | followed by a 16-byte MAC (96 bytes | 382 | | | total). | 383 | 0x06 | EMSG | Encrypted message. Message encrypted with | 384 | | | ChaCha20-Poly1305. Formatted as the N-byte | 385 | | | encrypted portion followed by a 16-byte | 386 | | | MAC (N + 16 bytes total). | 387 | 0x07-0xFF | | Reserved for future use. Types in this | 388 | | | range MUST NOT be sent. If they are | 389 | | | received, they MUST be ignored. This is to | 390 | | | allow future versions of document or other | 391 | | | documents to define new types without | 392 | | | breaking parsers. | 393 +-----------+----------+--------------------------------------------+ 395 7.3. Message Types 397 +--------------+------+---------------------------------------------+ 398 | Name | Type | Description | 399 +--------------+------+---------------------------------------------+ 400 | Invalid | 0 | Invalid message type. Avoid misinterpreting | 401 | | | zeroed memory. | 402 | Probe | 1 | See Section 3.1. | 403 | Response | 2 | See Section 3.2. | 404 | Announcement | 3 | See Section 3.3. | 405 | Query | 4 | See Section 3.4. | 406 | Answer | 5 | See Section 3.5. | 407 +--------------+------+---------------------------------------------+ 409 8. Security Considerations 411 o Privacy considerations are specified in draft-cheshire-dnssd- 412 privacy-considerations. 414 o Ephemeral key exchange uses elliptic curve Diffie-Hellman (ECDH) 415 with Curve25519 as specified in [RFC7748]. 417 o Signing and verification uses Ed25519 as specified in [RFC8032]. 419 o Symmetric encryption uses ChaCha20-Poly1305 as specified in 420 [RFC7539]. 422 o Key derivation uses HKDF as specified in [RFC5869] with SHA-512 as 423 the hash function. 425 o Randoms and randomization MUST use cryptographic random numbers. 427 Information leaks may still be possible in some situations. For 428 example, an attacker could capture probes from a peer they've 429 identified and replay them elsewhere within the allowed timestamp 430 window. This could be used to determine if a friend of that friend 431 is present on that network. 433 The network infrastructure may leak identifiers in the form of 434 persistent IP addresses and MAC addresses. Mitigating this requires 435 changes at lower levels of the network stack, such as periodically 436 changing IP addresses and MAC addresses. 438 9. IANA Considerations 440 The TLV and message types defined by this document are intended to be 441 managed by IANA. 443 10. To Do 445 The following are some of the things that still need to be specified 446 and decided: 448 o Figure out how sleep proxies might work with this protocol. 450 o Define probe and announcement random delays to reduce collisions. 452 o Describe when to use the same EPK2 in a response to reduce churn 453 on probe/response collisions. 455 o Consider randomly answering probes for non-friends to mask real 456 friends. 458 o Design public service protocol to allow pairing. 460 11. Normative References 462 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 463 Requirement Levels", BCP 14, RFC 2119, 464 DOI 10.17487/RFC2119, March 1997, 465 . 467 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 468 Key Derivation Function (HKDF)", RFC 5869, 469 DOI 10.17487/RFC5869, May 2010, 470 . 472 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 473 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 474 . 476 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 477 for Security", RFC 7748, DOI 10.17487/RFC7748, January 478 2016, . 480 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 481 Signature Algorithm (EdDSA)", RFC 8032, 482 DOI 10.17487/RFC8032, January 2017, 483 . 485 Author's Address 487 Bob Bradley 488 Apple Inc. 489 One Apple Park Way 490 Cupertino CA 95014 491 USA 493 Email: bradley@apple.com