Sha256: 967769127c5172bb64b6e581cb05b6fc003b6b7e45d6cdfc38f2490fb16baca5

Contents?: true

Size: 883 Bytes

Versions: 202

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true

module Aws
  module S3
    module EncryptionV2
      # @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

202 entries across 202 versions & 2 rubygems

Version Path
aws-sdk-s3-1.121.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.120.1 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.120.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.119.2 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.119.1 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.119.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.118.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.117.2 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.117.1 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.117.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.116.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.115.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.114.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.113.2 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.113.1 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.113.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.112.0 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.111.3 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.111.2 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb
aws-sdk-s3-1.111.1 lib/aws-sdk-s3/encryptionV2/io_decrypter.rb