Class: Aws::S3::Encryption::IODecrypter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-s3/encryption/io_decrypter.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cipher, io) ⇒ IODecrypter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of IODecrypter.

Parameters:

  • cipher (OpenSSL::Cipher)
  • io (IO#write)

    An IO-like object that responds to `#write`.


11
12
13
14
15
16
# 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

Instance Attribute Details

#io#write (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:


19
20
21
# File 'lib/aws-sdk-s3/encryption/io_decrypter.rb', line 19

def io
  @io
end

Instance Method Details

#finalizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


30
31
32
# File 'lib/aws-sdk-s3/encryption/io_decrypter.rb', line 30

def finalize
  @io.write(@cipher.final)
end

#write(chunk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


21
22
23
24
25
26
27
28
# 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