idnits 2.17.1 draft-cavage-http-signatures-11.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 : ---------------------------------------------------------------------------- ** The document seems to lack a Security Considerations section. ** The abstract seems to contain references ([2], [3], [4], [1]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. ** The document seems to lack a both a reference to RFC 2119 and the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. RFC 2119 keyword, line 216: '... REQUIRED. The `keyId` field is an ...' RFC 2119 keyword, line 220: '... Implementations MUST be able to disco...' RFC 2119 keyword, line 227: '... REQUIRED. The `signature` paramete...' RFC 2119 keyword, line 237: '... RECOMMENDED. The `algorithm` param...' RFC 2119 keyword, line 240: '... and MUST NOT be marked "deprecated"...' (30 more instances...) Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (April 24, 2019) is 1822 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) -- Looks like a reference, but probably isn't: '1' on line 708 -- Looks like a reference, but probably isn't: '2' on line 710 -- Looks like a reference, but probably isn't: '3' on line 712 -- Looks like a reference, but probably isn't: '4' on line 714 -- Looks like a reference, but probably isn't: '5' on line 716 -- Looks like a reference, but probably isn't: '6' on line 718 -- Looks like a reference, but probably isn't: '7' on line 720 -- Looks like a reference, but probably isn't: '8' on line 722 -- Looks like a reference, but probably isn't: '9' on line 724 -- Looks like a reference, but probably isn't: '10' on line 726 -- Looks like a reference, but probably isn't: '11' on line 728 -- Looks like a reference, but probably isn't: '12' on line 730 -- Looks like a reference, but probably isn't: '13' on line 732 -- Looks like a reference, but probably isn't: '14' on line 734 -- Looks like a reference, but probably isn't: '15' on line 736 -- Looks like a reference, but probably isn't: '16' on line 766 -- Looks like a reference, but probably isn't: '17' on line 772 -- Looks like a reference, but probably isn't: '18' on line 774 -- Looks like a reference, but probably isn't: '19' on line 784 -- Looks like a reference, but probably isn't: '20' on line 924 -- Looks like a reference, but probably isn't: '21' on line 935 -- Looks like a reference, but probably isn't: '22' on line 948 -- Looks like a reference, but probably isn't: '23' on line 960 -- Looks like a reference, but probably isn't: '24' on line 970 -- Looks like a reference, but probably isn't: '25' on line 980 -- Looks like a reference, but probably isn't: '26' on line 990 ** Obsolete normative reference: RFC 7230 (Obsoleted by RFC 9110, RFC 9112) ** Obsolete normative reference: RFC 7235 (Obsoleted by RFC 9110) -- Obsolete informational reference (is this intentional?): RFC 2617 (Obsoleted by RFC 7235, RFC 7615, RFC 7616, RFC 7617) -- Obsolete informational reference (is this intentional?): RFC 3230 (Obsoleted by RFC 9530) -- Obsolete informational reference (is this intentional?): RFC 5246 (Obsoleted by RFC 8446) Summary: 5 errors (**), 0 flaws (~~), 1 warning (==), 30 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group M. Cavage 3 Internet-Draft Oracle 4 Intended status: Standards Track M. Sporny 5 Expires: October 26, 2019 Digital Bazaar 6 April 24, 2019 8 Signing HTTP Messages 9 draft-cavage-http-signatures-11 11 Abstract 13 When communicating over the Internet using the HTTP protocol, it can 14 be desirable for a server or client to authenticate the sender of a 15 particular message. It can also be desirable to ensure that the 16 message was not tampered with during transit. This document 17 describes a way for servers and clients to simultaneously add 18 authentication and message integrity to HTTP messages by using a 19 digital signature. 21 Feedback 23 WARNING: DO NOT IMPLEMENT THIS SPECIFICATION AND PUSH THE CODE INTO 24 PRODUCTION. THIS VERSION OF THE SPECIFICATION IS ONLY FOR 25 EXPERIMENTAL IMPLEMENTATIONS. 27 This version (draft-cavage-http-signatures-11) is experimental and 28 implementers should be aware that a number of new features have been 29 introduced in this version that change previous algorithms in subtle 30 but important ways. Namely, there is now a backwards-compatible way 31 to modify the signature string construction algorithm, as well as two 32 new Signature Parameters to enable web browser-based clients to 33 include a signature creation and expiration timestamp. The new 34 features are designed to be fully backwards compatible. Older 35 features have been deprecated, but are still supported in the 36 algorithms described by this specification. There are no plans to 37 remove deprecated features from the specification to ensure backwards 38 compatability for implementations dating back to 2013. Test vectors 39 still need to be added for the new algorithms and digital signature 40 types such as Ed25519. 42 This specification is a joint work product of the W3C Digital 43 Verification Community Group [1] and the W3C Credentials Community 44 Group [2]. Feedback related to this specification should logged in 45 the issue tracker [3] or be sent to public-credentials@w3.org [4]. 47 Status of This Memo 49 This Internet-Draft is submitted in full conformance with the 50 provisions of BCP 78 and BCP 79. 52 Internet-Drafts are working documents of the Internet Engineering 53 Task Force (IETF). Note that other groups may also distribute 54 working documents as Internet-Drafts. The list of current Internet- 55 Drafts is at https://datatracker.ietf.org/drafts/current/. 57 Internet-Drafts are draft documents valid for a maximum of six months 58 and may be updated, replaced, or obsoleted by other documents at any 59 time. It is inappropriate to use Internet-Drafts as reference 60 material or to cite them other than as "work in progress." 62 This Internet-Draft will expire on October 26, 2019. 64 Copyright Notice 66 Copyright (c) 2019 IETF Trust and the persons identified as the 67 document authors. All rights reserved. 69 This document is subject to BCP 78 and the IETF Trust's Legal 70 Provisions Relating to IETF Documents 71 (https://trustee.ietf.org/license-info) in effect on the date of 72 publication of this document. Please review these documents 73 carefully, as they describe your rights and restrictions with respect 74 to this document. 76 Table of Contents 78 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 79 1.1. Using Signatures in HTTP Requests . . . . . . . . . . . . 4 80 1.2. Using Signatures in HTTP Responses . . . . . . . . . . . 5 81 2. The Components of a Signature . . . . . . . . . . . . . . . . 5 82 2.1. Signature Parameters . . . . . . . . . . . . . . . . . . 5 83 2.1.1. keyId . . . . . . . . . . . . . . . . . . . . . . . . 5 84 2.1.2. signature . . . . . . . . . . . . . . . . . . . . . . 5 85 2.1.3. algorithm . . . . . . . . . . . . . . . . . . . . . . 6 86 2.1.4. created . . . . . . . . . . . . . . . . . . . . . . . 6 87 2.1.5. expires . . . . . . . . . . . . . . . . . . . . . . . 6 88 2.1.6. headers . . . . . . . . . . . . . . . . . . . . . . . 6 89 2.2. Ambiguous Parameters . . . . . . . . . . . . . . . . . . 7 90 2.3. Signature String Construction . . . . . . . . . . . . . . 7 91 2.4. Creating a Signature . . . . . . . . . . . . . . . . . . 9 92 2.5. Verifying a Signature . . . . . . . . . . . . . . . . . . 10 93 3. The 'Signature' HTTP Authentication Scheme . . . . . . . . . 10 94 3.1. Authorization Header . . . . . . . . . . . . . . . . . . 10 95 3.1.1. Initiating Signature Authorization . . . . . . . . . 11 96 3.1.2. RSA Example . . . . . . . . . . . . . . . . . . . . . 11 97 3.1.3. HMAC Example . . . . . . . . . . . . . . . . . . . . 12 98 4. The 'Signature' HTTP Header . . . . . . . . . . . . . . . . . 12 99 4.1. Signature Header . . . . . . . . . . . . . . . . . . . . 13 100 4.1.1. RSA Example . . . . . . . . . . . . . . . . . . . . . 13 101 4.1.2. HMAC Example . . . . . . . . . . . . . . . . . . . . 14 102 5. References . . . . . . . . . . . . . . . . . . . . . . . . . 14 103 5.1. Normative References . . . . . . . . . . . . . . . . . . 14 104 5.2. Informative References . . . . . . . . . . . . . . . . . 15 105 5.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 16 106 Appendix A. Security Considerations . . . . . . . . . . . . . . 17 107 Appendix B. Extensions . . . . . . . . . . . . . . . . . . . . . 17 108 Appendix C. Test Values . . . . . . . . . . . . . . . . . . . . 17 109 C.1. Default Test . . . . . . . . . . . . . . . . . . . . . . 18 110 C.2. Basic Test . . . . . . . . . . . . . . . . . . . . . . . 19 111 C.3. All Headers Test . . . . . . . . . . . . . . . . . . . . 19 112 Appendix D. Acknowledgements . . . . . . . . . . . . . . . . . . 20 113 Appendix E. IANA Considerations . . . . . . . . . . . . . . . . 20 114 E.1. Signature Authentication Scheme . . . . . . . . . . . . . 20 115 E.2. HTTP Signatures Algorithms Registry . . . . . . . . . . . 20 116 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 22 118 1. Introduction 120 This protocol extension is intended to provide a simple and standard 121 way for clients to sign HTTP messages. 123 HTTP Authentication [RFC2617] defines Basic and Digest authentication 124 mechanisms, TLS 1.2 [RFC5246] defines cryptographically strong 125 transport layer security, and OAuth 2.0 [RFC6749] provides a fully- 126 specified alternative for authorization of web service requests. 127 Each of these approaches are employed on the Internet today with 128 varying degrees of protection. However, none of these schemes are 129 designed to cryptographically sign the HTTP messages themselves, 130 which is required in order to ensure end-to-end message integrity. 131 An added benefit of signing the HTTP message for the purposes of end- 132 to-end message integrity is that the client can be authenticated 133 using the same mechanism without the need for multiple round-trips. 135 Several web service providers have invented their own schemes for 136 signing HTTP messages, but to date, none have been standardized. 137 While there are no techniques in this proposal that are novel beyond 138 the previous art, it is useful to standardize a simple and 139 cryptographically strong mechanism for digitally signing HTTP 140 messages. 142 This specification presents two mechanisms with distinct purposes: 144 1. The "Signature" scheme which is intended primarily to allow a 145 sender to assert the contents of the message sent are correct and 146 have not been altered during transmission or storage in a way 147 that alters the meaning expressed in the original message as 148 signed. Any party reading the message (the verifier) may 149 independently confirm the validity of the message signature. 150 This scheme is agnostic to the client/server direction and can be 151 used to verify the contents of either HTTP requests, HTTP 152 reponses, or both. 154 2. The "Authorization" scheme which is intended primarily to allow a 155 sender to request access to a resource or resources by proving 156 that they control a secret key. This specification allows for 157 this both with a shared secret (using HMAC) or with public/ 158 private keys. The "Authorization" scheme is typically used in 159 authentication processes and not directly for message signing. 160 As a consequence `Authorization` header is normally generated 161 (and the message signed) by the HTTP client and the message 162 verified by the HTTP server. 164 1.1. Using Signatures in HTTP Requests 166 It is common practice to protect sensitive website and API 167 functionality via authentication mechanisms. Often, the entity 168 accessing these APIs is a piece of automated software outside of an 169 interactive human session. While there are mechanisms like OAuth and 170 API secrets that are used to grant API access, each have their 171 weaknesses such as unnecessary complexity for particular use cases or 172 the use of shared secrets which may not be acceptable to an 173 implementer. Shared secrets also prohibit any possibility for non- 174 repudiation, while secure transports such as TLS do not provide for 175 this at all. 177 Digital signatures are widely used to provide authentication and 178 integrity assurances without the need for shared secrets. They also 179 do not require a round-trip in order to authenticate the client, and 180 allow the integrity of a message to be verified independently of the 181 transport (e.g. TLS). A server need only have an understanding of 182 the key (e.g. through a mapping between the key being used to sign 183 the content and the authorized entity) to verify that a message was 184 signed by that entity. 186 When optionally combined with asymmetric keys associated with an 187 identity, this specification can also enable authentication of a 188 client and server with or without prior knowledge of each other. 190 1.2. Using Signatures in HTTP Responses 192 HTTP messages are routinely altered as they traverse the 193 infrastrcture of the Internet, for mostly benign reasons. Gateways 194 and proxies add, remove and alter headers for operational reasons, so 195 a sender cannot rely on the recipient receiving exactly the message 196 transmitted. By allowing a sender to sign specified headers, and 197 recipient or intermediate system can confirm that the original intent 198 of the sender is preserved, and including a Digest header can also 199 verify the message body is not modified. This allows any recipient 200 to easily confirm both the sender's identity, and any incidental or 201 malicious changes that alter the content or meaning of the message. 203 2. The Components of a Signature 205 There are a number of components in a signature that are common 206 between the 'Signature' HTTP Authentication Scheme and the 207 'Signature' HTTP Header. This section details the components of the 208 digital signature paremeters common to both schemes. 210 2.1. Signature Parameters 212 The following section details the Signature Parameters. 214 2.1.1. keyId 216 REQUIRED. The `keyId` field is an opaque string that the server can 217 use to look up the component they need to validate the signature. It 218 could be an SSH key fingerprint, a URL to machine-readable key data, 219 an LDAP DN, etc. Management of keys and assignment of `keyId` is out 220 of scope for this document. Implementations MUST be able to discover 221 metadata about the key from the `keyId` such that they can determine 222 the type of digital signature algorithm to employ when creating or 223 verifying signatures. 225 2.1.2. signature 227 REQUIRED. The `signature` parameter is a base 64 encoded digital 228 signature, as described in RFC 4648 [RFC4648], Section 4 [5]. The 229 client uses the `algorithm` and `headers` Signature Parameters to 230 form a canonicalized `signing string`. This `signing string` is then 231 signed with the key associated with `keyId` and the algorithm 232 corresponding to `algorithm`. The `signature` parameter is then set 233 to the base 64 encoding of the signature. 235 2.1.3. algorithm 237 RECOMMENDED. The `algorithm` parameter is used to specify the 238 signature string construction mechanism. Valid values for this 239 parameter can be found in the HTTP Signatures Algorithms Registry [6] 240 and MUST NOT be marked "deprecated". Implementers SHOULD derive the 241 digital signature algorithm used by an implementation from the key 242 metadata identified by the `keyId` rather than from this field. If 243 `algorithm` is provided and differs from the key metadata identified 244 by the `keyId`, for example `rsa-sha256` but an EdDSA key is 245 identified via `keyId`, then an implementation MUST produce an error. 246 Implementers should note that previous versions of the `algorithm` 247 parameter did not use the key information to derive the digital 248 signature type and thus could be utilized by attackers to expose 249 security vulnerabilities. 251 2.1.4. created 253 RECOMMENDED. The `created` field expresses when the signature was 254 created. The value MUST be a Unix timestamp integer value. A 255 signature with a `created` timestamp value that is in the future MUST 256 NOT be processed. Using a Unix timestamp simplifies processing and 257 avoids timezone management required by specifications such as 258 RFC3339. Subsecond precision is not supported. This value is useful 259 when clients are not capable of controlling the `Date` HTTP Header 260 such as when operating in certain web browser environments. 262 2.1.5. expires 264 OPTIONAL. The `expires` field expresses when the signature ceases to 265 be valid. The value MUST be a Unix timestamp integer value. A 266 signatures with a `expires` timestamp value that is in the past MUST 267 NOT be processed. Using a Unix timestamp simplifies processing and 268 avoid timezone management existing in RFC3339. Subsecod precision is 269 allowed using decimal notation. 271 2.1.6. headers 273 OPTIONAL. The `headers` parameter is used to specify the list of 274 HTTP headers included when generating the signature for the message. 275 If specified, it SHOULD be a lowercased, quoted list of HTTP header 276 fields, separated by a single space character. If not specified, 277 implementations MUST operate as if the field were specified with a 278 single value, `(created)`, in the list of HTTP headers. Note: 280 1. The list order is important, and MUST be specified in the order 281 the HTTP header field-value pairs are concatenated together 282 during Signature String Construction (Section 2.3) used during 283 signing and verifying. 285 2. A `headers` parameter value without any headers MAY be provided, 286 but since it results in a signature of an empty string it is of 287 almost no utility and SHOULD NOT be used. This is distinct from 288 not specifying a `headers` parameter at all. 290 2.2. Ambiguous Parameters 292 If any of the parameters listed above are erroneously duplicated in 293 the associated header field, then the last parameter defined MUST be 294 used. Any parameter that is not recognized as a parameter, or is not 295 well-formed, MUST be ignored. 297 2.3. Signature String Construction 299 A signed HTTP message needs to be tolerant of some trivial 300 alterations during transmission as it goes through gateways, proxies, 301 and other entities. These changes are often of little consequence 302 and very benign, but also often not visible to or detectable by 303 either the sender or the recipient. Simply signing the entire 304 message that was transmitted by the sender is therefore not feasible: 305 Even very minor changes would result in a signature which cannot be 306 verified. 308 This specification allows the sender to select which headers are 309 meaningful by including their names in the `headers` Signature 310 Parameter. The headers appearing in this parameter are then used to 311 construct the intermediate Signature String, which is the data that 312 is actually signed. 314 In order to generate the string that is signed with a key, the client 315 MUST use the values of each HTTP header field in the `headers` 316 Signature Parameter, in the order they appear in the `headers` 317 Signature Parameter. It is out of scope for this document to dictate 318 what header fields an application will want to enforce, but 319 implementers SHOULD at minimum include the `(request-target)` and 320 `(created)` header fields if `algorithm` does not start with `rsa`, 321 `hmac`, or `ecdsa`. Otherwise, `(request-target)` and `date` SHOULD 322 be included in the signature. 324 To include the HTTP request target in the signature calculation, use 325 the special `(request-target)` header field name. To include the 326 signature creation time, use the special `(created)` header field 327 name. To include the signature expiration time, use the special 328 `(expires)` header field name. 330 1. If the header field name is `(request-target)` then generate the 331 header field value by concatenating the lowercased :method, an 332 ASCII space, and the :path pseudo-headers (as specified in 333 HTTP/2, Section 8.1.2.3 [7]). Note: For the avoidance of doubt, 334 lowercasing only applies to the :method pseudo-header and not to 335 the :path pseudo-header. 337 2. If the header field name is `(created)` and the `algorithm` 338 parameter starts with `rsa`, `hmac`, or `ecdsa` an implementation 339 MUST produce an error. If the `created` Signature Parameter is 340 not specified, or is not an integer, an implementation MUST 341 produce an error. Otherwise, the header field value is the 342 integer expressed by the `created` signature parameter. 344 3. If the header field name is `(expires)` and the `algorithm` 345 parameter starts with `rsa`, `hmac`, or `ecdsa` an implementation 346 MUST produce an error. If the `expires` Signature Parameter is 347 not specified, or is not an integer, an implementation MUST 348 produce an error. Otherwise, the header field value is the 349 integer expressed by the `created` signature parameter. 351 4. Create the header field string by concatenating the lowercased 352 header field name followed with an ASCII colon `:`, an ASCII 353 space ` `, and the header field value. Leading and trailing 354 optional whitespace (OWS) in the header field value MUST be 355 omitted (as specified in RFC7230 [RFC7230], Section 3.2.4 [8]). 357 1. If there are multiple instances of the same header field, all 358 header field values associated with the header field MUST be 359 concatenated, separated by a ASCII comma and an ASCII space 360 `, `, and used in the order in which they will appear in the 361 transmitted HTTP message. 363 2. If the header value (after removing leading and trailing 364 whitespace) is a zero-length string, the signature string 365 line correlating with that header will simply be the 366 (lowercased) header name, an ASCII colon `:`, and an ASCII 367 space ` `. 369 3. Any other modification to the header field value MUST NOT be 370 made. 372 4. If a header specified in the headers parameter is malformed 373 or cannot be matched with a provided header in the message, 374 the implementation MUST produce an error. 376 5. If value is not the last value then append an ASCII newline `\n`. 378 To illustrate the rules specified above, assume a `headers` parameter 379 list with the value of `(request-target) (created) host date cache- 380 control x-emptyheader x-example` with the following HTTP request 381 headers: 383 GET /foo HTTP/1.1 384 Host: example.org 385 Date: Tue, 07 Jun 2014 20:51:35 GMT 386 X-Example: Example header 387 with some whitespace. 388 X-EmptyHeader: 389 Cache-Control: max-age=60 390 Cache-Control: must-revalidate 392 For the HTTP request headers above, the corresponding signature 393 string is: 395 (request-target): get /foo 396 (created): 1402170695 397 host: example.org 398 date: Tue, 07 Jun 2014 20:51:35 GMT 399 cache-control: max-age=60, must-revalidate 400 x-emptyheader: 401 x-example: Example header with some whitespace. 403 2.4. Creating a Signature 405 In order to create a signature, a client MUST: 407 1. Use the `headers` and `algorithm` values as well as the contents 408 of the HTTP message, to create the signature string. 410 2. Use the key associated with `keyId` to generate a digital 411 signature on the signature string. 413 3. The `signature` is then generated by base 64 encoding the output 414 of the digital signature algorithm. 416 For example, assume that the `algorithm` value is "hs2019" and the 417 `keyId` refers to an EdDSA public key. This would signal to the 418 application that the signature string construction mechanism is the 419 one defined in Section 2.3: Signature String Construction [9], the 420 signature string hashing function is SHA-512, and the signing 421 algorithm is Ed25519 as defined in RFC 8032 [RFC8032], Section 5.1: 422 Ed25519ph, Ed25519ctx, and Ed25519. The result of the signature 423 creation algorithm should result in a binary string, which is then 424 base 64 encoded and placed into the `signature` value. 426 2.5. Verifying a Signature 428 In order to verify a signature, a server MUST: 430 1. Use the received HTTP message, the `headers` value, and the 431 Signature String Construction (Section 2.3) algorithm to recreate 432 the signature. 434 2. The `algorithm`, `keyId`, and base 64 decoded `signature` listed 435 in the Signature Parameters are then used to verify the 436 authenticity of the digital signature. Note: The application 437 verifying the signature MUST derive the digital signature 438 algorithm from the metadata associated with the `keyId` and MUST 439 NOT use the value of `algorithm` from the signed message. 441 If a header specified in the `headers` value of the Signature 442 Parameters (or the default item `(created)` where the `headers` value 443 is not supplied) is absent from the message, the implementation MUST 444 produce an error. 446 For example, assume that the `algorithm` value was "hs2019" and and 447 the `keyId` refers to an EdDSA public key. This would signal to the 448 application that the signature string construction mechanism is the 449 one defined in Section 2.3: Signature String Construction [10], the 450 signature string hashing function is SHA-512, and the signing 451 algorithm is Ed25519 as defined in RFC 8032 [RFC8032], Section 5.1: 452 Ed25519ph, Ed25519ctx, and Ed25519. The result of the signature 453 verification algorithm should result in a successful verification 454 unless the headers protected by the signature were tampered with in 455 transit. 457 3. The 'Signature' HTTP Authentication Scheme 459 The "Signature" authentication scheme is based on the model that the 460 client must authenticate itself with a digital signature produced by 461 either a private asymmetric key (e.g., RSA) or a shared symmetric key 462 (e.g., HMAC). 464 The scheme is parameterized enough such that it is not bound to any 465 particular key type or signing algorithm. 467 3.1. Authorization Header 469 The client is expected to send an Authorization header (as defined in 470 RFC 7235 [RFC7235], Section 4.1 [11]) where the "auth-scheme" is 471 "Signature" and the "auth-param" parameters meet the requirements 472 listed in Section 2: The Components of a Signature. 474 The rest of this section uses the following HTTP request as an 475 example. 477 POST /foo HTTP/1.1 478 Host: example.org 479 Date: Tue, 07 Jun 2014 20:51:35 GMT 480 Content-Type: application/json 481 Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= 482 Content-Length: 18 484 {"hello": "world"} 486 Note that the use of the `Digest` header field is per RFC 3230 487 [RFC3230], Section 4.3.2 [12] and is included merely as a 488 demonstration of how an implementer could include information about 489 the body of the message in the signature. The following sections 490 also assume that the "rsa-key-1" keyId asserted by the client is an 491 identifier meaningful to the server. 493 3.1.1. Initiating Signature Authorization 495 A server may notify a client when a resource is protected by 496 requiring a signature. To initiate this process, the server will 497 request that the client authenticate itself via a 401 response [13] 498 code. The server may optionally specify which HTTP headers it 499 expects to be signed by specifying the `headers` parameter in the 500 WWW-Authenticate header. For example: 502 HTTP/1.1 401 Unauthorized 503 Date: Thu, 08 Jun 2014 18:32:30 GMT 504 Content-Length: 1234 505 Content-Type: text/html 506 WWW-Authenticate: Signature 507 realm="Example",headers="(request-target) (created)" 509 ... 511 3.1.2. RSA Example 513 The authorization header and signature would be generated as: 515 Authorization: Signature keyId="rsa-key-1",algorithm="hs2019", 516 headers="(request-target) (created) host digest content-length", 517 signature="Base64(RSA-SHA512(signing string))" 519 The client would compose the signing string as: 521 (request-target): post /foo\n 522 (created): 1402174295 523 host: example.org\n 524 digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=\n 525 content-length: 18 527 Note that the '\n' symbols above are included to demonstrate where 528 the new line character should be inserted. There is no new line on 529 the final line of the signing string. Each HTTP header above is 530 displayed on a new line to provide better readability of the example. 532 For an RSA-based signature, the authorization header and signature 533 would then be generated as: 535 Authorization: Signature keyId="rsa-key-1",algorithm="hs2019", 536 headers="(request-target) (created) host digest content-length", 537 signature="Base64(RSA-SHA512(signing string))" 539 3.1.3. HMAC Example 541 For an HMAC-based signature without a list of headers specified, the 542 authorization header and signature would be generated as: 544 Authorization: Signature keyId="hmac-key-1",algorithm="hs2019", 545 headers="(request-target) (created) host digest content-length", 546 signature="Base64(HMAC-SHA512(signing string))" 548 The only difference between the RSA Example and the HMAC Example is 549 the digital signature algorithm that is used. The client would 550 compose the signing string in the same way as the RSA Example above: 552 (request-target): post /foo\n 553 (created): 1402174295 554 host: example.org\n 555 digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=\n 556 content-length: 18 558 4. The 'Signature' HTTP Header 560 The "Signature" HTTP Header provides a mechanism to link the headers 561 of a message (client request or server response) to a digital 562 signature. By including the "Digest" header with a properly 563 formatted digest, the message body can also be linked to the 564 signature. The signature is generated and verified either using a 565 shared secret (e.g. HMAC) or public/private keys (e.g. RSA, EC). 566 This allows the receiver and/or any intermediate system to 567 immediately or later verify the integrity of the message. When the 568 signature is generated with a private key it can also provide a 569 measure of non-repudiation, though a full implementation of a non- 570 repudiatable statement is beyond the scope of this specification and 571 highly dependent on implementation. 573 The "Signature" scheme can also be used for authentication similar to 574 the purpose of the 'Signature' HTTP Authentication Scheme 575 (Section 3). The scheme is parameterized enough such that it is not 576 bound to any particular key type or signing algorithm. 578 4.1. Signature Header 580 The sender is expected to transmit a header (as defined in RFC 7230 581 [RFC7230], Section 3.2 [14]) where the "field-name" is "Signature", 582 and the "field-value" contains one or more "auth-param"s (as defined 583 in RFC 7235 [RFC7235], Section 4.1 [15]) where the "auth-param" 584 parameters meet the requirements listed in Section 2: The Components 585 of a Signature. 587 The rest of this section uses the following HTTP request as an 588 example. 590 POST /foo HTTP/1.1 591 Host: example.org 592 Date: Tue, 07 Jun 2014 20:51:35 GMT 593 Content-Type: application/json 594 Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= 595 Content-Length: 18 597 {"hello": "world"} 599 The following sections assume that the "rsa-key-1" keyId provided by 600 the signer is an identifier meaningful to the server. 602 4.1.1. RSA Example 604 The signature header and signature would be generated as: 606 Signature: keyId="rsa-key-1",algorithm="hs2019", 607 created=1402170695, expires=1402170995, 608 headers="(request-target) (created) (expires) 609 host date digest content-length", 610 signature="Base64(RSA-SHA256(signing string))" 612 The client would compose the signing string as: 614 (request-target): post /foo\n 615 (created): 1402170695 616 (expires): 1402170995 617 host: example.org\n 618 digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=\n 619 content-length: 18 621 Note that the '\n' symbols above are included to demonstrate where 622 the new line character should be inserted. There is no new line on 623 the final line of the signing string. Each HTTP header above is 624 displayed on a new line to provide better readability of the example. 626 For an RSA-based signature, the authorization header and signature 627 would then be generated as: 629 Signature: keyId="rsa-key-1",algorithm="hs2019",created=1402170695, 630 headers="(request-target) (created) host digest content-length", 631 signature="Base64(RSA-SHA512(signing string))" 633 4.1.2. HMAC Example 635 For an HMAC-based signature without a list of headers specified, the 636 authorization header and signature would be generated as: 638 Signature: keyId="hmac-key-1",algorithm="hs2019",created=1402170695, 639 headers="(request-target) (created) host digest content-length", 640 signature="Base64(HMAC-SHA512(signing string))" 642 The only difference between the RSA Example and the HMAC Example is 643 the signature algorithm that is used. The client would compose the 644 signing string in the same way as the RSA Example above: 646 (request-target): post /foo\n 647 (created): 1402170695 648 host: example.org\n 649 digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=\n 650 content-length: 18 652 5. References 654 5.1. Normative References 656 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 657 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 658 . 660 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 661 Protocol (HTTP/1.1): Message Syntax and Routing", 662 RFC 7230, DOI 10.17487/RFC7230, June 2014, 663 . 665 [RFC7235] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 666 Protocol (HTTP/1.1): Authentication", RFC 7235, 667 DOI 10.17487/RFC7235, June 2014, 668 . 670 5.2. Informative References 672 [RFC2617] Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., 673 Leach, P., Luotonen, A., and L. Stewart, "HTTP 674 Authentication: Basic and Digest Access Authentication", 675 RFC 2617, DOI 10.17487/RFC2617, June 1999, 676 . 678 [RFC3230] Mogul, J. and A. Van Hoff, "Instance Digests in HTTP", 679 RFC 3230, DOI 10.17487/RFC3230, January 2002, 680 . 682 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 683 (TLS) Protocol Version 1.2", RFC 5246, 684 DOI 10.17487/RFC5246, August 2008, 685 . 687 [RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms 688 (SHA and SHA-based HMAC and HKDF)", RFC 6234, 689 DOI 10.17487/RFC6234, May 2011, 690 . 692 [RFC6749] Hardt, D., Ed., "The OAuth 2.0 Authorization Framework", 693 RFC 6749, DOI 10.17487/RFC6749, October 2012, 694 . 696 [RFC8017] Moriarty, K., Ed., Kaliski, B., Jonsson, J., and A. Rusch, 697 "PKCS #1: RSA Cryptography Specifications Version 2.2", 698 RFC 8017, DOI 10.17487/RFC8017, November 2016, 699 . 701 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 702 Signature Algorithm (EdDSA)", RFC 8032, 703 DOI 10.17487/RFC8032, January 2017, 704 . 706 5.3. URIs 708 [1] https://w3c-dvcg.github.io/ 710 [2] https://w3c-ccg.github.io/ 712 [3] https://github.com/w3c-dvcg/http-signatures/issues 714 [4] mailto:public-credentials@w3.org 716 [5] https://tools.ietf.org/html/rfc4648#section-4 718 [6] #hsa-registry 720 [7] https://tools.ietf.org/html/rfc7540#section-8.1.2.3 722 [8] https://tools.ietf.org/html/rfc7230#section-3.2.4 724 [9] #canonicalization 726 [10] #canonicalization 728 [11] https://tools.ietf.org/html/rfc7235#section-2.1 730 [12] https://tools.ietf.org/html/rfc3230#section-4.3.2 732 [13] https://tools.ietf.org/html/rfc7235#section-3.1 734 [14] https://tools.ietf.org/html/rfc7230#section-3.2 736 [15] https://tools.ietf.org/html/rfc7235#section-4.1 738 [16] https://web-payments.org/specs/source/http-signatures-audit/ 740 [17] https://web-payments.org/specs/source/http-signature-nonces/ 742 [18] https://web-payments.org/specs/source/http-signature-trailers/ 744 [19] https://www.iana.org/assignments/http-auth-scheme-signature 746 [20] https://www.iana.org/assignments/http-authschemes 748 [21] https://www.iana.org/assignments/shm-algorithms 750 [22] #canonicalization 752 [23] #canonicalization 754 [24] #canonicalization 756 [25] #canonicalization 758 [26] #canonicalization 760 Appendix A. Security Considerations 762 There are a number of security considerations to take into account 763 when implementing or utilizing this specification. A thorough 764 security analysis of this protocol, including its strengths and 765 weaknesses, can be found in Security Considerations for HTTP 766 Signatures [16]. 768 Appendix B. Extensions 770 This specification was designed to be simple, modular, and 771 extensible. There are a number of other specifications that build on 772 this one. For example, the HTTP Signature Nonces [17] specification 773 details how to use HTTP Signatures over a non-secured channel like 774 HTTP and the HTTP Signature Trailers [18] specification explains how 775 to apply HTTP Signatures to streaming content. Developers that 776 desire more functionality than this specification provides are urged 777 to ensure that an extension specification doesn't already exist 778 before implementing a proprietary extension. 780 If extensions to this specification are made by adding new Signature 781 Parameters, those extension parameters MUST be registered in the 782 Signature Authentication Scheme Registry. The registry will be 783 created and maintained at (the suggested URI) 784 https://www.iana.org/assignments/http-auth-scheme-signature [19]. An 785 example entry in this registry is included below: 787 Signature Parameter: nonce 788 Reference to specification: [HTTP_AUTH_SIGNATURE_NONCE], Section XYZ. 789 Notes (optional): The HTTP Signature Nonces specification details 790 how to use HTTP Signatures over a unsecured channel like HTTP. 792 Appendix C. Test Values 794 WARNING: THESE TEST VECTORS ARE OLD AND POSSIBLY WRONG. THE NEXT 795 VERSION OF THIS SPECIFICATION WILL CONTAIN THE PROPER TEST VECTORS. 797 The following test data uses the following RSA 2048-bit keys, which 798 we will refer to as `keyId=Test` in the following samples: 800 -----BEGIN PUBLIC KEY----- 801 MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFENGw33yGihy92pDjZQhl0C3 802 6rPJj+CvfSC8+q28hxA161QFNUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6 803 Z4UMR7EOcpfdUE9Hf3m/hs+FUR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJw 804 oYi+1hqp1fIekaxsyQIDAQAB 805 -----END PUBLIC KEY----- 807 -----BEGIN RSA PRIVATE KEY----- 808 MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF 809 NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F 810 UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB 811 AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA 812 QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK 813 kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg 814 f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u 815 412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc 816 mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7 817 kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA 818 gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW 819 G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI 820 7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA== 821 -----END RSA PRIVATE KEY----- 823 All examples use this request: 825 POST /foo?param=value&pet=dog HTTP/1.1 826 Host: example.com 827 Date: Sun, 05 Jan 2014 21:31:40 GMT 828 Content-Type: application/json 829 Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= 830 Content-Length: 18 832 {"hello": "world"} 834 C.1. Default Test 836 If a list of headers is not included, the date is the only header 837 that is signed by default for rsa-sha256. The string to sign would 838 be: 840 date: Sun, 05 Jan 2014 21:31:40 GMT 842 The Authorization header would be: 844 Authorization: Signature keyId="Test",algorithm="rsa-sha256", 845 signature="SjWJWbWN7i0wzBvtPl8rbASWz5xQW6mcJmn+ibttBqtifLN7Sazz 846 6m79cNfwwb8DMJ5cou1s7uEGKKCs+FLEEaDV5lp7q25WqS+lavg7T8hc0GppauB 847 6hbgEKTwblDHYGEtbGmtdHgVCk9SuS13F0hZ8FD0k/5OxEPXe5WozsbM=" 848 The Signature header would be: 850 Signature: keyId="Test",algorithm="rsa-sha256", 851 signature="SjWJWbWN7i0wzBvtPl8rbASWz5xQW6mcJmn+ibttBqtifLN7Sazz 852 6m79cNfwwb8DMJ5cou1s7uEGKKCs+FLEEaDV5lp7q25WqS+lavg7T8hc0GppauB 853 6hbgEKTwblDHYGEtbGmtdHgVCk9SuS13F0hZ8FD0k/5OxEPXe5WozsbM=" 855 C.2. Basic Test 857 The minimum recommended data to sign is the (request-target), host, 858 and date. In this case, the string to sign would be: 860 (request-target): post /foo?param=value&pet=dog 861 host: example.com 862 date: Sun, 05 Jan 2014 21:31:40 GMT 864 The Authorization header would be: 866 Authorization: Signature keyId="Test",algorithm="rsa-sha256", 867 headers="(request-target) host date", 868 signature="qdx+H7PHHDZgy4y/Ahn9Tny9V3GP6YgBPyUXMmoxWtLbHpUnXS 869 2mg2+SbrQDMCJypxBLSPQR2aAjn7ndmw2iicw3HMbe8VfEdKFYRqzic+efkb3 870 nndiv/x1xSHDJWeSWkx3ButlYSuBskLu6kd9Fswtemr3lgdDEmn04swr2Os0=" 872 C.3. All Headers Test 874 A strong signature including all of the headers and a digest of the 875 body of the HTTP request would result in the following signing 876 string: 878 (request-target): post /foo?param=value&pet=dog 879 host: example.com 880 date: Sun, 05 Jan 2014 21:31:40 GMT 881 content-type: application/json 882 digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= 883 content-length: 18 885 The Authorization header would be: 887 Authorization: Signature keyId="Test",algorithm="rsa-sha256", 888 created=1402170695, expires=1402170699, 889 headers="(request-target) (created) (expires) 890 host date content-type digest content-length", 891 signature="vSdrb+dS3EceC9bcwHSo4MlyKS59iFIrhgYkz8+oVLEEzmYZZvRs 892 8rgOp+63LEM3v+MFHB32NfpB2bEKBIvB1q52LaEUHFv120V01IL+TAD48XaERZF 893 ukWgHoBTLMhYS2Gb51gWxpeIq8knRmPnYePbF5MOkR0Zkly4zKH7s1dE=" 895 The Signature header would be: 897 Signature: keyId="Test",algorithm="rsa-sha256", 898 created=1402170695, expires=1402170699, 899 headers="(request-target) (created) (expires) 900 host date content-type digest content-length", 901 signature="vSdrb+dS3EceC9bcwHSo4MlyKS59iFIrhgYkz8+oVLEEzmYZZvRs 902 8rgOp+63LEM3v+MFHB32NfpB2bEKBIvB1q52LaEUHFv120V01IL+TAD48XaERZF 903 ukWgHoBTLMhYS2Gb51gWxpeIq8knRmPnYePbF5MOkR0Zkly4zKH7s1dE=" 905 Appendix D. Acknowledgements 907 The editor would like to thank the following individuals for feedback 908 on and implementations of the specification (in alphabetical order): 909 Mark Adamcin, Mark Allen, Paul Annesley, Karl Boehlmark, Stephane 910 Bortzmeyer, Sarven Capadisli, Liam Dennehy, ductm54, Stephen Farrell, 911 Phillip Hallam-Baker, Eric Holmes, Andrey Kislyuk, Adam Knight, Dave 912 Lehn, Dave Longley, James H. Manger, Ilari Liusvaara, Mark 913 Nottingham, Yoav Nir, Adrian Palmer, Lucas Pardue, Roberto Polli, 914 Julian Reschke, Michael Richardson, Wojciech Rygielski, Adam Scarr, 915 Cory J. Slep, Dirk Stein, Henry Story, Lukasz Szewc, Chris Webber, 916 and Jeffrey Yasskin 918 Appendix E. IANA Considerations 920 E.1. Signature Authentication Scheme 922 The following entry should be added to the Authentication Scheme 923 Registry located at https://www.iana.org/assignments/http-authschemes 924 [20] 926 Authentication Scheme Name: Signature 927 Reference: [RFC_THIS_DOCUMENT], Section 2. 928 Notes (optional): The Signature scheme is designed for clients to 929 authenticate themselves with a server. 931 E.2. HTTP Signatures Algorithms Registry 933 The following initial entries should be added to the Canonicalization 934 Algorithms Registry to be created and maintained at (the suggested 935 URI) https://www.iana.org/assignments/shm-algorithms [21]: 937 Editor's note: The references in this section are problematic as many 938 of the specifications that they refer to are too implementation 939 specific, rather than just pointing to the proper signature and 940 hashing specifications. A better approach might be just specifying 941 the signature and hashing function specifications, leaving 942 implementers to connect the dots (which are not that hard to 943 connect). 945 Algorithm Name: hs2019 946 Status: active 947 Canonicalization Algorithm: [RFC_THIS_DOCUMENT], Section 2.3: 948 Signature String Construction [22] 949 Hash Algorithm: RFC 6234 [RFC6234], SHA-512 (SHA-2 with 512-bits of 950 digest output) 951 Digital Signature Algorithm: Derived from metadata associated with 952 `keyId`. Recommend support for RFC 8017 [RFC8017], Section 8.1: 953 RSASSA-PSS, RFC 6234 [RFC6234], Section 7.1: SHA-Based HMACs, ANSI 954 X9.62-2005 ECDSA, P-256, and RFC 8032 [RFC8032], Section 5.1: 955 Ed25519ph, Ed25519ctx, and Ed25519. 957 Algorithm Name: rsa-sha1 958 Status: deprecated, SHA-1 not secure. 959 Canonicalization Algorithm: [RFC_THIS_DOCUMENT], Section 2.3: 960 Signature String Construction [23] 961 Hash Algorithm: RFC 6234 [RFC6234], SHA-1 (SHA-1 with 160-bits of 962 digest output) 963 Digital Signature Algorithm: RFC 8017 [RFC8017], Section 8.2: RSASSA- 964 PKCS1-v1_5 966 Algorithm Name: rsa-sha256 967 Status: deprecated, specifying signature algorithm enables attack 968 vector. 969 Canonicalization Algorithm: [RFC_THIS_DOCUMENT], Section 2.3: 970 Signature String Construction [24] 971 Hash Algorithm: RFC 6234 [RFC6234], SHA-256 (SHA-2 with 256-bits of 972 digest output) 973 Digital Signature Algorithm: RFC 8017 [RFC8017], Section 8.1: RSASSA- 974 PSS 976 Algorithm Name: hmac-sha256 977 Status: deprecated, specifying signature algorithm enables attack 978 vector. 979 Canonicalization Algorithm: [RFC_THIS_DOCUMENT], Section 2.3: 980 Signature String Construction [25] 981 Hash Algorithm: RFC 6234 [RFC6234], SHA-256 (SHA-2 with 256-bits of 982 digest output) 983 Message Authentication Code Algorithm: RFC 6234 [RFC6234], 984 Section 7.1: SHA-Based HMACs 986 Algorithm Name: ecdsa-sha256 987 Status: deprecated, specifying signature algorithm enables attack 988 vector. 989 Canonicalization Algorithm: [RFC_THIS_DOCUMENT], Section 2.3: 990 Signature String Construction [26] 991 Hash Algorithm: RFC 6234 [RFC6234], SHA-256 (SHA-2 with 256-bits of 992 digest output) 993 Digital Signature Algorithm: ANSI X9.62-2005 ECDSA, P-256 995 Authors' Addresses 997 Mark Cavage 998 Oracle 999 500 Oracle Parkway 1000 Redwood Shores, CA 94065 1001 US 1003 Phone: +1 415 400 0626 1004 Email: mcavage@gmail.com 1005 URI: https://www.oracle.com/ 1007 Manu Sporny 1008 Digital Bazaar 1009 203 Roanoke Street W. 1010 Blacksburg, VA 24060 1011 US 1013 Phone: +1 540 961 4469 1014 Email: msporny@digitalbazaar.com 1015 URI: https://manu.sporny.org/