Sha256: 41cea081d6830d34dc5ffb6c957cc2590917a88d77b70f5178ebd406c12b061f

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents


module CcipherFactory
  module AsymKeyCipher
    module ECCAttEncrypt
      include Common
      include TR::CondUtils
      include Compression::CompressionHelper

      attr_accessor :recipient_key, :sender_keypair

      def att_encrypt_init(opts = { }, &block)

        @enc = AsymKeyCipher.encryptor(:ecc)
        @enc.output(intOutputFile)

        if is_compression_on?
          logger.tdebug :ecc_att_enc, "Compression on"
          @enc.compression_on
        else
          logger.tdebug :ecc_att_enc, "Compression off"
          @enc.compression_off
        end

        @enc.recipient_key = @recipient_key
        @enc.sender_keypair = @sender_keypair

        @enc.encrypt_init(opts)

        if block
          instance_eval(&block)
          att_encrypt_final
        else
          self
        end

      end

      def att_encrypt_update(val)
        raise ECCCipherError, "Output is required for encryption" if not is_output_given?
        @enc.encrypt_update(val) 
      end

      def att_encrypt_final

        ts = @enc.encrypt_final

        write_to_output(ts)

        intOutputFile.rewind
        while not intOutputFile.eof?
          write_to_output(intOutputFile.read)
        end

        intOutputFile.close!

        @output

      end

      def logger
        if @logger.nil?
          @logger = Tlogger.new
        end
        @logger
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ccipher_factory-0.1.2 lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb
ccipher_factory-0.1.1 lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb
ccipher_factory-0.1.0 lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb