Skip to content

Commit bbe399d

Browse files
committed
descriptor: improve consistency in use of "digest"
Signed-off-by: Jonathan Boulle <[email protected]>
1 parent ed86220 commit bbe399d

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

descriptor.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Extended _Descriptor_ field additions proposed in other OCI specifications SHOUL
5959

6060
The _digest_ property of a Descriptor acts as a content identifier, enabling [content addressability](http://en.wikipedia.org/wiki/Content-addressable_storage).
6161
It uniquely identifies content by taking a [collision-resistant hash](https://en.wikipedia.org/wiki/Cryptographic_hash_function) of the bytes.
62-
If the identifier can be communicated in a secure manner, one can retrieve the content from an insecure source, calculate the digest independently, and be certain that the correct content was obtained.
62+
If the digest can be communicated in a secure manner, one can retrieve the content from an insecure source, recalculate the digest independently, and be certain that the correct content was obtained.
6363

64-
The value of the digest property, the _digest string_, is a serialized hash result, consisting of an _algorithm_ portion and a _hex_ portion.
65-
The algorithm identifies the methodology used to calculate the digest; the hex portion is the lowercase hex-encoded result of the hash.
64+
The value of the digest property is a string consisting of an _algorithm_ portion (the "algorithm identifier") and a _hex_ portion.
65+
The algorithm identifier specifies the cryptographic hash function used to calculate the digest; the hex portion is the lowercase hex-encoded result of the hash.
6666

6767
The digest string MUST match the following grammar:
6868

@@ -74,20 +74,17 @@ hex := /[a-f0-9]+/
7474

7575
Some example digest strings include the following:
7676

77-
digest | algorithm |
77+
digest string | algorithm |
7878
------------------------------------------------------------------------|---------------------|
7979
sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b | [SHA-256](#sha-256) |
8080

81-
* Before consuming content targeted by a descriptor from untrusted sources, the byte content SHOULD be verified against the digest.
81+
* Before consuming content targeted by a descriptor from untrusted sources, the byte content SHOULD be verified against the digest string.
8282
* Before calculating the digest, the size of the content SHOULD be verified to reduce hash collision space.
8383
* Heavy processing before calculating a hash SHOULD be avoided.
84-
* Implementations MAY employ some canonicalization of the underlying content to ensure stable content identifiers.
84+
* Implementations MAY employ [canonicalization](canonicalization.md) of the underlying content to ensure stable content identifiers.
8585

86-
### Algorithms
86+
### Digest calculations
8787

88-
While the _algorithm_ component of the digest does allow one to utilize a wide variety of algorithms, compliant implementations SHOULD use [SHA-256](#sha-256).
89-
90-
Let's use a simple example in pseudo-code to demonstrate a digest calculation:
9188
A _digest_ is calculated by the following pseudo-code, where `H` is the selected hash algorithm, identified by string `<alg>`:
9289
```
9390
let ID(C) = Descriptor.digest
@@ -97,7 +94,7 @@ let verified = ID(C) == D
9794
```
9895
Above, we define the content identifier as `ID(C)`, extracted from the `Descriptor.digest` field.
9996
Content `C` is a string of bytes.
100-
Function `H` returns the hash of `C` in bytes and is passed to function `EncodeHex` to obtain the _digest_.
97+
Function `H` returns the hash of `C` in bytes and is passed to function `EncodeHex` and prefixed with the algorithm to obtain the digest.
10198
The result `verified` is true if `ID(C)` is equal to `D`, confirming that `C` is the content identified by `D`.
10299
After verification, the following is true:
103100

@@ -107,20 +104,22 @@ D == ID(C) == '<alg>:' + EncodeHex(H(C))
107104

108105
The _digest_ is confirmed as the content identifier by independently calculating the _digest_.
109106

110-
#### Registered identifiers
107+
### Registered algorithms
108+
109+
While the _algorithm_ portion (the "algorithm identifier") of the digest string allows the use of a variety of cryptographic algorithms, compliant implementations SHOULD use [SHA-256](#sha-256).
111110

112-
The following algorithm identifiers are defined by this specification:
111+
The following algorithm identifiers are currently defined by this specification:
113112

114-
| identifier | algorithm |
115-
|------------|---------------------|
116-
| `sha256` | [SHA-256](#sha-256) |
117-
| `sha512` | [SHA-512](#sha-512) |
113+
| algorithm identifier | algorithm |
114+
|----------------------|---------------------|
115+
| `sha256` | [SHA-256](#sha-256) |
116+
| `sha512` | [SHA-512](#sha-512) |
118117

119-
If a useful algorithm is not included in the above table, it SHOULD be submitted to this specification for standardization.
118+
If a useful algorithm is not included in the above table, it SHOULD be submitted to this specification for registration.
120119

121120
#### SHA-256
122121

123-
[SHA-256](https://tools.ietf.org/html/rfc4634#page-7) is a collision-resistant hash function, chosen for ubiquity, reasonable size and secure characteristics.
122+
[SHA-256][rfc4634-s4.1] is a collision-resistant hash function, chosen for ubiquity, reasonable size and secure characteristics.
124123
Implementations MUST implement SHA-256 digest verification for use in descriptors.
125124

126125
#### SHA-512
@@ -154,6 +153,7 @@ In the following example, the descriptor indicates that the referenced manifest
154153
```
155154

156155
[rfc3986]: https://tools.ietf.org/html/rfc3986
156+
[rfc4634-s4.1]: https://tools.ietf.org/html/rfc4634#section-4.1
157157
[rfc4634-s4.2]: https://tools.ietf.org/html/rfc4634#section-4.2
158158
[rfc6838]: https://tools.ietf.org/html/rfc6838
159159
[rfc6838-s4.2]: https://tools.ietf.org/html/rfc6838#section-4.2

0 commit comments

Comments
 (0)