Sha256: 5bed1f5018cfeabc73f22a97a39ebb8de6de2bc0e6852f680186bd18f1984d6f

Contents?: true

Size: 881 Bytes

Versions: 210

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true

module Aws
  module S3
    module Encryption
      # @api private
      class IODecrypter

        # @param [OpenSSL::Cipher] cipher
        # @param [IO#write] io An IO-like object that responds to `#write`.
        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

        # @return [#write]
        attr_reader :io

        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

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

      end
    end
  end
end

Version data entries

210 entries across 210 versions & 2 rubygems

Version Path
aws-sdk-s3-1.182.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.181.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.180.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.179.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.178.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.177.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.176.1 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.176.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.175.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.174.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.173.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.172.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.171.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.170.1 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.170.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.169.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.168.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.167.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.166.0 lib/aws-sdk-s3/encryption/io_decrypter.rb
aws-sdk-s3-1.165.0 lib/aws-sdk-s3/encryption/io_decrypter.rb