aws-sdk-s3 1.203.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 +30 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/bucket.rb +1 -1
- data/lib/aws-sdk-s3/bucket_acl.rb +1 -1
- data/lib/aws-sdk-s3/client.rb +319 -260
- data/lib/aws-sdk-s3/client_api.rb +59 -0
- data/lib/aws-sdk-s3/customizations/object.rb +3 -4
- 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/endpoints.rb +26 -0
- data/lib/aws-sdk-s3/file_downloader.rb +19 -2
- data/lib/aws-sdk-s3/object.rb +4 -4
- data/lib/aws-sdk-s3/object_acl.rb +1 -1
- data/lib/aws-sdk-s3/object_summary.rb +4 -4
- data/lib/aws-sdk-s3/transfer_manager.rb +3 -4
- data/lib/aws-sdk-s3/types.rb +206 -98
- data/lib/aws-sdk-s3.rb +1 -1
- data/sig/bucket.rbs +1 -1
- data/sig/client.rbs +38 -12
- data/sig/multipart_upload.rbs +1 -1
- data/sig/object.rbs +5 -5
- data/sig/object_summary.rbs +5 -5
- data/sig/types.rbs +45 -14
- metadata +17 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'openssl'
|
|
4
|
+
|
|
5
|
+
module Aws
|
|
6
|
+
module S3
|
|
7
|
+
module EncryptionV3
|
|
8
|
+
# @api private
|
|
9
|
+
module Utils
|
|
10
|
+
class << self
|
|
11
|
+
##= ../specification/s3-encryption/client.md#encryption-algorithm
|
|
12
|
+
##% The S3EC MUST validate that the configured encryption algorithm is not legacy.
|
|
13
|
+
def validate_cek(content_encryption_schema)
|
|
14
|
+
##= ../specification/s3-encryption/data-format/content-metadata.md#algorithm-suite-and-message-format-version-compatibility
|
|
15
|
+
##% Objects encrypted with ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY MUST use the V3 message format version only.
|
|
16
|
+
return '115' if content_encryption_schema.nil?
|
|
17
|
+
|
|
18
|
+
case content_encryption_schema
|
|
19
|
+
when :alg_aes_256_gcm_hkdf_sha512_commit_key
|
|
20
|
+
'115'
|
|
21
|
+
else
|
|
22
|
+
##= ../specification/s3-encryption/encryption.md#alg-aes-256-ctr-iv16-tag16-no-kdf
|
|
23
|
+
##% Attempts to encrypt using AES-CTR MUST fail.
|
|
24
|
+
##= ../specification/s3-encryption/encryption.md#alg-aes-256-ctr-hkdf-sha512-commit-key
|
|
25
|
+
##% Attempts to encrypt using key committing AES-CTR MUST fail.
|
|
26
|
+
##= ../specification/s3-encryption/client.md#encryption-algorithm
|
|
27
|
+
##% If the configured encryption algorithm is legacy, then the S3EC MUST throw an exception.
|
|
28
|
+
##= ../specification/s3-encryption/client.md#key-commitment
|
|
29
|
+
##% If the configured Encryption Algorithm is incompatible with the key commitment policy, then it MUST throw an exception.
|
|
30
|
+
raise ArgumentError, "Unsupported content_encryption_schema: #{content_encryption_schema}"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def encrypt_aes_gcm(key, data, auth_data)
|
|
35
|
+
cipher = aes_encryption_cipher(:GCM, key)
|
|
36
|
+
cipher.iv = (iv = cipher.random_iv)
|
|
37
|
+
cipher.auth_data = auth_data
|
|
38
|
+
|
|
39
|
+
iv + cipher.update(data) + cipher.final + cipher.auth_tag
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def encrypt_rsa(key, data, auth_data)
|
|
43
|
+
# Plaintext must be KeyLengthInBytes (1 Byte) + DataKey + AuthData
|
|
44
|
+
buf = [data.bytesize] + data.unpack('C*') + auth_data.unpack('C*')
|
|
45
|
+
key.public_encrypt(buf.pack('C*'), OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def decrypt_aes_gcm(key, data, auth_data)
|
|
49
|
+
# data is iv (12B) + key + tag (16B)
|
|
50
|
+
buf = data.unpack('C*')
|
|
51
|
+
iv = buf[0, 12].pack('C*') # iv will always be 12 bytes
|
|
52
|
+
tag = buf[-16, 16].pack('C*') # tag is 16 bytes
|
|
53
|
+
enc_key = buf[12, buf.size - (12 + 16)].pack('C*')
|
|
54
|
+
cipher = aes_cipher(:decrypt, :GCM, key, iv)
|
|
55
|
+
cipher.auth_tag = tag
|
|
56
|
+
cipher.auth_data = auth_data
|
|
57
|
+
cipher.update(enc_key) + cipher.final
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# returns the decrypted data + auth_data
|
|
61
|
+
def decrypt_rsa(key, enc_data)
|
|
62
|
+
# Plaintext must be KeyLengthInBytes (1 Byte) + DataKey + AuthData
|
|
63
|
+
buf = key.private_decrypt(enc_data, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING).unpack('C*')
|
|
64
|
+
key_length = buf[0]
|
|
65
|
+
data = buf[1, key_length].pack('C*')
|
|
66
|
+
auth_data = buf[key_length + 1, buf.length - key_length].pack('C*')
|
|
67
|
+
[data, auth_data]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# @param [String] block_mode "CBC" or "ECB"
|
|
71
|
+
# @param [OpenSSL::PKey::RSA, String, nil] key
|
|
72
|
+
# @param [String, nil] iv The initialization vector
|
|
73
|
+
def aes_encryption_cipher(block_mode, key = nil, iv = nil)
|
|
74
|
+
aes_cipher(:encrypt, block_mode, key, iv)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @param [String] block_mode "CBC" or "ECB"
|
|
78
|
+
# @param [OpenSSL::PKey::RSA, String, nil] key
|
|
79
|
+
# @param [String, nil] iv The initialization vector
|
|
80
|
+
def aes_decryption_cipher(block_mode, key = nil, iv = nil)
|
|
81
|
+
aes_cipher(:decrypt, block_mode, key, iv)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# @param [String] mode "encrypt" or "decrypt"
|
|
85
|
+
# @param [String] block_mode "CBC" or "ECB"
|
|
86
|
+
# @param [OpenSSL::PKey::RSA, String, nil] key
|
|
87
|
+
# @param [String, nil] iv The initialization vector
|
|
88
|
+
def aes_cipher(mode, block_mode, key, iv)
|
|
89
|
+
cipher =
|
|
90
|
+
if key
|
|
91
|
+
OpenSSL::Cipher.new("aes-#{cipher_size(key)}-#{block_mode.downcase}")
|
|
92
|
+
else
|
|
93
|
+
OpenSSL::Cipher.new("aes-256-#{block_mode.downcase}")
|
|
94
|
+
end
|
|
95
|
+
cipher.send(mode) # encrypt or decrypt
|
|
96
|
+
cipher.key = key if key
|
|
97
|
+
cipher.iv = iv if iv
|
|
98
|
+
cipher
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# @param [String] key
|
|
102
|
+
# @return [Integer]
|
|
103
|
+
# @raise ArgumentError
|
|
104
|
+
def cipher_size(key)
|
|
105
|
+
key.bytesize * 8
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# There is only 1 supported algorithm suite at this time
|
|
109
|
+
ENCRYPTION_KEY_INFO = ([0x00, 0x73].pack('C*') + 'DERIVEKEY'.encode('UTF-8')).freeze
|
|
110
|
+
COMMITMENT_KEY_INFO = ([0x00, 0x73].pack('C*') + 'COMMITKEY'.encode('UTF-8')).freeze
|
|
111
|
+
|
|
112
|
+
SHA512_DIGEST = OpenSSL::Digest::SHA512.new.freeze
|
|
113
|
+
V3_IV_BYTES = ("\x01" * 12).freeze
|
|
114
|
+
ALGO_ID = [0x00, 0x73].pack('C*').freeze
|
|
115
|
+
|
|
116
|
+
def generate_alg_aes_256_gcm_hkdf_sha512_commit_key_cipher(data_key)
|
|
117
|
+
##= ../specification/s3-encryption/encryption.md#content-encryption
|
|
118
|
+
##% The client MUST generate an IV or Message ID using the length of the IV or Message ID defined in the algorithm suite.
|
|
119
|
+
message_id = Utils.generate_message_id
|
|
120
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
121
|
+
##% - The salt MUST be the Message ID with the length defined in the algorithm suite.
|
|
122
|
+
commitment_key = Utils.derive_commitment_key(data_key, message_id)
|
|
123
|
+
cipher = alg_aes_256_gcm_hkdf_sha512_commit_key_cipher(:encrypt, data_key, message_id)
|
|
124
|
+
|
|
125
|
+
[
|
|
126
|
+
cipher,
|
|
127
|
+
##= ../specification/s3-encryption/encryption.md#content-encryption
|
|
128
|
+
##% The generated IV or Message ID MUST be set or returned from the encryption process such that it can be included in the content metadata.
|
|
129
|
+
message_id,
|
|
130
|
+
##= ../specification/s3-encryption/encryption.md#alg-aes-256-gcm-hkdf-sha512-commit-key
|
|
131
|
+
##% The derived key commitment value MUST be set or returned from the encryption process such that it can be included in the content metadata.
|
|
132
|
+
commitment_key
|
|
133
|
+
]
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def derive_alg_aes_256_gcm_hkdf_sha512_commit_key_cipher(data_key, message_id, stored_commitment_key)
|
|
137
|
+
raise Errors::DecryptionError, 'Data key length does not match algorithm suite' unless data_key.length == 32
|
|
138
|
+
|
|
139
|
+
raise Errors::DecryptionError, 'Message id length does not match algorithm suite' unless message_id.length == 28
|
|
140
|
+
|
|
141
|
+
unless stored_commitment_key.length == 28
|
|
142
|
+
raise Errors::DecryptionError, 'Commitment key length does not match algorithm suite'
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
##= ../specification/s3-encryption/decryption.md#decrypting-with-commitment
|
|
146
|
+
##= type=implication
|
|
147
|
+
##% When using an algorithm suite which supports key commitment,
|
|
148
|
+
##% the verification of the derived key commitment value MUST be done in constant time.
|
|
149
|
+
unless timing_safe_equal?(
|
|
150
|
+
##= ../specification/s3-encryption/decryption.md#decrypting-with-commitment
|
|
151
|
+
##% When using an algorithm suite which supports key commitment,
|
|
152
|
+
##% the client MUST verify that the [derived key commitment](./key-derivation.md#hkdf-operation) contains the same bytes
|
|
153
|
+
##% as the stored key commitment retrieved from the stored object's metadata.
|
|
154
|
+
Utils.derive_commitment_key(data_key, message_id),
|
|
155
|
+
stored_commitment_key
|
|
156
|
+
)
|
|
157
|
+
##= ../specification/s3-encryption/decryption.md#decrypting-with-commitment
|
|
158
|
+
##% When using an algorithm suite which supports key commitment,
|
|
159
|
+
##% the client MUST throw an exception when the derived key commitment value and stored key commitment value do not match.
|
|
160
|
+
raise Errors::DecryptionError, 'Commitment key verification failed'
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
##= ../specification/s3-encryption/decryption.md#decrypting-with-commitment
|
|
164
|
+
##% When using an algorithm suite which supports key commitment,
|
|
165
|
+
##% the client MUST verify the key commitment values match before deriving the [derived encryption key](./key-derivation.md#hkdf-operation).
|
|
166
|
+
|
|
167
|
+
alg_aes_256_gcm_hkdf_sha512_commit_key_cipher(:decrypt, data_key, message_id)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def alg_aes_256_gcm_hkdf_sha512_commit_key_cipher(mode, data_key, message_id)
|
|
171
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
172
|
+
##% The client MUST initialize the cipher, or call an AES-GCM encryption API, with the derived encryption key, an IV containing only bytes with the value 0x01,
|
|
173
|
+
##% and the tag length defined in the Algorithm Suite when encrypting or decrypting with ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY.
|
|
174
|
+
cipher = Utils.aes_cipher(
|
|
175
|
+
mode,
|
|
176
|
+
:GCM,
|
|
177
|
+
##= ../specification/s3-encryption/encryption.md#alg-aes-256-gcm-hkdf-sha512-commit-key
|
|
178
|
+
##% The client MUST use HKDF to derive the key commitment value and the derived encrypting key as described in [Key Derivation](key-derivation.md).
|
|
179
|
+
Utils.derive_encryption_key(data_key, message_id),
|
|
180
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
181
|
+
##% When encrypting or decrypting with ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY,
|
|
182
|
+
##% the IV used in the AES-GCM content encryption/decryption MUST consist entirely of bytes with the value 0x01.
|
|
183
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
184
|
+
##% The IV's total length MUST match the IV length defined by the algorithm suite.
|
|
185
|
+
V3_IV_BYTES
|
|
186
|
+
) #OpenSSL::Cipher.new("aes-256-gcm")
|
|
187
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
188
|
+
##% The client MUST set the AAD to the Algorithm Suite ID represented as bytes.
|
|
189
|
+
cipher.auth_data = ALGO_ID # auth_data must be set after key and iv
|
|
190
|
+
cipher
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def generate_data_key
|
|
194
|
+
OpenSSL::Random.random_bytes(32)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def generate_message_id
|
|
198
|
+
##= ../specification/s3-encryption/encryption.md#cipher-initialization
|
|
199
|
+
##= type=exception
|
|
200
|
+
##= reason=This would be a new runtime error that happens randomly.
|
|
201
|
+
##% The client SHOULD validate that the generated IV or Message ID is not zeros.
|
|
202
|
+
|
|
203
|
+
##= ../specification/s3-encryption/encryption.md#content-encryption
|
|
204
|
+
##% The client MUST generate an IV or Message ID using the length of the IV or Message ID defined in the algorithm suite.
|
|
205
|
+
OpenSSL::Random.random_bytes(28)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def derive_encryption_key(data_key, message_id)
|
|
209
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
210
|
+
##% - The DEK input pseudorandom key MUST be the output from the extract step.
|
|
211
|
+
hkdf(
|
|
212
|
+
data_key,
|
|
213
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
214
|
+
##% - The salt MUST be the Message ID with the length defined in the algorithm suite.
|
|
215
|
+
message_id,
|
|
216
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
217
|
+
##% - The input info MUST be a concatenation of the algorithm suite ID as bytes followed by the string DERIVEKEY as UTF8 encoded bytes.
|
|
218
|
+
ENCRYPTION_KEY_INFO,
|
|
219
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
220
|
+
##% - The length of the output keying material MUST equal the encryption key length specified by the algorithm suite encryption settings.
|
|
221
|
+
32
|
|
222
|
+
)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def derive_commitment_key(data_key, message_id)
|
|
226
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
227
|
+
##% - The CK input pseudorandom key MUST be the output from the extract step.
|
|
228
|
+
hkdf(
|
|
229
|
+
data_key,
|
|
230
|
+
message_id,
|
|
231
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
232
|
+
##% - The input info MUST be a concatenation of the algorithm suite ID as bytes followed by the string COMMITKEY as UTF8 encoded bytes.
|
|
233
|
+
COMMITMENT_KEY_INFO,
|
|
234
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
235
|
+
##% - The length of the output keying material MUST equal the commit key length specified by the supported algorithm suites.
|
|
236
|
+
28
|
|
237
|
+
)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
ONE_BYTE = [1].pack('C').freeze
|
|
241
|
+
# assert: the following function is equivalent to `OpenSSL::KDF.hkdf` for all desired_length <= 64
|
|
242
|
+
# see spec: 'produces identical output to native hkdf for random inputs (property-based test)'
|
|
243
|
+
def hkdf_fallback(input_key_material, salt, info, desired_length)
|
|
244
|
+
# Extract from RFC 5869
|
|
245
|
+
# PRK = HMAC-Hash(salt, IKM)
|
|
246
|
+
prk = OpenSSL::HMAC.digest(SHA512_DIGEST, salt, input_key_material)
|
|
247
|
+
|
|
248
|
+
# Expand from RFC 5869
|
|
249
|
+
# N = ceil(L/HashLen)
|
|
250
|
+
# T = T(1) | T(2) | T(3) | ... | T(N)
|
|
251
|
+
# OKM = first L octets of T
|
|
252
|
+
#
|
|
253
|
+
# where:
|
|
254
|
+
# T(0) = empty string (zero length)
|
|
255
|
+
# T(1) = HMAC-Hash(PRK, T(0) | info | 0x01)
|
|
256
|
+
# T(2) = HMAC-Hash(PRK, T(1) | info | 0x02)
|
|
257
|
+
# T(3) = HMAC-Hash(PRK, T(2) | info | 0x03)
|
|
258
|
+
#
|
|
259
|
+
# L == desired_length
|
|
260
|
+
# HashLen == 64 (because SHA512_DIGEST is fixed)
|
|
261
|
+
# N = ceil(desired_length/64)
|
|
262
|
+
# The only supported suites have desired_length less than 64
|
|
263
|
+
# This will result in a single iteration of the expand loop.
|
|
264
|
+
# This check verifies that it is safe to do not do a loop
|
|
265
|
+
raise Errors::DecryptionError, "Unsupported length: #{desired_length}" if desired_length > 64
|
|
266
|
+
|
|
267
|
+
# assert N == 1
|
|
268
|
+
#
|
|
269
|
+
# For a single iteration of the loop we then get:
|
|
270
|
+
# OKM = first L of T(0) | T(1)
|
|
271
|
+
# ==
|
|
272
|
+
# (T(0) + T(1))[0, desired_length]
|
|
273
|
+
# == {assert T(0) == ''}
|
|
274
|
+
# ('' + HMAC-Hash(PRK, '' + info + 0x01))[0, desired_length]
|
|
275
|
+
# == HMAC-Hash(PRK, info + 0x01)[0, desired_length]
|
|
276
|
+
# == {assert ONE_BYTE == 0x01}
|
|
277
|
+
# HMAC-Hash(PRK, info + ONE_BYTE)[0, desired_length]
|
|
278
|
+
# ==
|
|
279
|
+
OpenSSL::HMAC.digest(SHA512_DIGEST, prk, info + ONE_BYTE)[0, desired_length]
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
if defined?(OpenSSL::KDF) && OpenSSL::KDF.respond_to?(:hkdf)
|
|
283
|
+
def hkdf(input_key_material, salt, info, desired_length)
|
|
284
|
+
OpenSSL::KDF.hkdf(
|
|
285
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
286
|
+
##% - The input keying material MUST be the plaintext data key (PDK) generated by the key provider.
|
|
287
|
+
input_key_material,
|
|
288
|
+
salt: salt,
|
|
289
|
+
info: info,
|
|
290
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
291
|
+
##% - The length of the input keying material MUST equal the key derivation input length specified by the algorithm suite commit key derivation setting.
|
|
292
|
+
length: desired_length,
|
|
293
|
+
##= ../specification/s3-encryption/key-derivation.md#hkdf-operation
|
|
294
|
+
##% - The hash function MUST be specified by the algorithm suite commitment settings.
|
|
295
|
+
hash: SHA512_DIGEST
|
|
296
|
+
)
|
|
297
|
+
end
|
|
298
|
+
else
|
|
299
|
+
# This is done so that we can test hkdf_fallback when we have `OpenSSL::KDF.hkdf`
|
|
300
|
+
alias hkdf hkdf_fallback
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
if defined?(OpenSSL) && OpenSSL.respond_to?(:secure_compare)
|
|
304
|
+
def timing_safe_equal?(a, b)
|
|
305
|
+
OpenSSL.secure_compare(a, b)
|
|
306
|
+
end
|
|
307
|
+
else
|
|
308
|
+
def timing_safe_equal?(a, b)
|
|
309
|
+
return false unless a.bytesize == b.bytesize
|
|
310
|
+
|
|
311
|
+
l = a.unpack('C*')
|
|
312
|
+
r = 0
|
|
313
|
+
b.each_byte { |byte| r |= byte ^ l.shift }
|
|
314
|
+
r.zero?
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'aws-sdk-s3/encryptionV3/client'
|
|
2
|
+
require 'aws-sdk-s3/encryptionV3/decryption'
|
|
3
|
+
require 'aws-sdk-s3/encryptionV3/decrypt_handler'
|
|
4
|
+
require 'aws-sdk-s3/encryptionV3/default_cipher_provider'
|
|
5
|
+
require 'aws-sdk-s3/encryptionV3/encrypt_handler'
|
|
6
|
+
require 'aws-sdk-s3/encryptionV3/errors'
|
|
7
|
+
require 'aws-sdk-s3/encryptionV3/io_encrypter'
|
|
8
|
+
require 'aws-sdk-s3/encryptionV3/io_decrypter'
|
|
9
|
+
require 'aws-sdk-s3/encryptionV3/io_auth_decrypter'
|
|
10
|
+
require 'aws-sdk-s3/encryptionV3/key_provider'
|
|
11
|
+
require 'aws-sdk-s3/encryptionV3/kms_cipher_provider'
|
|
12
|
+
require 'aws-sdk-s3/encryptionV3/materials'
|
|
13
|
+
require 'aws-sdk-s3/encryptionV3/utils'
|
|
14
|
+
require 'aws-sdk-s3/encryptionV3/default_key_provider'
|
|
15
|
+
|
|
16
|
+
module Aws
|
|
17
|
+
module S3
|
|
18
|
+
module EncryptionV3
|
|
19
|
+
AES_GCM_TAG_LEN_BYTES = 16
|
|
20
|
+
EC_USER_AGENT = 'S3CryptoV3'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
data/lib/aws-sdk-s3/endpoints.rb
CHANGED
|
@@ -337,6 +337,17 @@ module Aws::S3
|
|
|
337
337
|
end
|
|
338
338
|
end
|
|
339
339
|
|
|
340
|
+
class GetBucketAbac
|
|
341
|
+
def self.build(context)
|
|
342
|
+
Aws::S3::EndpointParameters.create(
|
|
343
|
+
context.config,
|
|
344
|
+
bucket: context.params[:bucket],
|
|
345
|
+
use_dual_stack: context[:use_dualstack_endpoint],
|
|
346
|
+
accelerate: context[:use_accelerate_endpoint],
|
|
347
|
+
)
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
340
351
|
class GetBucketAccelerateConfiguration
|
|
341
352
|
def self.build(context)
|
|
342
353
|
Aws::S3::EndpointParameters.create(
|
|
@@ -878,6 +889,17 @@ module Aws::S3
|
|
|
878
889
|
end
|
|
879
890
|
end
|
|
880
891
|
|
|
892
|
+
class PutBucketAbac
|
|
893
|
+
def self.build(context)
|
|
894
|
+
Aws::S3::EndpointParameters.create(
|
|
895
|
+
context.config,
|
|
896
|
+
bucket: context.params[:bucket],
|
|
897
|
+
use_dual_stack: context[:use_dualstack_endpoint],
|
|
898
|
+
accelerate: context[:use_accelerate_endpoint],
|
|
899
|
+
)
|
|
900
|
+
end
|
|
901
|
+
end
|
|
902
|
+
|
|
881
903
|
class PutBucketAccelerateConfiguration
|
|
882
904
|
def self.build(context)
|
|
883
905
|
Aws::S3::EndpointParameters.create(
|
|
@@ -1348,6 +1370,8 @@ module Aws::S3
|
|
|
1348
1370
|
DeleteObjects.build(context)
|
|
1349
1371
|
when :delete_public_access_block
|
|
1350
1372
|
DeletePublicAccessBlock.build(context)
|
|
1373
|
+
when :get_bucket_abac
|
|
1374
|
+
GetBucketAbac.build(context)
|
|
1351
1375
|
when :get_bucket_accelerate_configuration
|
|
1352
1376
|
GetBucketAccelerateConfiguration.build(context)
|
|
1353
1377
|
when :get_bucket_acl
|
|
@@ -1440,6 +1464,8 @@ module Aws::S3
|
|
|
1440
1464
|
ListObjectsV2.build(context)
|
|
1441
1465
|
when :list_parts
|
|
1442
1466
|
ListParts.build(context)
|
|
1467
|
+
when :put_bucket_abac
|
|
1468
|
+
PutBucketAbac.build(context)
|
|
1443
1469
|
when :put_bucket_accelerate_configuration
|
|
1444
1470
|
PutBucketAccelerateConfiguration.build(context)
|
|
1445
1471
|
when :put_bucket_acl
|
|
@@ -90,12 +90,29 @@ module Aws
|
|
|
90
90
|
raise error unless error.nil?
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
+
def handle_checksum_mode_option(option_key, opts)
|
|
94
|
+
return false unless option_key == :checksum_mode && opts[:checksum_mode] == 'DISABLED'
|
|
95
|
+
|
|
96
|
+
msg = ':checksum_mode option is deprecated. Checksums will be validated by default. ' \
|
|
97
|
+
'To disable checksum validation, set :response_checksum_validation to "when_required" on your S3 client.'
|
|
98
|
+
warn(msg)
|
|
99
|
+
true
|
|
100
|
+
end
|
|
101
|
+
|
|
93
102
|
def get_opts(opts)
|
|
94
|
-
GET_OPTIONS.each_with_object({})
|
|
103
|
+
GET_OPTIONS.each_with_object({}) do |k, h|
|
|
104
|
+
next if k == :checksum_mode
|
|
105
|
+
|
|
106
|
+
h[k] = opts[k] if opts.key?(k)
|
|
107
|
+
end
|
|
95
108
|
end
|
|
96
109
|
|
|
97
110
|
def head_opts(opts)
|
|
98
|
-
HEAD_OPTIONS.each_with_object({})
|
|
111
|
+
HEAD_OPTIONS.each_with_object({}) do |k, h|
|
|
112
|
+
next if handle_checksum_mode_option(k, opts)
|
|
113
|
+
|
|
114
|
+
h[k] = opts[k] if opts.key?(k)
|
|
115
|
+
end
|
|
99
116
|
end
|
|
100
117
|
|
|
101
118
|
def compute_chunk(chunk_size, file_size)
|
data/lib/aws-sdk-s3/object.rb
CHANGED
|
@@ -765,7 +765,7 @@ module Aws::S3
|
|
|
765
765
|
# metadata_directive: "COPY", # accepts COPY, REPLACE
|
|
766
766
|
# tagging_directive: "COPY", # accepts COPY, REPLACE
|
|
767
767
|
# server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
|
|
768
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
|
|
768
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
|
|
769
769
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
770
770
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
771
771
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -1889,7 +1889,7 @@ module Aws::S3
|
|
|
1889
1889
|
# "MetadataKey" => "MetadataValue",
|
|
1890
1890
|
# },
|
|
1891
1891
|
# server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
|
|
1892
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
|
|
1892
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
|
|
1893
1893
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
1894
1894
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
1895
1895
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -2490,7 +2490,7 @@ module Aws::S3
|
|
|
2490
2490
|
# "MetadataKey" => "MetadataValue",
|
|
2491
2491
|
# },
|
|
2492
2492
|
# server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
|
|
2493
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
|
|
2493
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
|
|
2494
2494
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
2495
2495
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
2496
2496
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -3165,7 +3165,7 @@ module Aws::S3
|
|
|
3165
3165
|
# value: "MetadataValue",
|
|
3166
3166
|
# },
|
|
3167
3167
|
# ],
|
|
3168
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
|
|
3168
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
|
|
3169
3169
|
# },
|
|
3170
3170
|
# },
|
|
3171
3171
|
# },
|
|
@@ -362,7 +362,7 @@ module Aws::S3
|
|
|
362
362
|
# metadata_directive: "COPY", # accepts COPY, REPLACE
|
|
363
363
|
# tagging_directive: "COPY", # accepts COPY, REPLACE
|
|
364
364
|
# server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
|
|
365
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
|
|
365
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
|
|
366
366
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
367
367
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
368
368
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -1486,7 +1486,7 @@ module Aws::S3
|
|
|
1486
1486
|
# "MetadataKey" => "MetadataValue",
|
|
1487
1487
|
# },
|
|
1488
1488
|
# server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
|
|
1489
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
|
|
1489
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
|
|
1490
1490
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
1491
1491
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
1492
1492
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -2087,7 +2087,7 @@ module Aws::S3
|
|
|
2087
2087
|
# "MetadataKey" => "MetadataValue",
|
|
2088
2088
|
# },
|
|
2089
2089
|
# server_side_encryption: "AES256", # accepts AES256, aws:fsx, aws:kms, aws:kms:dsse
|
|
2090
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
|
|
2090
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
|
|
2091
2091
|
# website_redirect_location: "WebsiteRedirectLocation",
|
|
2092
2092
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
2093
2093
|
# sse_customer_key: "SSECustomerKey",
|
|
@@ -2762,7 +2762,7 @@ module Aws::S3
|
|
|
2762
2762
|
# value: "MetadataValue",
|
|
2763
2763
|
# },
|
|
2764
2764
|
# ],
|
|
2765
|
-
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS
|
|
2765
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE, FSX_OPENZFS, FSX_ONTAP
|
|
2766
2766
|
# },
|
|
2767
2767
|
# },
|
|
2768
2768
|
# },
|
|
@@ -124,10 +124,9 @@ module Aws
|
|
|
124
124
|
# Only used when no custom executor is provided (creates {DefaultExecutor} with given thread count).
|
|
125
125
|
#
|
|
126
126
|
# @option options [String] :checksum_mode ("ENABLED")
|
|
127
|
-
#
|
|
128
|
-
#
|
|
129
|
-
#
|
|
130
|
-
# To disable checksum validation, set `checksum_mode` to `"DISABLED"`.
|
|
127
|
+
# This option is deprecated. Use `:response_checksum_validation` on your S3 client instead.
|
|
128
|
+
# To disable checksum validation, set `response_checksum_validation: 'when_required'`
|
|
129
|
+
# when creating your S3 client.
|
|
131
130
|
#
|
|
132
131
|
# @option options [Callable] :on_checksum_validated
|
|
133
132
|
# Called each time a request's checksum is validated with the checksum algorithm and the
|