sse

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sse provides server-side encryption helpers for object operations.

Package sse provides Server-Side Encryption (SSE) support for S3-compatible storage.

This package implements three SSE modes:

  • SSE-S3: Server-managed encryption with AES-256
  • SSE-C: Customer-provided encryption keys
  • SSE-KMS: AWS Key Management Service (KMS) encryption

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKeySize is returned when SSE-C key is not 256 bits (32 bytes)
	ErrInvalidKeySize = errors.New("sse: encryption key must be 256 bits (32 bytes)")

	// ErrNoEncryptionConfig is returned when no encryption configuration is found
	ErrNoEncryptionConfig = errors.New("sse: bucket has no encryption configuration")
)

Functions

This section is empty.

Types

type ApplySSEByDefault

type ApplySSEByDefault struct {
	SSEAlgorithm   string `xml:"SSEAlgorithm"`             // AES256 or aws:kms
	KMSMasterKeyID string `xml:"KMSMasterKeyID,omitempty"` // KMS key ID for aws:kms
}

ApplySSEByDefault specifies the default encryption settings

type C added in v1.0.5

type C struct {
	Key       []byte
	Algorithm string // Default: AES256
}

C represents SSE-C encryption (customer-provided keys)

func NewSSEC added in v1.0.5

func NewSSEC(key []byte) (*C, error)

NewSSEC creates a new SSE-C encrypter with the given 256-bit key

func (*C) ApplyCopyHeaders added in v1.0.5

func (c *C) ApplyCopyHeaders(h http.Header)

ApplyCopyHeaders applies SSE-C headers for copy source

func (*C) ApplyHeaders added in v1.0.5

func (c *C) ApplyHeaders(h http.Header)

ApplyHeaders applies SSE-C headers to the request

func (*C) Type added in v1.0.5

func (c *C) Type() Type

Type returns the encryption type

type Configuration

type Configuration struct {
	XMLName xml.Name `xml:"ServerSideEncryptionConfiguration"`
	Rules   []Rule   `xml:"Rule"`
}

Configuration represents bucket-level default encryption configuration

func NewConfiguration added in v1.0.5

func NewConfiguration() *Configuration

NewConfiguration creates a default SSE-S3 bucket encryption configuration

func NewKMSConfiguration added in v1.0.5

func NewKMSConfiguration(keyID string) *Configuration

NewKMSConfiguration creates an SSE-KMS bucket encryption configuration

type Encrypter added in v1.0.5

type Encrypter interface {
	ApplyHeaders(h http.Header)
	Type() Type
}

Encrypter is the interface that wraps the ApplyHeaders method.

ApplyHeaders applies the appropriate SSE headers to an HTTP request.

type KMS added in v1.0.5

type KMS struct {
	KeyID   string
	Context map[string]string
}

KMS represents SSE-KMS encryption (AWS KMS-managed keys)

func NewSSEKMS added in v1.0.5

func NewSSEKMS(keyID string, context map[string]string) *KMS

NewSSEKMS creates a new SSE-KMS encrypter

func (*KMS) ApplyHeaders added in v1.0.5

func (k *KMS) ApplyHeaders(h http.Header)

ApplyHeaders applies SSE-KMS headers to the request

func (*KMS) Type added in v1.0.5

func (k *KMS) Type() Type

Type returns the encryption type

type Rule

type Rule struct {
	ApplySSEByDefault ApplySSEByDefault `xml:"ApplyServerSideEncryptionByDefault"`
	BucketKeyEnabled  bool              `xml:"BucketKeyEnabled,omitempty"`
}

Rule defines a server-side encryption rule

type S3 added in v1.0.5

type S3 struct{}

S3 represents SSE-S3 encryption (server-managed keys)

func NewSSES3 added in v1.0.5

func NewSSES3() *S3

NewSSES3 creates a new SSE-S3 encrypter

func (*S3) ApplyHeaders added in v1.0.5

func (s *S3) ApplyHeaders(h http.Header)

ApplyHeaders applies SSE-S3 headers to the request

func (*S3) Type added in v1.0.5

func (s *S3) Type() Type

Type returns the encryption type

type Type added in v1.0.5

type Type string

Type represents the server-side encryption type

const (
	// SSES3 represents S3-managed encryption (AES256)
	SSES3 Type = "AES256"
	// SSEKMS represents KMS-managed encryption
	SSEKMS Type = "aws:kms"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL