Skip to content

Commit e12b51e

Browse files
committed
First pass draft
Signed-off-by: Brandon Lum <[email protected]>
1 parent 775207b commit e12b51e

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

layer.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This document describes how to serialize a filesystem and filesystem changes lik
44
One or more layers are applied on top of each other to create a complete filesystem.
55
This document will use a concrete example to illustrate how to create and consume these filesystem layers.
66

7-
This section defines the `application/vnd.oci.image.layer.v1.tar`, `application/vnd.oci.image.layer.v1.tar+gzip`, `application/vnd.oci.image.layer.v1.tar+zstd`, `application/vnd.oci.image.layer.nondistributable.v1.tar`, `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip`, and `application/vnd.oci.image.layer.nondistributable.v1.tar+zstd` [media types](media-types.md).
7+
This section defines the `application/vnd.oci.image.layer.v1.tar`, `application/vnd.oci.image.layer.v1.tar+gzip`, `application/vnd.oci.image.layer.v1.tar+zstd`, `application/vnd.oci.image.layer.nondistributable.v1.tar`, `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip`, `application/vnd.oci.image.layer.nondistributable.v1.tar+zstd`, `application/vnd.oci.image.layer.v1.tar+enc`, `application/vnd.oci.image.layer.v1.tar+gzip+enc`, `application/vnd.oci.image.layer.nondistributable.v1.tar+enc` and `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip+enc` [media types](media-types.md).
88

99
## `+gzip` Media Types
1010

@@ -16,6 +16,13 @@ This section defines the `application/vnd.oci.image.layer.v1.tar`, `application/
1616
* The media type `application/vnd.oci.image.layer.v1.tar+zstd` represents an `application/vnd.oci.image.layer.v1.tar` payload which has been compressed with [zstd][rfc8478].
1717
* The media type `application/vnd.oci.image.layer.nondistributable.v1.tar+zstd` represents an `application/vnd.oci.image.layer.nondistributable.v1.tar` payload which has been compressed with [zstd][rfc8478].
1818

19+
## `+enc` Media Types
20+
21+
* The media type `application/vnd.oci.image.layer.v1.tar+enc` represents an `application/vnd.oci.image.layer.v1.tar` payload which has been [encrypted](#layer-encryption).
22+
* The media type `application/vnd.oci.image.layer.v1.tar+gzip+enc` represents an `application/vnd.oci.image.layer.v1.tar+gzip` payload which has been [encrypted](#layer-encryption).
23+
* The media type `application/vnd.oci.image.layer.nondistributable.v1.tar+enc` represents an `application/vnd.oci.image.layer.nondistributable.v1.tar` payload which has been [encrypted](#layer-encryption).
24+
* The media type `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip+enc` represents an `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip` payload which has been [encrypted](#layer-encryption).
25+
1926
## Distributable Format
2027

2128
* Layer Changesets for the [media type](media-types.md) `application/vnd.oci.image.layer.v1.tar` MUST be packaged in [tar archive][tar-archive].
@@ -332,6 +339,38 @@ Implementations SHOULD NOT upload layers tagged with this media type; however, s
332339

333340
[Descriptors](descriptor.md) referencing non-distributable layers MAY include `urls` for downloading these layers directly; however, the presence of the `urls` field SHOULD NOT be used to determine whether or not a layer is non-distributable.
334341

342+
343+
# Layer Encryption
344+
345+
To be able to protect the confidentiality of the data in layers, encryption of the layer data blobs can be done to prevent unauthorized access to layer data. Encryption is performed on the data blob of a layer by specifying a mediatype with the `+enc` suffix. For example, `application/vnd.oci.image.layer.v1.tar+enc` is an layer representation of an encrypted `application/vnd.oci.image.layer.v1.tar` layer.
346+
347+
When using the `+enc` mediatype, the layer data blobs are encrypted with a symmetric encryption algorithm (i.e. AES_128_GCM, AES_128_CBC, etc.) according to the [IANA Registry](https://www.iana.org/assignments/aead-parameters/aead-parameters.xhtml).
348+
349+
Details of the algorithms and protocols used in the encryption of the data blob are defined in a JSON object below. We note that:
350+
- The `cipher` field specifies the encryption algorithm in accordance with the [IANA Registry](https://www.iana.org/assignments/aead-parameters/aead-parameters.xhtml).
351+
- The `symkey` field specifies the base64 encoded bytes of the symmetric key used in decryption.
352+
- The `cipherOptions` field specifies additional parameters used in the decryption process of the specified algorithm. This should be in accordance with the RFC standard of the algorithm used.
353+
```
354+
{
355+
"cipher": "AES_128_GCM",
356+
"symkey": "54kiln1USEaKnlYhKdz+aA==",
357+
"cipheroptions": {
358+
"nonce": "AdcRPTAEhXx6uwuYcOquNA==",
359+
...
360+
}
361+
}
362+
```
363+
364+
Due to the precense of sensitive information in this sturcture, to ensure that only authorized parties are able to decrypt the layers, the decryption metadata objects are wrapped as encrypted messages to the authorized recipients in accordance with encrypted message standards such as [OpenPGP(RFC4880)](https://tools.ietf.org/html/rfc4880), [PKCS7(RFC2315)](https://tools.ietf.org/html/rfc2315), [JWE(RFC7516)](https://tools.ietf.org/html/rfc7516).
365+
366+
The following annotations are used to communicate these encrypted messages:
367+
- `org.opencontainers.image.enc.keys.pkcs7` - An array of base64 comma separated encrypted messages that contain LayerBlockCipherOptions to perform decryption of the layer data in accordance with [PKCS7(RFC2315)](https://tools.ietf.org/html/rfc2315)
368+
- `org.opencontainers.image.enc.keys.jwe` - An array of base64 comma separated encrypted messages that contain LayerBlockCipherOptions to perform decryption of the layer data in accordance with [JWE(RFC7516)](https://tools.ietf.org/html/rfc7516)
369+
- `org.opencontainers.image.enc.keys.openpgp` - An array of base64 comma separated encrypted messages that contain LayerBlockCipherOptions to perform decryption of the layer data in accordance with [OpenPGP(RFC4880)](https://tools.ietf.org/html/rfc4880)
370+
- `org.opencontainers.image.enc.keys.*` - An array of base64 comma separated encrypted messages that contain LayerBlockCipherOptions to perform decryption of the layer data in accordance with an appropriate standard of specified protocol.
371+
372+
The decryption of the image can be performed by unwrapping the LayerBlockCipherOptions using the `org.opencontainers.image.enc.keys.*` annotations and using the appropriate cipher with the unwrapped LayerBlockCipherOptions to decrypt the layer data blob.
373+
335374
[libarchive-tar]: https://github.com/libarchive/libarchive/wiki/ManPageTar5#POSIX_ustar_Archives
336375
[gnu-tar-standard]: http://www.gnu.org/software/tar/manual/html_node/Standard.html
337376
[rfc1952_2]: https://tools.ietf.org/html/rfc1952

specs-go/v1/annotations.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,16 @@ const (
5353

5454
// AnnotationDescription is the annotation key for the human-readable description of the software packaged in the image.
5555
AnnotationDescription = "org.opencontainers.image.description"
56+
57+
// AnnotationEncryptionKeysPkcs7 is the annotation key for the base64 encoded encrypted
58+
// messages containing metadata for decrypting encrypted data blobs.
59+
AnnotationEncryptionKeysPkcs7 = "org.opencontainers.image.enc.keys.pkcs7"
60+
61+
// AnnotationEncryptionKeysJwe is the annotation key for the base64 encoded encrypted
62+
// messages containing metadata for decrypting encrypted data blobs.
63+
AnnotationEncryptionKeysJwe = "org.opencontainers.image.enc.keys.jwe"
64+
65+
// AnnotationEncryptionKeysOpenPgp is the annotation key for the base64 encoded encrypted
66+
// messages containing metadata for decrypting encrypted data blobs.
67+
AnnotationEncryptionKeysOpenPgp = "org.opencontainers.image.enc.keys.openpgp"
5668
)

specs-go/v1/encryption.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1
16+
17+
// LayerBlockCipherOptions includes the information required to encrypt/decrypt
18+
// layer blob data.
19+
type LayerBlockCipherOptions struct {
20+
CipherType string `json:'cipher'`
21+
SymmetricKey []byte `json:'symkey'`
22+
CipherOptions map[string][]byte `json:'cipheroptions'`
23+
}

specs-go/v1/mediatype.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ const (
3030
// MediaTypeImageLayer is the media type used for layers referenced by the manifest.
3131
MediaTypeImageLayer = "application/vnd.oci.image.layer.v1.tar"
3232

33+
// MediaTypeImageLayerEnc is the media type used for encrypted layers
34+
// referenced by the manifest.
35+
MediaTypeImageLayerEnc = "application/vnd.oci.image.layer.v1.tar+enc"
36+
3337
// MediaTypeImageLayerGzip is the media type used for gzipped layers
3438
// referenced by the manifest.
3539
MediaTypeImageLayerGzip = "application/vnd.oci.image.layer.v1.tar+gzip"
@@ -38,6 +42,10 @@ const (
3842
// layers referenced by the manifest.
3943
MediaTypeImageLayerZstd = "application/vnd.oci.image.layer.v1.tar+zstd"
4044

45+
// MediaTypeImageLayerGzipEnc is the media type used for encrypted
46+
// gzipped layers referenced by the manifest.
47+
MediaTypeImageLayerGzipEnc = "application/vnd.oci.image.layer.v1.tar+gzip+enc"
48+
4149
// MediaTypeImageLayerNonDistributable is the media type for layers referenced by
4250
// the manifest but with distribution restrictions.
4351
MediaTypeImageLayerNonDistributable = "application/vnd.oci.image.layer.nondistributable.v1.tar"
@@ -52,6 +60,15 @@ const (
5260
// restrictions.
5361
MediaTypeImageLayerNonDistributableZstd = "application/vnd.oci.image.layer.nondistributable.v1.tar+zstd"
5462

63+
// MediaTypeImageLayerNonDistributableEnc is the media type for encrypted
64+
// layers referenced by the manifest but with distribution restrictions.
65+
MediaTypeImageLayerNonDistributableEnc = "application/vnd.oci.image.layer.nondistributable.v1.tar+enc"
66+
67+
// MediaTypeImageLayerNonDistributableGzipEnc is the media type for
68+
// gzipped and encrypted layers referenced by the manifest but with
69+
// distribution restrictions.
70+
MediaTypeImageLayerNonDistributableGzipEnc = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip+enc"
71+
5572
// MediaTypeImageConfig specifies the media type for the image configuration.
5673
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
5774
)

0 commit comments

Comments
 (0)