envelope.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package s3crypto
  2. // DefaultInstructionKeySuffix is appended to the end of the instruction file key when
  3. // grabbing or saving to S3
  4. const DefaultInstructionKeySuffix = ".instruction"
  5. const (
  6. metaHeader = "x-amz-meta"
  7. keyV1Header = "x-amz-key"
  8. keyV2Header = keyV1Header + "-v2"
  9. ivHeader = "x-amz-iv"
  10. matDescHeader = "x-amz-matdesc"
  11. cekAlgorithmHeader = "x-amz-cek-alg"
  12. wrapAlgorithmHeader = "x-amz-wrap-alg"
  13. tagLengthHeader = "x-amz-tag-len"
  14. unencryptedMD5Header = "x-amz-unencrypted-content-md5"
  15. unencryptedContentLengthHeader = "x-amz-unencrypted-content-length"
  16. )
  17. // Envelope encryption starts off by generating a random symmetric key using
  18. // AES GCM. The SDK generates a random IV based off the encryption cipher
  19. // chosen. The master key that was provided, whether by the user or KMS, will be used
  20. // to encrypt the randomly generated symmetric key and base64 encode the iv. This will
  21. // allow for decryption of that same data later.
  22. type Envelope struct {
  23. // IV is the randomly generated IV base64 encoded.
  24. IV string `json:"x-amz-iv"`
  25. // CipherKey is the randomly generated cipher key.
  26. CipherKey string `json:"x-amz-key-v2, x-amz-key"`
  27. // MaterialDesc is a description to distinguish from other envelopes.
  28. MatDesc string `json:"x-amz-matdesc"`
  29. WrapAlg string `json:"x-amz-wrap-alg"`
  30. CEKAlg string `json:"x-amz-cek-alg"`
  31. TagLen string `json:"x-amz-tag-len"`
  32. UnencryptedMD5 string `json:"x-amz-unencrypted-content-md5"`
  33. UnencryptedContentLen string `json:"x-amz-unencrypted-content-length"`
  34. }