class Aws::S3::EncryptionV2::IOAuthDecrypter
@api private
def finalize
def finalize @decrypter.finalize end
def initialize(options = {})
(**options)
-
:cipher
(required, OpenSSL::Cipher
) -- An initialized -
:encrypted_content_length
(required, Integer
) -- -
:io
(required, IO#write
) --
def initialize(options = {}) @decrypter = IODecrypter.new(options[:cipher], options[:io]) @max_bytes = options[:encrypted_content_length] @bytes_written = 0 end
def io
def io @decrypter.io end
def truncate_chunk(chunk)
def truncate_chunk(chunk) if chunk.bytesize + @bytes_written <= @max_bytes chunk elsif @bytes_written < @max_bytes chunk[0..(@max_bytes - @bytes_written - 1)] else # If the tag was sent over after the full body has been read, # we don't want to accidentally append it. "" end end
def write(chunk)
def write(chunk) chunk = truncate_chunk(chunk) if chunk.bytesize > 0 @bytes_written += chunk.bytesize @decrypter.write(chunk) end end