key_handler.go 544 B

123456789101112131415161718192021
  1. package s3crypto
  2. import "crypto/rand"
  3. // CipherDataGenerator handles generating proper key and IVs of proper size for the
  4. // content cipher. CipherDataGenerator will also encrypt the key and store it in
  5. // the CipherData.
  6. type CipherDataGenerator interface {
  7. GenerateCipherData(int, int) (CipherData, error)
  8. }
  9. // CipherDataDecrypter is a handler to decrypt keys from the envelope.
  10. type CipherDataDecrypter interface {
  11. DecryptKey([]byte) ([]byte, error)
  12. }
  13. func generateBytes(n int) []byte {
  14. b := make([]byte, n)
  15. rand.Read(b)
  16. return b
  17. }