16
vendor/github.com/containerd/imgcrypt/CHANGES
generated
vendored
16
vendor/github.com/containerd/imgcrypt/CHANGES
generated
vendored
@@ -1,5 +1,21 @@
|
||||
CHANGES
|
||||
|
||||
v1.1.7:
|
||||
- Added support for zstd-compressed layers
|
||||
- Update to ocicrypt v1.1.6 for zstd-related dependencies
|
||||
- Update to containerd v1.6.8
|
||||
- Sync'ed ctr-enc with upstream ctr changes to import command
|
||||
- Add support for --all-platforms to encrypt command of ctr-enc
|
||||
|
||||
v1.1.6:
|
||||
- Update to ocicrypt v1.1.5 for yaml v3.0 dependency
|
||||
- Update to containerd v1.6.6 for runc v1.1.2 dependency
|
||||
|
||||
v1.1.5:
|
||||
- Update to ocicrypt v1.1.4; sha256 is the default now for padding in OAEP
|
||||
for pkcs11; Set OCICRYPT_OAEP_HASHALG=sha1 environment variable to force
|
||||
sha1 usage, which is required for example for SoftHSM 2.6.1.
|
||||
|
||||
v1.1.4:
|
||||
- Fixed issue in CheckAuthorization() callpath for images with a ManifestList
|
||||
- CVE-2022-24778
|
||||
|
||||
6
vendor/github.com/containerd/imgcrypt/README.md
generated
vendored
6
vendor/github.com/containerd/imgcrypt/README.md
generated
vendored
@@ -4,7 +4,7 @@ Project `imgcrypt` is a non-core subproject of containerd.
|
||||
|
||||
The `imgcrypt` library provides API exensions for containerd to support encrypted container images and implements
|
||||
the `ctd-decoder` command line tool for use by containerd to decrypt encrypted container images. An extended version
|
||||
of containerd's `ctr` tool (`ctr-enc') with support for encrypting and decrypting container images is also provided.
|
||||
of containerd's `ctr` tool (`ctr-enc`) with support for encrypting and decrypting container images is also provided.
|
||||
|
||||
`imgcrypt` relies on the [`ocicrypt`](https://github.com/containers/ocicrypt) library for crypto functions on image layers.
|
||||
|
||||
@@ -37,6 +37,10 @@ state = "/tmp/run/containerd"
|
||||
accepts = ["application/vnd.oci.image.layer.v1.tar+gzip+encrypted"]
|
||||
returns = "application/vnd.oci.image.layer.v1.tar+gzip"
|
||||
path = "/usr/local/bin/ctd-decoder"
|
||||
[stream_processors."io.containerd.ocicrypt.decoder.v1.tar.zstd"]
|
||||
accepts = ["application/vnd.oci.image.layer.v1.tar+zstd+encrypted"]
|
||||
returns = "application/vnd.oci.image.layer.v1.tar+zstd"
|
||||
path = "/usr/local/bin/ctd-decoder"
|
||||
[stream_processors."io.containerd.ocicrypt.decoder.v1.tar"]
|
||||
accepts = ["application/vnd.oci.image.layer.v1.tar+encrypted"]
|
||||
returns = "application/vnd.oci.image.layer.v1.tar"
|
||||
|
||||
6
vendor/github.com/containerd/imgcrypt/images/encryption/any.go
generated
vendored
6
vendor/github.com/containerd/imgcrypt/images/encryption/any.go
generated
vendored
@@ -18,12 +18,14 @@ package encryption
|
||||
|
||||
import "github.com/gogo/protobuf/types"
|
||||
|
||||
type any interface {
|
||||
// pbAny takes proto-generated Any type.
|
||||
// https://developers.google.com/protocol-buffers/docs/proto3#any
|
||||
type pbAny interface {
|
||||
GetTypeUrl() string
|
||||
GetValue() []byte
|
||||
}
|
||||
|
||||
func fromAny(from any) *types.Any {
|
||||
func fromAny(from pbAny) *types.Any {
|
||||
if from == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
15
vendor/github.com/containerd/imgcrypt/images/encryption/encryption.go
generated
vendored
15
vendor/github.com/containerd/imgcrypt/images/encryption/encryption.go
generated
vendored
@@ -60,7 +60,7 @@ func isLocalPlatform(platform *ocispec.Platform) bool {
|
||||
// IsEncryptedDiff returns true if mediaType is a known encrypted media type.
|
||||
func IsEncryptedDiff(ctx context.Context, mediaType string) bool {
|
||||
switch mediaType {
|
||||
case encocispec.MediaTypeLayerGzipEnc, encocispec.MediaTypeLayerEnc:
|
||||
case encocispec.MediaTypeLayerZstdEnc, encocispec.MediaTypeLayerGzipEnc, encocispec.MediaTypeLayerEnc:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -113,12 +113,16 @@ func encryptLayer(cc *encconfig.CryptoConfig, dataReader content.ReaderAt, desc
|
||||
newDesc.MediaType = encocispec.MediaTypeLayerEnc
|
||||
case encocispec.MediaTypeLayerGzipEnc:
|
||||
newDesc.MediaType = encocispec.MediaTypeLayerGzipEnc
|
||||
case encocispec.MediaTypeLayerZstdEnc:
|
||||
newDesc.MediaType = encocispec.MediaTypeLayerZstdEnc
|
||||
case encocispec.MediaTypeLayerEnc:
|
||||
newDesc.MediaType = encocispec.MediaTypeLayerEnc
|
||||
|
||||
// TODO: Mediatypes to be added in ocispec
|
||||
case ocispec.MediaTypeImageLayerGzip:
|
||||
newDesc.MediaType = encocispec.MediaTypeLayerGzipEnc
|
||||
case ocispec.MediaTypeImageLayerZstd:
|
||||
newDesc.MediaType = encocispec.MediaTypeLayerZstdEnc
|
||||
case ocispec.MediaTypeImageLayer:
|
||||
newDesc.MediaType = encocispec.MediaTypeLayerEnc
|
||||
|
||||
@@ -145,6 +149,8 @@ func DecryptLayer(dc *encconfig.DecryptConfig, dataReader io.Reader, desc ocispe
|
||||
switch desc.MediaType {
|
||||
case encocispec.MediaTypeLayerGzipEnc:
|
||||
newDesc.MediaType = images.MediaTypeDockerSchema2LayerGzip
|
||||
case encocispec.MediaTypeLayerZstdEnc:
|
||||
newDesc.MediaType = ocispec.MediaTypeImageLayerZstd
|
||||
case encocispec.MediaTypeLayerEnc:
|
||||
newDesc.MediaType = images.MediaTypeDockerSchema2Layer
|
||||
default:
|
||||
@@ -170,6 +176,8 @@ func decryptLayer(cc *encconfig.CryptoConfig, dataReader content.ReaderAt, desc
|
||||
switch desc.MediaType {
|
||||
case encocispec.MediaTypeLayerGzipEnc:
|
||||
newDesc.MediaType = images.MediaTypeDockerSchema2LayerGzip
|
||||
case encocispec.MediaTypeLayerZstdEnc:
|
||||
newDesc.MediaType = ocispec.MediaTypeImageLayerZstd
|
||||
case encocispec.MediaTypeLayerEnc:
|
||||
newDesc.MediaType = images.MediaTypeDockerSchema2Layer
|
||||
default:
|
||||
@@ -284,7 +292,8 @@ func cryptChildren(ctx context.Context, cs content.Store, desc ocispec.Descripto
|
||||
case images.MediaTypeDockerSchema2Config, ocispec.MediaTypeImageConfig:
|
||||
config = child
|
||||
case images.MediaTypeDockerSchema2LayerGzip, images.MediaTypeDockerSchema2Layer,
|
||||
ocispec.MediaTypeImageLayerGzip, ocispec.MediaTypeImageLayer:
|
||||
ocispec.MediaTypeImageLayerGzip, ocispec.MediaTypeImageLayer,
|
||||
ocispec.MediaTypeImageLayerZstd:
|
||||
if cryptoOp == cryptoOpEncrypt && lf(child) {
|
||||
nl, err := cryptLayer(ctx, cs, child, cc, cryptoOp)
|
||||
if err != nil {
|
||||
@@ -295,7 +304,7 @@ func cryptChildren(ctx context.Context, cs content.Store, desc ocispec.Descripto
|
||||
} else {
|
||||
newLayers = append(newLayers, child)
|
||||
}
|
||||
case encocispec.MediaTypeLayerGzipEnc, encocispec.MediaTypeLayerEnc:
|
||||
case encocispec.MediaTypeLayerGzipEnc, encocispec.MediaTypeLayerZstdEnc, encocispec.MediaTypeLayerEnc:
|
||||
// this one can be decrypted but also its recipients list changed
|
||||
if lf(child) {
|
||||
nl, err := cryptLayer(ctx, cs, child, cc, cryptoOp)
|
||||
|
||||
2
vendor/github.com/containerd/imgcrypt/images/encryption/payload.go
generated
vendored
2
vendor/github.com/containerd/imgcrypt/images/encryption/payload.go
generated
vendored
@@ -38,7 +38,7 @@ func clearProcessorPayloads(c *diff.ApplyConfig) {
|
||||
reflect.ValueOf(&c.ProcessorPayloads).Elem().Set(empty)
|
||||
}
|
||||
|
||||
func setProcessorPayload(c *diff.ApplyConfig, id string, value any) {
|
||||
func setProcessorPayload(c *diff.ApplyConfig, id string, value pbAny) {
|
||||
if c.ProcessorPayloads == nil {
|
||||
clearProcessorPayloads(c)
|
||||
}
|
||||
|
||||
2
vendor/github.com/containers/ocicrypt/.travis.yml
generated
vendored
2
vendor/github.com/containers/ocicrypt/.travis.yml
generated
vendored
@@ -21,7 +21,7 @@ addons:
|
||||
go_import_path: github.com/containers/ocicrypt
|
||||
|
||||
install:
|
||||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.30.0
|
||||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
|
||||
|
||||
script:
|
||||
- make
|
||||
|
||||
1
vendor/github.com/containers/ocicrypt/MAINTAINERS
generated
vendored
1
vendor/github.com/containers/ocicrypt/MAINTAINERS
generated
vendored
@@ -3,3 +3,4 @@
|
||||
# Github ID, Name, Email Address
|
||||
lumjjb, Brandon Lum, lumjjb@gmail.com
|
||||
stefanberger, Stefan Berger, stefanb@linux.ibm.com
|
||||
arronwy, Arron Wang, arron.wang@intel.com
|
||||
|
||||
2
vendor/github.com/containers/ocicrypt/config/constructors.go
generated
vendored
2
vendor/github.com/containers/ocicrypt/config/constructors.go
generated
vendored
@@ -21,7 +21,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// EncryptWithJwe returns a CryptoConfig to encrypt with jwe public keys
|
||||
|
||||
2
vendor/github.com/containers/ocicrypt/crypto/pkcs11/common.go
generated
vendored
2
vendor/github.com/containers/ocicrypt/crypto/pkcs11/common.go
generated
vendored
@@ -17,7 +17,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
pkcs11uri "github.com/stefanberger/go-pkcs11uri"
|
||||
"gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Pkcs11KeyFile describes the format of the pkcs11 (private) key file.
|
||||
|
||||
26
vendor/github.com/containers/ocicrypt/crypto/pkcs11/pkcs11helpers.go
generated
vendored
26
vendor/github.com/containers/ocicrypt/crypto/pkcs11/pkcs11helpers.go
generated
vendored
@@ -40,8 +40,6 @@ import (
|
||||
var (
|
||||
// OAEPLabel defines the label we use for OAEP encryption; this cannot be changed
|
||||
OAEPLabel = []byte("")
|
||||
// OAEPDefaultHash defines the default hash used for OAEP encryption; this cannot be changed
|
||||
OAEPDefaultHash = "sha1"
|
||||
|
||||
// OAEPSha1Params describes the OAEP parameters with sha1 hash algorithm; needed by SoftHSM
|
||||
OAEPSha1Params = &pkcs11.OAEPParams{
|
||||
@@ -69,12 +67,12 @@ func rsaPublicEncryptOAEP(pubKey *rsa.PublicKey, plaintext []byte) ([]byte, stri
|
||||
)
|
||||
|
||||
oaephash := os.Getenv("OCICRYPT_OAEP_HASHALG")
|
||||
// The default is 'sha1'
|
||||
// The default is sha256 (previously was sha1)
|
||||
switch strings.ToLower(oaephash) {
|
||||
case "sha1", "":
|
||||
case "sha1":
|
||||
hashfunc = sha1.New()
|
||||
hashalg = "sha1"
|
||||
case "sha256":
|
||||
case "sha256", "":
|
||||
hashfunc = sha256.New()
|
||||
hashalg = "sha256"
|
||||
default:
|
||||
@@ -283,12 +281,12 @@ func publicEncryptOAEP(pubKey *Pkcs11KeyFileObject, plaintext []byte) ([]byte, s
|
||||
|
||||
var oaep *pkcs11.OAEPParams
|
||||
oaephash := os.Getenv("OCICRYPT_OAEP_HASHALG")
|
||||
// the default is sha1
|
||||
// The default is sha256 (previously was sha1)
|
||||
switch strings.ToLower(oaephash) {
|
||||
case "sha1", "":
|
||||
case "sha1":
|
||||
oaep = OAEPSha1Params
|
||||
hashalg = "sha1"
|
||||
case "sha256":
|
||||
case "sha256", "":
|
||||
oaep = OAEPSha256Params
|
||||
hashalg = "sha256"
|
||||
default:
|
||||
@@ -333,7 +331,7 @@ func privateDecryptOAEP(privKeyObj *Pkcs11KeyFileObject, ciphertext []byte, hash
|
||||
|
||||
var oaep *pkcs11.OAEPParams
|
||||
|
||||
// the default is sha1
|
||||
// An empty string from the Hash in the JSON historically defaults to sha1.
|
||||
switch hashalg {
|
||||
case "sha1", "":
|
||||
oaep = OAEPSha1Params
|
||||
@@ -410,9 +408,6 @@ func EncryptMultiple(pubKeys []interface{}, data []byte) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if hashalg == OAEPDefaultHash {
|
||||
hashalg = ""
|
||||
}
|
||||
recipient := Pkcs11Recipient{
|
||||
Version: 0,
|
||||
Blob: base64.StdEncoding.EncodeToString(ciphertext),
|
||||
@@ -431,15 +426,18 @@ func EncryptMultiple(pubKeys []interface{}, data []byte) ([]byte, error) {
|
||||
// {
|
||||
// "version": 0,
|
||||
// "blob": <base64 encoded RSA OAEP encrypted blob>,
|
||||
// "hash": <hash used for OAEP other than 'sha256'>
|
||||
// "hash": <hash used for OAEP other than 'sha1'>
|
||||
// } ,
|
||||
// {
|
||||
// "version": 0,
|
||||
// "blob": <base64 encoded RSA OAEP encrypted blob>,
|
||||
// "hash": <hash used for OAEP other than 'sha256'>
|
||||
// "hash": <hash used for OAEP other than 'sha1'>
|
||||
// } ,
|
||||
// [...]
|
||||
// }
|
||||
// Note: More recent versions of this code explicitly write 'sha1'
|
||||
// while older versions left it empty in case of 'sha1'.
|
||||
//
|
||||
func Decrypt(privKeyObjs []*Pkcs11KeyFileObject, pkcs11blobstr []byte) ([]byte, error) {
|
||||
pkcs11blob := Pkcs11Blob{}
|
||||
err := json.Unmarshal(pkcs11blobstr, &pkcs11blob)
|
||||
|
||||
8
vendor/github.com/containers/ocicrypt/encryption.go
generated
vendored
8
vendor/github.com/containers/ocicrypt/encryption.go
generated
vendored
@@ -33,9 +33,9 @@ import (
|
||||
"github.com/containers/ocicrypt/keywrap/pkcs11"
|
||||
"github.com/containers/ocicrypt/keywrap/pkcs7"
|
||||
"github.com/opencontainers/go-digest"
|
||||
log "github.com/sirupsen/logrus"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// EncryptLayerFinalizer is a finalizer run to return the annotations to set for
|
||||
@@ -143,6 +143,9 @@ func EncryptLayer(ec *config.EncryptConfig, encOrPlainLayerReader io.Reader, des
|
||||
|
||||
newAnnotations := make(map[string]string)
|
||||
keysWrapped := false
|
||||
if len(keyWrapperAnnotations) == 0 {
|
||||
return nil, errors.New("missing Annotations needed for decryption")
|
||||
}
|
||||
for annotationsID, scheme := range keyWrapperAnnotations {
|
||||
b64Annotations := desc.Annotations[annotationsID]
|
||||
keywrapper := GetKeyWrapper(scheme)
|
||||
@@ -211,6 +214,9 @@ func DecryptLayer(dc *config.DecryptConfig, encLayerReader io.Reader, desc ocisp
|
||||
func decryptLayerKeyOptsData(dc *config.DecryptConfig, desc ocispec.Descriptor) ([]byte, error) {
|
||||
privKeyGiven := false
|
||||
errs := ""
|
||||
if len(keyWrapperAnnotations) == 0 {
|
||||
return nil, errors.New("missing Annotations needed for decryption")
|
||||
}
|
||||
for annotationsID, scheme := range keyWrapperAnnotations {
|
||||
b64Annotation := desc.Annotations[annotationsID]
|
||||
if b64Annotation != "" {
|
||||
|
||||
2
vendor/github.com/containers/ocicrypt/keywrap/pkcs11/keywrapper_pkcs11.go
generated
vendored
2
vendor/github.com/containers/ocicrypt/keywrap/pkcs11/keywrapper_pkcs11.go
generated
vendored
@@ -139,7 +139,7 @@ func addPubKeys(dc *config.DecryptConfig, pubKeys [][]byte) ([]interface{}, erro
|
||||
return pkcs11Keys, nil
|
||||
}
|
||||
|
||||
func p11confFromParameters(dcparameters map[string][][]byte) (*pkcs11.Pkcs11Config, error){
|
||||
func p11confFromParameters(dcparameters map[string][][]byte) (*pkcs11.Pkcs11Config, error) {
|
||||
if _, ok := dcparameters["pkcs11-config"]; ok {
|
||||
return pkcs11.ParsePkcs11ConfigFile(dcparameters["pkcs11-config"][0])
|
||||
}
|
||||
|
||||
8
vendor/github.com/containers/ocicrypt/spec/spec.go
generated
vendored
8
vendor/github.com/containers/ocicrypt/spec/spec.go
generated
vendored
@@ -3,10 +3,14 @@ package spec
|
||||
const (
|
||||
// MediaTypeLayerEnc is MIME type used for encrypted layers.
|
||||
MediaTypeLayerEnc = "application/vnd.oci.image.layer.v1.tar+encrypted"
|
||||
// MediaTypeLayerGzipEnc is MIME type used for encrypted compressed layers.
|
||||
// MediaTypeLayerGzipEnc is MIME type used for encrypted gzip-compressed layers.
|
||||
MediaTypeLayerGzipEnc = "application/vnd.oci.image.layer.v1.tar+gzip+encrypted"
|
||||
// MediaTypeLayerZstdEnc is MIME type used for encrypted zstd-compressed layers.
|
||||
MediaTypeLayerZstdEnc = "application/vnd.oci.image.layer.v1.tar+zstd+encrypted"
|
||||
// MediaTypeLayerNonDistributableEnc is MIME type used for non distributable encrypted layers.
|
||||
MediaTypeLayerNonDistributableEnc = "application/vnd.oci.image.layer.nondistributable.v1.tar+encrypted"
|
||||
// MediaTypeLayerGzipEnc is MIME type used for non distributable encrypted compressed layers.
|
||||
// MediaTypeLayerGzipEnc is MIME type used for non distributable encrypted gzip-compressed layers.
|
||||
MediaTypeLayerNonDistributableGzipEnc = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip+encrypted"
|
||||
// MediaTypeLayerZstdEnc is MIME type used for non distributable encrypted zstd-compressed layers.
|
||||
MediaTypeLayerNonDistributableZsdtEnc = "application/vnd.oci.image.layer.nondistributable.v1.tar+zstd+encrypted"
|
||||
)
|
||||
|
||||
2
vendor/github.com/containers/ocicrypt/utils/ioutils.go
generated
vendored
2
vendor/github.com/containers/ocicrypt/utils/ioutils.go
generated
vendored
@@ -18,9 +18,9 @@ package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/pkg/errors"
|
||||
"io"
|
||||
"os/exec"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// FillBuffer fills the given buffer with as many bytes from the reader as possible. It returns
|
||||
|
||||
Reference in New Issue
Block a user