aws-sdk-s3 1.207.0 → 1.208.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/client.rb +1 -1
- data/lib/aws-sdk-s3/customizations.rb +1 -0
- data/lib/aws-sdk-s3/encryption/client.rb +2 -2
- data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +2 -0
- data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +2 -0
- data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +2 -0
- data/lib/aws-sdk-s3/encryptionV2/client.rb +98 -23
- data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +7 -162
- data/lib/aws-sdk-s3/encryptionV2/decryption.rb +205 -0
- data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +17 -0
- data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +2 -0
- data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +2 -0
- data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +8 -0
- data/lib/aws-sdk-s3/encryptionV2/utils.rb +5 -0
- data/lib/aws-sdk-s3/encryptionV3/client.rb +885 -0
- data/lib/aws-sdk-s3/encryptionV3/decrypt_handler.rb +98 -0
- data/lib/aws-sdk-s3/encryptionV3/decryption.rb +244 -0
- data/lib/aws-sdk-s3/encryptionV3/default_cipher_provider.rb +159 -0
- data/lib/aws-sdk-s3/encryptionV3/default_key_provider.rb +35 -0
- data/lib/aws-sdk-s3/encryptionV3/encrypt_handler.rb +98 -0
- data/lib/aws-sdk-s3/encryptionV3/errors.rb +47 -0
- data/lib/aws-sdk-s3/encryptionV3/io_auth_decrypter.rb +60 -0
- data/lib/aws-sdk-s3/encryptionV3/io_decrypter.rb +35 -0
- data/lib/aws-sdk-s3/encryptionV3/io_encrypter.rb +84 -0
- data/lib/aws-sdk-s3/encryptionV3/key_provider.rb +28 -0
- data/lib/aws-sdk-s3/encryptionV3/kms_cipher_provider.rb +159 -0
- data/lib/aws-sdk-s3/encryptionV3/materials.rb +58 -0
- data/lib/aws-sdk-s3/encryptionV3/utils.rb +321 -0
- data/lib/aws-sdk-s3/encryption_v2.rb +1 -0
- data/lib/aws-sdk-s3/encryption_v3.rb +24 -0
- data/lib/aws-sdk-s3.rb +1 -1
- metadata +17 -1
|
@@ -14,11 +14,15 @@ module Aws
|
|
|
14
14
|
options[:key_wrap_schema],
|
|
15
15
|
@key_provider.encryption_materials.key
|
|
16
16
|
)
|
|
17
|
+
##= ../specification/s3-encryption/encryption.md#content-encryption
|
|
18
|
+
##% The S3EC MUST use the encryption algorithm configured during [client](./client.md) initialization.
|
|
17
19
|
@content_encryption_schema = validate_cek(
|
|
18
20
|
options[:content_encryption_schema]
|
|
19
21
|
)
|
|
20
22
|
end
|
|
21
23
|
|
|
24
|
+
attr_reader :key_provider
|
|
25
|
+
|
|
22
26
|
# @return [Array<Hash,Cipher>] Creates an returns a new encryption
|
|
23
27
|
# envelope and encryption cipher.
|
|
24
28
|
def encryption_cipher(options = {})
|
|
@@ -30,9 +34,14 @@ module Aws
|
|
|
30
34
|
)
|
|
31
35
|
else
|
|
32
36
|
enc_key = encode64(
|
|
37
|
+
##= ../specification/s3-encryption/encryption.md#alg-aes-256-gcm-iv12-tag16-no-kdf
|
|
38
|
+
##% The client MUST NOT provide any AAD when encrypting with ALG_AES_256_GCM_IV12_TAG16_NO_KDF.
|
|
33
39
|
encrypt_aes_gcm(envelope_key(cipher), @content_encryption_schema)
|
|
34
40
|
)
|
|
35
41
|
end
|
|
42
|
+
|
|
43
|
+
##= ../specification/s3-encryption/data-format/content-metadata.md#algorithm-suite-and-message-format-version-compatibility
|
|
44
|
+
##% Objects encrypted with ALG_AES_256_GCM_IV12_TAG16_NO_KDF MUST use the V2 message format version only.
|
|
36
45
|
envelope = {
|
|
37
46
|
'x-amz-key-v2' => enc_key,
|
|
38
47
|
'x-amz-cek-alg' => @content_encryption_schema,
|
|
@@ -52,8 +61,16 @@ module Aws
|
|
|
52
61
|
master_key = @key_provider.key_for(envelope['x-amz-matdesc'])
|
|
53
62
|
if envelope.key? 'x-amz-key'
|
|
54
63
|
unless options[:security_profile] == :v2_and_legacy
|
|
64
|
+
##= ../specification/s3-encryption/decryption.md#legacy-decryption
|
|
65
|
+
##% If the S3EC is not configured to enable legacy unauthenticated content decryption, the client MUST throw an exception when attempting to decrypt an object encrypted with a legacy unauthenticated algorithm suite.
|
|
66
|
+
##= ../specification/s3-encryption/client.md#enable-legacy-unauthenticated-modes
|
|
67
|
+
##% When disabled, the S3EC MUST NOT decrypt objects encrypted using legacy content encryption algorithms; it MUST throw an exception when attempting to decrypt an object encrypted with a legacy content encryption algorithm.
|
|
55
68
|
raise Errors::LegacyDecryptionError
|
|
56
69
|
end
|
|
70
|
+
##= ../specification/s3-encryption/decryption.md#legacy-decryption
|
|
71
|
+
##% The S3EC MUST NOT decrypt objects encrypted using legacy unauthenticated algorithm suites unless specifically configured to do so.
|
|
72
|
+
##= ../specification/s3-encryption/client.md#enable-legacy-unauthenticated-modes
|
|
73
|
+
##% When enabled, the S3EC MUST be able to decrypt objects encrypted with all content encryption algorithms (both legacy and fully supported).
|
|
57
74
|
# Support for decryption of legacy objects
|
|
58
75
|
key = Utils.decrypt(master_key, decode64(envelope['x-amz-key']))
|
|
59
76
|
iv = decode64(envelope['x-amz-iv'])
|
|
@@ -28,6 +28,8 @@ module Aws
|
|
|
28
28
|
context.client.put_object(
|
|
29
29
|
bucket: context.params[:bucket],
|
|
30
30
|
key: context.params[:key] + suffix,
|
|
31
|
+
##= ../specification/s3-encryption/data-format/metadata-strategy.md#v1-v2-instruction-files
|
|
32
|
+
##% In the V1/V2 message format, all of the content metadata MUST be stored in the Instruction File.
|
|
31
33
|
body: Json.dump(envelope)
|
|
32
34
|
)
|
|
33
35
|
else # :metadata
|
|
@@ -44,6 +44,8 @@ module Aws
|
|
|
44
44
|
private
|
|
45
45
|
|
|
46
46
|
def encrypt_to_stringio(cipher, plain_text)
|
|
47
|
+
##= ../specification/s3-encryption/encryption.md#alg-aes-256-gcm-iv12-tag16-no-kdf
|
|
48
|
+
##% The client MUST append the GCM auth tag to the ciphertext if the underlying crypto provider does not do so automatically.
|
|
47
49
|
if plain_text.empty?
|
|
48
50
|
StringIO.new(cipher.final + cipher.auth_tag)
|
|
49
51
|
else
|
|
@@ -33,6 +33,8 @@ module Aws
|
|
|
33
33
|
end
|
|
34
34
|
cipher = Utils.aes_encryption_cipher(:GCM)
|
|
35
35
|
cipher.key = key_data.plaintext
|
|
36
|
+
##= ../specification/s3-encryption/data-format/content-metadata.md#algorithm-suite-and-message-format-version-compatibility
|
|
37
|
+
##% Objects encrypted with ALG_AES_256_GCM_IV12_TAG16_NO_KDF MUST use the V2 message format version only.
|
|
36
38
|
envelope = {
|
|
37
39
|
'x-amz-key-v2' => encode64(key_data.ciphertext_blob),
|
|
38
40
|
'x-amz-iv' => encode64(cipher.iv = cipher.random_iv),
|
|
@@ -53,9 +55,15 @@ module Aws
|
|
|
53
55
|
|
|
54
56
|
case envelope['x-amz-wrap-alg']
|
|
55
57
|
when 'kms'
|
|
58
|
+
##= ../specification/s3-encryption/client.md#enable-legacy-wrapping-algorithms
|
|
59
|
+
##% The S3EC MUST support the option to enable or disable legacy wrapping algorithms.
|
|
56
60
|
unless options[:security_profile] == :v2_and_legacy
|
|
61
|
+
##= ../specification/s3-encryption/client.md#enable-legacy-wrapping-algorithms
|
|
62
|
+
##% When disabled, the S3EC MUST NOT decrypt objects encrypted using legacy wrapping algorithms; it MUST throw an exception when attempting to decrypt an object encrypted with a legacy wrapping algorithm.
|
|
57
63
|
raise Errors::LegacyDecryptionError
|
|
58
64
|
end
|
|
65
|
+
##= ../specification/s3-encryption/client.md#enable-legacy-wrapping-algorithms
|
|
66
|
+
##% When enabled, the S3EC MUST be able to decrypt objects encrypted with all supported wrapping algorithms (both legacy and fully supported).
|
|
59
67
|
when 'kms+context'
|
|
60
68
|
if cek_alg != encryption_context['aws:x-amz-cek-alg']
|
|
61
69
|
raise Errors::CEKAlgMismatchError
|
|
@@ -80,6 +80,11 @@ module Aws
|
|
|
80
80
|
# @param [OpenSSL::PKey::RSA, String, nil] key
|
|
81
81
|
# @param [String, nil] iv The initialization vector
|
|
82
82
|
def aes_cipher(mode, block_mode, key, iv)
|
|
83
|
+
##= ../specification/s3-encryption/encryption.md#alg-aes-256-gcm-iv12-tag16-no-kdf
|
|
84
|
+
##% The client MUST initialize the cipher,
|
|
85
|
+
##% or call an AES-GCM encryption API, with the plaintext data key, the generated IV,
|
|
86
|
+
##% and the tag length defined in the Algorithm Suite
|
|
87
|
+
##% when encrypting with ALG_AES_256_GCM_IV12_TAG16_NO_KDF.
|
|
83
88
|
cipher = key ?
|
|
84
89
|
OpenSSL::Cipher.new("aes-#{cipher_size(key)}-#{block_mode.downcase}") :
|
|
85
90
|
OpenSSL::Cipher.new("aes-256-#{block_mode.downcase}")
|