draft-ietf-httpbis-digest-headers-04.txt   draft-ietf-httpbis-digest-headers-05.txt 
HTTP R. Polli HTTP R. Polli
Internet-Draft Team Digitale, Italian Government Internet-Draft Team Digitale, Italian Government
Intended status: Standards Track L. Pardue Obsoletes: 3230 (if approved) L. Pardue
Expires: 20 April 2021 Cloudflare Intended status: Standards Track Cloudflare
17 October 2020 Expires: 15 October 2021 13 April 2021
Digest Headers Digest Headers
draft-ietf-httpbis-digest-headers-04 draft-ietf-httpbis-digest-headers-05
Abstract Abstract
This document defines the HTTP Digest and Want-Digest fields, thus This document defines the HTTP Digest and Want-Digest fields, thus
allowing client and server to negotiate an integrity checksum of the allowing client and server to negotiate an integrity checksum of the
exchanged resource representation data. exchanged resource representation data.
This document obsoletes RFC 3230. It replaces the term "instance" This document obsoletes RFC 3230. It replaces the term "instance"
with "representation", which makes it consistent with the HTTP with "representation", which makes it consistent with the HTTP
Semantic and Context defined in draft-ietf-httpbis-semantics. Semantic and Context defined in draft-ietf-httpbis-semantics.
skipping to change at page 2, line 4 skipping to change at page 2, line 4
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on 20 April 2021. This Internet-Draft will expire on 15 October 2021.
Copyright Notice Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the Copyright (c) 2021 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents (https://trustee.ietf.org/ Provisions Relating to IETF Documents (https://trustee.ietf.org/
license-info) in effect on the date of publication of this document. license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. Code Components and restrictions with respect to this document. Code Components
extracted from this document must include Simplified BSD License text extracted from this document must include Simplified BSD License text
as described in Section 4.e of the Trust Legal Provisions and are as described in Section 4.e of the Trust Legal Provisions and are
provided without warranty as described in the Simplified BSD License. provided without warranty as described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1. A Brief History of HTTP Integrity Fields . . . . . . . . 4 1.1. A Brief History of HTTP Integrity Fields . . . . . . . . 4
1.2. This Proposal . . . . . . . . . . . . . . . . . . . . . . 4 1.2. This Proposal . . . . . . . . . . . . . . . . . . . . . . 4
1.3. Goals . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3. Goals . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4. Notational Conventions . . . . . . . . . . . . . . . . . 5 1.4. Notational Conventions . . . . . . . . . . . . . . . . . 6
2. Representation Digest . . . . . . . . . . . . . . . . . . . . 6 2. Representation Digest . . . . . . . . . . . . . . . . . . . . 6
3. The Digest Field . . . . . . . . . . . . . . . . . . . . . . 7 3. The Digest Field . . . . . . . . . . . . . . . . . . . . . . 7
4. The Want-Digest Field . . . . . . . . . . . . . . . . . . . . 7 4. The Want-Digest Field . . . . . . . . . . . . . . . . . . . . 8
5. Digest Algorithm Values . . . . . . . . . . . . . . . . . . . 8 5. Digest Algorithm Values . . . . . . . . . . . . . . . . . . . 8
6. Use of Digest when acting on resources . . . . . . . . . . . 10 6. Use of Digest when acting on resources . . . . . . . . . . . 11
6.1. Digest and PATCH . . . . . . . . . . . . . . . . . . . . 11 6.1. Digest and PATCH . . . . . . . . . . . . . . . . . . . . 11
7. Deprecate Negotiation of Content-MD5 . . . . . . . . . . . . 11 7. Deprecate Negotiation of Content-MD5 . . . . . . . . . . . . 11
8. Obsolete Digest Header Field Parameters . . . . . . . . . . . 11 8. Obsolete Digest Field Parameters . . . . . . . . . . . . . . 12
9. Relationship to Subresource Integrity (SRI) . . . . . . . . . 11 9. Relationship to Subresource Integrity (SRI) . . . . . . . . . 12
9.1. Supporting Both SRI and Representation Digest . . . . . . 12 9.1. Supporting Both SRI and Representation Digest . . . . . . 13
10. Examples of Unsolicited Digest . . . . . . . . . . . . . . . 13 10. Examples of Unsolicited Digest . . . . . . . . . . . . . . . 13
10.1. Server Returns Full Representation Data . . . . . . . . 13 10.1. Server Returns Full Representation Data . . . . . . . . 13
10.2. Server Returns No Representation Data . . . . . . . . . 13 10.2. Server Returns No Representation Data . . . . . . . . . 14
10.3. Server Returns Partial Representation Data . . . . . . . 14 10.3. Server Returns Partial Representation Data . . . . . . . 14
10.4. Client and Server Provide Full Representation Data . . . 14 10.4. Client and Server Provide Full Representation Data . . . 15
10.5. Client Provides Full Representation Data, Server Provides 10.5. Client Provides Full Representation Data, Server Provides
No Representation Data . . . . . . . . . . . . . . . . 15 No Representation Data . . . . . . . . . . . . . . . . 15
10.6. Client and Server Provide Full Representation Data, Client 10.6. Client and Server Provide Full Representation Data, Client
Uses id-sha-256. . . . . . . . . . . . . . . . . . . . 15 Uses id-sha-256. . . . . . . . . . . . . . . . . . . . 16
10.7. POST Response does not Reference the Request URI . . . . 16 10.7. POST Response does not Reference the Request URI . . . . 17
10.8. POST Response Describes the Request Status . . . . . . . 17 10.8. POST Response Describes the Request Status . . . . . . . 18
10.9. Digest with PATCH . . . . . . . . . . . . . . . . . . . 17 10.9. Digest with PATCH . . . . . . . . . . . . . . . . . . . 18
10.10. Error responses . . . . . . . . . . . . . . . . . . . . 18 10.10. Error responses . . . . . . . . . . . . . . . . . . . . 19
10.11. Use with trailers and transfer coding . . . . . . . . . 19 10.11. Use with Trailer Fields and Transfer Coding . . . . . . 20
11. Examples of Want-Digest Solicited Digest . . . . . . . . . . 19 11. Examples of Want-Digest Solicited Digest . . . . . . . . . . 21
11.1. Server Selects Client's Least Preferred Algorithm . . . 20 11.1. Server Selects Client's Least Preferred Algorithm . . . 21
11.2. Server Selects Algorithm Unsupported by Client . . . . . 20 11.2. Server Selects Algorithm Unsupported by Client . . . . . 22
11.3. Server Does Not Support Client Algorithm and Returns an 11.3. Server Does Not Support Client Algorithm and Returns an
Error . . . . . . . . . . . . . . . . . . . . . . . . . 20 Error . . . . . . . . . . . . . . . . . . . . . . . . . 22
12. Security Considerations . . . . . . . . . . . . . . . . . . . 21 12. Security Considerations . . . . . . . . . . . . . . . . . . . 22
12.1. Digest Does Not Protect the Full HTTP Message . . . . . 21 12.1. Digest Does Not Protect the Full HTTP Message . . . . . 22
12.2. Broken Cryptographic Algorithms . . . . . . . . . . . . 21 12.2. Broken Cryptographic Algorithms . . . . . . . . . . . . 23
12.3. Other Deprecated Algorithms . . . . . . . . . . . . . . 21 12.3. Other Deprecated Algorithms . . . . . . . . . . . . . . 23
12.4. Digest for End-to-End Integrity . . . . . . . . . . . . 21 12.4. Digest for End-to-End Integrity . . . . . . . . . . . . 23
12.5. Digest and Content-Location in responses . . . . . . . . 22 12.5. Digest and Content-Location in Responses . . . . . . . . 23
12.6. Usage in signatures . . . . . . . . . . . . . . . . . . 22 12.6. Usage in Signatures . . . . . . . . . . . . . . . . . . 24
12.7. Usage in trailers . . . . . . . . . . . . . . . . . . . 22 12.7. Usage in Trailer Fields . . . . . . . . . . . . . . . . 24
12.8. Usage with encryption . . . . . . . . . . . . . . . . . 23 12.8. Usage with Encryption . . . . . . . . . . . . . . . . . 25
12.9. Algorithm Agility . . . . . . . . . . . . . . . . . . . 23 12.9. Algorithm Agility . . . . . . . . . . . . . . . . . . . 25
13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 23 12.9.1. Duplicate digest-algorithm in field value . . . . . 25
13.1. Establish the HTTP Digest Algorithm Values . . . . . . . 23 12.10. Resource exhaustion . . . . . . . . . . . . . . . . . . 26
13.2. The "status" Field in the HTTP Digest Algorithm 13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 26
Values . . . . . . . . . . . . . . . . . . . . . . . . 23 13.1. Establish the HTTP Digest Algorithm Values Registry . . 26
13.3. Deprecate "MD5" Digest Algorithm . . . . . . . . . . . . 24 13.2. The "status" Field in the HTTP Digest Algorithm Values
13.4. Update "UNIXsum" Digest Algorithm . . . . . . . . . . . 24 Registry . . . . . . . . . . . . . . . . . . . . . . . 26
13.5. Update "UNIXcksum" Digest Algorithm . . . . . . . . . . 24 13.3. Deprecate "MD5" Digest Algorithm . . . . . . . . . . . . 26
13.6. Update "CRC32c" Digest Algorithm . . . . . . . . . . . . 25 13.4. Update "UNIXsum" Digest Algorithm . . . . . . . . . . . 26
13.7. Deprecate "SHA" Digest Algorithm . . . . . . . . . . . . 25 13.5. Update "UNIXcksum" Digest Algorithm . . . . . . . . . . 27
13.8. Obsolete "ADLER32" Digest Algorithm . . . . . . . . . . 25 13.6. Update "CRC32c" Digest Algorithm . . . . . . . . . . . . 27
13.9. Obsolete "contentMD5" token in Digest Algorithm . . . . 26 13.7. Deprecate "SHA" Digest Algorithm . . . . . . . . . . . . 27
13.10. The "id-sha-256" Digest Algorithm . . . . . . . . . . . 26 13.8. Obsolete "ADLER32" Digest Algorithm . . . . . . . . . . 28
13.11. The "id-sha-512" Digest Algorithm . . . . . . . . . . . 26 13.9. Obsolete "contentMD5" token in Digest Algorithm . . . . 28
13.12. Changes compared to RFC5843 . . . . . . . . . . . . . . 26 13.10. The "id-sha-256" Digest Algorithm . . . . . . . . . . . 28
13.13. Want-Digest Field Registration . . . . . . . . . . . . . 27 13.11. The "id-sha-512" Digest Algorithm . . . . . . . . . . . 29
13.14. Digest Header Field Registration . . . . . . . . . . . . 27 13.12. Changes Compared to RFC5843 . . . . . . . . . . . . . . 29
14. References . . . . . . . . . . . . . . . . . . . . . . . . . 27 13.13. Want-Digest Field Registration . . . . . . . . . . . . . 29
14.1. Normative References . . . . . . . . . . . . . . . . . . 27 13.14. Digest Field Registration . . . . . . . . . . . . . . . 29
14.2. Informative References . . . . . . . . . . . . . . . . . 29 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 30
Appendix A. Resource Representation and Representation-Data . . 30 14.1. Normative References . . . . . . . . . . . . . . . . . . 30
Appendix B. FAQ . . . . . . . . . . . . . . . . . . . . . . . . 32 14.2. Informative References . . . . . . . . . . . . . . . . . 31
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 34 Appendix A. Resource Representation and Representation-Data . . 33
Code Samples . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Appendix B. FAQ . . . . . . . . . . . . . . . . . . . . . . . . 35
Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 36
Since draft-ietf-httpbis-digest-headers-03 . . . . . . . . . . 35 Code Samples . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Since draft-ietf-httpbis-digest-headers-02 . . . . . . . . . . 35 Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Since draft-ietf-httpbis-digest-headers-01 . . . . . . . . . . 36 Since draft-ietf-httpbis-digest-headers-04 . . . . . . . . . . 38
Since draft-ietf-httpbis-digest-headers-00 . . . . . . . . . . 36 Since draft-ietf-httpbis-digest-headers-03 . . . . . . . . . . 38
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 36 Since draft-ietf-httpbis-digest-headers-02 . . . . . . . . . . 38
Since draft-ietf-httpbis-digest-headers-01 . . . . . . . . . . 38
Since draft-ietf-httpbis-digest-headers-00 . . . . . . . . . . 39
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 39
1. Introduction 1. Introduction
The core specification of HTTP does not define a means to protect the The core specification of HTTP does not define a means to protect the
integrity of resources. When HTTP messages are transferred between integrity of resources. When HTTP messages are transferred between
endpoints, the protocol might choose to make use of features of the endpoints, the protocol might choose to make use of features of the
lower layer in order to provide some integrity protection; for lower layer in order to provide some integrity protection; for
instance TCP checksums or TLS records [RFC2818]. instance TCP checksums or TLS records [RFC2818].
However, there are cases where relying on this alone is insufficient. However, there are cases where relying on this alone is insufficient.
An HTTP-level integrity mechanism that operates independent of An HTTP-level integrity mechanism that operates independent of
transfer can be used to detect programming errors and/or corruption transfer can be used to detect programming errors and/or corruption
of data at rest, be used across multiple hops in order to provide of data in flight or at rest, be used across multiple hops in order
end-to-end integrity guarantees, aid fault diagnosis across hops and to provide end-to-end integrity guarantees, can aid fault diagnosis
system boundaries, and can be used to validate integrity when across hops and system boundaries, and can be used to validate
reconstructing a resource fetched using different HTTP connections. integrity when reconstructing a resource fetched using different HTTP
connections.
This document defines a mechanism that acts on HTTP representation- This document defines a mechanism that acts on HTTP representation-
data. It can be combined with other mechanisms that protect data. It can be combined with other mechanisms that protect
representation-metadata, such as digital signatures, in order to representation-metadata, such as digital signatures, in order to
protect the desired parts of an HTTP exchange in whole or in part. protect the desired parts of an HTTP exchange in whole or in part.
1.1. A Brief History of HTTP Integrity Fields 1.1. A Brief History of HTTP Integrity Fields
The Content-MD5 header field was originally introduced to provide The Content-MD5 header field was originally introduced to provide
integrity, but HTTP/1.1 ([RFC7231], Appendix B) obsoleted it: integrity, but HTTP/1.1 ([RFC7231], Appendix B) obsoleted it:
The Content-MD5 header field has been removed because it was The Content-MD5 header field has been removed because it was
inconsistently implemented with respect to partial responses. inconsistently implemented with respect to partial responses.
[RFC3230] provided a more flexible solution introducing the concept [RFC3230] provided a more flexible solution introducing the concept
of "instance", and the fields "Digest" and "Want-Digest". of "instance", and the fields "Digest" and "Want-Digest".
1.2. This Proposal 1.2. This Proposal
The concept of "selected representation" defined in Section 7 of The concept of "selected representation" defined in Section 3.2 of
[SEMANTICS] makes [RFC3230] definitions inconsistent with current [SEMANTICS] makes [RFC3230] definitions inconsistent with current
HTTP semantics. This document updates the "Digest" and "Want-Digest" HTTP semantics. This document updates the "Digest" and "Want-Digest"
field definitions to align with [SEMANTICS] concepts. field definitions to align with [SEMANTICS] concepts.
Basing "Digest" on the selected representation makes it Basing "Digest" on the selected representation makes it
straightforward to apply it to use-cases where the transferred data straightforward to apply it to use-cases where the transferred data
does require some sort of manipulation to be considered a does require some sort of manipulation to be considered a
representation, or conveys a partial representation of a resource eg. representation, or conveys a partial representation of a resource eg.
Range Requests (see Section 13.2 of [SEMANTICS]). Range Requests (see Section 14.2 of [SEMANTICS]).
Changes are semantically compatible with existing implementations and This document replaces [RFC3230] to better align with [SEMANTICS] and
better cover both the request and response cases. to provide more detailed description of "Digest" usage in request and
response cases. Changes are intended to be semantically compatible
with existing implementations but note that negotiation of "Content-
MD5" is deprecated Section 7, "Digest" field parameters are obsoleted
Section 8, "md5" and "sha" digest-algorithms are obsoleted
Section 12.2 and the "adler32" algorithm is deprecated Section 12.3.
The value of "Digest" is calculated on selected representation, which The value of "Digest" is calculated on selected representation, which
is tied to the value contained in any "Content-Encoding" or "Content- is tied to the value contained in any "Content-Encoding" or "Content-
Type" header fields. Therefore, a given resource may have multiple Type" header fields. Therefore, a given resource may have multiple
different digest values. different digest values.
To allow both parties to exchange a Digest of a representation with To allow both parties to exchange a Digest of a representation with
no content codings (see Section 7.5.1 of [SEMANTICS]) two more no content codings (see Section 8.4.1 of [SEMANTICS]) two more
digest-algorithms are added ("id-sha-256" and "id-sha-512"). digest-algorithms are added ("id-sha-256" and "id-sha-512").
1.3. Goals 1.3. Goals
The goals of this proposal are: The goals of this proposal are:
1. Digest coverage for either the resource's "representation data" 1. Digest coverage for either the resource's "representation data"
or "selected representation data" communicated via HTTP. or "selected representation data" communicated via HTTP.
2. Support for multiple digest-algorithms. 2. Support for multiple digest-algorithms.
3. Negotiation of the use of digests. 3. Negotiation of the use of digests.
The goals do not include: The goals do not include:
HTTP message integrity: The digest mechanism described here does not HTTP message integrity: Digest mechanisms do not cover the full HTTP
cover the full HTTP message nor its semantic, as representation message nor its semantic, as representation metadata is not
metadata are not included in the checksum. included in the checksum.
HTTP field integrity: The digest mechanisms described here cover HTTP field integrity: Digest mechanisms cover only representation
only representation and selected representation data, and do not and selected representation data, and do not protect the integrity
protect the integrity of associated representation metadata or of associated representation metadata or other message fields.
other message fields.
Authentication: The digest mechanisms described here are not meant Authentication: Digest mechanisms do not support authentication of
to support authentication of the source of a digest or of a the source of a digest, message or anything else. These
message or anything else. These mechanisms, therefore, are not a mechanisms, therefore, are not a sufficient defense against many
sufficient defense against many kinds of malicious attacks. kinds of malicious attacks.
Privacy: Digest mechanisms do not provide message privacy. Privacy: Digest mechanisms do not provide message privacy.
Authorization: The digest mechanisms described here are not meant to Authorization: Digest mechanisms do not support authorization or
support authorization or other kinds of access controls. other kinds of access controls.
1.4. Notational Conventions 1.4. Notational Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP "OPTIONAL" in this document are to be interpreted as described in
14 ([RFC2119] and [RFC8174]) when, and only when, they appear in all BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
This document uses the Augmented BNF defined in [RFC5234] and updated This document uses the Augmented BNF defined in [RFC5234] and updated
by [RFC7405] along with the "#rule" extension defined in by [RFC7405] along with the "#rule" extension defined in
Section 5.7.1 of [SEMANTICS]. Section 5.6.1 of [SEMANTICS].
The definitions "representation", "selected representation", The definitions "representation", "selected representation",
"representation data", "representation metadata", and "payload body" "representation data", "representation metadata", and "content" in
in this document are to be interpreted as described in [SEMANTICS]. this document are to be interpreted as described in [SEMANTICS].
Algorithm names respect the casing used in their definition document Algorithm names respect the casing used in their definition document
(eg. SHA-1, CRC32c) whereas digest-algorithm tokens are quoted (eg. (eg. SHA-1, CRC32c) whereas digest-algorithm tokens are quoted (eg.
"sha", "crc32c"). "sha", "crc32c").
2. Representation Digest 2. Representation Digest
The representation digest is an integrity mechanism for HTTP The representation digest is an integrity mechanism for HTTP
resources which uses a checksum that is calculated independently of resources which uses a checksum that is calculated independently of
the payload body (see Section 5.5.4 of [SEMANTICS]). It uses the the content (see Section 6.4 of [SEMANTICS]). It uses the
representation data (see Section 7.2 of [SEMANTICS]), that can be representation data (see Section 8.1 of [SEMANTICS]), that can be
fully or partially contained in the payload body, or not contained at fully or partially contained in the content, or not contained at all:
all:
representation-data := Content-Encoding( Content-Type( bits ) ) representation-data := Content-Encoding( Content-Type( bits ) )
This takes into account the effect of the HTTP semantics on the This takes into account the effect of the HTTP semantics on the
messages; for example the payload body can be affected by Range messages; for example, the content can be affected by Range Requests
Requests or methods such as HEAD, while the way the payload body is or methods such as HEAD, while the way the content is transferred "on
transferred "on the wire" is dependent on other transformations (eg. the wire" is dependent on other transformations (e.g. transfer
transfer codings for HTTP/1.1 see 6.1 of [HTTP11]): Appendix A codings for HTTP/1.1 - see Section 6.1 of [HTTP11]). To help
contains several examples to help illustrate those effects. illustrate how such things affect "Digest", several examples are
provided in Appendix A.
A representation digest consists of the value of a checksum computed A representation digest consists of the value of a checksum computed
on the entire selected "representation data" (see Section 7 of on the entire selected "representation data" (see Section 8.1 of
[SEMANTICS]) of a resource identified according to Section 5.5.2 of [SEMANTICS]) of a resource identified according to Section 6.4.2 of
[SEMANTICS] together with an indication of the algorithm used [SEMANTICS] together with an indication of the algorithm used:
representation-data-digest = digest-algorithm "=" representation-data-digest = digest-algorithm "="
<encoded digest output> <encoded digest output>
When a message has no representation data it is still possible to
assert that no representation data was sent computing the
representation digest on an empty string (see Section 12.6).
The checksum is computed using one of the digest-algorithms listed in The checksum is computed using one of the digest-algorithms listed in
Section 5 and then encoded in the associated format. Section 5 and then encoded in the associated format.
The example below shows the "sha-256" digest-algorithm which uses The example below shows the "sha-256" digest-algorithm that uses
base64 encoding. base64 encoding.
sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
3. The Digest Field 3. The Digest Field
The "Digest" field contains a list of one or more representation The "Digest" field contains a list of one or more representation
digest values as defined in Section 2. It can be used in both digest values as defined in Section 2. It can be used in both
request and response. requests and responses.
Digest = "Digest" ":" OWS 1#representation-data-digest Digest = 1#representation-data-digest
The relationship between "Content-Location" (see Section 7.8 of For example:
Digest: id-sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==
The relationship between "Content-Location" (see Section 8.7 of
[SEMANTICS]) and "Digest" is demonstrated in Section 10.7. A [SEMANTICS]) and "Digest" is demonstrated in Section 10.7. A
comprehensive set of examples showing the impacts of representation comprehensive set of examples showing the impacts of representation
metadata, payload transformations and HTTP methods on Digest is metadata, payload transformations and HTTP methods on Digest is
provided in Section 10 and Section 11. provided in Section 10 and Section 11.
A "Digest" field MAY contain multiple representation-data-digest A "Digest" field MAY contain multiple representation-data-digest
values. For example, a server may provide representation-data-digest values. For example, a server may provide representation-data-digest
values using different algorithms, allowing it to support a values using different algorithms, allowing it to support a
population of clients with different evolving capabilities; this is population of clients with different evolving capabilities; this is
particularly useful in support of transitioning away from weaker particularly useful in support of transitioning away from weaker
algorithms should the need arise (see Section 12.9). algorithms should the need arise (see Section 12.9).
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
A recipient MAY ignore any or all of the representation-data-digests A recipient MAY ignore any or all of the representation-data-digests
in a Digest field. This allows the recipient to choose which digest- in a Digest field. This allows the recipient to choose which digest-
algorithm(s) to use for validation instead of verifying every algorithm(s) to use for validation instead of verifying every
received representation-data-digest. received representation-data-digest.
A sender MAY send a representation-data-digest using a digest- A sender MAY send a representation-data-digest using a digest-
algorithm without knowing whether the recipient supports the digest- algorithm without knowing whether the recipient supports the digest-
algorithm, or even knowing that the recipient will ignore it. algorithm, or even knowing that the recipient will ignore it.
"Digest" can be sent in a trailer section. When using incremental "Digest" can be sent in a trailer section. When an incremental
digest-algorithms this allows the sender and the receiver to digest-algorithms is used, the sender and the receiver can
dynamically compute the digest value while streaming the content. dynamically compute the digest value while streaming the content.
Two examples of its use are
Digest: id-sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
4. The Want-Digest Field 4. The Want-Digest Field
The "Want-Digest" field indicates the sender's desire to receive a The "Want-Digest" field indicates the sender's desire to receive a
representation digest on messages associated with the request URI and representation digest on messages associated with the request URI and
representation metadata. representation metadata.
Want-Digest = "Want-Digest" ":" OWS 1#want-digest-value Want-Digest = 1#want-digest-value
want-digest-value = digest-algorithm [ ";" "q" "=" qvalue] want-digest-value = digest-algorithm [ ";" "q" "=" qvalue]
qvalue = ( "0"  [ "."  0*1DIGIT ] ) / qvalue = ( "0"  [ "."  0*1DIGIT ] ) /
  ( "1"  [ "."  0*1( "0" ) ] )   ( "1"  [ "."  0*1( "0" ) ] )
If a digest-algorithm is not accompanied by a "qvalue", it is treated If a digest-algorithm is not accompanied by a "qvalue", it is treated
as if its associated "qvalue" were 1.0. as if its associated "qvalue" were 1.0.
The sender is willing to accept a digest-algorithm if and only if it The sender is willing to accept a digest-algorithm if and only if it
is listed in a "Want-Digest" field of a message, and its "qvalue" is is listed in a "Want-Digest" field of a message, and its "qvalue" is
non-zero. non-zero.
If multiple acceptable digest-algorithm values are given, the If multiple acceptable digest-algorithm values are given, the
sender's preferred digest-algorithm is the one (or ones) with the sender's preferred digest-algorithm is the one (or ones) with the
highest "qvalue". highest "qvalue".
Two examples of its use are Two examples of its use are:
Want-Digest: sha-256 Want-Digest: sha-256
Want-Digest: sha-512;q=0.3, sha-256;q=1, unixsum;q=0 Want-Digest: sha-512;q=0.3, sha-256;q=1, unixsum;q=0
5. Digest Algorithm Values 5. Digest Algorithm Values
Digest-algorithm values are used to indicate a specific digest Digest-algorithm values are used to indicate a specific digest
computation. computation.
digest-algorithm = token digest-algorithm = token
All digest-algorithm values are case-insensitive but the lower case All digest-algorithm values are case-insensitive but lower case is
is preferred. preferred.
The Internet Assigned Numbers Authority (IANA) acts as a registry for The Internet Assigned Numbers Authority (IANA) acts as a registry for
digest-algorithm values. The registry contains the tokens listed digest-algorithm values. The registry contains the tokens listed
below. below.
Some digest-algorithms, although registered, rely on vulnerable Some digest-algorithms, although registered, rely on vulnerable
algorithms: the "md5" digest-algorithm MUST NOT be used due to algorithms and MUST not be used:
collision attacks [CMU-836068] and the "sha" digest-algorithm MUST
NOT be used due to collision attacks [IACR-2020-014]. * "md5", see [CMU-836068] and [NO-MD5];
* "sha", see [IACR-2020-014] and [NO-SHA1].
See the references above for further information.
sha-256 sha-256
* Description: The SHA-256 algorithm [RFC6234]. The output of * Description: The SHA-256 algorithm [RFC6234]. The output of
this algorithm is encoded using the base64 encoding [RFC4648]. this algorithm is encoded using the base64 encoding [RFC4648].
* Reference: [RFC6234], [RFC4648], this document. * Reference: [RFC6234], [RFC4648], this document.
* Status: standard * Status: standard
sha-512 sha-512
skipping to change at page 9, line 17 skipping to change at page 9, line 34
this algorithm is encoded using the base64 encoding [RFC4648]. this algorithm is encoded using the base64 encoding [RFC4648].
* Reference: [RFC6234], [RFC4648], this document. * Reference: [RFC6234], [RFC4648], this document.
* Status: standard * Status: standard
md5 md5
* Description: The MD5 algorithm, as specified in [RFC1321]. The * Description: The MD5 algorithm, as specified in [RFC1321]. The
output of this algorithm is encoded using the base64 encoding output of this algorithm is encoded using the base64 encoding
[RFC4648]. This digest-algorithm MUST NOT be used as it's now [RFC4648]. This digest-algorithm MUST NOT be used as it's now
vulnerable to collision attacks [CMU-836068]. vulnerable to collision attacks. See [NO-MD5] and
[CMU-836068].
* Reference: [RFC1321], [RFC4648], this document. * Reference: [RFC1321], [RFC4648], this document.
* Status: deprecated * Status: deprecated
sha sha
* Description: The SHA-1 algorithm [RFC3174]. The output of this * Description: The SHA-1 algorithm [RFC3174]. The output of this
algorithm is encoded using the base64 encoding [RFC4648]. This algorithm is encoded using the base64 encoding [RFC4648]. This
digest-algorithm MUST NOT be used as it's now vulnerable to digest-algorithm MUST NOT be used as it's now vulnerable to
collision attacks [IACR-2020-014]. collision attacks. See [NO-SHA1] and [IACR-2020-014].
* Reference: [RFC3174], [RFC6234], [RFC4648], this document. * Reference: [RFC3174], [RFC6234], [RFC4648], this document.
* Status: deprecated * Status: deprecated
unixsum unixsum
* Description: The algorithm computed by the UNIX "sum" command, * Description: The algorithm computed by the UNIX "sum" command,
as defined by the Single UNIX Specification, Version 2 [UNIX]. as defined by the Single UNIX Specification, Version 2 [UNIX].
The output of this algorithm is an ASCII decimal-digit string The output of this algorithm is an ASCII decimal-digit string
representing the 16-bit checksum, which is the first word of representing the 16-bit checksum, which is the first word of
skipping to change at page 10, line 28 skipping to change at page 10, line 48
id-sha-256 id-sha-256
* Description: The sha-256 digest of the representation-data of * Description: The sha-256 digest of the representation-data of
the resource when no content coding is applied the resource when no content coding is applied
* Reference: [RFC6234], [RFC4648], this document. * Reference: [RFC6234], [RFC4648], this document.
* Status: standard * Status: standard
If other digest-algorithm values are defined, the associated encoding If other digest-algorithm values are defined, the associated encoding
MUST either be represented as a quoted string, or MUST NOT include MUST either be represented as a quoted string or MUST NOT include ";"
";" or "," in the character sets used for the encoding. or "," in the character sets used for the encoding.
6. Use of Digest when acting on resources 6. Use of Digest when acting on resources
POST and PATCH requests can appear to convey partial representations POST and PATCH requests can appear to convey partial representations
but are semantically acting on resources. The enclosed but are semantically acting on resources. The enclosed
representation, including its metadata refers to that action. representation, including its metadata, refers to that action.
In these requests the representation digest MUST be computed on the In these requests the representation digest MUST be computed on the
representation-data of that action. This is the only possible choice representation-data of that action. This is the only possible choice
because representation digest requires complete representation because representation digest requires complete representation
metadata (see Section 2). metadata (see Section 2).
In responses, In responses,
* if the representation describes the status of the request, * if the representation describes the status of the request,
"Digest" MUST be computed on the enclosed representation (see "Digest" MUST be computed on the enclosed representation (see
skipping to change at page 11, line 12 skipping to change at page 11, line 34
different from the target resource. That might or might not different from the target resource. That might or might not
result in computing "Digest" on the enclosed representation. result in computing "Digest" on the enclosed representation.
The latter case might be done according to the HTTP semantics of the The latter case might be done according to the HTTP semantics of the
given method, for example using the "Content-Location" header field. given method, for example using the "Content-Location" header field.
In contrast, the "Location" header field does not affect "Digest" In contrast, the "Location" header field does not affect "Digest"
because it is not representation metadata. because it is not representation metadata.
6.1. Digest and PATCH 6.1. Digest and PATCH
In PATCH requests the representation digest MUST be computed on the In PATCH requests, the representation digest MUST be computed on the
patch document because the representation metadata refers to the patch document because the representation metadata refers to the
patch document and not to the target resource (see Section 2 of patch document and not to the target resource (see Section 2 of
[RFC5789]). [PATCH]).
In PATCH responses the representation digest MUST be computed on the In PATCH responses, the representation digest MUST be computed on the
selected representation of the patched resource. selected representation of the patched resource.
"Digest" usage with PATCH is thus very similar to the POST one, but "Digest" usage with PATCH is thus very similar to POST, but with the
with the resource's own semantic partly implied by the method and by resource's own semantic partly implied by the method and by the patch
the patch document. document.
7. Deprecate Negotiation of Content-MD5 7. Deprecate Negotiation of Content-MD5
This RFC deprecates the negotiation of Content-MD5 as it has been This RFC deprecates the negotiation of Content-MD5 as it has been
obsoleted by [RFC7231]. The "contentMD5" token defined in Section 5 obsoleted by [RFC7231]. The "contentMD5" token defined in Section 5
of [RFC3230] MUST NOT be used as a digest-algorithm. of [RFC3230] MUST NOT be used as a digest-algorithm.
8. Obsolete Digest Header Field Parameters 8. Obsolete Digest Field Parameters
This document obsoletes the usage of parameters with "Digest" Section 4.1.1 and 4.2 of [RFC3230] defined field parameters. This
introduced in Section 4.1.1 and 4.2 of [RFC3230] because this feature document obsoletes the usage of parameters with "Digest" because this
has not been widely deployed and complicates field-value processing. feature has not been widely deployed and complicates field-value
processing.
Field parameters provided a common way to attach additional [RFC3230] intended field parameters to provide a common way to attach
information to a representation-data-digest, but if they are used as additional information to a representation-data-digest. However, if
an input to validate the checksum, an attacker could alter them to parameters are used as an input to validate the checksum, an attacker
steer the validation behavior. could alter them to steer the validation behavior.
A digest-algorithm can still be parameterized defining its own way to A digest-algorithm can still be parameterized by defining its own way
encode parameters into the representation-data-digest in such a way to encode parameters into the representation-data-digest, in such a
as to mitigate security risks related to its computation. way as to mitigate security risks related to its computation.
9. Relationship to Subresource Integrity (SRI) 9. Relationship to Subresource Integrity (SRI)
Subresource Integrity [SRI] is an integrity mechanism that shares Subresource Integrity [SRI] is an integrity mechanism that shares
some similarities to the present document's mechanism. However, some similarities to the present document's mechanism. However,
there are differences in motivating factors, threat model and there are differences in motivating factors, threat model and
specification of integrity digest generation, signalling and specification of integrity digest generation, signalling and
validation. validation.
SRI allows a first-party authority to declare an integrity assertion SRI allows a first-party authority to declare an integrity assertion
skipping to change at page 12, line 23 skipping to change at page 12, line 47
digests are presented in Section 12. This contrast is interesting digests are presented in Section 12. This contrast is interesting
because on one hand self-assertion is less likely to be affected by because on one hand self-assertion is less likely to be affected by
coordination problems such as the first-party holding stale coordination problems such as the first-party holding stale
information about the third party, but on the other hand the self- information about the third party, but on the other hand the self-
assertion is only as trustworthy as the authority that provided it. assertion is only as trustworthy as the authority that provided it.
The SRI "integrity" attribute contains a cryptographic hash algorithm The SRI "integrity" attribute contains a cryptographic hash algorithm
and digest value which is similar to "representation-data-digest" and digest value which is similar to "representation-data-digest"
(see Section 2). The major differences are in serialization format. (see Section 2). The major differences are in serialization format.
The SRI digest value is calculated over the identity encoding of the
resource, not the selected representation (as specified for
"representation-data-digest" in this document). Section 3.4.5 of
[SRI] describes the benefit of the identity approach - the SRI
"integrity" attribute can contain multiple algorithm-value pairs
where each applies to a different identity encoded payload. This
allows for protection of distinct resources sharing a URL. However,
this is a contrast to the design of representation digests, where
multiple "Digest" field-values all protect the same representation.
SRI does not specify handling of partial representation data (e.g. SRI does not specify handling of partial representation data (e.g.
Range requests). In contrast, this document specifies handling in Range requests). In contrast, this document specifies handling in
terms that are fully compatible with core HTTP concepts (an example terms that are fully compatible with core HTTP concepts (an example
is provided in Section 10.3). is provided in Section 10.3).
SRI specifies strong requirements on the selection of algorithm for SRI specifies strong requirements on the selection of algorithm for
generation and validation of digests. In contrast, the requirements generation and validation of digests. In contrast, the requirements
in this document are weaker. in this document are weaker.
SRI defines no method for a client to declare an integrity assertion SRI defines no method for a client to declare an integrity assertion
skipping to change at page 13, line 23 skipping to change at page 13, line 37
find one validates successfully while the other fails. This document find one validates successfully while the other fails. This document
specifies no requirements or guidance for user agents that experience specifies no requirements or guidance for user agents that experience
such cases. such cases.
10. Examples of Unsolicited Digest 10. Examples of Unsolicited Digest
The following examples demonstrate interactions where a server The following examples demonstrate interactions where a server
responds with a "Digest" field even though the client did not solicit responds with a "Digest" field even though the client did not solicit
one using "Want-Digest". one using "Want-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.
"Digest" is media-type agnostic and does not provide canonicalization
algorithms for specific formats. Examples of "Digest" are calculated
inclusive of any space.
10.1. Server Returns Full Representation Data 10.1. Server Returns Full Representation Data
Request: Request:
GET /items/123 GET /items/123 HTTP/1.1
Host: foo.example
Response: Response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
{"hello": "world"} {"hello": "world"}
10.2. Server Returns No Representation Data 10.2. Server Returns No Representation Data
Requests without a payload body can still send a "Digest" field In this example, a HEAD request is used to retrieve the checksum of a
applying the digest-algorithm to an empty representation. resource.
As there is no content coding applied, the "sha-256" and the "id-sha- The response "Digest" field-value is calculated over the JSON object
256" digest-values in the response are the same. "{"hello": "world"}", which is not shown because there is no payload
data.
Request: Request:
HEAD /items/123 HTTP/1.1 HEAD /items/123 HTTP/1.1
Digest: sha-256=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= Host: foo.example
Response: Response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Digest: id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
10.3. Server Returns Partial Representation Data 10.3. Server Returns Partial Representation Data
In this example, the client makes a range request and the server
responds with partial content. The "Digest" field-value represents
the entire JSON object "{"hello": "world"}".
Request: Request:
GET /items/123 GET /items/123 HTTP/1.1
Host: foo.example
Range: bytes=1-7 Range: bytes=1-7
Response: Response:
HTTP/1.1 206 Partial Content HTTP/1.1 206 Partial Content
Content-Type: application/json Content-Type: application/json
Content-Range: bytes 1-7/18 Content-Range: bytes 1-7/18
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
"hello" "hello"
10.4. Client and Server Provide Full Representation Data 10.4. Client and Server Provide Full Representation Data
The request contains a "Digest" field calculated on the enclosed The request contains a "Digest" field-value calculated on the
representation. enclosed representation. It also includes an "Accept-Encoding: br"
header field that advertises the client supports brotli encoding.
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 The response includes a "Content-Encoding: br" that indicates the
selected representation is brotli encoded. The "Digest" field-value selected representation is brotli encoded. The "Digest" field-value
is therefore different compared to the request. is therefore different compared to the request.
The response body is displayed as a base64-encoded string because it For presentation purposes, the response body is displayed as a
contains non-printable characters. base64-encoded string because it contains non-printable characters.
Request: Request:
PUT /items/123 PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json Content-Type: application/json
Accept-Encoding: br Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
{"hello": "world"} {"hello": "world"}
Response: Response:
HTTP/1.1 200 Ok
Content-Type: application/json Content-Type: application/json
Content-Location: /items/123
Content-Encoding: br Content-Encoding: br
Content-Length: 22
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo= Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=
iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw== iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw==
10.5. Client Provides Full Representation Data, Server Provides No 10.5. Client Provides Full Representation Data, Server Provides No
Representation Data Representation Data
Request "Digest" value is calculated on the enclosed payload. The request "Digest" field-value is calculated on the enclosed
Response "Digest" value depends on the representation metadata header payload.
fields, including "Content-Encoding: br" even when the response does
not contain a payload body. The response "Digest" field-value depends on the representation
metadata header fields, including "Content-Encoding: br" even when
the response does not contain content.
Request: Request:
PUT /items/123 PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json Content-Type: application/json
Content-Length: 18 Content-Length: 18
Accept-Encoding: br Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
{"hello": "world"} {"hello": "world"}
Response: Response:
HTTP/1.1 204 No Content HTTP/1.1 204 No Content
skipping to change at page 16, line 6 skipping to change at page 16, line 44
request; request;
* one taking into account the "Content-Encoding". * one taking into account the "Content-Encoding".
As the response body contains non-printable characters, it is As the response body contains non-printable characters, it is
displayed as a base64-encoded string. displayed as a base64-encoded string.
Request: Request:
PUT /items/123 HTTP/1.1 PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json Content-Type: application/json
Accept-Encoding: br Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
{"hello": "world"} {"hello": "world"}
Response: Response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Content-Encoding: br Content-Encoding: br
Content-Location: /items/123
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=, Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw== iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw==
10.7. POST Response does not Reference the Request URI 10.7. POST Response does not Reference the Request URI
Request "Digest" value is computed on the enclosed representation The request "Digest" field-value is computed on the enclosed
(see Section 6). representation (see Section 6).
The representation enclosed in the response refers to the resource The representation enclosed in the response refers to the resource
identified by "Content-Location" (see [SEMANTICS], Section 5.5.2). identified by "Content-Location" (see [SEMANTICS], Section 6.4.2).
"Digest" is thus computed on the enclosed representation. "Digest" is thus computed on the enclosed representation.
Request: Request:
POST /books HTTP/1.1 POST /books HTTP/1.1
Host: foo.example
Content-Type: application/json Content-Type: application/json
Accept: application/json Accept: application/json
Accept-Encoding: identity Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ= Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=
{"title": "New Title"} {"title": "New Title"}
Response Response:
HTTP/1.1 201 Created HTTP/1.1 201 Created
Content-Type: application/json Content-Type: application/json
Digest: id-sha-256=BZlF2v0IzjuxN01RQ97EUXriaNNLhtI8Chx8Eq+XYSc=
Content-Location: /books/123 Content-Location: /books/123
Location: /books/123
Digest: id-sha-256=yxOAqEeoj+reqygSIsLpT0LhumrNkIds5uLKtmdLyYE=
{"id": "123", "title": "New Title"} {
"id": "123",
"title": "New Title"
}
Note that a "204 No Content" response without a payload body but with Note that a "204 No Content" response without content but with the
the same "Digest" field-value would have been legitimate too. same "Digest" field-value would have been legitimate too.
10.8. POST Response Describes the Request Status 10.8. POST Response Describes the Request Status
Request "Digest" value is computed on the enclosed representation The request "Digest" field-value is computed on the enclosed
(see Section 6). representation (see Section 6).
The representation enclosed in the response describes the status of The representation enclosed in the response describes the status of
the request, so "Digest" is computed on that enclosed representation. the request, so "Digest" is computed on that enclosed representation.
Response "Digest" has no explicit relation with the resource Response "Digest" has no explicit relation with the resource
referenced by "Location". referenced by "Location".
Request: Request:
POST /books HTTP/1.1 POST /books HTTP/1.1
Host: foo.example
Content-Type: application/json Content-Type: application/json
Accept: application/json Accept: application/json
Accept-Encoding: identity Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ= Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=
Location: /books/123 Location: /books/123
{"title": "New Title"} {"title": "New Title"}
Response Response:
HTTP/1.1 201 Created HTTP/1.1 201 Created
Content-Type: application/json Content-Type: application/json
Digest: id-sha-256=0o/WKwSfnmIoSlop2LV/ISaBDth05IeW27zzNMUh5l8= Digest: id-sha-256=2LBp5RKZGpsSNf8BPXlXrX4Td4Tf5R5bZ9z7kdi5VvY=
Location: /books/123 Location: /books/123
{ {
"status": "created", "status": "created",
"id": "123", "id": "123",
"ts": 1569327729, "ts": 1569327729,
"instance": "/books/123" "instance": "/books/123"
} }
10.9. Digest with PATCH 10.9. Digest with PATCH
This case is analogous to a POST request where the target resource This case is analogous to a POST request where the target resource
reflects the effective request URI. reflects the effective request URI.
The PATCH request uses the "application/merge-patch+json" media type The PATCH request uses the "application/merge-patch+json" media type
defined in [RFC7396]. defined in [RFC7396].
"Digest" is calculated on the enclosed payload, which corresponds to "Digest" is calculated on the enclosed payload, which corresponds to
the patch document. the patch document.
The response "Digest" is computed on the complete representation of The response "Digest" field-value is computed on the complete
the patched resource. representation of the patched resource.
Request: Request:
PATCH /books/123 HTTP/1.1 PATCH /books/123 HTTP/1.1
Host: foo.example
Content-Type: application/merge-patch+json Content-Type: application/merge-patch+json
Accept: application/json Accept: application/json
Accept-Encoding: identity Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ= Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=
{"title": "New Title"} {"title": "New Title"}
Response: Response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Digest: id-sha-256=BZlF2v0IzjuxN01RQ97EUXriaNNLhtI8Chx8Eq+XYSc= Digest: id-sha-256=yxOAqEeoj+reqygSIsLpT0LhumrNkIds5uLKtmdLyYE=
{"id": "123", "title": "New Title"} {
"id": "123",
"title": "New Title"
}
Note that a "204 No Content" response without a payload body but with Note that a "204 No Content" response without content but with the
the same "Digest" field-value would have been legitimate too. same "Digest" field-value would have been legitimate too.
10.10. Error responses 10.10. Error responses
In error responses, the representation-data does not necessarily In error responses, the representation-data does not necessarily
refer to the target resource. Instead it refers to the refer to the target resource. Instead, it refers to the
representation of the error. representation of the error.
In the following example a client attempts to patch the resource In the following example a client attempts to patch the resource
located at /books/123. However, the resource does not exist and the located at /books/123. However, the resource does not exist and the
server generates a 404 response with a body that describes the error server generates a 404 response with a body that describes the error
in accordance with [RFC7807]. in accordance with [RFC7807].
The digest of the response is computed on this enclosed The response "Digest" field-value is computed on this enclosed
representation. representation.
Request: Request:
PATCH /books/123 HTTP/1.1 PATCH /books/123 HTTP/1.1
Host: foo.example
Content-Type: application/merge-patch+json Content-Type: application/merge-patch+json
Accept: application/json Accept: application/json
Accept-Encoding: identity Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ= Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=
{"title": "New Title"} {"title": "New Title"}
Response: Response:
HTTP/1.1 404 Not Found HTTP/1.1 404 Not Found
Content-Type: application/problem+json Content-Type: application/problem+json
Digest: sha-256=UJSojgEzqUe4UoHzmNl5d2xkmrW3BOdmvsvWu1uFeu0= Digest: sha-256=KPqhVXAT25LLitV1w0O167unHmVQusu+fpxm65zAsvk=
{ {
"title": "Not Found", "title": "Not Found",
"detail": "Cannot PATCH a non-existent resource", "detail": "Cannot PATCH a non-existent resource",
"status": 404 "status": 404
} }
10.11. Use with trailers and transfer coding 10.11. Use with Trailer Fields and Transfer Coding
An origin server sends "Digest" in the HTTP trailer, so it can An origin server sends "Digest" as trailer field, so it can calculate
calculate digest-value while streaming content and thus mitigate digest-value while streaming content and thus mitigate resource
resource consumption. The field value is the same as in Section 10.1 consumption. The "Digest" field-value is the same as in Section 10.1
because "Digest" is designed to be independent from the use of one or because "Digest" is designed to be independent from the use of one or
more transfer codings (see Section 2). more transfer codings (see Section 2).
Request: Request:
GET /items/123 GET /items/123 HTTP/1.1
Host: foo.example
Response: Response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Transfer-Encoding: chunked Transfer-Encoding: chunked
Trailer: Digest Trailer: Digest
8\r\n 8\r\n
{"hello"\r\n {"hello"\r\n
skipping to change at page 20, line 5 skipping to change at page 21, line 24
2\r\n 2\r\n
"}\r\n "}\r\n
0\r\n 0\r\n
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
11. Examples of Want-Digest Solicited Digest 11. Examples of Want-Digest Solicited Digest
The following examples demonstrate interactions where a client The following examples demonstrate interactions where a client
solicits a "Digest" using "Want-Digest". solicits a "Digest" using "Want-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.
"Digest" is media-type agnostic and does not provide canonicalization
algorithms for specific formats. Examples of "Digest" are calculated
inclusive of any space.
11.1. Server Selects Client's Least Preferred Algorithm 11.1. Server Selects Client's Least Preferred Algorithm
The client requests a digest, preferring "sha". The server is free The client requests a digest, preferring "sha". The server is free
to reply with "sha-256" anyway. to reply with "sha-256" anyway.
Request: Request:
GET /items/123 HTTP/1.1 GET /items/123 HTTP/1.1
Host: foo.example
Want-Digest: sha-256;q=0.3, sha;q=1 Want-Digest: sha-256;q=0.3, sha;q=1
Response: Response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
{"hello": "world"} {"hello": "world"}
11.2. Server Selects Algorithm Unsupported by Client 11.2. Server Selects Algorithm Unsupported by Client
The client requests a sha digest only. The server is currently free The client requests a "sha" digest only. The server is currently
to reply with a Digest containing an unsupported algorithm. free to reply with a Digest containing an unsupported algorithm.
Request: Request:
GET /items/123 GET /items/123 HTTP/1.1
Host: foo.example
Want-Digest: sha;q=1 Want-Digest: sha;q=1
Response: Response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Digest: id-sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm Digest: id-sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
+AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew== +AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==
{"hello": "world"} {"hello": "world"}
11.3. Server Does Not Support Client Algorithm and Returns an Error 11.3. Server Does Not Support Client Algorithm and Returns an Error
The client requests a sha Digest, the server advises for sha-256 and The client requests a "sha" Digest, the server advises "sha-256" and
sha-512 "sha-512".
Request: Request:
GET /items/123 GET /items/123 HTTP/1.1
Host: foo.example
Want-Digest: sha;q=1 Want-Digest: sha;q=1
Response: Response:
HTTP/1.1 400 Bad Request HTTP/1.1 400 Bad Request
Want-Digest: sha-256, sha-512 Want-Digest: sha-256, sha-512
12. Security Considerations 12. Security Considerations
12.1. Digest Does Not Protect the Full HTTP Message 12.1. Digest Does Not Protect the Full HTTP Message
This document specifies a data integrity mechanism that protects HTTP This document specifies a data integrity mechanism that protects HTTP
"representation data", but not HTTP "representation metadata" fields, "representation data", but not HTTP "representation metadata" fields,
from certain kinds of accidental corruption. from certain kinds of accidental corruption.
"Digest" is not intended as general protection against malicious "Digest" is not intended to be a general protection against malicious
tampering with HTTP messages, this can be achieved by combining it tampering with HTTP messages. This can be achieved by combining it
with other approaches such as transport-layer security or digital with other approaches such as transport-layer security or digital
signatures. signatures.
12.2. Broken Cryptographic Algorithms 12.2. Broken Cryptographic Algorithms
Cryptographic algorithms are intended to provide a proof of integrity Cryptographic algorithms are intended to provide a proof of integrity
suited towards cryptographic constructions such as signatures. suited towards cryptographic constructions such as signatures.
However, these rely on collision-resistance for their security proofs However, these rely on collision-resistance for their security proofs
[CMU-836068]. The "md5" and "sha" digest-algorithms are vulnerable [CMU-836068]. The "md5" and "sha" digest-algorithms are vulnerable
to collisions attacks, so they MUST NOT be used with "Digest". to collisions attacks, so they MUST NOT be used with "Digest".
12.3. Other Deprecated Algorithms 12.3. Other Deprecated Algorithms
The ADLER32 algorithm defined in [RFC1950] has been deprecated by The ADLER32 algorithm defined in [RFC1950] has been deprecated by
[RFC3309] because under certain conditions it provides weak detection [RFC3309] because, under certain conditions, it provides weak
of errors and is now NOT RECOMMENDED for use with "Digest". detection of errors. It is now NOT RECOMMENDED for use with
"Digest".
12.4. Digest for End-to-End Integrity 12.4. Digest for End-to-End Integrity
"Digest" alone does not provide end-to-end integrity of HTTP messages "Digest" only covers the "representation data" and not the
over multiple hops, as it just covers the "representation data" and "representation metadata". "Digest" could help protect the
not the "representation metadata". "representation data" from buggy manipulation, undesired
"transforming proxies" (see Section 7.7 of [SEMANTICS]) or other
Besides, it allows to protect "representation data" from buggy actions as the data passes across multiple hops or system boundaries.
manipulation, buggy compression, etc. Even a simple mechanism for end-to-end "representation data"
integrity is valuable because user-agent can validate that resource
retrieval succeeded before handing off to a HTML parser, video player
etc. for parsing.
Moreover identity digest-algorithms (eg. "id-sha-256" and "id-sha- Identity digest-algorithms (e.g. "id-sha-256" and "id-sha-512") are
512") allow piecing together a resource from different sources (e.g. particularly useful for end-to-end integrity because they allow
different servers that perhaps apply different content codings) piecing together a resource from different sources with different
enabling the user-agent to detect that the application-layer tasks HTTP messaging characteristics. For example, different servers that
completed properly, before handing off to say the HTML parser, video apply different content codings.
player etc.
Even a simple mechanism for end-to-end validation is thus valuable. Note that using "Digest" 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 Section 12.6.
12.5. Digest and Content-Location in responses 12.5. Digest and Content-Location in Responses
When a state-changing method returns the "Content-Location" header When a state-changing method returns the "Content-Location" header
field, the enclosed representation refers to the resource identified field, the enclosed representation refers to the resource identified
by its value and "Digest" is computed accordingly. by its value and "Digest" is computed accordingly.
12.6. Usage in signatures 12.6. Usage in Signatures
Digital signatures are widely used together with checksums to provide Digital signatures are widely used together with checksums to provide
the certain identification of the origin of a message [NIST800-32]. the certain identification of the origin of a message [NIST800-32].
Such signatures can protect one or more HTTP fields and there are Such signatures can protect one or more HTTP fields and there are
additional considerations when "Digest" is included in this set. additional considerations when "Digest" is included in this set.
Since the "Digest" field is a hash of a resource representation, it Since the "Digest" field is a hash of a resource representation, it
explicitly depends on the "representation metadata" (eg. the values explicitly depends on the "representation metadata" (eg. the values
of "Content-Type", "Content-Encoding" etc). A signature that of "Content-Type", "Content-Encoding" etc). A signature that
protects "Digest" but not other "representation metadata" can expose protects "Digest" but not other "representation metadata" can expose
the communication to tampering. For example, an actor could the communication to tampering. For example, an actor could
manipulate the "Content-Type" field-value and cause a digest manipulate the "Content-Type" field-value and cause a digest
validation failure at the recipient, preventing the application from validation failure at the recipient, preventing the application from
accessing the representation. Such an attack consumes the resources accessing the representation. Such an attack consumes the resources
of both endpoints. See also Section 12.5. of both endpoints. See also Section 12.5.
"Digest" SHOULD always be used over a connection which provides "Digest" SHOULD always be used over a connection that provides
integrity at the transport layer that protects HTTP fields. integrity at the transport layer that protects HTTP fields.
A "Digest" field using NOT RECOMMENDED digest-algorithms SHOULD NOT A "Digest" field using NOT RECOMMENDED digest-algorithms SHOULD NOT
be used in signatures. be used in signatures.
Using signatures to protect the "Digest" of an empty representation Using signatures to protect the "Digest" of an empty representation
allows receiving endpoints to detect if an eventual payload has been allows receiving endpoints to detect if an eventual payload has been
stripped or added. stripped or added.
12.7. Usage in trailers Any mangling of "Digest", including de-duplication of representation-
data-digest values or combining different field values (see
Section 5.2 of [SEMANTICS]) might affect signature validation.
When used in trailers, the receiver gets the digest value after the 12.7. Usage in Trailer Fields
payload body and may thus be tempted to process the data before
validating the digest value. Instead, data should only be processed
after validating the Digest.
If received in trailers, "Digest" MUST NOT be discarded; instead it When "Digest" is used in trailer fields, the receiver gets the digest
MAY be merged in the header section (See Section 5.6.2 of value after the content and may thus be tempted to process the data
before validating the digest value. It is prefereable that data is
only be processed after validating the Digest.
If received in trailers, "Digest" MUST NOT be discarded; instead, it
MAY be merged in the header section (See Section 6.5.1 of
[SEMANTICS]). [SEMANTICS]).
Not every digest-algorithm is suitable for trailers, as they may Not every digest-algorithm is suitable for use in the trailer
require to pre-process the whole payload before sending a message section, some may require to pre-process the whole payload before
(eg. see [I-D.thomson-http-mice]). sending a message (eg. see [I-D.thomson-http-mice]).
12.8. Usage with encryption 12.8. Usage with Encryption
"Digest" may expose information details of encrypted payload when the "Digest" may expose details of encrypted payload when the checksum is
checksum is computed on the unencrypted data. An example of that is computed on the unencrypted data. For example, the use of the "id-
the use of the "id-sha-256" digest-algorithm in conjunction with the sha-256" digest-algorithm in conjunction with the encrypted content-
encrypted content-coding [RFC8188]. coding [RFC8188].
The representation-data-digest of an encrypted payload can change The representation-data-digest of an encrypted payload can change
between different messages depending on the encryption algorithm between different messages depending on the encryption algorithm
used; in those cases its value could not be used to provide a proof used; in those cases its value could not be used to provide a proof
of integrity "at rest" unless the whole (e.g. encoded) payload body of integrity "at rest" unless the whole (e.g. encoded) content is
is persisted. persisted.
12.9. Algorithm Agility 12.9. Algorithm Agility
The security properties of digest-algorithms are not fixed. The security properties of digest-algorithms are not fixed.
Algorithm Agility (see [RFC7696]) is achieved by providing Algorithm Agility (see [RFC7696]) is achieved by providing
implementations flexibility in their choice of digest-algorithm from implementations with flexibility choose digest-algorithms from the
the IANA Digest Algorithm Values registry in Section 13.1. IANA Digest Algorithm Values registry in Section 13.1.
To help endpoints understand weaker algorithms from stronger ones, To help endpoints understand weaker algorithms from stronger ones,
this document adds to the IANA Digest Algorithm Values registry a new this document adds to the IANA Digest Algorithm Values registry a new
"Status" field containing the most-recent appraisal of the digest- "Status" field containing the most-recent appraisal of the digest-
algorithm; the allowed values are specified in Section 13.2. algorithm; the allowed values are specified in Section 13.2.
An endpoint might have a preference for algorithms, such as An endpoint might have a preference for algorithms, such as
preferring "standard" algorithms over "deprecated" ones. Transition preferring "standard" algorithms over "deprecated" ones. Transition
from weak algorithms is supported by negotiation of digest-algorithm from weak algorithms is supported by negotiation of digest-algorithm
using "Want-Digest" (see Section 4) or by sending multiple using "Want-Digest" (see Section 4) or by sending multiple
representation-data-digest values from which the receiver chooses. representation-data-digest values from which the receiver chooses.
Endpoints are advised that sending multiple values consumes Endpoints are advised that sending multiple values consumes
resources, which may be wasted if the receiver ignores them (see resources, which may be wasted if the receiver ignores them (see
Section 3). Section 3).
12.9.1. Duplicate digest-algorithm in field value
An endpoint might receive multiple representation-data-digest values
(see Section 3) that use the same digest-algorithm with different or
identical digest-values. For example:
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=,
sha-256=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
A receiver is permitted to ignore any representation-data-digest
value, so validation of duplicates is left as an implementation
decision. Endpoints might select all, some or none of the values for
checksum comparison and, based on the intersection of those results,
conditionally pass or fail digest validation.
12.10. Resource exhaustion
"Digest" 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.
13. IANA Considerations 13. IANA Considerations
13.1. Establish the HTTP Digest Algorithm Values 13.1. Establish the HTTP Digest Algorithm Values Registry
This memo sets this spec to be the establishing document for the HTTP This memo sets this specification to be the establishing document for
Digest Algorithm Values (https://www.iana.org/assignments/http-dig- the HTTP Digest Algorithm Values (https://www.iana.org/assignments/
alg/http-dig-alg.xhtml) http-dig-alg/http-dig-alg.xhtml) registry.
13.2. The "status" Field in the HTTP Digest Algorithm Values 13.2. The "status" Field in the HTTP Digest Algorithm Values Registry
This memo adds the field "Status" to the HTTP Digest Algorithm Values This memo adds the field "Status" to the HTTP Digest Algorithm Values
(https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml) (https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml)
registry. The allowed values for the "Status" fields are described registry. The allowed values for the "Status" fields are described
below. below.
Status Status
* "standard" for standardized algorithms without known problems; * "standard" for standardized algorithms without known problems;
* "experimental", "obsoleted" or some other appropriate value - * "experimental", "obsoleted" or some other appropriate value -
skipping to change at page 26, line 47 skipping to change at page 29, line 17
This memo registers the "id-sha-512" digest-algorithm in the HTTP This memo registers the "id-sha-512" digest-algorithm in the HTTP
Digest Algorithm Values (https://www.iana.org/assignments/http-dig- Digest Algorithm Values (https://www.iana.org/assignments/http-dig-
alg/http-dig-alg.xhtml) registry: alg/http-dig-alg.xhtml) registry:
* Digest Algorithm: id-sha-512 * Digest Algorithm: id-sha-512
* Description: As specified in Section 5. * Description: As specified in Section 5.
* Status: As specified in Section 5. * Status: As specified in Section 5.
13.12. Changes compared to RFC5843 13.12. Changes Compared to RFC5843
The digest-algorithm values for "MD5", "SHA", "SHA-256", "SHA-512", The digest-algorithm values for "MD5", "SHA", "SHA-256", "SHA-512",
"UNIXcksum", "UNIXsum", "ADLER32" and "CRC32c" have been updated to "UNIXcksum", "UNIXsum", "ADLER32" and "CRC32c" have been updated to
lowercase. lowercase.
The status of "MD5" has been updated to "deprecated", and its The status of "MD5" has been updated to "deprecated", and its
description states that this algorithm MUST NOT be used. description states that this algorithm MUST NOT be used.
The status of "SHA" has been updated to "deprecated", and its The status of "SHA" has been updated to "deprecated", and its
description states that this algorithm MUST NOT be used. description states that this algorithm MUST NOT be used.
skipping to change at page 27, line 28 skipping to change at page 29, line 46
This section registers the "Want-Digest" field in the "Hypertext This section registers the "Want-Digest" field in the "Hypertext
Transfer Protocol (HTTP) Field Name Registry" [SEMANTICS]. Transfer Protocol (HTTP) Field Name Registry" [SEMANTICS].
Field name: "Want-Digest" Field name: "Want-Digest"
Status: permanent Status: permanent
Specification document(s): Section 4 of this document Specification document(s): Section 4 of this document
13.14. Digest Header Field Registration 13.14. Digest Field Registration
This section registers the "Digest" field in the "Hypertext Transfer This section registers the "Digest" field in the "Hypertext Transfer
Protocol (HTTP) Field Name Registry" [SEMANTICS]. Protocol (HTTP) Field Name Registry" [SEMANTICS].
Field name: "Digest" Field name: "Digest"
Status: permanent Status: permanent
Specification document(s): Section 3 of this document Specification document(s): Section 3 of this document
14. References 14. References
14.1. Normative References 14.1. Normative References
[CMU-836068] [CMU-836068]
Carnagie Mellon University, Software Engineering Carnagie Mellon University, Software Engineering
skipping to change at page 28, line 14 skipping to change at page 30, line 30
[NIST800-32] [NIST800-32]
National Institute of Standards and Technology, U.S. National Institute of Standards and Technology, U.S.
Department of Commerce, "Introduction to Public Key Department of Commerce, "Introduction to Public Key
Technology and the Federal PKI Infrastructure", February Technology and the Federal PKI Infrastructure", February
2001, <https://nvlpubs.nist.gov/nistpubs/Legacy/SP/ 2001, <https://nvlpubs.nist.gov/nistpubs/Legacy/SP/
nistspecialpublication800-32.pdf>. nistspecialpublication800-32.pdf>.
[RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, [RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321,
DOI 10.17487/RFC1321, April 1992, DOI 10.17487/RFC1321, April 1992,
<https://www.rfc-editor.org/info/rfc1321>. <https://www.rfc-editor.org/rfc/rfc1321>.
[RFC1950] Deutsch, P. and J-L. Gailly, "ZLIB Compressed Data Format [RFC1950] Deutsch, P. and J-L. Gailly, "ZLIB Compressed Data Format
Specification version 3.3", RFC 1950, Specification version 3.3", RFC 1950,
DOI 10.17487/RFC1950, May 1996, DOI 10.17487/RFC1950, May 1996,
<https://www.rfc-editor.org/info/rfc1950>. <https://www.rfc-editor.org/rfc/rfc1950>.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/info/rfc2119>. <https://www.rfc-editor.org/rfc/rfc2119>.
[RFC3174] Eastlake 3rd, D. and P. Jones, "US Secure Hash Algorithm 1 [RFC3174] Eastlake 3rd, D. and P. Jones, "US Secure Hash Algorithm 1
(SHA1)", RFC 3174, DOI 10.17487/RFC3174, September 2001, (SHA1)", RFC 3174, DOI 10.17487/RFC3174, September 2001,
<https://www.rfc-editor.org/info/rfc3174>. <https://www.rfc-editor.org/rfc/rfc3174>.
[RFC3230] Mogul, J. and A. Van Hoff, "Instance Digests in HTTP", [RFC3230] Mogul, J. and A. Van Hoff, "Instance Digests in HTTP",
RFC 3230, DOI 10.17487/RFC3230, January 2002, RFC 3230, DOI 10.17487/RFC3230, January 2002,
<https://www.rfc-editor.org/info/rfc3230>. <https://www.rfc-editor.org/rfc/rfc3230>.
[RFC3309] Stone, J., Stewart, R., and D. Otis, "Stream Control [RFC3309] Stone, J., Stewart, R., and D. Otis, "Stream Control
Transmission Protocol (SCTP) Checksum Change", RFC 3309, Transmission Protocol (SCTP) Checksum Change", RFC 3309,
DOI 10.17487/RFC3309, September 2002, DOI 10.17487/RFC3309, September 2002,
<https://www.rfc-editor.org/info/rfc3309>. <https://www.rfc-editor.org/rfc/rfc3309>.
[RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006,
<https://www.rfc-editor.org/info/rfc4648>. <https://www.rfc-editor.org/rfc/rfc4648>.
[RFC4960] Stewart, R., Ed., "Stream Control Transmission Protocol", [RFC4960] Stewart, R., Ed., "Stream Control Transmission Protocol",
RFC 4960, DOI 10.17487/RFC4960, September 2007, RFC 4960, DOI 10.17487/RFC4960, September 2007,
<https://www.rfc-editor.org/info/rfc4960>. <https://www.rfc-editor.org/rfc/rfc4960>.
[RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", STD 68, RFC 5234, Specifications: ABNF", STD 68, RFC 5234,
DOI 10.17487/RFC5234, January 2008, DOI 10.17487/RFC5234, January 2008,
<https://www.rfc-editor.org/info/rfc5234>. <https://www.rfc-editor.org/rfc/rfc5234>.
[RFC5843] Bryan, A., "Additional Hash Algorithms for HTTP Instance [RFC5843] Bryan, A., "Additional Hash Algorithms for HTTP Instance
Digests", RFC 5843, DOI 10.17487/RFC5843, April 2010, Digests", RFC 5843, DOI 10.17487/RFC5843, April 2010,
<https://www.rfc-editor.org/info/rfc5843>. <https://www.rfc-editor.org/rfc/rfc5843>.
[RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms [RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms
(SHA and SHA-based HMAC and HKDF)", RFC 6234, (SHA and SHA-based HMAC and HKDF)", RFC 6234,
DOI 10.17487/RFC6234, May 2011, DOI 10.17487/RFC6234, May 2011,
<https://www.rfc-editor.org/info/rfc6234>. <https://www.rfc-editor.org/rfc/rfc6234>.
[RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF",
RFC 7405, DOI 10.17487/RFC7405, December 2014, RFC 7405, DOI 10.17487/RFC7405, December 2014,
<https://www.rfc-editor.org/info/rfc7405>. <https://www.rfc-editor.org/rfc/rfc7405>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/info/rfc8174>. May 2017, <https://www.rfc-editor.org/rfc/rfc8174>.
[SEMANTICS] [SEMANTICS]
Fielding, R., Nottingham, M., and J. Reschke, "HTTP Fielding, R. T., Nottingham, M., and J. Reschke, "HTTP
Semantics", Work in Progress, Internet-Draft, draft-ietf- Semantics", Work in Progress, Internet-Draft, draft-ietf-
httpbis-semantics-12, 2 October 2020, httpbis-semantics-15, 30 March 2021,
<http://www.ietf.org/internet-drafts/draft-ietf-httpbis- <https://tools.ietf.org/html/draft-ietf-httpbis-semantics-
semantics-12.txt>. 15>.
[UNIX] The Open Group, "The Single UNIX Specification, Version 2 [UNIX] The Open Group, "The Single UNIX Specification, Version 2
- 6 Vol Set for UNIX 98", February 1997. - 6 Vol Set for UNIX 98", February 1997.
14.2. Informative References 14.2. Informative References
[HTTP11] Fielding, R., Nottingham, M., and J. Reschke, "HTTP/1.1 [HTTP11] Fielding, R. T., Nottingham, M., and J. Reschke,
Messaging", Work in Progress, Internet-Draft, draft-ietf- "HTTP/1.1", Work in Progress, Internet-Draft, draft-ietf-
httpbis-messaging-12, 2 October 2020, httpbis-messaging-15, 30 March 2021,
<http://www.ietf.org/internet-drafts/draft-ietf-httpbis- <https://tools.ietf.org/html/draft-ietf-httpbis-messaging-
messaging-12.txt>. 15>.
[I-D.ietf-httpbis-header-structure] [I-D.ietf-httpbis-header-structure]
Nottingham, M. and P. Kamp, "Structured Field Values for Nottingham, M. and P. Kamp, "Structured Field Values for
HTTP", Work in Progress, Internet-Draft, draft-ietf- HTTP", Work in Progress, Internet-Draft, draft-ietf-
httpbis-header-structure-19, 3 June 2020, httpbis-header-structure-19, 3 June 2020,
<http://www.ietf.org/internet-drafts/draft-ietf-httpbis- <https://tools.ietf.org/html/draft-ietf-httpbis-header-
header-structure-19.txt>. structure-19>.
[I-D.thomson-http-mice] [I-D.thomson-http-mice]
Thomson, M. and J. Yasskin, "Merkle Integrity Content Thomson, M. and J. Yasskin, "Merkle Integrity Content
Encoding", Work in Progress, Internet-Draft, draft- Encoding", Work in Progress, Internet-Draft, draft-
thomson-http-mice-03, 13 August 2018, thomson-http-mice-03, 13 August 2018,
<http://www.ietf.org/internet-drafts/draft-thomson-http- <https://tools.ietf.org/html/draft-thomson-http-mice-03>.
mice-03.txt>.
[RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, [NO-MD5] Turner, S. and L. Chen, "Updated Security Considerations
DOI 10.17487/RFC2818, May 2000, for the MD5 Message-Digest and the HMAC-MD5 Algorithms",
<https://www.rfc-editor.org/info/rfc2818>. RFC 6151, DOI 10.17487/RFC6151, March 2011,
<https://www.rfc-editor.org/rfc/rfc6151>.
[RFC5789] Dusseault, L. and J. Snell, "PATCH Method for HTTP", [NO-SHA1] Polk, T., Chen, L., Turner, S., and P. Hoffman, "Security
Considerations for the SHA-0 and SHA-1 Message-Digest
Algorithms", RFC 6194, DOI 10.17487/RFC6194, March 2011,
<https://www.rfc-editor.org/rfc/rfc6194>.
[PATCH] Dusseault, L. and J. Snell, "PATCH Method for HTTP",
RFC 5789, DOI 10.17487/RFC5789, March 2010, RFC 5789, DOI 10.17487/RFC5789, March 2010,
<https://www.rfc-editor.org/info/rfc5789>. <https://www.rfc-editor.org/rfc/rfc5789>.
[RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818,
DOI 10.17487/RFC2818, May 2000,
<https://www.rfc-editor.org/rfc/rfc2818>.
[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Semantics and Content", RFC 7231, Protocol (HTTP/1.1): Semantics and Content", RFC 7231,
DOI 10.17487/RFC7231, June 2014, DOI 10.17487/RFC7231, June 2014,
<https://www.rfc-editor.org/info/rfc7231>. <https://www.rfc-editor.org/rfc/rfc7231>.
[RFC7396] Hoffman, P. and J. Snell, "JSON Merge Patch", RFC 7396, [RFC7396] Hoffman, P. and J. Snell, "JSON Merge Patch", RFC 7396,
DOI 10.17487/RFC7396, October 2014, DOI 10.17487/RFC7396, October 2014,
<https://www.rfc-editor.org/info/rfc7396>. <https://www.rfc-editor.org/rfc/rfc7396>.
[RFC7696] Housley, R., "Guidelines for Cryptographic Algorithm [RFC7696] Housley, R., "Guidelines for Cryptographic Algorithm
Agility and Selecting Mandatory-to-Implement Algorithms", Agility and Selecting Mandatory-to-Implement Algorithms",
BCP 201, RFC 7696, DOI 10.17487/RFC7696, November 2015, BCP 201, RFC 7696, DOI 10.17487/RFC7696, November 2015,
<https://www.rfc-editor.org/info/rfc7696>. <https://www.rfc-editor.org/rfc/rfc7696>.
[RFC7807] Nottingham, M. and E. Wilde, "Problem Details for HTTP [RFC7807] Nottingham, M. and E. Wilde, "Problem Details for HTTP
APIs", RFC 7807, DOI 10.17487/RFC7807, March 2016, APIs", RFC 7807, DOI 10.17487/RFC7807, March 2016,
<https://www.rfc-editor.org/info/rfc7807>. <https://www.rfc-editor.org/rfc/rfc7807>.
[RFC8188] Thomson, M., "Encrypted Content-Encoding for HTTP", [RFC8188] Thomson, M., "Encrypted Content-Encoding for HTTP",
RFC 8188, DOI 10.17487/RFC8188, June 2017, RFC 8188, DOI 10.17487/RFC8188, June 2017,
<https://www.rfc-editor.org/info/rfc8188>. <https://www.rfc-editor.org/rfc/rfc8188>.
[SRI] Akhawe, D., Braun, F., Marier, F., and J. Weinberger, [SRI] Akhawe, D., Braun, F., Marier, F., and J. Weinberger,
"Subresource Integrity", W3C Recommendation REC-SRI- "Subresource Integrity", W3C Recommendation REC-SRI-
20160623, 23 June 2016, 20160623, 23 June 2016,
<https://www.w3.org/TR/2016/REC-SRI-20160623/>. <https://www.w3.org/TR/2016/REC-SRI-20160623/>.
Appendix A. Resource Representation and Representation-Data Appendix A. Resource Representation and Representation-Data
The following examples show how representation metadata, payload The following examples show how representation metadata, payload
transformations and method impacts on the message and payload body. transformations and method impacts on the message and content. When
When the payload body contains non-printable characters (eg. when it the content contains non-printable characters (eg. when it is
is compressed) it is shown as base64-encoded string. compressed) it is shown as base64-encoded string.
A request with a json object without any content coding. A request with a JSON object without any content coding.
Request: Request:
PUT /entries/1234 HTTP/1.1 PUT /entries/1234 HTTP/1.1
Host: foo.example
Content-Type: application/json Content-Type: application/json
{"hello": "world"} {"hello": "world"}
Here is a gzip-compressed json object using a content coding. Here is a gzip-compressed JSON object using a content coding.
Request: Request:
PUT /entries/1234 HTTP/1.1 PUT /entries/1234 HTTP/1.1
Host: foo.example
Content-Type: application/json Content-Type: application/json
Content-Encoding: gzip Content-Encoding: gzip
H4sIAItWyFwC/6tWSlSyUlAypANQqgUAREcqfG0AAAA= H4sIAItWyFwC/6tWSlSyUlAypANQqgUAREcqfG0AAAA=
Now the same payload body conveys a malformed json object. Now the same content conveys a malformed JSON object.
Request: Request:
PUT /entries/1234 HTTP/1.1 PUT /entries/1234 HTTP/1.1
Host: foo.example
Content-Type: application/json Content-Type: application/json
H4sIAItWyFwC/6tWSlSyUlAypANQqgUAREcqfG0AAAA= H4sIAItWyFwC/6tWSlSyUlAypANQqgUAREcqfG0AAAA=
A Range-Request alters the payload body, conveying a partial A Range-Request alters the content, conveying a partial
representation. representation.
Request: Request:
GET /entries/1234 HTTP/1.1 GET /entries/1234 HTTP/1.1
Host: foo.example
Range: bytes=1-7 Range: bytes=1-7
Response: Response:
HTTP/1.1 206 Partial Content HTTP/1.1 206 Partial Content
Content-Encoding: gzip Content-Encoding: gzip
Content-Type: application/json Content-Type: application/json
Content-Range: bytes 1-7/18 Content-Range: bytes 1-7/18
iwgAla3RXA== iwgAla3RXA==
Now the method too alters the payload body. Now the method too alters the content.
Request: Request:
HEAD /entries/1234 HTTP/1.1 HEAD /entries/1234 HTTP/1.1
Host: foo.example
Accept: application/json Accept: application/json
Accept-Encoding: gzip Accept-Encoding: gzip
Response: Response:
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
Content-Encoding: gzip Content-Encoding: gzip
Finally the semantics of an HTTP response might decouple the Finally the semantics of an HTTP response might decouple the
effective request URI from the enclosed representation. In the effective request URI from the enclosed representation. In the
example response below, the "Content-Location" header field indicates example response below, the "Content-Location" header field indicates
that the enclosed representation refers to the resource available at that the enclosed representation refers to the resource available at
skipping to change at page 32, line 19 skipping to change at page 35, line 6
Finally the semantics of an HTTP response might decouple the Finally the semantics of an HTTP response might decouple the
effective request URI from the enclosed representation. In the effective request URI from the enclosed representation. In the
example response below, the "Content-Location" header field indicates example response below, the "Content-Location" header field indicates
that the enclosed representation refers to the resource available at that the enclosed representation refers to the resource available at
"/authors/123". "/authors/123".
Request: Request:
POST /authors/ HTTP/1.1 POST /authors/ HTTP/1.1
Host: foo.example
Accept: application/json Accept: application/json
Content-Type: application/json Content-Type: application/json
{"author": "Camilleri"} {"author": "Camilleri"}
Response: Response:
HTTP/1.1 201 Created HTTP/1.1 201 Created
Content-Type: application/json Content-Type: application/json
Content-Location: /authors/123 Content-Location: /authors/123
Location: /authors/123 Location: /authors/123
{"id": "123", "author": "Camilleri"} {"id": "123", "author": "Camilleri"}
Appendix B. FAQ Appendix B. FAQ
1. Why remove all references to content-md5? 1. Why remove all references to content-md5?
Those were unnecessary to understanding and using this spec. Those were unnecessary to understanding and using this
specification.
2. Why remove references to instance manipulation? 2. Why remove references to instance manipulation?
Those were unnecessary for correctly using and applying the spec. Those were unnecessary for correctly using and applying the
An example with Range Request is more than enough. This doc uses specification. An example with Range Request is more than
the term "partial representation" which should group all those enough. This document uses the term "partial representation"
cases. which should group all those cases.
3. How to use "Digest" with "PATCH" method? 3. How to use "Digest" with "PATCH" method?
See Section 6. See Section 6.
4. Why remove references to delta-encoding? 4. Why remove references to delta-encoding?
Unnecessary for a correct implementation of this spec. The
revised spec can be nicely adapted to "delta encoding", but all Unnecessary for a correct implementation of this specification.
the references here to delta encoding don't add anything to this The revised specification can be nicely adapted to "delta
RFC. Another job would be to refresh delta encoding. encoding", but all the references here to delta encoding don't
add anything to this RFC. Another job would be to refresh delta
encoding.
5. Why remove references to Digest Authentication? 5. Why remove references to Digest Authentication?
This RFC seems to me completely unrelated to Digest This specification seems to me completely unrelated to Digest
Authentication but for the word "Digest". Authentication but for the word "Digest".
6. What changes in "Want-Digest"? 6. What changes in "Want-Digest"?
The contentMD5 token defined in Section 5 of [RFC3230] is The contentMD5 token defined in Section 5 of [RFC3230] is
deprecated by Section 7. deprecated by Section 7.
To clarify that "Digest" and "Want-Digest" can be used in both To clarify that "Digest" and "Want-Digest" can be used in both
requests and responses - [RFC3230] carefully uses "sender" and requests and responses - [RFC3230] carefully uses "sender" and
"receiver" in their definition - we added examples on using "receiver" in their definition - we added examples on using
"Want-Digest" in responses to advertise the supported digest- "Want-Digest" in responses to advertise the supported digest-
algorithms and the inability to accept requests with unsupported algorithms and the inability to accept requests with unsupported
digest-algorithms. digest-algorithms.
skipping to change at page 33, line 26 skipping to change at page 36, line 14
The contentMD5 token defined in Section 5 of [RFC3230] is The contentMD5 token defined in Section 5 of [RFC3230] is
deprecated by Section 7. deprecated by Section 7.
To clarify that "Digest" and "Want-Digest" can be used in both To clarify that "Digest" and "Want-Digest" can be used in both
requests and responses - [RFC3230] carefully uses "sender" and requests and responses - [RFC3230] carefully uses "sender" and
"receiver" in their definition - we added examples on using "receiver" in their definition - we added examples on using
"Want-Digest" in responses to advertise the supported digest- "Want-Digest" in responses to advertise the supported digest-
algorithms and the inability to accept requests with unsupported algorithms and the inability to accept requests with unsupported
digest-algorithms. digest-algorithms.
7. Does this spec changes supported algorithms? 7. Does this specification change supported algorithms?
This RFC updates [RFC5843] which is still delegated for all Yes. This RFC updates [RFC5843] which is still delegated for all
algorithms updates, and adds two more algorithms: "id-sha-256" algorithms updates, and adds two more algorithms: "id-sha-256"
and "id-sha-512" which allows to send a checksum of a resource and "id-sha-512" which allows to send a checksum of a resource
representation with no content codings applied. To simplify a representation with no content codings applied. To simplify a
future transition to Structured Fields future transition to Structured Fields
[I-D.ietf-httpbis-header-structure] we suggest to use lowercase [I-D.ietf-httpbis-header-structure] we suggest to use lowercase
for digest-algorithms. for digest-algorithms.
8. What about mid-stream trailers? 8. What about mid-stream trailer fields?
While mid-stream trailers (https://github.com/httpwg/http-core/ While mid-stream trailer fields (https://github.com/httpwg/http-
issues/313#issuecomment-584389706) are interesting, since this core/issues/313#issuecomment-584389706) are interesting, since
specification is a rewrite of [RFC3230] we do not think we should this specification is a rewrite of [RFC3230] we do not think we
face that. As a first thought, nothing in this document should face that. As a first thought, nothing in this document
precludes future work that would find a use for mid-stream precludes future work that would find a use for mid-stream
trailers, for example an incremental digest-algorithm. A trailers, for example an incremental digest-algorithm. A
document defining such a digest-algorithm is best positioned to document defining such a digest-algorithm is best positioned to
describe how it is used. describe how it is used.
Acknowledgements Acknowledgements
The vast majority of this document is inherited from [RFC3230], so The vast majority of this document is inherited from [RFC3230], so
thanks to J. Mogul and A. Van Hoff for their great work. The thanks to J. Mogul and A. Van Hoff for their great work. The
original idea of refreshing this document arose from an interesting original idea of refreshing this document arose from an interesting
discussion with M. Nottingham, J. Yasskin and M. Thomson when discussion with M. Nottingham, J. Yasskin and M. Thomson when
reviewing the MICE content coding. reviewing the MICE content coding.
Code Samples Code Samples
_RFC Editor: Please remove this section before publication._ _RFC Editor: Please remove this section before publication._
How can I generate and validate the "Digest" values shown in the How can I generate and validate the "Digest" values shown in the
examples throughout this document? examples throughout this document?
The following python3 code can be used to generate digests for JSON
The following python3 code can be used to generate digests for json
objects using SHA algorithms for a range of encodings. Note that objects using SHA algorithms for a range of encodings. Note that
these are formatted as base64. This function could be adapted to these are formatted as base64. This function could be adapted to
other algorithms and should take into account their specific other algorithms and should take into account their specific
formatting rules. formatting rules.
import base64, json, hashlib, brotli import base64, json, hashlib, brotli, logging
log = logging.getLogger()
def digest(item, encoding=lambda x: x, algorithm=hashlib.sha256): def encode_item(item, encoding=lambda x: x):
json_bytes = json.dumps(item).encode() indent = 2 if isinstance(item, dict) and len(item) > 1 else None
content_encoded = encoding(json_bytes) json_bytes = json.dumps(item, indent=indent).encode()
checksum_bytes = algorithm(content_encoded).digest() return encoding(json_bytes)
return base64.encodebytes(checksum_bytes).strip()
item = {"hello": "world"} def digest_bytes(bytes_, algorithm=hashlib.sha256):
checksum_bytes = algorithm(bytes_).digest()
log.warning("Log bytes: \n[%r]", bytes_)
return base64.encodebytes(checksum_bytes).strip()
print("Encoding | digest-algorithm | digest-value") def digest(item, encoding=lambda x: x, algorithm=hashlib.sha256):
print("Identity | sha256 |", digest(item)) content_encoded = encode_item(item, encoding)
# Encoding | digest-algorithm | digest-value return digest_bytes(content_encoded, algorithm)
# Identity | sha256 | 4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=
print("Encoding | digest-algorithm | digest-value") item = {"hello": "world"}
print("Brotli | sha256 |", digest(item, encoding=brotli.compress))
# Encoding | digest-algorithm | digest-value
# Brotli , sha256 4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=
print("Encoding | digest-algorithm | digest-value") print("Encoding | digest-algorithm | digest-value")
print("Identity | sha512 |", digest(item, algorithm=hashlib.sha512)) print("Identity | sha256 |", digest(item))
# Encoding | digest-algorithm | digest-value # Encoding | digest-algorithm | digest-value
# Identity | sha512 | b'WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2s # Identity | sha256 | X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
vX+TaPm+AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==\n'
print("Encoding | digest-algorithm | digest-value")
print("Brotli | sha256 |", digest(item, encoding=brotli.compress))
# Encoding | digest-algorithm | digest-value
# Brotli | sha256 | 4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=
print("Encoding | digest-algorithm | digest-value")
print("Identity | sha512 |", digest(item, algorithm=hashlib.sha512))
# Encoding | digest-algorithm | digest-value
# Identity | sha512 | b'WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm'
# '+AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew=='
Changes Changes
_RFC Editor: Please remove this section before publication._ _RFC Editor: Please remove this section before publication._
Since draft-ietf-httpbis-digest-headers-04
* Improve SRI section #1354
* About duplicate digest-algorithms #1221
* Improve security considerations #852
* md5 and sha deprecation references #1392
* Obsolete 3230 #1395
* Editorial #1362
Since draft-ietf-httpbis-digest-headers-03 Since draft-ietf-httpbis-digest-headers-03
* Reference semantics-12 * Reference semantics-12
* Detail encryption quirks * Detail encryption quirks
* Details on Algorithm agility #1250 * Details on Algorithm agility #1250
* Obsolete parameters #850 * Obsolete parameters #850
skipping to change at page 37, line 4 skipping to change at page 39, line 32
* Update CRC32C value in IANA table #828 * Update CRC32C value in IANA table #828
* Use when acting on resources (POST, PATCH) #853 * Use when acting on resources (POST, PATCH) #853
* Added Relationship with SRI, draft Use Cases #868, #971 * Added Relationship with SRI, draft Use Cases #868, #971
* Warn about the implications of "Content-Location" * Warn about the implications of "Content-Location"
Authors' Addresses Authors' Addresses
Roberto Polli Roberto Polli
Team Digitale, Italian Government Team Digitale, Italian Government
Italy
Email: robipolli@gmail.com Email: robipolli@gmail.com
Lucas Pardue Lucas Pardue
Cloudflare Cloudflare
Email: lucaspardue.24.7@gmail.com Email: lucaspardue.24.7@gmail.com
 End of changes. 183 change blocks. 
342 lines changed or deleted 473 lines changed or added

This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/