1package s3crypto 2 3import ( 4 "crypto/rand" 5 6 "github.com/aws/aws-sdk-go/aws" 7) 8 9// CipherDataGenerator handles generating proper key and IVs of proper size for the 10// content cipher. CipherDataGenerator will also encrypt the key and store it in 11// the CipherData. 12type CipherDataGenerator interface { 13 GenerateCipherData(int, int) (CipherData, error) 14} 15 16// CipherDataGeneratorWithContext handles generating proper key and IVs of 17// proper size for the content cipher. CipherDataGenerator will also encrypt 18// the key and store it in the CipherData. 19type CipherDataGeneratorWithContext interface { 20 GenerateCipherDataWithContext(aws.Context, int, int) (CipherData, error) 21} 22 23// CipherDataDecrypter is a handler to decrypt keys from the envelope. 24type CipherDataDecrypter interface { 25 DecryptKey([]byte) ([]byte, error) 26} 27 28// CipherDataDecrypterWithContext is a handler to decrypt keys from the envelope with request context. 29type CipherDataDecrypterWithContext interface { 30 DecryptKeyWithContext(aws.Context, []byte) ([]byte, error) 31} 32 33func generateBytes(n int) []byte { 34 b := make([]byte, n) 35 rand.Read(b) 36 return b 37} 38