--- 1/draft-ietf-httpbis-message-signatures-07.txt 2022-01-28 16:13:09.540470648 -0800 +++ 2/draft-ietf-httpbis-message-signatures-08.txt 2022-01-28 16:13:09.620471708 -0800 @@ -1,21 +1,21 @@ HTTP A. Backman, Ed. Internet-Draft Amazon Intended status: Standards Track J. Richer -Expires: 23 June 2022 Bespoke Engineering +Expires: 1 August 2022 Bespoke Engineering M. Sporny Digital Bazaar - 20 December 2021 + 28 January 2022 HTTP Message Signatures - draft-ietf-httpbis-message-signatures-07 + draft-ietf-httpbis-message-signatures-08 Abstract This document describes a mechanism for creating, encoding, and verifying digital signatures or message authentication codes over components of an HTTP message. This mechanism supports use cases where the full HTTP message may not be known to the signer, and where the message may be transformed (e.g., by intermediaries) before reaching the verifier. This document also describes a means for requesting that a signature be applied to a subsequent HTTP message @@ -45,25 +45,25 @@ Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on 23 June 2022. + This Internet-Draft will expire on 1 August 2022. Copyright Notice - Copyright (c) 2021 IETF Trust and the persons identified as the + Copyright (c) 2022 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/ license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License. @@ -71,107 +71,111 @@ Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1. Requirements Discussion . . . . . . . . . . . . . . . . . 5 1.2. HTTP Message Transformations . . . . . . . . . . . . . . 6 1.3. Safe Transformations . . . . . . . . . . . . . . . . . . 6 1.4. Conventions and Terminology . . . . . . . . . . . . . . . 7 1.5. Application of HTTP Message Signatures . . . . . . . . . 9 2. HTTP Message Components . . . . . . . . . . . . . . . . . . . 10 2.1. HTTP Fields . . . . . . . . . . . . . . . . . . . . . . . 11 - 2.1.1. Canonicalized Structured HTTP Fields . . . . . . . . 12 - 2.1.2. HTTP Field Examples . . . . . . . . . . . . . . . . . 12 - 2.1.3. Dictionary Structured Field Members . . . . . . . . . 12 - 2.2. Specialty Components . . . . . . . . . . . . . . . . . . 13 - 2.2.1. Signature Parameters . . . . . . . . . . . . . . . . 14 - 2.2.2. Method . . . . . . . . . . . . . . . . . . . . . . . 16 - 2.2.3. Target URI . . . . . . . . . . . . . . . . . . . . . 16 - 2.2.4. Authority . . . . . . . . . . . . . . . . . . . . . . 17 - 2.2.5. Scheme . . . . . . . . . . . . . . . . . . . . . . . 17 - 2.2.6. Request Target . . . . . . . . . . . . . . . . . . . 18 - 2.2.7. Path . . . . . . . . . . . . . . . . . . . . . . . . 19 - 2.2.8. Query . . . . . . . . . . . . . . . . . . . . . . . . 20 - 2.2.9. Query Parameters . . . . . . . . . . . . . . . . . . 20 - 2.2.10. Status Code . . . . . . . . . . . . . . . . . . . . . 21 - 2.2.11. Request-Response Signature Binding . . . . . . . . . 22 - 2.3. Creating the Signature Input String . . . . . . . . . . . 23 - 3. HTTP Message Signatures . . . . . . . . . . . . . . . . . . . 26 - 3.1. Creating a Signature . . . . . . . . . . . . . . . . . . 26 - 3.2. Verifying a Signature . . . . . . . . . . . . . . . . . . 28 - 3.2.1. Enforcing Application Requirements . . . . . . . . . 30 - 3.3. Signature Algorithm Methods . . . . . . . . . . . . . . . 31 - 3.3.1. RSASSA-PSS using SHA-512 . . . . . . . . . . . . . . 32 - 3.3.2. RSASSA-PKCS1-v1_5 using SHA-256 . . . . . . . . . . . 32 - 3.3.3. HMAC using SHA-256 . . . . . . . . . . . . . . . . . 33 - 3.3.4. ECDSA using curve P-256 DSS and SHA-256 . . . . . . . 33 - 3.3.5. JSON Web Signature (JWS) algorithms . . . . . . . . . 34 - 4. Including a Message Signature in a Message . . . . . . . . . 34 - 4.1. The 'Signature-Input' HTTP Field . . . . . . . . . . . . 35 - 4.2. The 'Signature' HTTP Field . . . . . . . . . . . . . . . 35 - 4.3. Multiple Signatures . . . . . . . . . . . . . . . . . . . 36 - 5. Requesting Signatures . . . . . . . . . . . . . . . . . . . . 38 - 5.1. The Accept-Signature Field . . . . . . . . . . . . . . . 39 - 5.2. Processing an Accept-Signature . . . . . . . . . . . . . 40 - 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 40 - 6.1. HTTP Signature Algorithms Registry . . . . . . . . . . . 41 - 6.1.1. Registration Template . . . . . . . . . . . . . . . . 41 - 6.1.2. Initial Contents . . . . . . . . . . . . . . . . . . 42 - 6.2. HTTP Signature Metadata Parameters Registry . . . . . . . 42 - 6.2.1. Registration Template . . . . . . . . . . . . . . . . 42 - 6.2.2. Initial Contents . . . . . . . . . . . . . . . . . . 43 - 6.3. HTTP Signature Specialty Component Identifiers - Registry . . . . . . . . . . . . . . . . . . . . . . . . 43 - 6.3.1. Registration Template . . . . . . . . . . . . . . . . 44 - 6.3.2. Initial Contents . . . . . . . . . . . . . . . . . . 44 - 7. Security Considerations . . . . . . . . . . . . . . . . . . . 45 - 7.1. Signature Verification Skipping . . . . . . . . . . . . . 46 - 7.2. Use of TLS . . . . . . . . . . . . . . . . . . . . . . . 46 - 7.3. Signature Replay . . . . . . . . . . . . . . . . . . . . 47 - 7.4. Insufficient Coverage . . . . . . . . . . . . . . . . . . 47 - 7.5. Cryptography and Signature Collision . . . . . . . . . . 48 - 7.6. Key Theft . . . . . . . . . . . . . . . . . . . . . . . . 48 - 7.7. Modification of Required Message Parameters . . . . . . . 49 - 7.8. Mismatch of Signature Parameters from Message . . . . . . 49 - 7.9. Multiple Signature Confusion . . . . . . . . . . . . . . 49 - 7.10. Signature Labels . . . . . . . . . . . . . . . . . . . . 50 - 7.11. Symmetric Cryptography . . . . . . . . . . . . . . . . . 50 - 7.12. Canonicalization Attacks . . . . . . . . . . . . . . . . 50 - 7.13. Key Specification Mix-Up . . . . . . . . . . . . . . . . 51 - 7.14. HTTP Versions and Component Ambiguity . . . . . . . . . . 51 - 7.15. Key and Algorithm Specification Downgrades . . . . . . . 52 - 7.16. Parsing Structured Field Values . . . . . . . . . . . . . 52 - 7.17. Choosing Message Components . . . . . . . . . . . . . . . 53 - 8. Privacy Considerations . . . . . . . . . . . . . . . . . . . 53 - 8.1. Identification through Keys . . . . . . . . . . . . . . . 53 - 8.2. Signatures do not provide confidentiality . . . . . . . . 54 - 8.3. Oracles . . . . . . . . . . . . . . . . . . . . . . . . . 54 - 8.4. Required Content . . . . . . . . . . . . . . . . . . . . 54 - 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 54 - 9.1. Normative References . . . . . . . . . . . . . . . . . . 54 - 9.2. Informative References . . . . . . . . . . . . . . . . . 56 - Appendix A. Detecting HTTP Message Signatures . . . . . . . . . 57 - Appendix B. Examples . . . . . . . . . . . . . . . . . . . . . . 57 - B.1. Example Keys . . . . . . . . . . . . . . . . . . . . . . 57 - B.1.1. Example Key RSA test . . . . . . . . . . . . . . . . 57 - B.1.2. Example RSA PSS Key . . . . . . . . . . . . . . . . . 58 - B.1.3. Example ECC P-256 Test Key . . . . . . . . . . . . . 59 - B.1.4. Example Shared Secret . . . . . . . . . . . . . . . . 60 - B.2. Test Cases . . . . . . . . . . . . . . . . . . . . . . . 60 - B.2.1. Minimal Signature Using rsa-pss-sha512 . . . . . . . 61 - B.2.2. Selective Covered Components using rsa-pss-sha512 . . 61 - B.2.3. Full Coverage using rsa-pss-sha512 . . . . . . . . . 62 - B.2.4. Signing a Response using ecdsa-p256-sha256 . . . . . 63 - B.2.5. Signing a Request using hmac-sha256 . . . . . . . . . 63 - B.3. TLS-Terminating Proxies . . . . . . . . . . . . . . . . . 64 - Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 66 - Document History . . . . . . . . . . . . . . . . . . . . . . . . 67 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 70 + 2.1.1. Canonicalized Structured HTTP Fields . . . . . . . . 13 + 2.1.2. Dictionary Structured Field Members . . . . . . . . . 13 + 2.2. Derived Components . . . . . . . . . . . . . . . . . . . 14 + 2.2.1. Signature Parameters . . . . . . . . . . . . . . . . 16 + 2.2.2. Method . . . . . . . . . . . . . . . . . . . . . . . 17 + 2.2.3. Target URI . . . . . . . . . . . . . . . . . . . . . 18 + 2.2.4. Authority . . . . . . . . . . . . . . . . . . . . . . 18 + 2.2.5. Scheme . . . . . . . . . . . . . . . . . . . . . . . 19 + 2.2.6. Request Target . . . . . . . . . . . . . . . . . . . 19 + 2.2.7. Path . . . . . . . . . . . . . . . . . . . . . . . . 20 + 2.2.8. Query . . . . . . . . . . . . . . . . . . . . . . . . 21 + 2.2.9. Query Parameters . . . . . . . . . . . . . . . . . . 22 + 2.2.10. Status Code . . . . . . . . . . . . . . . . . . . . . 23 + 2.2.11. Request-Response Signature Binding . . . . . . . . . 23 + 2.3. Creating the Signature Input String . . . . . . . . . . . 26 + 3. HTTP Message Signatures . . . . . . . . . . . . . . . . . . . 28 + 3.1. Creating a Signature . . . . . . . . . . . . . . . . . . 29 + 3.2. Verifying a Signature . . . . . . . . . . . . . . . . . . 31 + 3.2.1. Enforcing Application Requirements . . . . . . . . . 33 + 3.3. Signature Algorithm Methods . . . . . . . . . . . . . . . 34 + 3.3.1. RSASSA-PSS using SHA-512 . . . . . . . . . . . . . . 35 + 3.3.2. RSASSA-PKCS1-v1_5 using SHA-256 . . . . . . . . . . . 35 + 3.3.3. HMAC using SHA-256 . . . . . . . . . . . . . . . . . 36 + 3.3.4. ECDSA using curve P-256 DSS and SHA-256 . . . . . . . 36 + 3.3.5. EdDSA using curve edwards25519 . . . . . . . . . . . 37 + 3.3.6. JSON Web Signature (JWS) algorithms . . . . . . . . . 38 + 4. Including a Message Signature in a Message . . . . . . . . . 38 + 4.1. The 'Signature-Input' HTTP Field . . . . . . . . . . . . 38 + 4.2. The 'Signature' HTTP Field . . . . . . . . . . . . . . . 39 + 4.3. Multiple Signatures . . . . . . . . . . . . . . . . . . . 40 + 5. Requesting Signatures . . . . . . . . . . . . . . . . . . . . 43 + 5.1. The Accept-Signature Field . . . . . . . . . . . . . . . 44 + 5.2. Processing an Accept-Signature . . . . . . . . . . . . . 45 + 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 45 + 6.1. HTTP Signature Algorithms Registry . . . . . . . . . . . 46 + 6.1.1. Registration Template . . . . . . . . . . . . . . . . 46 + 6.1.2. Initial Contents . . . . . . . . . . . . . . . . . . 47 + 6.2. HTTP Signature Metadata Parameters Registry . . . . . . . 47 + 6.2.1. Registration Template . . . . . . . . . . . . . . . . 47 + 6.2.2. Initial Contents . . . . . . . . . . . . . . . . . . 48 + 6.3. HTTP Signature Derived Component Identifiers Registry . . 49 + 6.3.1. Registration Template . . . . . . . . . . . . . . . . 49 + 6.3.2. Initial Contents . . . . . . . . . . . . . . . . . . 50 + 7. Security Considerations . . . . . . . . . . . . . . . . . . . 51 + 7.1. Signature Verification Skipping . . . . . . . . . . . . . 51 + 7.2. Use of TLS . . . . . . . . . . . . . . . . . . . . . . . 51 + 7.3. Signature Replay . . . . . . . . . . . . . . . . . . . . 52 + 7.4. Insufficient Coverage . . . . . . . . . . . . . . . . . . 52 + 7.5. Cryptography and Signature Collision . . . . . . . . . . 53 + 7.6. Key Theft . . . . . . . . . . . . . . . . . . . . . . . . 53 + 7.7. Modification of Required Message Parameters . . . . . . . 54 + 7.8. Mismatch of Signature Parameters from Message . . . . . . 54 + 7.9. Multiple Signature Confusion . . . . . . . . . . . . . . 54 + 7.10. Signature Labels . . . . . . . . . . . . . . . . . . . . 55 + 7.11. Symmetric Cryptography . . . . . . . . . . . . . . . . . 55 + 7.12. Canonicalization Attacks . . . . . . . . . . . . . . . . 56 + 7.13. Key Specification Mix-Up . . . . . . . . . . . . . . . . 56 + 7.14. HTTP Versions and Component Ambiguity . . . . . . . . . . 56 + 7.15. Key and Algorithm Specification Downgrades . . . . . . . 57 + 7.16. Parsing Structured Field Values . . . . . . . . . . . . . 57 + 7.17. Choosing Message Components . . . . . . . . . . . . . . . 58 + 7.18. Confusing HTTP Field Names for Derived Component + Identifiers . . . . . . . . . . . . . . . . . . . . . . 58 + 7.19. Non-deterministic Signature Primitives . . . . . . . . . 59 + 8. Privacy Considerations . . . . . . . . . . . . . . . . . . . 59 + 8.1. Identification through Keys . . . . . . . . . . . . . . . 59 + 8.2. Signatures do not provide confidentiality . . . . . . . . 59 + 8.3. Oracles . . . . . . . . . . . . . . . . . . . . . . . . . 60 + 8.4. Required Content . . . . . . . . . . . . . . . . . . . . 60 + 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 60 + 9.1. Normative References . . . . . . . . . . . . . . . . . . 60 + 9.2. Informative References . . . . . . . . . . . . . . . . . 62 + Appendix A. Detecting HTTP Message Signatures . . . . . . . . . 63 + Appendix B. Examples . . . . . . . . . . . . . . . . . . . . . . 63 + B.1. Example Keys . . . . . . . . . . . . . . . . . . . . . . 63 + B.1.1. Example Key RSA test . . . . . . . . . . . . . . . . 63 + B.1.2. Example RSA PSS Key . . . . . . . . . . . . . . . . . 64 + B.1.3. Example ECC P-256 Test Key . . . . . . . . . . . . . 65 + B.1.4. Example Shared Secret . . . . . . . . . . . . . . . . 66 + B.1.5. Example Ed25519 Test Key . . . . . . . . . . . . . . 66 + B.2. Test Cases . . . . . . . . . . . . . . . . . . . . . . . 66 + B.2.1. Minimal Signature Using rsa-pss-sha512 . . . . . . . 67 + B.2.2. Selective Covered Components using rsa-pss-sha512 . . 68 + B.2.3. Full Coverage using rsa-pss-sha512 . . . . . . . . . 69 + B.2.4. Signing a Response using ecdsa-p256-sha256 . . . . . 70 + B.2.5. Signing a Request using hmac-sha256 . . . . . . . . . 71 + B.2.6. Signing a Request using ed25519 . . . . . . . . . . . 71 + B.3. TLS-Terminating Proxies . . . . . . . . . . . . . . . . . 72 + Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 74 + Document History . . . . . . . . . . . . . . . . . . . . . . . . 75 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 78 1. Introduction Message integrity and authenticity are important security properties that are critical to the secure operation of many HTTP applications. Application developers typically rely on the transport layer to provide these properties, by operating their application over [TLS]. However, TLS only guarantees these properties over a single TLS connection, and the path between client and application may be composed of multiple independent TLS connections (for example, if the @@ -360,35 +363,33 @@ Message it applies to. HTTP Message Component Value: The value associated with a given component identifier within the context of a particular HTTP Message. Component values are derived from the HTTP Message and are usually subject to a canonicalization process. Covered Components: An ordered set of HTTP message component identifiers for fields - (Section 2.1) and specialty components (Section 2.2) that - indicates the set of message components covered by the signature, - not including the @signature-params specialty identifier itself. - The order of this set is preserved and communicated between the - signer and verifier to facilitate reconstruction of the signature - input. + (Section 2.1) and derived components (Section 2.2) that indicates + the set of message components covered by the signature, never + including the @signature-params identifier itself. The order of + this set is preserved and communicated between the signer and + verifier to facilitate reconstruction of the signature input. Signature Input: The sequence of bytes processed by the cryptographic algorithm to produce or verify the HTTP Message Signature. The signature input is generated by the signer and verifier using the covered components set and the HTTP Message. HTTP Message Signature Algorithm: - A cryptographic algorithm that describes the signing and verification process for the signature, defined in terms of the HTTP_SIGN and HTTP_VERIFY primitives described in Section 3.3. Key Material: The key material required to create or verify the signature. The key material is often identified with an explicit key identifier, allowing the signer to indicate to the verifier which key was used. @@ -484,136 +485,191 @@ an sf-string value and MAY define parameters which are included using the parameters rule. component-identifier = sf-string parameters Note that this means the serialization of the component identifier itself is encased in double quotes, with parameters following as a semicolon-separated list, such as "cache-control", "date", or "@signature-params". - Component identifiers including their parameters MUST NOT be repeated - within a single list of covered components. + Component identifiers, including component identifiers with + parameters, MUST NOT be repeated within a single list of covered + components. Component identifiers with different parameter values + MAY be repeated within a single list of covered components. The component value associated with a component identifier is defined by the identifier itself. Component values MUST NOT contain newline (\n) characters. The following sections define component identifier types, their parameters, their associated values, and the canonicalization rules for their values. The method for combining component identifiers into the signature input is defined in Section 2.3. 2.1. HTTP Fields The component identifier for an HTTP field is the lowercased form of its field name. While HTTP field names are case-insensitive, implementations MUST use lowercased field names (e.g., content-type, date, etag) when using them as component identifiers. Unless overridden by additional parameters and rules, the HTTP field - value MUST be canonicalized with the following steps: + value MUST be canonicalized as a single combined value as defined in + Section 5.2 of [SEMANTICS]. + + If the combined value is not available for a given header, the + following algorithm will produce canonicalized results for an + implementation: 1. Create an ordered list of the field values of each instance of the field in the message, in the order that they occur (or will occur) in the message. 2. Strip leading and trailing whitespace from each item in the list. + Note that since HTTP field values are not allowed to contain + leading and trailing whitespace, this will be a no-op in a + compliant implementation. - 3. Concatenate the list items together, with a single comma "," and - space " " between each item. - - The resulting string is the canonicalized component value. - -2.1.1. Canonicalized Structured HTTP Fields - - If value of the the HTTP field in question is a structured field - ([RFC8941]), the component identifier MAY include the sf parameter. - If this parameter is included, the HTTP field value MUST be - canonicalized using the rules specified in Section 4 of [RFC8941]. - For example, this process will replace any optional internal - whitespace with a single space character. + 3. Remove any obsolete line-folding within the line and replace it + with a single space (), as discussed in Section 5.2 of + [MESSAGING]. Note that this behavior is specific to [MESSAGING] + and does not apply to other versions of the HTTP specification. - The resulting string is used as the component value in Section 2.1. + 4. Concatenate the list of values together with a single comma (,) + and a single space () between each item. -2.1.2. HTTP Field Examples + The resulting string is the canonicalized component value. Following are non-normative examples of canonicalized values for - header fields, given the following example HTTP message: + header fields, given the following example HTTP message fragment: Host: www.example.com - Date: Tue, 07 Jun 2014 20:51:35 GMT + Date: Tue, 20 Apr 2021 02:07:56 GMT X-OWS-Header: Leading and trailing whitespace. X-Obs-Fold-Header: Obsolete line folding. - X-Empty-Header: Cache-Control: max-age=60 Cache-Control: must-revalidate - X-Dictionary: a=1, b=2;x=1;y=2, c=(a b c) + Example-Dictionary: a=1, b=2;x=1;y=2, c=(a b c) The following example shows canonicalized values for these example header fields, presented using the signature input string format discussed in Section 2.3: - "cache-control": max-age=60, must-revalidate| - "date": Tue, 07 Jun 2014 20:51:35 GMT| - "host": www.example.com| - "x-empty-header": - "x-obs-fold-header": Obsolete line folding. + "host": www.example.com + "date": Tue, 20 Apr 2021 02:07:56 GMT "x-ows-header":Leading and trailing whitespace. - "x-dictionary": a=1, b=2;x=1;y=2, c=(a b c) - "x-dictionary";sf: a=1, b=2;x=1;y=2, c=(a b c) + "x-obs-fold-header": Obsolete line folding. + "cache-control": max-age=60, must-revalidate + "Example-dictionary": a=1, b=2;x=1;y=2, c=(a b c) -2.1.3. Dictionary Structured Field Members + Since empty HTTP header fields are allowed, they are also able to be + signed when present in a message. The canonicalized value is the + empty string. This means that the following empty header: + + NOTE: '\' line wrapping per RFC 8792 + + X-Empty-Header: \ + + Is serialized by the signature input generation algorithm + (Section 2.3) with an empty string value following the colon and + space added after the content identifier. + + NOTE: '\' line wrapping per RFC 8792 + + "x-empty-header": \ + + Note: these are shown here using the line wrapping algorithm in + [RFC8792] due to limitations in the document format that strips + trailing spaces from diagrams. + +2.1.1. Canonicalized Structured HTTP Fields + + If value of the the HTTP field in question is a structured field + ([RFC8941]), the component identifier MAY include the sf parameter to + indicate it is a known structured field. If this parameter is + included with a component identifier, the HTTP field value MUST be + serialized using the rules specified in Section 4 of [RFC8941] + applicable to the type of the HTTP field. Note that this process + will replace any optional internal whitespace with a single space + character, among other potential transformations of the value. + + For example, the following dictionary field is a valid serialization: + + Example-Dictionary: a=1, b=2;x=1;y=2, c=(a b c) + + If included in the input string as-is, it would be: + + "example-dictionary": a=1, b=2;x=1;y=2, c=(a b c) + + However, if the sf parameter is added, the value is re-serialized as + follows: + + "example-dictionary";sf: a=1, b=2;x=1;y=2, c=(a b c) + + The resulting string is used as the component value in Section 2.1. + +2.1.2. Dictionary Structured Field Members An individual member in the value of a Dictionary Structured Field is identified by using the parameter key to indicate the member key as an sf-string value. An individual member in the value of a Dictionary Structured Field is canonicalized by applying the serialization algorithm described in - Section 4.1.2 of [RFC8941] on a Dictionary containing only that item. + Section 4.1.2 of [RFC8941] on the member value and its parameters, + without the dictionary key. Each parameterized key for a given field MUST NOT appear more than once in the signature input. Parameterized keys MAY appear in any order. Following are non-normative examples of canonicalized values for Dictionary Structured Field Members given the following example header field, whose value is known to be a Dictionary: - X-Dictionary: a=1, b=2;x=1;y=2, c=(a b c) + Example-Dictionary: a=1, b=2;x=1;y=2, c=(a b c) The following example shows canonicalized values for different component identifiers of this field, presented using the signature input string format discussed in Section 2.3: - "x-dictionary";key="a": 1 - "x-dictionary";key="b": 2;x=1;y=2 - "x-dictionary";key="c": (a, b, c) + "example-dictionary";key="a": 1 + "example-dictionary";key="b": 2;x=1;y=2 + "example-dictionary";key="c": (a b c) -2.2. Specialty Components + Note that the value for key="c" has been re-serialized. - Message components not found in an HTTP field can be included in the - signature input by defining a component identifier and the - canonicalization method for its component value. +2.2. Derived Components - To differentiate specialty component identifiers from HTTP fields, - specialty component identifiers MUST start with the "at" @ character. - This specification defines the following specialty component + In addition to HTTP fields, there are a number of different + components that can be derived from the control data, processing + context, or other aspects of the HTTP message being signed. Such + derived components can be included in the signature input by defining + a component identifier and the derivation method for its component + value. + + Derived component identifiers MUST start with the "at" @ character. + This differentiates derived component identifiers from HTTP field + names, which cannot contain the @ character as per Section 5.1 of + [SEMANTICS]. Processors of HTTP Message Signatures MUST treat + derived component identifiers separately from field names, as + discussed in Section 7.18. + + This specification defines the following derived component identifiers: @signature-params The signature metadata parameters for this signature. (Section 2.2.1) @method The method used for a request. (Section 2.2.2) - @target-uri The full target URI for a request. (Section 2.2.3) @authority The authority of the target URI for a request. (Section 2.2.4) @scheme The scheme of the target URI for a request. (Section 2.2.5) @request-target The request target. (Section 2.2.6) @path The absolute path portion of the target URI for a request. @@ -624,39 +679,45 @@ (Section 2.2.8) @query-params The parsed query parameters of the target URI for a request. (Section 2.2.9) @status The status code for a response. (Section 2.2.10). @request-response A signature from a request message that resulted in this response message. (Section 2.2.11) - Additional specialty component identifiers MAY be defined and - registered in the HTTP Signatures Specialty Component Identifier + Additional derived component identifiers MAY be defined and + registered in the HTTP Signatures Derived Component Identifier Registry. (Section 6.3) - Specialty components can be applied in one or more of three targets: + Derived components can be applied in one or more of three targets: request: Values derived from and results applied to an HTTP request message as described in {{Section 3.4 of SEMANTICS. response: Values derived from and results applied to an HTTP response message as described in Section 3.4 of [SEMANTICS]. related-response: Values derived from an HTTP request message and results applied to the HTTP response message that is responding to that specific request. A component identifier definition MUST define all targets to which it can be applied. + The component value MUST be derived from the HTTP message being + signed or the context in which the derivation occurs. The derived + component value MUST be of the following form: + + derived-component-value = *VCHAR + 2.2.1. Signature Parameters HTTP Message Signatures have metadata properties that provide information regarding the signature's generation and verification, such as the set of covered components, a timestamp, identifiers for verification key material, and other utilities. The signature parameters component identifier is @signature-params. This message component's value is REQUIRED as part of the signature input string (Section 2.3) but the component identifier MUST NOT be @@ -713,22 +774,22 @@ Note that the inner-list serialization is used for the covered component value instead of the sf-list serialization in order to facilitate this value's inclusion in message fields such as the Signature-Input field's dictionary, as discussed in Section 4.1. This example shows a canonicalized value for the parameters of a given signature: NOTE: '\' line wrapping per RFC 8792 - ("@target-uri" "@authority" "date" "cache-control" "x-empty-header" \ - "x-example");keyid="test-key-rsa-pss";alg="rsa-pss-sha512";\ + ("@target-uri" "@authority" "date" "cache-control")\ + ;keyid="test-key-rsa-pss";alg="rsa-pss-sha512";\ created=1618884475;expires=1618884775 Note that an HTTP message could contain multiple signatures (Section 4.3), but only the signature parameters used for a single signature are included in an entry. 2.2.2. Method The @method component identifier refers to the HTTP method of a request message. The component value of is canonicalized by taking @@ -1012,191 +1073,234 @@ key Identifies which signature from the response to sign. The component value is the sf-binary representation of the signature value of the referenced request identified by the key parameter. For example, when serving this signed request: NOTE: '\' line wrapping per RFC 8792 - POST /foo?param=value&pet=dog HTTP/1.1 + POST /foo?param=Value&Pet=dog HTTP/1.1 Host: example.com Date: Tue, 20 Apr 2021 02:07:55 GMT Content-Type: application/json + Content-Digest: sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+T\ + aPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: Content-Length: 18 - Signature-Input: sig1=("@authority" "content-type")\ + Signature-Input: sig1=("@method" "@authority" "@path" \ + "content-digest" "content-length" "content-type")\ ;created=1618884475;keyid="test-key-rsa-pss" - Signature: sig1=:KuhJjsOKCiISnKHh2rln5ZNIrkRvue0DSu5rif3g7ckTbbX7C4\ - Jp3bcGmi8zZsFRURSQTcjbHdJtN8ZXlRptLOPGHkUa/3Qov79gBeqvHNUO4bhI27p\ - 4WzD1bJDG9+6ml3gkrs7rOvMtROObPuc78A95fa4+skS/t2T7OjkfsHAm/enxf1fA\ - wkk15xj0n6kmriwZfgUlOqyff0XLwuH4XFvZ+ZTyxYNoo2+EfFg4NVfqtSJch2WDY\ - 7n/qmhZOzMfyHlggWYFnDpyP27VrzQCQg8rM1Crp6MrwGLa94v6qP8pq0sQVq2DLt\ - 4NJSoRRqXTvqlWIRnexmcKXjQFVz6YSA==: + Signature: sig1=:LAH8BjcfcOcLojiuOBFWn0P5keD3xAOuJRGziCLuD8r5MW9S0\ + RoXXLzLSRfGY/3SF8kVIkHjE13SEFdTo4Af/fJ/Pu9wheqoLVdwXyY/UkBIS1M8Br\ + c8IODsn5DFIrG0IrburbLi0uCc+E2ZIIb6HbUJ+o+jP58JelMTe0QE3IpWINTEzpx\ + jqDf5/Df+InHCAkQCTuKsamjWXUpyOT1Wkxi7YPVNOjW4MfNuTZ9HdbD2Tr65+BXe\ + TG9ZS/9SWuXAc+BZ8WyPz0QRz//ec3uWXd7bYYODSjRAxHqX+S1ag3LZElYyUKaAI\ + jZ8MGOt4gXEwCSLDv/zqxZeWLj/PDkn6w==: {"hello": "world"} This would result in the following unsigned response message: - HTTP/1.1 200 OK + HTTP/1.1 503 Service Unavailable Date: Tue, 20 Apr 2021 02:07:56 GMT Content-Type: application/json Content-Length: 62 {"busy": true, "message": "Your call is very important to us"} - The server signs the response with its own key and includes the - signature of sig1 from the request in the covered components of the - response. The signature input string for this example is: + To cryptographically link the response to the request, the server + signs the response with its own key and includes the signature of + sig1 from the request in the covered components of the response. The + signature input string for this example is: NOTE: '\' line wrapping per RFC 8792 - "content-type": application/json + "@status": 503 "content-length": 62 - "@status": 200 - "@request-response";key="sig1": :KuhJjsOKCiISnKHh2rln5ZNIrkRvue0DSu\ - 5rif3g7ckTbbX7C4Jp3bcGmi8zZsFRURSQTcjbHdJtN8ZXlRptLOPGHkUa/3Qov79\ - gBeqvHNUO4bhI27p4WzD1bJDG9+6ml3gkrs7rOvMtROObPuc78A95fa4+skS/t2T7\ - OjkfsHAm/enxf1fAwkk15xj0n6kmriwZfgUlOqyff0XLwuH4XFvZ+ZTyxYNoo2+Ef\ - Fg4NVfqtSJch2WDY7n/qmhZOzMfyHlggWYFnDpyP27VrzQCQg8rM1Crp6MrwGLa94\ - v6qP8pq0sQVq2DLt4NJSoRRqXTvqlWIRnexmcKXjQFVz6YSA==: - "@signature-params": ("content-type" "content-length" "@status" \ - "@request-response";key="sig1");created=1618884475\ + "content-type": application/json + "@request-response";key="sig1": :LAH8BjcfcOcLojiuOBFWn0P5keD3xAOuJR\ + GziCLuD8r5MW9S0RoXXLzLSRfGY/3SF8kVIkHjE13SEFdTo4Af/fJ/Pu9wheqoLVd\ + wXyY/UkBIS1M8Brc8IODsn5DFIrG0IrburbLi0uCc+E2ZIIb6HbUJ+o+jP58JelMT\ + e0QE3IpWINTEzpxjqDf5/Df+InHCAkQCTuKsamjWXUpyOT1Wkxi7YPVNOjW4MfNuT\ + Z9HdbD2Tr65+BXeTG9ZS/9SWuXAc+BZ8WyPz0QRz//ec3uWXd7bYYODSjRAxHqX+S\ + 1ag3LZElYyUKaAIjZ8MGOt4gXEwCSLDv/zqxZeWLj/PDkn6w==: + "@signature-params": ("@status" "content-length" "content-type" \ + "@request-response";key="sig1");created=1618884479\ ;keyid="test-key-ecc-p256" The signed response message is: NOTE: '\' line wrapping per RFC 8792 - HTTP/1.1 200 OK + HTTP/1.1 503 Service Unavailable Date: Tue, 20 Apr 2021 02:07:56 GMT Content-Type: application/json Content-Length: 62 - Signature-Input: sig1=("content-type" "content-length" "@status" \ - "@request-response";key="sig1");created=1618884475\ + Signature-Input: reqres=("@status" "content-length" "content-type" \ + "@request-response";key="sig1");created=1618884479\ ;keyid="test-key-ecc-p256" - Signature: sig1=:crVqK54rxvdx0j7qnt2RL1oQSf+o21S/6Uk2hyFpoIfOT0q+Hv\ - msYAXUXzo0Wn8NFWh/OjWQOXHAQdVnTk87Pw==: + Signature: reqres=:JqzXLIjNd6VWVg/M7enbjWkOgsPmIK9vcoFQEkLD0SXNbFjR\ + 6d+olsof1dv7xC7ygF1q0YKjVrbV2QlCpDxrHg==: {"busy": true, "message": "Your call is very important to us"} Since the request's signature value itself is not repeated in the response, the requester MUST keep the original signature value around long enough to validate the signature of the response that uses this component identifier. + Note that the ECDSA algorithm in use here is non-deterministic, + meaning a different signature value will be created every time the + algorithm is run. The signature value provided here can be validated + against the given keys, but newly-generated signature values are not + expected to match the example. See Section 7.19. + The @request-response component identifier MUST NOT be used in a request message. 2.3. Creating the Signature Input String The signature input is a US-ASCII string containing the canonicalized HTTP message components covered by the signature. The input to the - signature creation algorithm is the list of covered component - identifiers and their associated values, along with an additional - signature parameters. To create the signature input string, the - signer or verifier concatenates together entries for each identifier - in the signature's covered components (including their parameters) - using the following algorithm: + signature input creation algorithm is the list of covered component + identifiers and their associated values, along with any additional + signature parameters. The output is the signature input string, + which has the following form: + + signature-input = *( signature-input-line LF ) signature-params-line + signature-input-line = component-identifier ":" SP ( derived-component-value / field-value ) + signature-params-line = DQUOTE "@signature-params" DQUOTE ":" SP inner-list + + To create the signature input string, the signer or verifier + concatenates together entries for each identifier in the signature's + covered components (including their parameters) using the following + algorithm: 1. Let the output be an empty string. 2. For each message component item in the covered components set (in order): 1. Append the component identifier for the covered component - serialized according to the component-identifier rule. + serialized according to the component-identifier rule. Note + that this serialization places the component identifier in + double quotes and appends any parameters outside of the + quotes. 2. Append a single colon : 3. Append a single space " " - 4. Append the covered component's canonicalized component value, - as defined by the HTTP message component type. (Section 2.1 - and Section 2.2) + 4. Determine the component value for the component identifier. - 5. Append a single newline \n + * If the component identifier starts with an "at" character + (@), derive the component's value from the message + according to the specific rules defined for the derived + component identifier, as in Section 2.2. If the derived + component identifier is unknown or the value cannot be + derived, produce an error. + + * If the component identifier does not start with an "at" + character (@), canonicalize the HTTP field value as + described in Section 2.1. If the value cannot be + calculated, produce an error. + + 5. Append the covered component's canonicalized component value. + + 6. Append a single newline \n 3. Append the signature parameters component (Section 2.2.1) as follows: 1. Append the component identifier for the signature parameters serialized according to the component-identifier rule, i.e. "@signature-params" 2. Append a single colon : 3. Append a single space " " 4. Append the signature parameters' canonicalized component value as defined in Section 2.2.1 4. Return the output string. If covered components reference a component identifier that cannot be resolved to a component value in the message, the implementation MUST - produce an error. Such situations are included but not limited to: + produce an error and not create an input string. Such situations are + included but not limited to: - * The signer or verifier does not understand the component + * The signer or verifier does not understand the derived component identifier. * The component identifier identifies a field that is not present in the message or whose value is malformed. * The component identifier indicates that a structured field - serialization is used, but the field in question is known to not - be a structured field or the type of structured field is not known - to the verifier. + serialization is used (via the sf parameter), but the field in + question is known to not be a structured field or the type of + structured field is not known to the implementation. * The component identifier is a dictionary member identifier that references a field that is not present in the message, is not a Dictionary Structured Field, or whose value is malformed. * The component identifier is a dictionary member identifier or a named query parameter identifier that references a member that is not present in the component value, or whose value is malformed. - E.g., the identifier is "x-dictionary";key="c" and the value of - the x-dictionary header field is a=1, b=2 + E.g., the identifier is "example-dictionary";key="c" and the value + of the Example-Dictionary header field is a=1, b=2, which does not + have the c value. In the following non-normative example, the HTTP message being signed is the following request: - GET /foo HTTP/1.1 - Host: example.org + POST /foo?param=Value&Pet=dog HTTP/1.1 + Host: example.com Date: Tue, 20 Apr 2021 02:07:55 GMT - X-Example: Example header - with some whitespace. - X-Empty-Header: - Cache-Control: max-age=60 - Cache-Control: must-revalidate + Content-Type: application/json + Content-Digest: sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+T\ + aPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: + Content-Length: 18 + + {"hello": "world"} The covered components consist of the @method, @path, and @authority - specialty component identifiers followed by the Cache-Control, X- - Empty-Header, X-Example HTTP headers, in order. The signature - parameters consist of a creation timestamp is 1618884475 and the key - identifier is test-key-rsa-pss. The signature input string for this - message with these parameters is: + derived component identifiers followed by the Content-Digest, + Content-Length, and Content-Type HTTP header fields, in order. The + signature parameters consist of a creation timestamp of 1618884473 + and a key identifier of test-key-rsa-pss. Note that no explicit alg + parameter is given here since the verifier is assumed by the + application to correctly use the RSA PSS algorithm based on the + identified key. The signature input string for this message with + these parameters is: NOTE: '\' line wrapping per RFC 8792 - "@method": GET + "@method": POST + "@authority": example.com "@path": /foo - "@authority": example.org - "cache-control": max-age=60, must-revalidate - "x-empty-header": - "x-example": Example header with some whitespace. - "@signature-params": ("@method" "@path" "@authority" \ - "cache-control" "x-empty-header" "x-example");created=1618884475\ - ;keyid="test-key-rsa-pss" + "content-digest": sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX\ + +TaPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: + "content-length": 18 + "content-type": application/json + "@signature-params": ("@method" "@authority" "@path" \ + "content-digest" "content-length" "content-type")\ + ;created=1618884473;keyid="test-key-rsa-pss" Figure 1: Non-normative example Signature Input + Note that the example signature input here, or anywhere else within + this specification, does not include the final newline that ends the + example. + 3. HTTP Message Signatures An HTTP Message Signature is a signature over a string generated from a subset of the components of an HTTP message in addition to metadata about the signature itself. When successfully verified against an HTTP message, an HTTP Message Signature provides cryptographic proof that the message is semantically equivalent to the message for which the signature was generated, with respect to the subset of message components that was signed. @@ -1229,31 +1333,31 @@ 4. The signer creates an ordered set of component identifiers representing the message components to be covered by the signature, and attaches signature metadata parameters to this set. The serialized value of this is later used as the value of the Signature-Input field as described in Section 4.1. * Once an order of covered components is chosen, the order MUST NOT change for the life of the signature. * Each covered component identifier MUST be either an HTTP field - in the message Section 2.1 or a specialty component identifier + in the message Section 2.1 or a derived component identifier listed in Section 2.2 or its associated registry. * Signers of a request SHOULD include some or all of the message control data in the covered components, such as the @method, @authority, @target-uri, or some combination thereof. * Signers SHOULD include the created signature metadata parameter to indicate when the signature was created. - * The @signature-params specialty component identifier is not + * The @signature-params derived component identifier is not explicitly listed in the list of covered component identifiers, because it is required to always be present as the last line in the signature input. This ensures that a signature always covers its own metadata. * Further guidance on what to include in this set and in what order is out of scope for this document. 5. The signer creates the signature input string based on these signature parameters. (Section 2.3) @@ -1268,29 +1372,35 @@ field as defined in Section 4.2. For example, given the HTTP message and signature parameters in the example in Section 2.3, the example signature input string is signed with the test-key-rsa-pss key in Appendix B.1.2 and the RSA PSS algorithm described in Section 3.3.1, giving the following message signature output value, encoded in Base64: NOTE: '\' line wrapping per RFC 8792 - P0wLUszWQjoi54udOtydf9IWTfNhy+r53jGFj9XZuP4uKwxyJo1RSHi+oEF1FuX6O29\ - d+lbxwwBao1BAgadijW+7O/PyezlTnqAOVPWx9GlyntiCiHzC87qmSQjvu1CFyFuWSj\ - dGa3qLYYlNm7pVaJFalQiKWnUaqfT4LyttaXyoyZW84jS8gyarxAiWI97mPXU+OVM64\ - +HVBHmnEsS+lTeIsEQo36T3NFf2CujWARPQg53r58RmpZ+J9eKR2CD6IJQvacn5A4Ix\ - 5BUAVGqlyp8JYm+S/CWJi31PNUjRRCusCVRj05NrxABNFv3r5S9IXf2fYJK+eyW4AiG\ - VMvMcOg== + HIbjHC5rS0BYaa9v4QfD4193TORw7u9edguPh0AW3dMq9WImrlFrCGUDih47vAxi4L2\ + YRZ3XMJc1uOKk/J0ZmZ+wcta4nKIgBkKq0rM9hs3CQyxXGxHLMCy8uqK488o+9jrptQ\ + +xFPHK7a9sRL1IXNaagCNN3ZxJsYapFj+JXbmaI5rtAdSfSvzPuBCh+ARHBmWuNo1Uz\ + VVdHXrl8ePL4cccqlazIJdC4QEjrF+Sn4IxBQzTZsL9y9TP5FsZYzHvDqbInkTNigBc\ + E9cKOYNFCn4D/WM7F6TNuZO9EgtzepLWcjTymlHzK7aXq6Am6sfOrpIC49yXjj3ae6H\ + RalVc/g== Figure 2: Non-normative example signature value + Note that the RSA PSS algorithm in use here is non-deterministic, + meaning a different signature value will be created every time the + algorithm is run. The signature value provided here can be validated + against the given keys, but newly-generated signature values are not + expected to match the example. See Section 7.19. + 3.2. Verifying a Signature Verification of an HTTP message signature is a process that takes as its input the message (including Signature and Signature-Input fields) and the requirements for the application. The output of the verification is either a positive verification or an error. In order to verify a signature, a verifier MUST follow the following algorithm: @@ -1369,37 +1479,38 @@ If any of the above steps fail or produce an error, the signature validation fails. For example, verifying the signature with the key sig1 of the following message with the test-key-rsa-pss key in Appendix B.1.2 and the RSA PSS algorithm described in Section 3.3.1: NOTE: '\' line wrapping per RFC 8792 - GET /foo HTTP/1.1 - Host: example.org + POST /foo?param=Value&Pet=dog HTTP/1.1 + Host: example.com Date: Tue, 20 Apr 2021 02:07:55 GMT - X-Example: Example header - with some whitespace. - X-Empty-Header: - Cache-Control: max-age=60 - Cache-Control: must-revalidate - Signature-Input: sig1=("@method" "@path" "@authority" \ - "cache-control" "x-empty-header" "x-example");created=1618884475\ - ;keyid="test-key-rsa-pss" - Signature: sig1=:P0wLUszWQjoi54udOtydf9IWTfNhy+r53jGFj9XZuP4uKwxyJo1\ - RSHi+oEF1FuX6O29d+lbxwwBao1BAgadijW+7O/PyezlTnqAOVPWx9GlyntiCiHzC8\ - 7qmSQjvu1CFyFuWSjdGa3qLYYlNm7pVaJFalQiKWnUaqfT4LyttaXyoyZW84jS8gya\ - rxAiWI97mPXU+OVM64+HVBHmnEsS+lTeIsEQo36T3NFf2CujWARPQg53r58RmpZ+J9\ - eKR2CD6IJQvacn5A4Ix5BUAVGqlyp8JYm+S/CWJi31PNUjRRCusCVRj05NrxABNFv3\ - r5S9IXf2fYJK+eyW4AiGVMvMcOg==: + Content-Type: application/json + Content-Digest: sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+T\ + aPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: + Content-Length: 18 + Signature-Input: sig1=("@method" "@authority" "@path" \ + "content-digest" "content-length" "content-type")\ + ;created=1618884473;keyid="test-key-rsa-pss" + Signature: sig1=:HIbjHC5rS0BYaa9v4QfD4193TORw7u9edguPh0AW3dMq9WImrl\ + FrCGUDih47vAxi4L2YRZ3XMJc1uOKk/J0ZmZ+wcta4nKIgBkKq0rM9hs3CQyxXGxH\ + LMCy8uqK488o+9jrptQ+xFPHK7a9sRL1IXNaagCNN3ZxJsYapFj+JXbmaI5rtAdSf\ + SvzPuBCh+ARHBmWuNo1UzVVdHXrl8ePL4cccqlazIJdC4QEjrF+Sn4IxBQzTZsL9y\ + 9TP5FsZYzHvDqbInkTNigBcE9cKOYNFCn4D/WM7F6TNuZO9EgtzepLWcjTymlHzK7\ + aXq6Am6sfOrpIC49yXjj3ae6HRalVc/g==: + + {"hello": "world"} With the additional requirements that at least the method, path, authority, and cache-control be signed, and that the signature creation timestamp is recent enough at the time of verification, the verification passes. 3.2.1. Enforcing Application Requirements The verification requirements specified in this document are intended as a baseline set of restrictions that are generally applicable to @@ -1443,37 +1554,36 @@ requirements. Applications MUST enforce the requirements defined in this document. Regardless of use case, applications MUST NOT accept signatures that do not conform to these requirements. 3.3. Signature Algorithm Methods HTTP Message signatures MAY use any cryptographic digital signature or MAC method that is appropriate for the key material, environment, - and needs of the signer and verifier. All signatures are generated - from and verified against the byte values of the signature input - string defined in Section 2.3. + and needs of the signer and verifier. Each signature algorithm method takes as its input the signature - input string as a set of byte values (I), the signing key material - (Ks), and outputs the signature output as a set of byte values (S): + input string defined in Section 2.3 as a byte array (M), the signing + key material (Ks), and outputs the signature output as a byte array + (S): - HTTP_SIGN (I, Ks) -> S + HTTP_SIGN (M, Ks) -> S Each verification algorithm method takes as its input the - recalculated signature input string as a set of byte values (I), the - verification key material (Kv), and the presented signature to be - verified as a set of byte values (S) and outputs the verification - result (V) as a boolean: + recalculated signature input string defined in Section 2.3 as a byte + array (M), the verification key material (Kv), and the presented + signature to be verified as a byte array (S) and outputs the + verification result (V) as a boolean: - HTTP_VERIFY (I, Kv, S) -> V + HTTP_VERIFY (M, Kv, S) -> V This section contains several common algorithm methods. The method to use can be communicated through the algorithm signature parameter defined in Section 2.2.1, by reference to the key material, or through mutual agreement between the signer and verifier. 3.3.1. RSASSA-PSS using SHA-512 To sign using this algorithm, the signer applies the RSASSA-PSS-SIGN (K, M) function [RFC8017] with the signer's private signing key (K) and the signature input string (M) (Section 2.3). The mask @@ -1487,22 +1597,28 @@ To verify using this algorithm, the verifier applies the RSASSA-PSS- VERIFY ((n, e), M, S) function [RFC8017] using the public key portion of the verification key material ((n, e)) and the signature input string (M) re-created as described in Section 3.2. The mask generation function is MGF1 as specified in [RFC8017] with a hash function of SHA-512 [RFC6234]. The salt length (sLen) is 64 bytes. The hash function (Hash) SHA-512 [RFC6234] is applied to the signature input string to create the digest content to which the verification function is applied. The verifier extracts the HTTP message signature to be verified (S) as described in Section 3.2. - The results of the verification function are compared to the http - message signature to determine if the signature presented is valid. + The results of the verification function indicate if the signature + presented is valid. + + Note that the output of RSA PSS algorithms are non-deterministic, and + therefore it is not correct to re-calculate a new signature on the + signature input and compare the results to an existing signature. + Instead, the verification algorithm defined here needs to be used. + See Section 7.19. Use of this algorithm can be indicated at runtime using the rsa-pss- sha512 value for the alg signature parameter. 3.3.2. RSASSA-PKCS1-v1_5 using SHA-256 To sign using this algorithm, the signer applies the RSASSA- PKCS1-V1_5-SIGN (K, M) function [RFC8017] with the signer's private signing key (K) and the signature input string (M) (Section 2.3). The hash SHA-256 [RFC6234] is applied to the signature input string @@ -1544,39 +1660,75 @@ Use of this algorithm can be indicated at runtime using the hmac- sha256 value for the alg signature parameter. 3.3.4. ECDSA using curve P-256 DSS and SHA-256 To sign using this algorithm, the signer applies the ECDSA algorithm [FIPS186-4] using curve P-256 with the signer's private signing key and the signature input string (Section 2.3). The hash SHA-256 [RFC6234] is applied to the signature input string to create the - digest content to which the digital signature is applied. The - resulting signed content byte array is the HTTP message signature - output used in Section 3.1. + digest content to which the digital signature is applied, (M). The + signature algorithm returns two integer values, r and s. These are + both encoded in big-endian unsigned integers, zero-padded to + 32-octets each. These encoded values are concatenated into a single + 64-octet array consisting of the encoded value of r followed by the + encoded value of s. The resulting concatenation of (r, s) is byte + array of the HTTP message signature output used in Section 3.1. To verify using this algorithm, the verifier applies the ECDSA algorithm [FIPS186-4] using the public key portion of the verification key material and the signature input string re-created as described in Section 3.2. The hash function SHA-256 [RFC6234] is applied to the signature input string to create the digest content to - which the verification function is applied. The verifier extracts - the HTTP message signature to be verified (S) as described in - Section 3.2. The results of the verification function are compared - to the http message signature to determine if the signature presented - is valid. + which the signature verification function is applied, (M). The + verifier extracts the HTTP message signature to be verified (S) as + described in Section 3.2. This value is a 64-octet array consisting + of the encoded values of r and s concatenated in order. These are + both encoded in big-endian unsigned integers, zero-padded to + 32-octets each. The resulting signature value (r, s) is used as + input to the signature verification function. The results of the + verification function indicate if the signature presented is valid. + + Note that the output of ECDSA algorithms are non-deterministic, and + therefore it is not correct to re-calculate a new signature on the + signature input and compare the results to an existing signature. + Instead, the verification algorithm defined here needs to be used. + See Section 7.19. Use of this algorithm can be indicated at runtime using the ecdsa- p256-sha256 value for the alg signature parameter. -3.3.5. JSON Web Signature (JWS) algorithms +3.3.5. EdDSA using curve edwards25519 + + To sign using this algorithm, the signer applies the Ed25519 + algorithm Section 5.1.6 of [RFC8032] with the signer's private + signing key and the signature input string (Section 2.3). The + signature input string is taken as the input message (M) with no pre- + hash function. The signature is a 64-octet concatenation of R and S + as specified in Section 5.1.6 of [RFC8032], and this is taken as a + byte array for the HTTP message signature output used in Section 3.1. + + To verify using this algorithm, the signer applies the Ed25519 + algorithm Section 5.1.7 of [RFC8032] using the public key portion of + the verification key material (A) and the signature input string re- + created as described in Section 3.2. The signature input string is + taken as the input message (M) with no pre-hash function. The + signature to be verified is processed as the 64-octet concatenation + of R and S as specified in Section 5.1.7 of [RFC8032]. The results + of the verification function indicate if the signature presented is + valid. + + Use of this algorithm can be indicated at runtime using the ed25519 + value for the alg signature parameter. + +3.3.6. JSON Web Signature (JWS) algorithms If the signing algorithm is a JOSE signing algorithm from the JSON Web Signature and Encryption Algorithms Registry established by [RFC7518], the JWS algorithm definition determines the signature and hashing algorithms to apply for both signing and verification. For both signing and verification, the HTTP messages signature input string (Section 2.3) is used as the entire "JWS Signing Input". The JOSE Header defined in [RFC7517] is not used, and the signature input string is not first encoded in Base64 before applying the algorithm. @@ -1615,21 +1767,21 @@ generated from components within the HTTP message. Each member describes a single message signature. The member's name is an identifier that uniquely identifies the message signature within the context of the HTTP message. The member's value is the serialization of the covered components including all signature metadata parameters, using the serialization process defined in Section 2.2.1. NOTE: '\' line wrapping per RFC 8792 Signature-Input: sig1=("@method" "@target-uri" "host" "date" \ - "cache-control" "x-empty-header" "x-example");created=1618884475\ + "cache-control");created=1618884475\ ;keyid="test-key-rsa-pss" To facilitate signature validation, the Signature-Input field value MUST contain the same serialized value used in generating the signature input string's @signature-params value. The signer MAY include the Signature-Input field as a trailer to facilitate signing a message after its content has been processed by the signer. However, since intermediaries are allowed to drop trailers as per [SEMANTICS], it is RECOMMENDED that the Signature- @@ -1679,93 +1831,142 @@ they can be used to include multiple signatures within the same HTTP message by using distinct signature labels. These multiple signatures could be added all by the same signer or could come from several different signers. For example, a signer may include multiple signatures signing the same message components with different keys or algorithms to support verifiers with different capabilities, or a reverse proxy may include information about the client in fields when forwarding the request to a service host, including a signature over the client's original signature values. - The following is a non-normative example of header fields a reverse - proxy sets in addition to the examples in the previous sections. + The following is a non-normative example starts with a signed request + from the client. The proxy takes this request validates the client's + signature. NOTE: '\' line wrapping per RFC 8792 + POST /foo?param=Value&Pet=dog HTTP/1.1 + Host: example.com + Date: Tue, 20 Apr 2021 02:07:55 GMT + Content-Type: application/json + Content-Digest: sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+T\ + aPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: + Content-Length: 18 + Signature-Input: sig1=("@method" "@authority" "@path" \ + "content-digest" "content-length" "content-type")\ + ;created=1618884475;keyid="test-key-rsa-pss" + Signature: sig1=:LAH8BjcfcOcLojiuOBFWn0P5keD3xAOuJRGziCLuD8r5MW9S0\ + RoXXLzLSRfGY/3SF8kVIkHjE13SEFdTo4Af/fJ/Pu9wheqoLVdwXyY/UkBIS1M8Br\ + c8IODsn5DFIrG0IrburbLi0uCc+E2ZIIb6HbUJ+o+jP58JelMTe0QE3IpWINTEzpx\ + jqDf5/Df+InHCAkQCTuKsamjWXUpyOT1Wkxi7YPVNOjW4MfNuTZ9HdbD2Tr65+BXe\ + TG9ZS/9SWuXAc+BZ8WyPz0QRz//ec3uWXd7bYYODSjRAxHqX+S1ag3LZElYyUKaAI\ + jZ8MGOt4gXEwCSLDv/zqxZeWLj/PDkn6w==: + + {"hello": "world"} + + The proxy then alters the message before forwarding it on to the + origin server, changing the target host and adding the Forwarded + header defined in [RFC7239]. + + NOTE: '\' line wrapping per RFC 8792 + + POST /foo?param=Value&Pet=dog HTTP/1.1 + Host: origin.host.internal.example + Date: Tue, 20 Apr 2021 02:07:56 GMT + Content-Type: application/json + Content-Digest: sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+T\ + aPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: + Content-Length: 18 Forwarded: for=192.0.2.123 - Signature-Input: sig1=("@method" "@path" "@authority" \ - "cache-control" "x-empty-header" "x-example")\ + Signature-Input: sig1=("@method" "@authority" "@path" \ + "content-digest" "content-length" "content-type")\ ;created=1618884475;keyid="test-key-rsa-pss" - Signature: sig1=:P0wLUszWQjoi54udOtydf9IWTfNhy+r53jGFj9XZuP4uKwxyJo\ - 1RSHi+oEF1FuX6O29d+lbxwwBao1BAgadijW+7O/PyezlTnqAOVPWx9GlyntiCi\ - HzC87qmSQjvu1CFyFuWSjdGa3qLYYlNm7pVaJFalQiKWnUaqfT4LyttaXyoyZW8\ - 4jS8gyarxAiWI97mPXU+OVM64+HVBHmnEsS+lTeIsEQo36T3NFf2CujWARPQg53\ - r58RmpZ+J9eKR2CD6IJQvacn5A4Ix5BUAVGqlyp8JYm+S/CWJi31PNUjRRCusCV\ - Rj05NrxABNFv3r5S9IXf2fYJK+eyW4AiGVMvMcOg==: + Signature: sig1=:LAH8BjcfcOcLojiuOBFWn0P5keD3xAOuJRGziCLuD8r5MW9S0\ + RoXXLzLSRfGY/3SF8kVIkHjE13SEFdTo4Af/fJ/Pu9wheqoLVdwXyY/UkBIS1M8Br\ + c8IODsn5DFIrG0IrburbLi0uCc+E2ZIIb6HbUJ+o+jP58JelMTe0QE3IpWINTEzpx\ + jqDf5/Df+InHCAkQCTuKsamjWXUpyOT1Wkxi7YPVNOjW4MfNuTZ9HdbD2Tr65+BXe\ + TG9ZS/9SWuXAc+BZ8WyPz0QRz//ec3uWXd7bYYODSjRAxHqX+S1ag3LZElYyUKaAI\ + jZ8MGOt4gXEwCSLDv/zqxZeWLj/PDkn6w==: - The client's request includes a signature value under the label sig1, - which the proxy signs in addition to the Forwarded header defined in - [RFC7239]. Note that since the client's signature already covers the - client's Signature-Input value for sig1, this value is transitively - covered by the proxy's signature and need not be added explicitly. - This results in a signature input string of: + {"hello": "world"} + The proxy includes the client's signature value under the label sig1, + which the proxy signs in addition to the Forwarded header. Note that + since the client's signature already covers the client's Signature- + Input value for sig1, this value is transitively covered by the + proxy's signature and need not be added explicitly. The proxy + identifies its own key and algorithm and, in this example, includes + an expiration for the signature to indicate to downstream systems + that the proxy will not vouch for this signed message past this short + time window. This results in a signature input string of: NOTE: '\' line wrapping per RFC 8792 - "signature";key="sig1": :P0wLUszWQjoi54udOtydf9IWTfNhy+r53jGFj9XZuP\ - 4uKwxyJo1RSHi+oEF1FuX6O29d+lbxwwBao1BAgadijW+7O/PyezlTnqAOVPWx9Gl\ - yntiCiHzC87qmSQjvu1CFyFuWSjdGa3qLYYlNm7pVaJFalQiKWnUaqfT4LyttaXyo\ - yZW84jS8gyarxAiWI97mPXU+OVM64+HVBHmnEsS+lTeIsEQo36T3NFf2CujWARPQg\ - 53r58RmpZ+J9eKR2CD6IJQvacn5A4Ix5BUAVGqlyp8JYm+S/CWJi31PNUjRRCusCV\ - Rj05NrxABNFv3r5S9IXf2fYJK+eyW4AiGVMvMcOg==: + "signature";key="sig1": :LAH8BjcfcOcLojiuOBFWn0P5keD3xAOuJRGziCLuD8\ + r5MW9S0RoXXLzLSRfGY/3SF8kVIkHjE13SEFdTo4Af/fJ/Pu9wheqoLVdwXyY/UkB\ + IS1M8Brc8IODsn5DFIrG0IrburbLi0uCc+E2ZIIb6HbUJ+o+jP58JelMTe0QE3IpW\ + INTEzpxjqDf5/Df+InHCAkQCTuKsamjWXUpyOT1Wkxi7YPVNOjW4MfNuTZ9HdbD2T\ + r65+BXeTG9ZS/9SWuXAc+BZ8WyPz0QRz//ec3uWXd7bYYODSjRAxHqX+S1ag3LZEl\ + YyUKaAIjZ8MGOt4gXEwCSLDv/zqxZeWLj/PDkn6w==: "forwarded": for=192.0.2.123 "@signature-params": ("signature";key="sig1" "forwarded")\ - ;created=1618884480;keyid="test-key-rsa";alg="rsa-v1_5-sha256" + ;created=1618884480;expires=1618884540;keyid="test-key-rsa"\ + ;alg="rsa-v1_5-sha256" And a signature output value of: NOTE: '\' line wrapping per RFC 8792 - cjGvZwbsq9JwexP9TIvdLiivxqLINwp/ybAc19KOSQuLvtmMt3EnZxNiE+797dXK2cj\ - PPUFqoZxO8WWx1SnKhAU9SiXBr99NTXRmA1qGBjqus/1Yxwr8keB8xzFt4inv3J3zP0\ - k6TlLkRJstkVnNjuhRIUA/ZQCo8jDYAl4zWJJjppy6Gd1XSg03iUa0sju1yj6rcKbMA\ - BBuzhUz4G0u1hZkIGbQprCnk/FOsqZHpwaWvY8P3hmcDHkNaavcokmq+3EBDCQTzgwL\ - qfDmV0vLCXtDda6CNO2Zyum/pMGboCnQn/VkQ+j8kSydKoFg6EbVuGbrQijth6I0dDX\ - 2/HYcJg== + G1WLTL4/9PGSKEQbSAMypZNk+I2dpLJ6qvl2JISahlP31OO/QEUd8/HdO2O7vYLi5k3\ + JIiAK3UPK4U+kvJZyIUidsiXlzRI+Y2se3SGo0D8dLfhG95bKr6ukYXl60QHpsGRTfS\ + iwdtvYKXGpKNrMlISJYd+oGrGRyI9gbCy0aFhc6I/okIMLeK4g9PgzpC3YTwhUQ98KI\ + BNLWHgREfBgJxjPbxFlsgJ9ykPviLj8GKJ81HwsK3XM9P7WaS7fMGOt8h1kSqgkZQB9\ + YqiIo+WhHvJa7iPy8QrYFKzx9BBEY6AwfStZAsXXz3LobZseyxsYcLJLs8rY0wVA9NP\ + sxKrHGA== + These values are added to the HTTP request message by the proxy. The original signature is included under the identifier sig1, and the reverse proxy's signature is included under the label proxy_sig. The proxy uses the key test-key-rsa to create its signature using the rsa-v1_5-sha256 signature algorithm, while the client's original signature was made using the key id of test-key-rsa-pss and an RSA PSS signature algorithm. NOTE: '\' line wrapping per RFC 8792 + POST /foo?param=Value&Pet=dog HTTP/1.1 + Host: origin.host.internal.example + Date: Tue, 20 Apr 2021 02:07:56 GMT + Content-Type: application/json + Content-Digest: sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+T\ + aPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: + Content-Length: 18 Forwarded: for=192.0.2.123 - Signature-Input: sig1=("@method" "@path" "@authority" \ - "cache-control" "x-empty-header" "x-example")\ + Signature-Input: sig1=("@method" "@authority" "@path" \ + "content-digest" "content-length" "content-type")\ ;created=1618884475;keyid="test-key-rsa-pss", \ proxy_sig=("signature";key="sig1" "forwarded")\ - ;created=1618884480;keyid="test-key-rsa";alg="rsa-v1_5-sha256" - Signature: sig1=:P0wLUszWQjoi54udOtydf9IWTfNhy+r53jGFj9XZuP4uKwxyJo\ - 1RSHi+oEF1FuX6O29d+lbxwwBao1BAgadijW+7O/PyezlTnqAOVPWx9GlyntiCi\ - HzC87qmSQjvu1CFyFuWSjdGa3qLYYlNm7pVaJFalQiKWnUaqfT4LyttaXyoyZW8\ - 4jS8gyarxAiWI97mPXU+OVM64+HVBHmnEsS+lTeIsEQo36T3NFf2CujWARPQg53\ - r58RmpZ+J9eKR2CD6IJQvacn5A4Ix5BUAVGqlyp8JYm+S/CWJi31PNUjRRCusCV\ - Rj05NrxABNFv3r5S9IXf2fYJK+eyW4AiGVMvMcOg==:, \ - proxy_sig=:cjGvZwbsq9JwexP9TIvdLiivxqLINwp/ybAc19KOSQuLvtmMt3EnZx\ - NiE+797dXK2cjPPUFqoZxO8WWx1SnKhAU9SiXBr99NTXRmA1qGBjqus/1Yxwr8k\ - eB8xzFt4inv3J3zP0k6TlLkRJstkVnNjuhRIUA/ZQCo8jDYAl4zWJJjppy6Gd1X\ - Sg03iUa0sju1yj6rcKbMABBuzhUz4G0u1hZkIGbQprCnk/FOsqZHpwaWvY8P3hm\ - cDHkNaavcokmq+3EBDCQTzgwLqfDmV0vLCXtDda6CNO2Zyum/pMGboCnQn/VkQ+\ - j8kSydKoFg6EbVuGbrQijth6I0dDX2/HYcJg==: + ;created=1618884480;expires=1618884540;keyid="test-key-rsa"\ + ;alg="rsa-v1_5-sha256" + Signature: sig1=:LAH8BjcfcOcLojiuOBFWn0P5keD3xAOuJRGziCLuD8r5MW9S0\ + RoXXLzLSRfGY/3SF8kVIkHjE13SEFdTo4Af/fJ/Pu9wheqoLVdwXyY/UkBIS1M8\ + Brc8IODsn5DFIrG0IrburbLi0uCc+E2ZIIb6HbUJ+o+jP58JelMTe0QE3IpWINT\ + EzpxjqDf5/Df+InHCAkQCTuKsamjWXUpyOT1Wkxi7YPVNOjW4MfNuTZ9HdbD2Tr\ + 65+BXeTG9ZS/9SWuXAc+BZ8WyPz0QRz//ec3uWXd7bYYODSjRAxHqX+S1ag3LZE\ + lYyUKaAIjZ8MGOt4gXEwCSLDv/zqxZeWLj/PDkn6w==:, \ + proxy_sig=:G1WLTL4/9PGSKEQbSAMypZNk+I2dpLJ6qvl2JISahlP31OO/QEUd8/\ + HdO2O7vYLi5k3JIiAK3UPK4U+kvJZyIUidsiXlzRI+Y2se3SGo0D8dLfhG95bKr\ + 6ukYXl60QHpsGRTfSiwdtvYKXGpKNrMlISJYd+oGrGRyI9gbCy0aFhc6I/okIML\ + eK4g9PgzpC3YTwhUQ98KIBNLWHgREfBgJxjPbxFlsgJ9ykPviLj8GKJ81HwsK3X\ + M9P7WaS7fMGOt8h1kSqgkZQB9YqiIo+WhHvJa7iPy8QrYFKzx9BBEY6AwfStZAs\ + XXz3LobZseyxsYcLJLs8rY0wVA9NPsxKrHGA==: + + {"hello": "world"} The proxy's signature and the client's original signature can be verified independently for the same message, based on the needs of the application. Since the proxy's signature covers the client signature, the backend service fronted by the proxy can trust that the proxy has validated the incoming signature. 5. Requesting Signatures While a signer is free to attach a signature to a request or response @@ -1809,21 +2010,21 @@ signature. The member's name is an identifier that uniquely identifies the requested message signature within the context of the target HTTP message. The member's value is the serialization of the desired covered components of the target message, including any allowed signature metadata parameters, using the serialization process defined in Section 2.2.1. NOTE: '\' line wrapping per RFC 8792 Accept-Signature: sig1=("@method" "@target-uri" "host" "date" \ - "cache-control" "x-empty-header" "x-example")\ + "cache-control")\ ;keyid="test-key-rsa-pss" The requested signature MAY include parameters, such as a desired algorithm or key identifier. These parameters MUST NOT include parameters that the signer is expected to generate, including the created and nonce parameters. 5.2. Processing an Accept-Signature The receiver of an Accept-Signature field fulfills that header as @@ -1932,20 +2133,24 @@ | | | | Section 3.3.2 | +-------------------+--------+-------------------+---------------+ | hmac-sha256 | Active | HMAC using | [[This | | | | SHA-256 | document]], | | | | | Section 3.3.3 | +-------------------+--------+-------------------+---------------+ | ecdsa-p256-sha256 | Active | ECDSA using curve | [[This | | | | P-256 DSS and | document]], | | | | SHA-256 | Section 3.3.4 | +-------------------+--------+-------------------+---------------+ + | ed25519 | Active | Edwards Curve DSA | [[This | + | | | using curve | document]], | + | | | edwards25519 | Section 3.3.5 | + +-------------------+--------+-------------------+---------------+ Table 1 6.2. HTTP Signature Metadata Parameters Registry This document defines the signature parameters structure, the values of which may have parameters containing metadata about a message signature. IANA is asked to create and maintain a new registry titled "HTTP Signature Metadata Parameters" to record and maintain the set of parameters defined for use with member values in the @@ -1998,69 +2203,69 @@ | | signing and verification keys | this document | | | used to create this signature | | +---------+-------------------------------+------------------+ | nonce | A single-use nonce value | Section 2.2.1 of | | | | this document | +---------+-------------------------------+------------------+ Table 2: Initial contents of the HTTP Signature Metadata Parameters Registry. -6.3. HTTP Signature Specialty Component Identifiers Registry +6.3. HTTP Signature Derived Component Identifiers Registry This document defines a method for canonicalizing HTTP message components, including components that can be derived from the context of the HTTP message outside of the HTTP fields. These components are identified by a unique string, known as the component identifier. - Component identifiers for specialty components always start with the + Component identifiers for derived components always start with the "@" (at) symbol to distinguish them from HTTP header fields. IANA is asked to create and maintain a new registry typed "HTTP Signature - Specialty Component Identifiers" to record and maintain the set of - non-field component identifiers and the methods to produce their + Derived Component Identifiers" to record and maintain the set of non- + field component identifiers and the methods to produce their associated component values. Initial values for this registry are given in Section 6.3.2. Future assignments and modifications to existing assignments are to be made through the Expert Review registration policy [RFC8126] and shall follow the template presented in Section 6.3.1. 6.3.1. Registration Template Identifier: - An identifier for the HTTP specialty component identifier. The - name MUST begin with the "@" character followed by an ASCII string + An identifier for the HTTP derived component identifier. The name + MUST begin with the "@" character followed by an ASCII string consisting only of lower-case characters ("a" - "z"), digits ("0" - "9"), and hyphens ("-"), and SHOULD NOT exceed 20 characters in length. The identifier MUST be unique within the context of the registry. Status: A brief text description of the status of the algorithm. The description MUST begin with one of "Active" or "Deprecated", and MAY provide further context or explanation as to the reason for the status. Target: - The valid message targets for the specialty parameter. MUST be - one of the values "Request", "Request, Response", "Request, - Related-Response", or "Related-Response". The semantics of these - are defined in Section 2.2. + The valid message targets for the derived parameter. MUST be one + of the values "Request", "Request, Response", "Request, Related- + Response", or "Related-Response". The semantics of these are + defined in Section 2.2. Specification document(s): Reference to the document(s) that specify the token endpoint authorization method, preferably including a URI that can be used to retrieve a copy of the document(s). An indication of the relevant sections may also be included but is not required. 6.3.2. Initial Contents The table below contains the initial contents of the HTTP Signature - Specialty Component Identifiers Registry. + Derived Component Identifiers Registry. +===================+========+==================+==================+ | Identifier | Status | Target | Specification | | | | | document(s) | +===================+========+==================+==================+ | @signature-params | Active | Request, | Section 2.2.1 of | | | | Response | this document | +-------------------+--------+------------------+------------------+ | @method | Active | Request, | Section 2.2.2 of | | | | Related-Response | this document | @@ -2086,29 +2291,30 @@ | @query-params | Active | Request, | Section 2.2.9 of | | | | Related-Response | this document | +-------------------+--------+------------------+------------------+ | @status | Active | Response | Section 2.2.10 | | | | | of this document | +-------------------+--------+------------------+------------------+ | @request-response | Active | Related-Response | Section 2.2.11 | | | | | of this document | +-------------------+--------+------------------+------------------+ - Table 3: Initial contents of the HTTP Signature Specialty Component - Identifiers Registry. + Table 3: Initial contents of the HTTP Signature Derived + Component Identifiers Registry. 7. Security Considerations In order for an HTTP message to be considered covered by a signature, all of the following conditions have to be true: * a signature is expected or allowed on the message by the verifier + * the signature exists on the message * the signature is verified against the identified key material and algorithm * the key material and algorithm are appropriate for the context of the message * the signature is within expected time boundaries @@ -2371,24 +2577,24 @@ Some message components are expressed in different ways across HTTP versions. For example, the authority of the request target is sent using the Host header field in HTTP 1.1 but with the :authority pseudo-header in HTTP 2. If a signer sends an HTTP 1.1 message and signs the Host field, but the message is translated to HTTP 2 before it reaches the verifier, the signature will not validate as the Host header field could be dropped. It is for this reason that HTTP Message Signatures defines a set of - specialty components that define a single way to get value in - question, such as the @authority specialty component identifier - (Section 2.2.4). Applications should therefore prefer specialty - component identifiers for such options where possible. + derived components that define a single way to get value in question, + such as the @authority derived component identifier (Section 2.2.4) + in lieu of the Host header field. Applications should therefore + prefer derived component identifiers for such options where possible. 7.15. Key and Algorithm Specification Downgrades Applications of this specification need to protect against key specification downgrade attacks. For example, the same RSA key can be used for both RSA-PSS and RSA v1.5 signatures. If an application expects a key to only be used with RSA-PSS, it needs to reject signatures for that key using the weaker RSA 1.5 specification. Another example of a downgrade attack occurs when an asymmetric @@ -2403,21 +2609,21 @@ specification does allow runtime specification of the algorithm using the alg signature parameter, applications are encouraged to use other mechanisms such as static configuration or higher protocol-level algorithm specification instead. 7.16. Parsing Structured Field Values Several parts of this specification rely on the parsing of structured field values [RFC8941]. In particular, normalization of HTTP structured field values (Section 2.1.1), referencing members of a - dictionary structured field (Section 2.1.3), and processing the + dictionary structured field (Section 2.1.2), and processing the @signature-input value when verifying a signature (Section 3.2). While structured field values are designed to be relatively simple to parse, a naive or broken implementation of such a parser could lead to subtle attack surfaces being exposed in the implementation. For example, if a buggy parser of the @signature-input value does not enforce proper closing of quotes around string values within the list of component identifiers, an attacker could take advantage of this and inject additional content into the signature input string through manipulating the Signature-Input field value on a message. @@ -2447,20 +2653,55 @@ Some components are expected to be changed by intermediaries and ought not to be signed under most circumstance. The Via and Forwarded header fields, for example, are expected to be manipulated by proxies and other middle-boxes, including replacing or entirely dropping existing values. These fields should not be covered by the signature except in very limited and tightly-coupled scenarios. Additional considerations for choosing signature aspects are discussed in Section 1.5. +7.18. Confusing HTTP Field Names for Derived Component Identifiers + + The definition of HTTP field names does not allow for the use of the + @ character anywhere in the name. As such, since all derived + component identifiers start with the @ character, these namespaces + should be completely separate. However, some HTTP implementations + are not sufficiently strict about the characters accepted in HTTP + headers. In such implementations, a sender (or attacker) could + inject a header field starting with an @ character and have it passed + through to the application code. These invalid header fields could + be used to override a portion of the derived message content and + substitute an arbitrary value, providing a potential place for an + attacker to mount a signature collision (Section 7.5) attack. + + To combat this, when selecting values for a message component, if the + component identifier starts with the @ character, it needs to be + processed as a derived component and never taken as a fields. Only + if the component identifier does not start with the @ character can + it be taken from the fields of the message. The algorithm discussed + in Section 2.3 provides a safe order of operations. + +7.19. Non-deterministic Signature Primitives + + Some cryptographic primitives such as RSA PSS and ECDSA have non- + deterministic outputs, which include some amount of entropy within + the algorithm. For such algorithms, multiple signatures generated in + succession will not match. A lazy implementation of a verifier could + ignore this distinction and simply check for the same value being + created by re-signing the signature input. Such an implementation + would work for deterministic algorithms such as HMAC and EdDSA but + fail to verify valid signatures made using non-deterministic + algorithms. It is therefore important that a verifier always use the + correctly-defined verification function for the algorithm in question + and not do a simple comparison. + 8. Privacy Considerations 8.1. Identification through Keys If a signer uses the same key with multiple verifiers, or uses the same key over time with a single verifier, the ongoing use of that key can be used to track the signer throughout the set of verifiers that messages are sent to. Since cryptographic keys are meant to be functionally unique, the use of the same key over time is a strong indicator that it is the same party signing multiple messages. @@ -2548,20 +2789,43 @@ [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005, . + [RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms + (SHA and SHA-based HMAC and HKDF)", RFC 6234, + DOI 10.17487/RFC6234, May 2011, + . + + [RFC7517] Jones, M., "JSON Web Key (JWK)", RFC 7517, + DOI 10.17487/RFC7517, May 2015, + . + + [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, + DOI 10.17487/RFC7518, May 2015, + . + + [RFC8017] Moriarty, K., Ed., Kaliski, B., Jonsson, J., and A. Rusch, + "PKCS #1: RSA Cryptography Specifications Version 2.2", + RFC 8017, DOI 10.17487/RFC8017, November 2016, + . + + [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital + Signature Algorithm (EdDSA)", RFC 8032, + DOI 10.17487/RFC8032, January 2017, + . + [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, . [RFC8792] Watsen, K., Auerswald, E., Farrel, A., and Q. Wu, "Handling Long Lines in Content of Internet-Drafts and RFCs", RFC 8792, DOI 10.17487/RFC8792, June 2020, . [RFC8941] Nottingham, M. and P-H. Kamp, "Structured Field Values for @@ -2582,49 +2846,29 @@ Security (TLS) and Datagram Transport Layer Security (DTLS)", BCP 195, RFC 7525, May 2015. Moriarty, K. and S. Farrell, "Deprecating TLS 1.0 and TLS 1.1", BCP 195, RFC 8996, March 2021. [I-D.ietf-httpbis-client-cert-field] Campbell, B. and M. Bishop, "Client-Cert HTTP Header - Field: Conveying Client Certificate Information from TLS - Terminating Reverse Proxies to Origin Server - Applications", Work in Progress, Internet-Draft, draft- - ietf-httpbis-client-cert-field-00, 8 June 2021, + Field", Work in Progress, Internet-Draft, draft-ietf- + httpbis-client-cert-field-01, 25 January 2022, . - - [RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms - (SHA and SHA-based HMAC and HKDF)", RFC 6234, - DOI 10.17487/RFC6234, May 2011, - . + client-cert-field-01>. [RFC7239] Petersson, A. and M. Nilsson, "Forwarded HTTP Extension", RFC 7239, DOI 10.17487/RFC7239, June 2014, . - [RFC7517] Jones, M., "JSON Web Key (JWK)", RFC 7517, - DOI 10.17487/RFC7517, May 2015, - . - - [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, - DOI 10.17487/RFC7518, May 2015, - . - - [RFC8017] Moriarty, K., Ed., Kaliski, B., Jonsson, J., and A. Rusch, - "PKCS #1: RSA Cryptography Specifications Version 2.2", - RFC 8017, DOI 10.17487/RFC8017, November 2016, - . - [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for Writing an IANA Considerations Section in RFCs", BCP 26, RFC 8126, DOI 10.17487/RFC8126, June 2017, . [TLS] Rescorla, E., "The Transport Layer Security (TLS) Protocol Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, . Appendix A. Detecting HTTP Message Signatures @@ -2762,201 +3006,284 @@ B.1.4. Example Shared Secret The following shared secret is 64 randomly-generated bytes encoded in Base64, referred to in this document as test-shared-secret. NOTE: '\' line wrapping per RFC 8792 uzvJfB4u3N0Jy4T7NZ75MDVcr8zSTInedJtkgcu46YW4XByzNJjxBdtjUkdJPBt\ bmHhIDi6pcl8jsasjlTMtDQ== +B.1.5. Example Ed25519 Test Key + + The following key is an elliptical curve key over the Edwards curve + ed25519, referred to in this document as test-key-edd25519. + + -----BEGIN PRIVATE KEY----- + MC4CAQAwBQYDK2VwBCIEIJ+DYvh6SEqVTm50DFtMDoQikTmiCqirVv9mWG9qfSnF + -----END PRIVATE KEY----- + + -----BEGIN PUBLIC KEY----- + MCowBQYDK2VwAyEAJrQLj5P/89iXES9+vFgrIy29clF9CC/oPPsw3c5D0bs= + -----END PUBLIC KEY----- + B.2. Test Cases This section provides non-normative examples that may be used as test cases to validate implementation correctness. These examples are based on the following HTTP messages: For requests, this test-request message is used: - POST /foo?param=value&pet=dog HTTP/1.1 + POST /foo?param=Value&Pet=dog HTTP/1.1 Host: example.com Date: Tue, 20 Apr 2021 02:07:55 GMT Content-Type: application/json - Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= + Content-Digest: sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+T\ + aPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: Content-Length: 18 {"hello": "world"} For responses, this test-response message is used: HTTP/1.1 200 OK Date: Tue, 20 Apr 2021 02:07:56 GMT Content-Type: application/json - Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= - Content-Length: 18 + Content-Digest: sha-512=:JlEy2bfUz7WrWIjc1qV6KVLpdr/7L5/L4h7Sxvh6sN\ + HpDQWDCL+GauFQWcZBvVDhiyOnAQsxzZFYwi0wDH+1pw==: + Content-Length: 23 - {"hello": "world"} + {"message": "good dog"} B.2.1. Minimal Signature Using rsa-pss-sha512 - This example presents a minimal Signature-Input and Signature header - for a signature using the rsa-pss-sha512 algorithm over test-request, - covering none of the components of the HTTP message request but - providing a timestamped signature proof of possession of the key. + This example presents a minimal signature using the rsa-pss-sha512 + algorithm over test-request, covering none of the components of the + HTTP message, but providing a timestamped signature proof of + possession of the key with a signer-provided nonce. The corresponding signature input is: NOTE: '\' line wrapping per RFC 8792 - "@signature-params": ();created=1618884475\ - ;keyid="test-key-rsa-pss";alg="rsa-pss-sha512" + "@signature-params": ();created=1618884473;keyid="test-key-rsa-pss"\ + ;nonce="b3k2pp5k7z-50gnwp.yemd" This results in the following Signature-Input and Signature headers - being added to the message: + being added to the message under the signature label sig-b21: NOTE: '\' line wrapping per RFC 8792 - Signature-Input: sig1=();created=1618884475\ - ;keyid="test-key-rsa-pss";alg="rsa-pss-sha512" - Signature: sig1=:HWP69ZNiom9Obu1KIdqPPcu/C1a5ZUMBbqS/xwJECV8bhIQVmE\ - AAAzz8LQPvtP1iFSxxluDO1KE9b8L+O64LEOvhwYdDctV5+E39Jy1eJiD7nYREBgx\ - TpdUfzTO+Trath0vZdTylFlxK4H3l3s/cuFhnOCxmFYgEa+cw+StBRgY1JtafSFwN\ - cZgLxVwialuH5VnqJS4JN8PHD91XLfkjMscTo4jmVMpFd3iLVe0hqVFl7MDt6TMkw\ - IyVFnEZ7B/VIQofdShO+C/7MuupCSLVjQz5xA+Zs6Hw+W9ESD/6BuGs6LF1TcKLxW\ - +5K+2zvDY/Cia34HNpRW5io7Iv9/b7iQ==: + Signature-Input: sig-b21=();created=1618884473\ + ;keyid="test-key-rsa-pss";nonce="b3k2pp5k7z-50gnwp.yemd" + Signature: sig-b21=:d2pmTvmbncD3xQm8E9ZV2828BjQWGgiwAaw5bAkgibUopem\ + LJcWDy/lkbbHAve4cRAtx31Iq786U7it++wgGxbtRxf8Udx7zFZsckzXaJMkA7ChG\ + 52eSkFxykJeNqsrWH5S+oxNFlD4dzVuwe8DhTSja8xxbR/Z2cOGdCbzR72rgFWhzx\ + 2VjBqJzsPLMIQKhO4DGezXehhWwE56YCE+O6c0mKZsfxVrogUvA4HELjVKWmAvtl6\ + UnCh8jYzuVG5WSb/QEVPnP5TmcAnLH1g+s++v6d4s8m0gCw1fV5/SITLq9mhho8K3\ + +7EPYTU8IU1bLhdxO5Nyt8C8ssinQ98Xw9Q==: Note that since the covered components list is empty, this signature - could be applied by an attacker to an unrelated HTTP message. + could be applied by an attacker to an unrelated HTTP message. In + this example, the nonce parameter is included to prevent the same + signature from being replayed more than once, but if an attacker + intercepts the signature and prevents its delivery to the verifier, + the attacker could apply this signature to another message. Therefore, use of an empty covered components set is discouraged. + See Section 7.4 for more discussion. + + Note that the RSA PSS algorithm in use here is non-deterministic, + meaning a different signature value will be created every time the + algorithm is run. The signature value provided here can be validated + against the given keys, but newly-generated signature values are not + expected to match the example. See Section 7.19. B.2.2. Selective Covered Components using rsa-pss-sha512 This example covers additional components in test-request using the rsa-pss-sha512 algorithm. The corresponding signature input is: NOTE: '\' line wrapping per RFC 8792 "@authority": example.com - "content-type": application/json - "@signature-params": ("@authority" "content-type")\ - ;created=1618884475;keyid="test-key-rsa-pss" + "content-digest": sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX\ + +TaPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: + "@signature-params": ("@authority" "content-digest")\ + ;created=1618884473;keyid="test-key-rsa-pss" This results in the following Signature-Input and Signature headers - being added to the message: + being added to the message under the label sig-b22: NOTE: '\' line wrapping per RFC 8792 - Signature-Input: sig1=("@authority" "content-type")\ - ;created=1618884475;keyid="test-key-rsa-pss" - Signature: sig1=:ik+OtGmM/kFqENDf9Plm8AmPtqtC7C9a+zYSaxr58b/E6h81gh\ - JS3PcH+m1asiMp8yvccnO/RfaexnqanVB3C72WRNZN7skPTJmUVmoIeqZncdP2mlf\ - xlLP6UbkrgYsk91NS6nwkKC6RRgLhBFqzP42oq8D2336OiQPDAo/04SxZt4Wx9nDG\ - uy2SfZJUhsJqZyEWRk4204x7YEB3VxDAAlVgGt8ewilWbIKKTOKp3ymUeQIwptqYw\ - v0l8mN404PPzRBTpB7+HpClyK4CNp+SVv46+6sHMfJU4taz10s/NoYRmYCGXyadzY\ - YDj0BYnFdERB6NblI/AOWFGl5Axhhmjg==: + Signature-Input: sig-b22=("@authority" "content-digest")\ + ;created=1618884473;keyid="test-key-rsa-pss" + Signature: sig-b22=:Fee1uy9YGZq5UUwwYU6vz4dZNvfw3GYrFl1L6YlVIyUMuWs\ + wWDNSvql4dVtSeidYjYZUm7SBCENIb5KYy2ByoC3bI+7gydd2i4OAT5lyDtmeapnA\ + a8uP/b9xUpg+VSPElbBs6JWBIQsd+nMdHDe+ls/IwVMwXktC37SqsnbNyhNp6kcvc\ + WpevjzFcD2VqdZleUz4jN7P+W5A3wHiMGfIjIWn36KXNB+RKyrlGnIS8yaBBrom5r\ + cZWLrLbtg6VlrH1+/07RV+kgTh/l10h8qgpl9zQHu7mWbDKTq0tJ8K4ywcPoC4s2I\ + 4rU88jzDKDGdTTQFZoTVZxZmuTM1FvHfzIw==: + + Note that the RSA PSS algorithm in use here is non-deterministic, + meaning a different signature value will be created every time the + algorithm is run. The signature value provided here can be validated + against the given keys, but newly-generated signature values are not + expected to match the example. See Section 7.19. B.2.3. Full Coverage using rsa-pss-sha512 - This example covers all headers in test-request (including the - message body Digest) plus various elements of the control data, using - the rsa-pss-sha512 algorithm. + This example covers all applicable in test-request (including the + content type and length) plus many derived components, again using + the rsa-pss-sha512 algorithm. Note that the Host header field is not + covered because the @authority derived component is included instead. The corresponding signature input is: NOTE: '\' line wrapping per RFC 8792 - "date": Tue, 20 Apr 2021 02:07:56 GMT + "date": Tue, 20 Apr 2021 02:07:55 GMT "@method": POST "@path": /foo - "@query": ?param=value&pet=dog + "@query": param=Value&Pet=dog "@authority": example.com "content-type": application/json - "digest": SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= + "content-digest": sha-512=:WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX\ + +TaPm+AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==: "content-length": 18 "@signature-params": ("date" "@method" "@path" "@query" \ - "@authority" "content-type" "digest" "content-length")\ - ;created=1618884475;keyid="test-key-rsa-pss" + "@authority" "content-type" "content-digest" "content-length")\ + ;created=1618884473;keyid="test-key-rsa-pss" This results in the following Signature-Input and Signature headers - being added to the message: + being added to the message under the label sig-b23: NOTE: '\' line wrapping per RFC 8792 - Signature-Input: sig1=("date" "@method" "@path" "@query" \ - "@authority" "content-type" "digest" "content-length")\ - ;created=1618884475;keyid="test-key-rsa-pss" - Signature: sig1=:JuJnJMFGD4HMysAGsfOY6N5ZTZUknsQUdClNG51VezDgPUOW03\ - QMe74vbIdndKwW1BBrHOHR3NzKGYZJ7X3ur23FMCdANe4VmKb3Rc1Q/5YxOO8p7Ko\ - yfVa4uUcMk5jB9KAn1M1MbgBnqwZkRWsbv8ocCqrnD85Kavr73lx51k1/gU8w673W\ - T/oBtxPtAn1eFjUyIKyA+XD7kYph82I+ahvm0pSgDPagu917SlqUjeaQaNnlZzO03\ - Iy1RZ5XpgbNeDLCqSLuZFVID80EohC2CQ1cL5svjslrlCNstd2JCLmhjL7xV3NYXe\ - rLim4bqUQGRgDwNJRnqobpS6C1NBns/Q==: + Signature-Input: sig-b23=("date" "@method" "@path" "@query" \ + "@authority" "content-type" "content-digest" "content-length")\ + ;created=1618884473;keyid="test-key-rsa-pss" + Signature: sig-b23=:f9nOGJSjCdQ/t+/Mp7gpAHU7Kn1LpnWJE6W2081yRFITJob\ + BDODwQNxnjiIdAGstfGKuM2vlc5SyN16//K5dBLGoiaboMco4J6R0zS+8oXqD7o6K\ + RpIZR/qMrFc5Bu6f6UxuoWZPfCxhs3vxL/60JbF8dcdul1b77mWyC07ZjZ9VkelBy\ + eF5+zN7v6Al/vnBzMS3H1NLz9dI2sw5Vb7kxQQ6CvEI9v3R30aFgWz4rCuyT0Kt3y\ + tQvTHOBsadF66eDe641Sd6O/DgbdFibsE/+ToYopL9NlAuva42NlcFemrozvOKvGI\ + PXdAPqmng/bePoSR6DIaFbWp5aDlNSbWlcA==: Note in this example that the value of the Date header and the value of the created signature parameter need not be the same. This is due to the fact that the Date header is added when creating the HTTP Message and the created parameter is populated when creating the signature over that message, and these two times could vary. If the Date header is covered by the signature, it is up to the verifier to determine whether its value has to match that of the created parameter or not. + Note that the RSA PSS algorithm in use here is non-deterministic, + meaning a different signature value will be created every time the + algorithm is run. The signature value provided here can be validated + against the given keys, but newly-generated signature values are not + expected to match the example. See Section 7.19. + B.2.4. Signing a Response using ecdsa-p256-sha256 This example covers portions of the test-response response message using the ecdsa-p256-sha256 algorithm and the key test-key-ecc-p256. The corresponding signature input is: NOTE: '\' line wrapping per RFC 8792 + "@status": 200 "content-type": application/json - "digest": SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= - "content-length": 18 - "@signature-params": ("content-type" "digest" "content-length")\ - ;created=1618884475;keyid="test-key-ecc-p256" + "content-digest": sha-512=:JlEy2bfUz7WrWIjc1qV6KVLpdr/7L5/L4h7Sxvh6\ + sNHpDQWDCL+GauFQWcZBvVDhiyOnAQsxzZFYwi0wDH+1pw==: + "content-length": 23 + "@signature-params": ("@status" "content-type" "content-digest" \ + "content-length");created=1618884473;keyid="test-key-ecc-p256" This results in the following Signature-Input and Signature headers - being added to the message: + being added to the message under the label sig-b24: NOTE: '\' line wrapping per RFC 8792 - Signature-Input: sig1=("content-type" "digest" "content-length")\ - ;created=1618884475;keyid="test-key-ecc-p256" - Signature: sig1=:n8RKXkj0iseWDmC6PNSQ1GX2R9650v+lhbb6rTGoSrSSx18zmn\ - 6fPOtBx48/WffYLO0n1RHHf9scvNGAgGq52Q==: + Signature-Input: sig-b24=("@status" "content-type" \ + "content-digest" "content-length");created=1618884473\ + ;keyid="test-key-ecc-p256" + Signature: sig-b24=:0Ry6HsvzS5VmA6HlfBYS/fYYeNs7fYuA7s0tAdxfUlPGv0C\ + SVuwrrzBOjcCFHTxVRJ01wjvSzM2BetJauj8dsw==: + + Note that the ECDSA algorithm in use here is non-deterministic, + meaning a different signature value will be created every time the + algorithm is run. The signature value provided here can be validated + against the given keys, but newly-generated signature values are not + expected to match the example. See Section 7.19. B.2.5. Signing a Request using hmac-sha256 This example covers portions of the test-request using the hmac- sha256 algorithm and the secret test-shared-secret. The corresponding signature input is: NOTE: '\' line wrapping per RFC 8792 + "date": Tue, 20 Apr 2021 02:07:55 GMT "@authority": example.com + "content-type": application/json + "@signature-params": ("date" "@authority" "content-type")\ + ;created=1618884473;keyid="test-shared-secret" + + This results in the following Signature-Input and Signature headers + being added to the message under the label sig-b25: + + NOTE: '\' line wrapping per RFC 8792 + + Signature-Input: sig-b25=("date" "@authority" "content-type")\ + ;created=1618884473;keyid="test-shared-secret" + Signature: sig-b25=:pxcQw6G3AjtMBQjwo8XzkZf/bws5LelbaMk5rGIGtE8=: + + Before using symmetric signatures in practice, see the discussion of + the security tradeoffs in Section 7.11. + +B.2.6. Signing a Request using ed25519 + + This example covers portions of the test-request using the ed25519 + algorithm and the key test-key-ed25519. + + The corresponding signature input is: + + NOTE: '\' line wrapping per RFC 8792 + "date": Tue, 20 Apr 2021 02:07:55 GMT + "@method": POST + "@path": /foo + "@authority": example.com "content-type": application/json - "@signature-params": ("@authority" "date" "content-type")\ - ;created=1618884475;keyid="test-shared-secret" + "content-length": 18 + "@signature-params": ("date" "@method" "@path" "@authority" \ + "content-type" "content-length");created=1618884473\ + ;keyid="test-key-ed25519" This results in the following Signature-Input and Signature headers - being added to the message: + being added to the message under the label sig-b26: NOTE: '\' line wrapping per RFC 8792 - Signature-Input: sig1=("@authority" "date" "content-type")\ - ;created=1618884475;keyid="test-shared-secret" - Signature: sig1=:fN3AMNGbx0V/cIEKkZOvLOoC3InI+lM2+gTv22x3ia8=: + Signature-Input: sig-b26=("date" "@method" "@path" "@authority" \ + "content-type" "content-length");created=1618884473\ + ;keyid="test-key-ed25519" + Signature: sig-b26=:wqcAqbmYJ2ji2glfAMaRy4gruYYnx2nEFN2HN6jrnDnQCK1\ + u02Gb04v9EDgwUPiu4A0w6vuQv5lIp5WPpBKRCw==: B.3. TLS-Terminating Proxies In this example, there is a TLS-terminating reverse proxy sitting in front of the resource. The client does not sign the request but instead uses mutual TLS to make its call. The terminating proxy validates the TLS stream and injects a Client-Cert header according to [I-D.ietf-httpbis-client-cert-field], and then applies a signature to this field. By signing this header field, a reverse proxy can not only attest to its own validation of the initial request's TLS @@ -2974,21 +3301,21 @@ {"hello": "world"} The proxy processes the TLS connection and extracts the client's TLS certificate to a Client-Cert header field and passes it along to the internal service hosted at service.internal.example. This results in the following unsigned request: NOTE: '\' line wrapping per RFC 8792 - POST /foo?Param=value&pet=Dog HTTP/1.1 + POST /foo?param=Value&Pet=dog HTTP/1.1 Host: service.internal.example Date: Tue, 20 Apr 2021 02:07:55 GMT Content-Type: application/json Content-Length: 18 Client-Cert: :MIIBqDCCAU6gAwIBAgIBBzAKBggqhkjOPQQDAjA6MRswGQYDVQQKD\ BJMZXQncyBBdXRoZW50aWNhdGUxGzAZBgNVBAMMEkxBIEludGVybWVkaWF0ZSBDQT\ AeFw0yMDAxMTQyMjU1MzNaFw0yMTAxMjMyMjU1MzNaMA0xCzAJBgNVBAMMAkJDMFk\ wEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE8YnXXfaUgmnMtOXU/IncWalRhebrXmck\ C8vdgJ1p5Be5F/3YC8OthxM4+k1M6aEAEFcGzkJiNy6J84y7uzo9M6NyMHAwCQYDV\ R0TBAIwADAfBgNVHSMEGDAWgBRm3WjLa38lbEYCuiCPct0ZaSED2DAOBgNVHQ8BAf\ @@ -3001,65 +3328,65 @@ Without a signature, the internal service would need to trust that the incoming connection has the right information. By signing the Client-Cert header and other portions of the internal request, the internal service can be assured that the correct party, the trusted proxy, has processed the request and presented it to the correct service. The proxy's signature input consists of the following: NOTE: '\' line wrapping per RFC 8792 "@path": /foo - "@query": Param=value&pet=Dog + "@query": param=Value&Pet=dog "@method": POST "@authority": service.internal.example "client-cert": :MIIBqDCCAU6gAwIBAgIBBzAKBggqhkjOPQQDAjA6MRswGQYDVQQ\ KDBJMZXQncyBBdXRoZW50aWNhdGUxGzAZBgNVBAMMEkxBIEludGVybWVkaWF0ZSBD\ QTAeFw0yMDAxMTQyMjU1MzNaFw0yMTAxMjMyMjU1MzNaMA0xCzAJBgNVBAMMAkJDM\ FkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE8YnXXfaUgmnMtOXU/IncWalRhebrXm\ ckC8vdgJ1p5Be5F/3YC8OthxM4+k1M6aEAEFcGzkJiNy6J84y7uzo9M6NyMHAwCQY\ DVR0TBAIwADAfBgNVHSMEGDAWgBRm3WjLa38lbEYCuiCPct0ZaSED2DAOBgNVHQ8B\ Af8EBAMCBsAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwHQYDVR0RAQH/BBMwEYEPYmRjQ\ GV4YW1wbGUuY29tMAoGCCqGSM49BAMCA0gAMEUCIBHda/r1vaL6G3VliL4/Di6YK0\ Q6bMjeSkC3dFCOOB8TAiEAx/kHSB4urmiZ0NX5r5XarmPk0wmuydBVoU4hBVZ1yhk=: "@signature-params": ("@path" "@query" "@method" "@authority" \ - "client-cert");created=1618884475;keyid="test-key-ecc-p256" + "client-cert");created=1618884473;keyid="test-key-ecc-p256" This results in the following signature: NOTE: '\' line wrapping per RFC 8792 - 5gudRjXaHrAYbEaQUOoY9TuvqWOdPcspkp7YyKCB0XhyAG9cB715hucPPanEK0OVyiN\ - LJqcoq2Yn1DPWQcnbog== + aLFj9LxKArG+6IY9mfdR3e6K1zfoDJKw71fAkWROXZh34FIiWKAgshFIfBjmiU2X01u\ + 6YbDkRgzwyg5L9tky0w== Which results in the following signed request sent from the proxy to - the internal service: + the internal service with the proxy's signature under the label ttrp: NOTE: '\' line wrapping per RFC 8792 - POST /foo?Param=value&pet=Dog HTTP/1.1 + POST /foo?param=Value&Pet=dog HTTP/1.1 Host: service.internal.example Date: Tue, 20 Apr 2021 02:07:55 GMT Content-Type: application/json Content-Length: 18 Client-Cert: :MIIBqDCCAU6gAwIBAgIBBzAKBggqhkjOPQQDAjA6MRswGQYDVQQKD\ BJMZXQncyBBdXRoZW50aWNhdGUxGzAZBgNVBAMMEkxBIEludGVybWVkaWF0ZSBDQT\ AeFw0yMDAxMTQyMjU1MzNaFw0yMTAxMjMyMjU1MzNaMA0xCzAJBgNVBAMMAkJDMFk\ wEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE8YnXXfaUgmnMtOXU/IncWalRhebrXmck\ C8vdgJ1p5Be5F/3YC8OthxM4+k1M6aEAEFcGzkJiNy6J84y7uzo9M6NyMHAwCQYDV\ R0TBAIwADAfBgNVHSMEGDAWgBRm3WjLa38lbEYCuiCPct0ZaSED2DAOBgNVHQ8BAf\ 8EBAMCBsAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwHQYDVR0RAQH/BBMwEYEPYmRjQGV\ 4YW1wbGUuY29tMAoGCCqGSM49BAMCA0gAMEUCIBHda/r1vaL6G3VliL4/Di6YK0Q6\ bMjeSkC3dFCOOB8TAiEAx/kHSB4urmiZ0NX5r5XarmPk0wmuydBVoU4hBVZ1yhk=: Signature-Input: ttrp=("@path" "@query" "@method" "@authority" \ - "client-cert");created=1618884475;keyid="test-key-ecc-p256" - Signature: ttrp=:5gudRjXaHrAYbEaQUOoY9TuvqWOdPcspkp7YyKCB0XhyAG9cB7\ - 15hucPPanEK0OVyiNLJqcoq2Yn1DPWQcnbog==: + "client-cert");created=1618884473;keyid="test-key-ecc-p256" + Signature: ttrp=:aLFj9LxKArG+6IY9mfdR3e6K1zfoDJKw71fAkWROXZh34FIiWK\ + AgshFIfBjmiU2X01u6YbDkRgzwyg5L9tky0w==: {"hello": "world"} The internal service can validate the proxy's signature and therefore be able to trust that the client's certificate has been appropriately processed. Acknowledgements This specification was initially based on the draft-cavage-http- @@ -3079,20 +3406,34 @@ Palmer, Lucas Pardue, Roberto Polli, Julian Reschke, Michael Richardson, Wojciech Rygielski, Adam Scarr, Cory J. Slep, Dirk Stein, Henry Story, Lukasz Szewc, Chris Webber, and Jeffrey Yasskin. Document History _RFC EDITOR: please remove this section before publication_ * draft-ietf-httpbis-message-signatures + - -08 + + o Editorial fixes. + + o Changed "specialty component" to "derived component". + + o Expanded signature input generation and ABNF rules. + + o Added Ed25519 algorithm. + + o Clarified encoding of ECDSA signature. + + o Clarified use of non-deterministic algorithms. + - -07 o Added security and privacy considerations. o Added pointers to algorithm values from definition sections. o Expanded IANA registry sections. o Clarified that the signing and verification algorithms take application requirements as inputs.