class Aws::S3::Encryption::IODecrypter

@api private

Attributes

io[R]

@return [#write]

Public Class Methods

new(cipher, io) click to toggle source

@param [OpenSSL::Cipher] cipher @param [IO#write] io An IO-like object that responds to `#write`.

# File lib/aws-sdk-s3/encryption/io_decrypter.rb, line 11
def initialize(cipher, io)
  @cipher = cipher
  # Ensure that IO is reset between retries
  @io = io.tap { |io| io.truncate(0) if io.respond_to?(:truncate) }
  @cipher_buffer = String.new
end

Public Instance Methods

finalize() click to toggle source
# File lib/aws-sdk-s3/encryption/io_decrypter.rb, line 30
def finalize
  @io.write(@cipher.final)
end
write(chunk) click to toggle source
# File lib/aws-sdk-s3/encryption/io_decrypter.rb, line 21
def write(chunk)
  # decrypt and write
  if @cipher.method(:update).arity == 1
    @io.write(@cipher.update(chunk))
  else
    @io.write(@cipher.update(chunk, @cipher_buffer))
  end
end