Digest FieldsTeam Digitale, Italian GovernmentItalyrobipolli@gmail.comCloudflarelucaspardue.24.7@gmail.com
Applications and Real-Time
HTTPDigestThis document defines HTTP fields that support integrity digests. The Content-Digest field can be used for the integrity of HTTP message content. The Repr-Digest field can be used for the integrity of HTTP representations. Want-Content-Digest and Want-Repr-Digest can be used to indicate a sender's interest and preferences for receiving the respective Integrity fields.This document obsoletes RFC 3230 and the Digest and Want-Digest HTTP fields.Status information for this document may be found at .Discussion of this document takes place on the HTTP Working Group mailing list (), which is archived at . Working Group information can be found at .Source for this draft and an issue tracker can be found at .IntroductionHTTP does not define the means to protect the data integrity of content or representations. When HTTP messages are transferred between endpoints, lower layer features or properties such as TCP checksums or TLS records can provide some integrity protection. However, transport-oriented integrity provides a limited utility because it is opaque to the application layer and only covers the extent of a single connection. HTTP messages often travel over a chain of separate connections, in between connections there is a possibility for unintended or malicious data corruption. An HTTP integrity mechanism can provide the means for endpoints, or applications using HTTP, to detect data corruption and make a choice about how to act on it. An example use case is to aid fault detection and diagnosis across system boundaries.This document defines two digest integrity mechanisms for HTTP. First, content integrity, which acts on conveyed content (). Second, representation data integrity, which acts on representation data (). This supports advanced use cases such as validating the integrity of a resource that was reconstructed from parts retrieved using multiple requests or connections.This document obsoletes RFC 3230 and therefore the Digest and Want-Digest HTTP fields; see .Document StructureThis document is structured as follows:New request and response header and trailer field definitions. (Content-Digest), (Repr-Digest), and (Want-Content-Digest and Want-Repr-Digest).Considerations specific to representation data integrity. (State-changing requests), (Content-Location), contains worked examples of Representation data in message exchanges, and and contain worked examples of Repr-Digest and Want-Repr-Digest fields in message exchanges. presents hash algorithm considerations and defines registration procedures for future entries.Concept OverviewThe HTTP fields defined in this document can be used for HTTP integrity. Senders choose a hashing algorithm and calculate a digest from an input related to the HTTP message, the algorithm identifier and digest are transmitted in an HTTP field. Receivers can validate the digest for integrity purposes. Hashing algorithms are registered in the "Hash Algorithms for HTTP Digest Fields" (see ).Selecting the data on which digests are calculated depends on the use case of HTTP messages. This document provides different fields for HTTP representation data and HTTP content.There are use-cases where a simple digest of the HTTP content bytes is required. The Content-Digest request and response header and trailer field is defined to support digests of content (); see .For more advanced use-cases, the Repr-Digest request and response header and trailer field () is defined. It contains a digest value computed by applying a hashing algorithm to selected representation data (). Basing Repr-Digest on the selected representation makes it straightforward to apply it to use-cases where the message content requires some sort of manipulation to be considered as representation of the resource or content conveys a partial representation of a resource, such as Range Requests (see ).Content-Digest and Repr-Digest support hashing algorithm agility. The Want-Content-Digest and Want-Repr-Digest fields allow endpoints to express interest in Content-Digest and Repr-Digest respectively, and to express algorithm preferences in either.Content-Digest and Repr-Digest are collectively termed Integrity fields. Want-Content-Digest and Want-Repr-Digest are collectively termed Integrity preference fields.Integrity fields are tied to the Content-Encoding and Content-Type header fields. Therefore, a given resource may have multiple different digest values when transferred with HTTP.Integrity fields do not provide integrity for HTTP messages or fields. However, they can be combined with other mechanisms that protect metadata, such as digital signatures, in order to protect the phases of an HTTP exchange in whole or in part. For example, HTTP Message Signatures could be used to sign Integrity fields, thus providing coverage for HTTP content or representation data.This specification does not define means for authentication, authorization or privacy.Obsoleting RFC 3230 defined the Digest and Want-Digest HTTP fields for HTTP integrity. It also coined the term "instance" and "instance manipulation" in order to explain concepts that are now more universally defined, and implemented, as HTTP semantics such as selected representation data ().Experience has shown that implementations of have interpreted the meaning of "instance" inconsistently, leading to interoperability issues. The most common issue relates to the mistake of calculating the digest using (what we now call) message content, rather than using (what we now call) representation data as was originally intended. Interestingly, time has also shown that a digest of message content can be beneficial for some use cases. So it is difficult to detect if non-conformance to is intentional or unintentional.In order to address potential inconsistencies and ambiguity across implementations of Digest and Want-Digest, this document obsoletes . The Integrity fields (Sections and ) and Integrity preference fields () defined in this document are better aligned with current HTTP semantics and have names that more clearly articulate the intended usages.Notational ConventionsThe key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 when, and only when, they appear in all capitals, as shown here.This document uses the Augmented BNF defined in and updated by . This includes the rules: CR (carriage return), LF (line feed), and CRLF (CR LF).This document uses the following terminology from to specify syntax and parsing: Boolean, Byte Sequence, Dictionary, Integer, and List.The definitions "representation", "selected representation", "representation data", "representation metadata", "user agent" and "content" in this document are to be interpreted as described in .This document uses the line folding strategies described in .Hashing algorithm names respect the casing used in their definition document (e.g. SHA-1, CRC32c) whereas hashing algorithm keys are quoted (e.g. "sha", "crc32c").The term "checksum" describes the output of the application of an algorithm to a sequence of bytes, whereas "digest" is only used in relation to the value contained in the fields.Integrity fields: collective term for Content-Digest and Repr-DigestIntegrity preference fields: collective term for Want-Repr-Digest and Want-Content-DigestThe Content-Digest FieldThe Content-Digest HTTP field can be used in requests and responses to communicate digests that are calculated using a hashing algorithm applied to the actual message content (see ). It is a Dictionary (see ) where each:key conveys the hashing algorithm (see ) used to compute the digest;value is a Byte Sequence (), that conveys an encoded version of the byte output produced by the digest calculation.For example:The Dictionary type can be used, for example, to attach multiple digests calculated using different hashing algorithms in order to support a population of endpoints with different or evolving capabilities. Such an approach could support transitions away from weaker algorithms (see ).A recipient MAY ignore any or all digests. This allows the recipient to choose which hashing algorithm(s) to use for validation instead of verifying every digest.A sender MAY send a digest without knowing whether the recipient supports a given hashing algorithm, or even knowing that the recipient will ignore it.Content-Digest can be sent in a trailer section. In this case, Content-DigestMAY be merged into the header section; see .The Repr-Digest FieldThe Repr-Digest HTTP field can be used in requests and responses to communicate digests that are calculated using a hashing algorithm applied to the entire selected representation data (see ).Representations take into account the effect of the HTTP semantics on messages. For example, the content can be affected by Range Requests or methods such as HEAD, while the way the content is transferred "on the wire" is dependent on other transformations (e.g. transfer codings for HTTP/1.1 - see ). To help illustrate HTTP representation concepts, several examples are provided in .When a message has no representation data it is still possible to assert that no representation data was sent by computing the digest on an empty string (see ).Repr-Digest is a Dictionary (see ) where each:key conveys the hashing algorithm (see ) used to compute the digest;value is a Byte Sequence, that conveys an encoded version of the byte output produced by the digest calculation.For example:The Dictionary type can be used, for example, to attach multiple digests calculated using different hashing algorithms in order to support a population of endpoints with different or evolving capabilities. Such an approach could support transitions away from weaker algorithms (see ).A recipient MAY ignore any or all digests. This allows the recipient to choose which hashing algorithm(s) to use for validation instead of verifying every digest.A sender MAY send a digest without knowing whether the recipient supports a given hashing algorithm, or even knowing that the recipient will ignore it.Repr-Digest can be sent in a trailer section. In this case, Repr-DigestMAY be merged into the header section; see .Using Repr-Digest in State-Changing RequestsWhen the representation enclosed in a state-changing request does not describe the target resource, the representation digest MUST be computed on the representation data. This is the only possible choice because representation digest requires complete representation metadata (see ).In responses,if the representation describes the status of the request, Repr-DigestMUST be computed on the enclosed representation (see );if there is a referenced resource Repr-DigestMUST be computed on the selected representation of the referenced resource even if that is different from the target resource. That might or might not result in computing Repr-Digest on the enclosed representation.The latter case is done according to the HTTP semantics of the given method, for example using the Content-Location header field (see ). In contrast, the Location header field does not affect Repr-Digest because it is not representation metadata.For example, in PATCH requests, the representation digest will be computed on the patch document because the representation metadata refers to the patch document and not to the target resource (see ). In responses, instead, the representation digest will be computed on the selected representation of the patched resource.Repr-Digest and Content-Location in ResponsesWhen a state-changing method returns the Content-Location header field, the enclosed representation refers to the resource identified by its value and Repr-Digest is computed accordingly. An example is given in .Integrity preference fieldsSenders can indicate their interest in Integrity fields and hashing algorithm preferences using the Want-Content-Digest or Want-Repr-Digest fields. These can be used in both requests and responses.Want-Content-Digest indicates that the sender would like to receive a content digest on messages associated with the request URI and representation metadata, using the Content-Digest field.Want-Repr-Digest indicates that the sender would like to receive a representation digest on messages associated with the request URI and representation metadata, using the Repr-Digest field.If Want-Content-Digest or Want-Repr-Digest are used in a response, it indicates that the server would like the client to provide the respective Integrity field on future requests.Integrity preference fields are only a hint. The receiver of the field can ignore it and send an Integrity field using any algorithm or omit the field entirely, for example see . It is not a protocol error if preferences are ignored. Applications that use Integrity fields and Integrity preferences can define expectations or constraints that operate in addition to this specification. How to deal with an ignored preferences is a scenario that should be considered.Want-Content-Digest and Want-Repr-Digest are of type Dictionary where each:key conveys the hashing algorithm (see );value is an Integer () that conveys an ascending, relative, weighted preference. It must be in the range 0 to 10 inclusive. 1 is the least preferred, 10 is the most preferred, and a value of 0 means "not acceptable".Examples:Hash Algorithm Considerations and RegistrationThere are a wide variety of hashing algorithms that can be used for the purposes of integrity. The choice of algorithm depends on several factors such as the integrity use case, implementation needs or constraints, or application design and workflows.An initial set of algorithms will be registered with IANA in the "Hash Algorithms for HTTP Digest Fields" registry; see . Additional algorithms can be registered in accordance with the policies set out in this section.Each algorithm has a status field, which is intended to provide an aid to implementation selection.Algorithms with a status value of "standard" are suitable for many purposes, including adversarial situations where hash functions might need to provide resistance to collision, first-preimage and second-preimage attacks. For adversarial situations, selecting which of the "standard" algorithms are acceptable will depend on the level of protection the circumstances demand. As there is no negotiation, endpoints that depend on a digest for security will be vulnerable to attacks on the weakest algorithm they are willing to accept.Algorithms with a status value of "insecure" either provide none of these properties, or are known to be weak (see and ). These algorithms MAY be used to preserve integrity against corruption, but MUST NOT be used in a potentially adversarial setting; for example, when signing Integrity fields' values for authenticity.Discussion of algorithm agility is presented in .Registration requests for the "Hash Algorithms for HTTP Digest Fields" registry use the Specification Required policy (). Requests should use the following template:Algorithm Key: the Structured Fields key value used in Content-Digest, Repr-Digest, Want-Content-Digest, or Want-Repr-Digest field Dictionary member keysStatus: the status of the algorithm. The options are: "standard" - for standardized algorithms without known problems,"provisional" - for non-standard or unproven algorithms,"insecure" - for insecure algorithms,"reserved" - for algorithms that use a reserved token value that cannot be expressed in Structured FieldsDescription: a short description of the algorithmReference(s): pointer(s) to the primary document(s) defining the technical details of the algorithm, and optionally the keyWhen reviewing registration requests, the designated expert(s) should pay attention to the requested status. The status value should reflect standardization status and the broad opinion of relevant interest groups such as the IETF or security-related SDOs. The "standard" status is not suitable for an algorithm that is known to be weak, broken or experimental. If a registration request attempts to register such an algorithm as "standard", the designated expert(s) should suggest an alternative status of "insecure" or "provisional".When reviewing registration requests, the designated expert(s) cannot use a status of "insecure" or "provisional" as grounds for rejection.Requests to update or change the fields in an existing registration are permitted. For example, this could allow for the transition of an algorithm status from "standard" to "insecure" as the security environment evolves.Security ConsiderationsHTTP Messages Are Not Protected In FullThis document specifies a data integrity mechanism that protects HTTP representation data or content, but not HTTP header and trailer fields, from certain kinds of corruption.Integrity fields are not intended to be a general protection against malicious tampering with HTTP messages. This can be achieved by combining it with other approaches such as transport-layer security or digital signatures (for example, HTTP Message Signatures ).End-to-End IntegrityIntegrity fields can help detect representation data or content modification due to implementation errors, undesired "transforming proxies" (see ) or other actions as the data passes across multiple hops or system boundaries. Even a simple mechanism for end-to-end representation data integrity is valuable because a user agent can validate that resource retrieval succeeded before handing off to a HTML parser, video player etc. for parsing.Note that using these mechanisms alone does not provide end-to-end integrity of HTTP messages over multiple hops, since metadata could be manipulated at any stage. Methods to protect metadata are discussed in .Usage in SignaturesDigital signatures are widely used together with checksums to provide the certain identification of the origin of a message . Such signatures can protect one or more HTTP fields and there are additional considerations when Integrity fields are included in this set.There are no restrictions placed on the type or format of digitial signature that Integrity fields can be used with. One possible approach is to combine them with HTTP Message Signatures .Digests explicitly depend on the "representation metadata" (e.g. the values of Content-Type, Content-Encoding etc). A signature that protects Integrity fields but not other "representation metadata" can expose the communication to tampering. For example, an actor could manipulate the Content-Type field-value and cause a digest validation failure at the recipient, preventing the application from accessing the representation. Such an attack consumes the resources of both endpoints. See also .Signatures are likely to be deemed an adversarial setting when applying Integrity fields; see . Using signatures to protect the checksum of an empty representation allows receiving endpoints to detect if an eventual payload has been stripped or added.Any mangling of Integrity fields, including digests' de-duplication or combining different field values (see ) might affect signature validation.Usage in Trailer FieldsBefore sending Integrity fields in a trailer section, the sender should consider that intermediaries are explicitly allowed to drop any trailer (see ).When Integrity fields are used in a trailer section, the field-values are received after the content. Eager processing of content before the trailer section prevents digest validation, possibly leading to processing of invalid data.Not every hashing algorithm is suitable for use in the trailer section, some may require to pre-process the whole payload before sending a message (e.g. see ).Variations Within Content EncodingContent coding mechanisms can support different encoding parameters, meaning that the same input content can produce different outputs. For example, GZIP supports mulitple compression levels. Such encoding parameters are generally not communicated as representation metadata, for instance different compression levels would all use the same "Content-Encoding: gzip" field. Other examples include where encoding relies on nonces or timestamps, such as the aes128gcm content coding defined .Since it is possible for there to be variation within content coding, the checksum conveyed by the integrity field cannot be used to provide a proof of integrity "at rest" unless the whole (e.g. encoded) content is persisted.Algorithm AgilityThe security properties of hashing algorithms are not fixed. Algorithm Agility (see ) is achieved by providing implementations with flexibility to choose hashing algorithms from the IANA Hash Algorithms for HTTP Digest Fields registry; see .Transition from weak algorithms is supported by negotiation of hashing algorithm using Want-Content-Digest or Want-Repr-Digest (see ) or by sending multiple digests from which the receiver chooses. Endpoints are advised that sending multiple values consumes resources, which may be wasted if the receiver ignores them (see ).While algorithm agility allows the migration to stronger algorithms it does not prevent the use of weaker algorithms. Integrity fields do not provide any mitigations for downgrade or substitution attacks (see ) of the hashing algorithm. To protect against such attacks, endpoints could restrict their set of supported algorithms to stronger ones and protect the fields value by using TLS and/or digital signatures.Resource exhaustionIntegrity fields validation consumes computational resources. In order to avoid resource exhaustion, implementations can restrict validation of the algorithm types, number of validations, or the size of content.IANA ConsiderationsHTTP Field Name RegistrationIANA is asked to update the "Hypertext Transfer Protocol (HTTP) Field Name Registry" registry () according to the table below:Field NameStatusReferenceContent-Digestpermanent of this documentRepr-Digestpermanent of this documentWant-Content-Digestpermanent of this documentWant-Repr-Digestpermanent of this documentDigestobsoleted, of this documentWant-Digestobsoleted, of this documentEstablish the Hash Algorithms for HTTP Digest Fields RegistryIANA is requested to create the new "Hash Algorithms for HTTP Digest Fields" registry at https://www.iana.org/assignments/http-digest-hash-alg/ and populate it with the entries in . The procedure for new registrations is provided in .Algorithm KeyStatusDescriptionReference(s)sha-512standardThe SHA-512 algorithm., , this document.sha-256standardThe SHA-256 algorithm., , this document.md5insecureThe MD5 algorithm. It is vulnerable to collision attacks; see and , , this document.shainsecureThe SHA-1 algorithm. It is vulnerable to collision attacks; see and , , this document.unixsuminsecureThe algorithm used by the UNIX "sum" command., , , this document.unixcksuminsecureThe algorithm used by the UNIX "cksum" command., , , this document.adlerinsecureThe ADLER32 algorithm., this document.crc32cinsecureThe CRC32c algorithm. appendix B, this document.Deprecate the Hypertext Transfer Protocol (HTTP) Digest Algorithm Values RegistryIANA is requested to deprecate the "Hypertext Transfer Protocol (HTTP) Digest Algorithm Values" registry at https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml.The MD5 Message-Digest AlgorithmUS Secure Hash Algorithm 1 (SHA1)ZLIB Compressed Data Format Specification version 3.3The Base16, Base32, and Base64 Data EncodingsAugmented BNF for Syntax Specifications: ABNFUS Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)Case-Sensitive String Support in ABNFHandling Long Lines in Content of Internet-Drafts and RFCsHTTP SemanticsKey words for use in RFCs to Indicate Requirement LevelsAmbiguity of Uppercase vs Lowercase in RFC 2119 Key WordsStructured Field Values for HTTPGuidelines for Writing an IANA Considerations Section in RFCsInstance Digests in HTTPHTTP/1.1PATCH Method for HTTPUpdated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 AlgorithmsSecurity Considerations for the SHA-0 and SHA-1 Message-Digest AlgorithmsHTTP Message SignaturesAmazonBespoke EngineeringDigital BazaarThe Single UNIX Specification, Version 2 - 6 Vol Set for UNIX 98The Open GroupIntroduction to Public Key Technology and the Federal PKI InfrastructureNational Institute of Standards and Technology, U.S. Department of CommerceMD5 Vulnerable to collision attacksCarnegie Mellon University, Software Engineering InstituteSHA-1 is a ShamblesInria, FranceNanyang Technological University, Singapore; Temasek Laboratories, SingaporeThe Transport Layer Security (TLS) Protocol Version 1.3Merkle Integrity Content EncodingMozillaGoogleEncrypted Content-Encoding for HTTPGuidelines for Cryptographic Algorithm Agility and Selecting Mandatory-to-Implement AlgorithmsCryptographic Message Syntax (CMS) Algorithm Identifier Protection AttributeStream Control Transmission ProtocolJSON Merge PatchProblem Details for HTTP APIsResource Representation and Representation DataThe following examples show how representation metadata, payload transformations and method impacts on the message and content. When the content contains non-printable characters (e.g. when it is compressed) it is shown as a sequence of hex-encoded bytes.Compression is an efficient way to reduce the content length.Sending the compressed form of the content without the correct content coding means that the content is malformed. In this case, the server can reply with an error.A Range-Request affects the transferred message content, conveying a partial representation of the JSON object in .The method can also affect the transferred message content. For example, the response to a HEAD request does not carry content.Finally, the semantics of a response might decouple the target URI from the enclosed representation. In the example response below, the Content-Location header field indicates that the enclosed representation refers to the resource available at /authors/123, even though the request is directed to /authors/.Examples of Unsolicited DigestThe following examples demonstrate interactions where a server responds with a Content-Digest or Repr-Digest fields even though the client did not solicit one using Want-Content-Digest or Want-Repr-Digest.Some examples include JSON objects in the content. For presentation purposes, objects that fit completely within the line-length limits are presented on a single line using compact notation with no leading space. Objects that would exceed line-length limits are presented across multiple lines (one line per key-value pair) with 2 spaced of leading indentation.Checksum mechanisms defined in this document are media-type agnostic and do not provide canonicalization algorithms for specific formats. Examples are calculated inclusive of any space. While examples can include both fields, Content-Digest and Repr-Digest can be returned independently.Server Returns Full Representation DataIn this example, the message content conveys complete representation data. This means that in the response, Content-Digest and Repr-Digest are both computed over the JSON object {"hello": "world"} followed by an LF, and thus have the same value.Server Returns No Representation DataIn this example, a HEAD request is used to retrieve the checksum of a resource.The response Content-Digest field-value is computed on empty content. Repr-Digest is calculated over the JSON object {"hello": "world"} followed by an LF, which is not shown because there is no payload data.Server Returns Partial Representation DataIn this example, the client makes a range request and the server responds with partial content.In the response message above, note that the Repr-Digest and Content-Digests are different. The Repr-Digest field-value is calculated across the entire JSON object {"hello": "world"} followed by an LF, and the field isHowever, since the message content is constrained to bytes 10-18, the Content-Digest field-value is calculated over the sequence "world"} followed by an LF, thus resulting inClient and Server Provide Full Representation DataThe request contains a Repr-Digest field-value calculated on the enclosed representation. It also includes an Accept-Encoding: br header field that advertises the client supports Brotli encoding.The response includes a Content-Encoding: br that indicates the selected representation is Brotli-encoded. The Repr-Digest field-value is therefore different compared to the request.For presentation purposes, the response body is displayed as a sequence of hex-encoded bytes because it contains non-printable characters.Client Provides Full Representation Data, Server Provides No Representation DataThe request Repr-Digest field-value is calculated on the enclosed content, which is the JSON object {"hello": "world"} followed by an LFThe response Repr-Digest field-value depends on the representation metadata header fields, including Content-Encoding: br even when the response does not contain content.Client and Server Provide Full Representation DataThe response contains two digest values using different algorithms.For presentation purposes, the response body is displayed as a sequence of hex-encoded bytes because it contains non-printable characters.POST Response does not Reference the Request URIThe request Repr-Digest field-value is computed on the enclosed representation (see ), which is the JSON object {"title": "New Title"} followed by an LF.The representation enclosed in the response is a multiline JSON object followed by an LF. It refers to the resource identified by Content-Location (see ); an application can thus use Repr-Digest in association with the resource referenced by Content-Location.POST Response Describes the Request StatusThe request Repr-Digest field-value is computed on the enclosed representation (see ), which is the JSON object {"title": "New Title"} followed by an LF.The representation enclosed in the response describes the status of the request, so Repr-Digest is computed on that enclosed representation. It is a multiline JSON object followed by an LF.Response Repr-Digest has no explicit relation with the resource referenced by Location.Digest with PATCHThis case is analogous to a POST request where the target resource reflects the target URI.The PATCH request uses the application/merge-patch+json media type defined in . Repr-Digest is calculated on the enclosed payload, which corresponds to the patch document and is the JSON object {"title": "New Title"} followed by an LF.The response Repr-Digest field-value is computed on the complete representation of the patched resource. It is a multiline JSON object followed by an LF.Note that a 204 No Content response without content but with the same Repr-Digest field-value would have been legitimate too. In that case, Content-Digest would have been computed on an empty content.Error responsesIn error responses, the representation data does not necessarily refer to the target resource. Instead, it refers to the representation of the error.In the following example, a client sends the same request from to patch the resource located at /books/123. However, the resource does not exist and the server generates a 404 response with a body that describes the error in accordance with .The response Repr-Digest field-value is computed on this enclosed representation. It is a multiline JSON object followed by an LF.Use with Trailer Fields and Transfer CodingAn origin server sends Repr-Digest as trailer field, so it can calculate digest-value while streaming content and thus mitigate resource consumption. The Repr-Digest field-value is the same as in because Repr-Digest is designed to be independent from the use of one or more transfer codings (see ).In the response content below, the string "\r\n" represent the bytes CRLF.Examples of Want-Repr-Digest Solicited DigestThe following examples demonstrate interactions where a client solicits a Repr-Digest using Want-Repr-Digest. The behavior of Content-Digest and Want-Content-Digest is identical.Some examples include JSON objects in the content. For presentation purposes, objects that fit completely within the line-length limits are presented on a single line using compact notation with no leading space. Objects that would exceed line-length limits are presented across multiple lines (one line per key-value pair) with 2 spaced of leading indentation.Checksum mechanisms described in this document are media-type agnostic and do not provide canonicalization algorithms for specific formats. Examples are calculated inclusive of any space.Server Selects Client's Least Preferred AlgorithmThe client requests a digest, preferring "sha". The server is free to reply with "sha-256" anyway.Server Selects Algorithm Unsupported by ClientThe client requests a "sha" digest because that is the only algorithm it supports. The server is not obliged to produce a response containing a "sha" digest, it instead uses a different algorithm.Server Does Not Support Client Algorithm and Returns an Error is an example where a server ignores the client's preferred digest algorithm. Alternatively a server can also reject the request and return a response with error status code such as 4xx or 5xx. This specification does not prescribe any requirement on status code selection; the follow example illustrates one possible option.In this example, the client requests a "sha" Repr-Digest, and the server returns an error with problem details contained in the content. The problem details contain a list of the hashing algorithms that the server supports. This is purely an example, this specification does not define any format or requirements for such content.Sample Digest ValuesThis section shows examples of digest values for different hashing algorithms. The input value is the JSON object {"hello": "world"}. The digest values are each produced by running the relevant hashing algorithm over the input and running the output bytes through Byte Sequence serialization; see .Migrating from RFC 3230HTTP digests are computed by applying a hashing algorithm to input data. RFC 3230 defined the input data as an "instance", a term it also defined. The concept of instance has since been superseded by the HTTP semantic term "representation". It is understood that some implementations of RFC 3230 mistook "instance" to mean HTTP content. Using content for the Digest field is an error that leads to interoperability problems between peers that implement RFC 3230.RFC 3230 was only ever intended to use what HTTP now defines as selected representation data. The semantic concept of digest and representation are explained alongside the definition of the Repr-Digest field.While the syntax of Digest and Repr-Digest are different, the considerations and examples this document gives for Repr-Digest apply equally to Digest because they operate on the same input data; see Sections , and .RFC 3230 could never communicate the digest of HTTP message content in the Digest field; Content-Digest now provides that capability.RFC 3230 allowed algorithms to define their output encoding format for use with the Digest field. This resulted in a mixed of formats such as base64, hex or decimal. By virtue of using Structured fields, Content-Digest and Repr-Digest use only a single encoding format. Further explanation and examples are provided in .AcknowledgementsThis document is based on ideas from , so thanks to Jeff Mogul and Arthur Van Hoff for their great work. The original idea of refreshing RFC3230 arose from an interesting discussion with Mark Nottingham, Jeffrey Yasskin and Martin Thomson when reviewing the MICE content coding.Thanks to Julian Reschke for his valuable contributions to this document, and to the following contributors that have helped improve this specification by reporting bugs, asking smart questions, drafting or reviewing text, and evaluating open issues: Mike Bishop, Brian Campbell, Matthew Kerwin, James Manger, Tommy Pauly, Sean Turner, Justin Richer, and Erik Wilde.Code SamplesHow can I generate and validate the digest values, computed over the JSON object {"hello": "world"} followed by an LF, shown in the examples throughout this document?The following python3 code can be used to generate digests for JSON objects using SHA algorithms for a range of encodings. Note that these are formatted as base64. This function could be adapted to other algorithms and should take into account their specific formatting rules.ChangesSince draft-ietf-httpbis-digest-headers-10Editorial or minor changesSince draft-ietf-httpbis-digest-headers-09Editorial or minor changesSince draft-ietf-httpbis-digest-headers-08Add note about migrating from RFC 3230. #1968, #1971Clarify what Want-* means in responses. #2097Editorial changes to structure and to align to HTTP style guide.Since draft-ietf-httpbis-digest-headers-07Introduced Repr-Digest and Want-Repr-Digest, and deprecated Digest and Want-Digest. Use of Structured Fields. #1993, #1919IANA refactoring. #1983No normative text in security considerations. #1972Since draft-ietf-httpbis-digest-headers-06Remove id-sha-256 and id-sha-512 from the list of supported algorithms #855Since draft-ietf-httpbis-digest-headers-05Reboot digest-algorithm values registry #1567Add Content-Digest #1542Remove SRI section #1478Since draft-ietf-httpbis-digest-headers-04Improve SRI section #1354About duplicate digest-algorithms #1221Improve security considerations #852md5 and sha deprecation references #1392Obsolete 3230 #1395Editorial #1362Since draft-ietf-httpbis-digest-headers-03Reference semantics-12Detail encryption quirksDetails on Algorithm agility #1250Obsolete parameters #850Since draft-ietf-httpbis-digest-headers-02Deprecate SHA-1 #1154Avoid id-* with encrypted contentDigest is independent from MESSAGING and HTTP/1.1 is not normative #1215Identity is not a valid field value for content-encoding #1223Mention trailers #1157Reference httpbis-semantics #1156Add contentMD5 as an obsoleted digest-algorithm #1249Use lowercase digest-algorithms names in the doc and in the digest-algorithm IANA table.Since draft-ietf-httpbis-digest-headers-01Digest of error responses is computed on the error representation-data #1004Effect of HTTP semantics on payload and message body moved to appendix #1122Editorial refactoring, moving headers sections up. #1109-#1112, #1116, #1117, #1122-#1124Since draft-ietf-httpbis-digest-headers-00Align title with document nameAdd id-sha-* algorithm examples #880Reference and instead of FIPS-1Deprecate MD5Obsolete ADLER-32 but don't forbid it #828Update CRC32C value in IANA table #828Use when acting on resources (POST, PATCH) #853Added Relationship with SRI, draft Use Cases #868, #971Warn about the implications of Content-Location