Skip to content

Commit 7637741

Browse files
committed
schema/digest: include characters urlsafe base64 encoding
Signed-off-by: Stephen J Day <[email protected]>
1 parent d75e562 commit 7637741

File tree

4 files changed

+52
-41
lines changed

4 files changed

+52
-41
lines changed

descriptor.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The following field keys are reserved and MUST NOT be used by other specificatio
5757
All other fields may be included in other OCI specifications.
5858
Extended _Descriptor_ field additions proposed in other OCI specifications SHOULD first be considered for addition into this specification.
5959

60-
## Digests and Verification
60+
## Digests
6161

6262
The _digest_ property of a Descriptor acts as a content identifier, enabling [content addressability](http://en.wikipedia.org/wiki/Content-addressable_storage).
6363
It uniquely identifies content by taking a [collision-resistant hash](https://en.wikipedia.org/wiki/Cryptographic_hash_function) of the bytes.
@@ -71,26 +71,30 @@ A digest string MUST match the following grammar:
7171
```
7272
digest := algorithm ":" encoded
7373
algorithm := /[a-z0-9]+(?:[+._-][a-z0-9]+)*/
74-
encoded := /[a-zA-Z0-9]+/
74+
encoded := /[a-zA-Z0-9_-]+/
7575
```
76-
Some example digests include the following:
76+
77+
Some example digest strings include the following:
7778

7879
digest | algorithm | Supported |
7980
------------------------------------------------------------------------|---------------------|-----------|
8081
sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b | [SHA-256](#sha-256) | Yes |
8182
sha512:401b09eab3c013d4ca54922bb802bec8fd5318192b0a75f201d8b3727429080fb337591abd3e44453b954555b7a0812e1081c39b740293f765eae731f5a65ed1 | [SHA-256](#sha-512) | Yes |
8283
multihash+base58:QmRZxt2b1FVZPNqd8hsiykDL3TdBDeTSPX9Kv46HmX4Gx8` | Multihash | No |
84+
sha256+b64:LCa0a2j_xo_5m0U8HTBBNBNCLXBkg7-g-YpeiGJm564 | SHA-256 with base64 | No |
8385

8486
Please see [Registered Algorithms](#registered-identifiers) for a list of supported algorithms.
8587

8688
Implementations SHOULD allow digests that are unsupported to pass validation if they comply with the above grammar.
8789
While `sha256` will only use hex encoded digests, support for separators in _algorithm_ and alpha numeric in _encoded_ is included to allow for future extension of digest support.
8890
As an example, we can paramterize the encoding and algorithm as `multihash+base58:QmRZxt2b1FVZPNqd8hsiykDL3TdBDeTSPX9Kv46HmX4Gx8`, which would be considered valid but unsupported by this specification.
8991

90-
* Before consuming content targeted by a descriptor from untrusted sources, the byte content SHOULD be verified against the digest string.
91-
* Before calculating the digest, the size of the content SHOULD be verified to reduce hash collision space.
92-
* Heavy processing before calculating a hash SHOULD be avoided.
93-
* Implementations MAY employ [canonicalization](canonicalization.md) of the underlying content to ensure stable content identifiers.
92+
### Verification
93+
94+
Before consuming content targeted by a descriptor from untrusted sources, the byte content SHOULD be verified against the digest string.
95+
Before calculating the digest, the size of the content SHOULD be verified to reduce hash collision space.
96+
Heavy processing before calculating a hash SHOULD be avoided.
97+
Implementations MAY employ [canonicalization](canonicalization.md) of the underlying content to ensure stable content identifiers.
9498

9599
### Digest calculations
96100

schema/defs-descriptor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"digest": {
1010
"description": "the cryptographic checksum digest of the object, in the pattern '<algorithm>:<encoded>'",
1111
"type": "string",
12-
"pattern": "^[a-z0-9]+(?:[+._-][a-z0-9]+)*:[a-zA-Z0-9]+$"
12+
"pattern": "^[a-z0-9]+(?:[+._-][a-z0-9]+)*:[a-zA-Z0-9_-]+$"
1313
},
1414
"urls": {
1515
"description": "a list of urls from which this object may be downloaded",

schema/descriptor_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ func TestDescriptor(t *testing.T) {
276276
}`,
277277
fail: true,
278278
},
279+
{
280+
descriptor: `{
281+
"digest": "sha256+b64:LCa0a2j_xo_5m0U8HTBBNBNCLXBkg7-g-YpeiGJm564",
282+
"size": 1000000,
283+
"mediaType": "application/vnd.oci.image.config.v1+json"
284+
}`,
285+
},
279286
} {
280287
r := strings.NewReader(tt.descriptor)
281288
err := schema.ValidatorMediaTypeDescriptor.Validate(r)

schema/fs.go

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -222,32 +222,32 @@ b1D07fCyW0vviMlWxN4UcYpZ/Enjdtf+RQ3SGiZ/vj8oANpKu/UTMV9kR1SDMjPzGZ6y5MQwnZvwWfX7
222222

223223
"/content-descriptor.json": {
224224
local: "content-descriptor.json",
225-
size: 1091,
226-
modtime: 1489087148,
225+
size: 1085,
226+
modtime: 1493147571,
227227
compressed: `
228-
H4sIAAAAAAAA/5yTwW7UMBCG73mKUVqpl27NoeIQVb3AnQPcEAevPY6nJLYZz6oE1HdHjrNsAoiFve2O
229-
/m/mm2j8vQFoLWbDlIRiaDto3yUMb2IQTQEZyi8MAm+XUGR4n9CQI6Nn4ra0uM7G46gL7kVSp9RTjmFX
230-
q3eRe2VZO9m9ule1dlU5skckd0rFhMEcJ+cZq2llf06vnEwJCxn3T2ik1hLHhCyEue2gLAbQjmhJf6jh
231-
Wvp9X/EIc640heigFBgdMgaDFlYzZvya0RXOosu7k9hd2fhKWXQUqPTO6jR9Zl9qizbTt3M+JQIUYD8J
232-
5v90+oMIBXl9v5Ww1GOWMxqGpySxZ508GTAezed8GKGyR63qclt0y9+kRZAD3Dx4nf1j9+Dxq7ZoaNTD
233-
Qj7eXPI1F+PNFgce8l920DBQFS1BcBxHePZkPIinvJjDqCfYI9j4HIaoLdpL7GaTjZsOIcr8RjaK/3ry
234-
NOoeV4ev1v0uEFzj1bNZXFvGLwdiLGIff30365vdnk4D8Kl5aX4EAAD//4LEuuxDBAAA
228+
H4sIAAAAAAAA/5yTwW7UMBCG73mKUVqpl27NoeIQVb3AnQPcEAevPY6nbGwznlW1oL47mniXJoAo3Vsy
229+
+r+Zz8n4RwfQe6yOqQjl1A/QfyiY3uUklhIy6BMmgffHUGb4WNBRIGdn4lpbXFYXcbKKR5EyGPNQc9q0
230+
6k3m0Xi2QTZvbk2rXTSO/AmpgzG5YHKnyXXGWtr4X9MbJ4eCSubtAzpptcK5IAth7QfQgwH0E3qyn1q4
231+
lf48r0SEOadNIQfQAmNAxuTQw2LGjF8yBuU8hrp5FrvRE18Yj4ESae9qnqfP7FNr0Vf6/pKPRoASbA+C
232+
9ZVOfxGhJG9v1xKeRqzygobjQ5E8si2RHLiI7mvdT9DYk1ZzuVZdfS1WBDnB1Z3djZlJ4nQ/3OmP9ejv
233+
r875jkfXlf+ed/Uf9hZ21BQ1CIHzBI+RXASJVI/OMNkDbBF8fky7bD36c+xmk5WbTSnLfDtWiv+77DTZ
234+
ERcrb5b9zhBc4s2zO7r2jN/2xKhin3+/McttXS9NB/Cle+p+BgAA///HjexwPQQAAA==
235235
`,
236236
},
237237

238238
"/defs-descriptor.json": {
239239
local: "defs-descriptor.json",
240-
size: 918,
241-
modtime: 1493145992,
240+
size: 921,
241+
modtime: 1493324159,
242242
compressed: `
243-
H4sIAAAAAAAA/6STTW/UQAyG7/srzHRFgd1sCgckoqqooncO5dRqW7kTJ3HJfMjjVbVU+99RPprdFoFA
244-
HBKNLft9/TiTxxmAKSlZ4agcvCnAXFDFnrsoQURRtpsWBTTA10j+S/CK7EngYmwLApeRLFdssddYDqKT
245-
iimg8wEwjkrGb9tIUwrAcNm5NqoxFXkeInn75JFWQeo82YYc5uywprycXPO92vJJSwdtk1TY1/t8RFWS
246-
Hu/m+jy7wuzHSfZpvT++Opq/zm5uV4v148ny/YePu/zvyuamt9gNTqbkmpIe0r1YrjYEVrZRQy0YG7Zg
247-
G7Lf08bB0Auhgq4o3N2T1SWw78MRAI5Psa2DsDburDgdWs6O/3EBI9bizefierG6zdZT5u27ojufZ1d9
248-
+IJuI236AxtCywNAVwiVBAcPDdsGtOE0EoHDLdwRlOHBtwFLKn8dHkVwu0+zkjv0/T0mgKmCOOy+gNkI
249-
mzG/e4aB3gfF51fzf+7hod409Fyo6vRKqtLqPgV/lB/8ErnDeNnPPrzHPc+6Zzf7GQAA///h5dXMlgMA
250-
AA==
243+
H4sIAAAAAAAA/6STX2/TMBTF3/spLl7FgDZN4QFp0TQ0sXcextOmrrqzb+I74j+yXU1l6ndHTrK0KwKB
244+
9pDIPro+5/5unKcJgFAUZWCf2FlRgbiimi3nXQSPIbHctBggOfjmyX51NiFbCnA1HHMBrj1Jrlli5zHv
245+
TUcXUUHOARCGFOP3radRAhCscqpOyceqLJ0nK58z4sKFpoxSk8GSDTZUqjG13LvNn71S7y1iCmybve4x
246+
JQod3t3tZXGDxc9lcbbaL9+cTN8Wd+vFbPW0nH/89HlX/lvZVHQRuz5JKG4opkO6o+EmTSDD1ifXBPSa
247+
JUhN8kfcGOjPgqshF7n7B5JpDmy77QAAp+fYNi5w0uaiOs+jUqQuTv9zAgPX7N2X6na2WBerUXn/ocrr
248+
y+JmWZyti9XsCHAT2vgXPISWe4ZcCHVwBh41Sw1JcxygwOAW7gmUe7StQ0Xq9/YxBNzuZU5kDnP/DAog
249+
ahcM5o8gNoHFoO9eYKC1LuHL2/maq3joNzY9DVRnP0V1XDxEZ0/Kg7+iNOivu9779zDnSX52k18BAAD/
250+
/7fEAguZAwAA
251251
`,
252252
},
253253

@@ -268,21 +268,21 @@ fIvD7in0ryMEy+fK1G6UfmdTE+tvpoL+1wV/AgAA//96IpqyhgYAAA==
268268

269269
"/image-index-schema.json": {
270270
local: "image-index-schema.json",
271-
size: 3157,
272-
modtime: 1489087148,
271+
size: 3151,
272+
modtime: 1493147606,
273273
compressed: `
274-
H4sIAAAAAAAA/7yWz27bOBDG736KgRIglyRcLII9GEEuu5ec9tCglyKHCTmyJrVIlaSTuIXfvSBp2ZIo
275-
u4lq9GYPOd98vxH//ZgBFIqctNx4NrqYQ/F/Q/pfoz2yJgv3NS4I7rWiN/jUkOSSJcaplyH33MmKagx5
276-
lffNXIhnZ/RVil4buxDKYumv/roRKXaW8li1KW4uhGlIy7aki2lptuBQXnAonxL9uqGQap6eSfoUa6xp
277-
yHomV8whIAEUKf8zWZewUjinfajYQcm0VOASHjnw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