MCPcopy Create free account
hub / github.com/containerd/imgcrypt / cryptImage

Function cryptImage

images/encryption/encryption.go:451–463  ·  view source on GitHub ↗

cryptImage is the dispatcher to encrypt/decrypt an image; it accepts either an OCI descriptor representing a manifest list or a single manifest

(ctx context.Context, cs content.Store, desc ocispec.Descriptor, cc *encconfig.CryptoConfig, lf LayerFilter, cryptoOp cryptoOp)

Source from the content-addressed store, hash-verified

449// cryptImage is the dispatcher to encrypt/decrypt an image; it accepts either an OCI descriptor
450// representing a manifest list or a single manifest
451func cryptImage(ctx context.Context, cs content.Store, desc ocispec.Descriptor, cc *encconfig.CryptoConfig, lf LayerFilter, cryptoOp cryptoOp) (ocispec.Descriptor, bool, error) {
452 if cc == nil {
453 return ocispec.Descriptor{}, false, errors.New("invalid argument: CryptoConfig must not be nil")
454 }
455 switch desc.MediaType {
456 case ocispec.MediaTypeImageIndex, images.MediaTypeDockerSchema2ManifestList:
457 return cryptManifestList(ctx, cs, desc, cc, lf, cryptoOp)
458 case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
459 return cryptManifest(ctx, cs, desc, cc, lf, cryptoOp)
460 default:
461 return ocispec.Descriptor{}, false, fmt.Errorf("unhandled media type: %s", desc.MediaType)
462 }
463}
464
465// EncryptImage encrypts an image; it accepts either an OCI descriptor representing a manifest list or a single manifest
466func EncryptImage(ctx context.Context, cs content.Store, desc ocispec.Descriptor, cc *encconfig.CryptoConfig, lf LayerFilter) (ocispec.Descriptor, bool, error) {

Callers 3

EncryptImageFunction · 0.70
DecryptImageFunction · 0.70
CheckAuthorizationFunction · 0.70

Calls 2

cryptManifestListFunction · 0.85
cryptManifestFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…