Skip to content

Commit f135fa9

Browse files
committed
Updated to split public/private cipher options
Signed-off-by: Brandon Lum <[email protected]>
1 parent f21e591 commit f135fa9

File tree

2 files changed

+69
-13
lines changed

2 files changed

+69
-13
lines changed

annotations.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ This specification defines the following annotation keys, intended for but not l
4040
```
4141
* **org.opencontainers.image.title** Human-readable title of the image (string)
4242
* **org.opencontainers.image.description** Human-readable description of the software packaged in the image (string)
43-
* **org.opencontainers.image.org.opencontainers.image.enc.keys.pkcs7** Base64 comma separated [PKCS7(RFC2315)](https://tools.ietf.org/html/rfc2315) encrypted messages that contain wrapped LayerBlockCipherOptions JSON objects for [encryption](layer.md#layer-encryption)
44-
* **org.opencontainers.image.org.opencontainers.image.enc.keys.jwe** Base64 comma separated [JWE(RFC7516)](https://tools.ietf.org/html/rfc7516) encrypted messages that contain wrapped LayerBlockCipherOptions JSON objects for [encryption](layer.md#layer-encryption)
45-
* **org.opencontainers.image.org.opencontainers.image.enc.keys.openpgp** Base64 comma separated [OpenPGP(RFC4880)](https://tools.ietf.org/html/rfc4880) encrypted messages that contain wrapped LayerBlockCipherOptions JSON objects for [encryption](layer.md#layer-encryption)
43+
* **org.opencontainers.image.org.opencontainers.image.enc.keys.pkcs7** Base64 comma separated [PKCS7(RFC2315)](https://tools.ietf.org/html/rfc2315) encrypted messages that contain wrapped PrivateLayerBlockCipherOptions JSON objects for [encryption](layer.md#layer-encryption)
44+
* **org.opencontainers.image.org.opencontainers.image.enc.keys.jwe** Base64 comma separated [JWE(RFC7516)](https://tools.ietf.org/html/rfc7516) encrypted messages that contain wrapped PrivateLayerBlockCipherOptions JSON objects for [encryption](layer.md#layer-encryption)
45+
* **org.opencontainers.image.org.opencontainers.image.enc.keys.openpgp** Base64 comma separated [OpenPGP(RFC4880)](https://tools.ietf.org/html/rfc4880) encrypted messages that contain wrapped PrivateLayerBlockCipherOptions JSON objects for [encryption](layer.md#layer-encryption)
46+
* **org.opencontainers.image.org.opencontainers.image.enc.pubopts** Base64 encoded PublicLayerBlockCipherOptions JSON object for [encryption](layer.md#layer-encryption)
4647
4748
## Back-compatibility with Label Schema
4849

layer.md

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,32 +339,87 @@ Implementations SHOULD NOT upload layers tagged with this media type; however, s
339339

340340
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.
341341

342-
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).
342+
When using the `+enc` mediatype, the layer data blobs are encrypted. In order to decrypt an image, the encryption metadata is required.
343343

344-
Details of the algorithms and protocols used in the encryption of the data blob are defined in a JSON object below. We note that:
345-
- The `cipher` field specifies the encryption algorithm in accordance with the [IANA Registry](https://www.iana.org/assignments/aead-parameters/aead-parameters.xhtml).
344+
## Encryption Metadata
345+
346+
The encryption metadata consists of 2 parts: PublicLayerBlockCipherOptions and PrivateLayerBlockCipherOptions. The PublicLayerBlockCipherOptions contain encryption metadata that is public, i.e. cipher type, HMAC, etc. and PrivateLayerBlockCipherOptions contains the encryption metadata which should be confidential, i.e. symmetric key, nonce (optional), etc. These are stored in the respective [**org.opencontainers.image.enc** prefixed annotations](annotations.md).
347+
348+
Below are golang definitions of these JSON objects:
349+
350+
```
351+
// PublicLayerBlockCipherOptions includes the information required to encrypt/decrypt
352+
// an image which are public and can be deduplicated in plaintext across multiple
353+
// recipients
354+
type PublicLayerBlockCipherOptions struct {
355+
// CipherType denotes the cipher type according to the list of OCI suppported
356+
// cipher types
357+
CipherType string `json:"cipher"`
358+
359+
// Hmac contains the hmac string to help verify encryption
360+
Hmac string `json:"hmac"`
361+
362+
// CipherOptions contains the cipher metadata used for encryption/decryption
363+
// This field should be populated by Encrypt/Decrypt calls
364+
CipherOptions map[string][]byte `json:"cipheroptions"`
365+
}
366+
367+
// PrivateLayerBlockCipherOptions includes the information required to encrypt/decrypt
368+
// an image which are sensitive and should not be in plaintext
369+
type PrivateLayerBlockCipherOptions struct {
370+
// SymmetricKey represents the symmetric key used for encryption/decryption
371+
// This field should be populated by Encrypt/Decrypt calls
372+
SymmetricKey []byte `json:"symkey"`
373+
374+
// Digest is the digest of the original data for verification.
375+
// This is NOT populated by Encrypt/Decrypt calls
376+
Digest digest.Digest `json:"digest"`
377+
378+
// CipherOptions contains the cipher metadata used for encryption/decryption
379+
// This field should be populated by Encrypt/Decrypt calls
380+
CipherOptions map[string][]byte `json:"cipheroptions"`
381+
}
382+
```
383+
384+
Details of the algorithms and protocols used in the encryption of the data blob are defined in these JSON objects. Here are some examples of the Public/Private LayerBlockCipherOptions.
385+
- The `cipher` field specifies the encryption algorithm to use according to the [list of cipher types supported](#cipher-types).
346386
- The `symkey` field specifies the base64 encoded bytes of the symmetric key used in decryption.
347387
- 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.
348388
```
389+
PublicLayerBlockCipherOption
390+
{
391+
"cipher": "AES_256_CTR_HMAC_SHA256",
392+
"hmac": "M0M5OTA5QUZFQzI1MzU0RDU1MURBRTIxNTkwQkIyNkUzOEQ1M0YyMTczQjhEM0RDM0VFRTRDMDQ3RTdBQjFDMQ=="
393+
"cipheroptions": {}
394+
}
395+
396+
PrivateLayerBlockCipherOption
349397
{
350-
"cipher": "AES_128_GCM",
351398
"symkey": "54kiln1USEaKnlYhKdz+aA==",
352399
"cipheroptions": {
353400
"nonce": "AdcRPTAEhXx6uwuYcOquNA==",
354401
...
355402
}
356403
}
404+
357405
```
358406

359-
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).
407+
The PublicLayerBlockCipherOptions JSON object is stored base64 encoded in the layer annotation **org.opencontainers.image.enc.pubopts**.
408+
409+
The PrivateLayerBlockCipherOptions JSON object is not stored in plaintext due to the sensitive nature of the contents. Instead, the object goes through a cryptographic wrapping process. This ensures 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).
360410

361411
The following annotations are used to communicate these encrypted messages:
362-
- `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)
363-
- `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)
364-
- `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)
365-
- `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.
412+
- `org.opencontainers.image.enc.keys.pkcs7` - An array of base64 comma separated encrypted messages that contain PrivateLayerBlockCipherOptions to perform decryption of the layer data in accordance with [PKCS7(RFC2315)](https://tools.ietf.org/html/rfc2315)
413+
- `org.opencontainers.image.enc.keys.jwe` - An array of base64 comma separated encrypted messages that contain PrivateLayerBlockCipherOptions to perform decryption of the layer data in accordance with [JWE(RFC7516)](https://tools.ietf.org/html/rfc7516)
414+
- `org.opencontainers.image.enc.keys.openpgp` - An array of base64 comma separated encrypted messages that contain PrivateLayerBlockCipherOptions to perform decryption of the layer data in accordance with [OpenPGP(RFC4880)](https://tools.ietf.org/html/rfc4880)
415+
- `org.opencontainers.image.enc.keys.*` - An array of base64 comma separated encrypted messages that contain PrivateLayerBlockCipherOptions to perform decryption of the layer data in accordance with an appropriate standard of specified protocol.
416+
417+
The decryption of the image can be performed by unwrapping the PrivateLayerBlockCipherOptions using the `org.opencontainers.image.enc.keys.*` annotations and using the appropriate cipher with the unwrapped PrivateLayerBlockCipherOptions to decrypt the layer data blob.
418+
419+
### Cipher Types
366420

367-
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.
421+
The current list of cipher types supported are:
422+
- `AES_256_CTR_HMAC_SHA256` - Encryption with `AES_256_CTR` algorithm [FIPS-197](https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf) with Encrypt-then-mac [RFC7366](https://tools.ietf.org/html/rfc7366). The protocols used in this cipher type is in accordance to FIPS 140-2 compliant standards.
368423

369424
[libarchive-tar]: https://github.com/libarchive/libarchive/wiki/ManPageTar5#POSIX_ustar_Archives
370425
[gnu-tar-standard]: http://www.gnu.org/software/tar/manual/html_node/Standard.html

0 commit comments

Comments
 (0)