github.com/aavshr/aws-sdk-go@v1.41.3/service/s3/s3crypto/cipher_builder.go (about)

     1  package s3crypto
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/aavshr/aws-sdk-go/aws"
     7  )
     8  
     9  // ContentCipherBuilder is a builder interface that builds
    10  // ciphers for each request.
    11  type ContentCipherBuilder interface {
    12  	ContentCipher() (ContentCipher, error)
    13  }
    14  
    15  // ContentCipherBuilderWithContext is a builder interface that builds
    16  // ciphers for each request.
    17  type ContentCipherBuilderWithContext interface {
    18  	ContentCipherWithContext(aws.Context) (ContentCipher, error)
    19  }
    20  
    21  // ContentCipher deals with encrypting and decrypting content
    22  type ContentCipher interface {
    23  	EncryptContents(io.Reader) (io.Reader, error)
    24  	DecryptContents(io.ReadCloser) (io.ReadCloser, error)
    25  	GetCipherData() CipherData
    26  }
    27  
    28  // CipherData is used for content encryption. It is used for storing the
    29  // metadata of the encrypted content.
    30  type CipherData struct {
    31  	Key                 []byte
    32  	IV                  []byte
    33  	WrapAlgorithm       string
    34  	CEKAlgorithm        string
    35  	TagLength           string
    36  	MaterialDescription MaterialDescription
    37  	// EncryptedKey should be populated when calling GenerateCipherData
    38  	EncryptedKey []byte
    39  
    40  	Padder Padder
    41  }
    42  
    43  // Clone returns a new copy of CipherData
    44  func (cd CipherData) Clone() (v CipherData) {
    45  	v = cd
    46  	v.MaterialDescription = cd.MaterialDescription.Clone()
    47  	return v
    48  }