Module: CcipherFactory::AsymKeyCipher::ECCAttEncrypt

Includes:
Common, Compression::CompressionHelper, TR::CondUtils
Defined in:
lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Compression::CompressionHelper

#compress_data_if_active, #compression_off, #compression_on, #compressor, #decompress_data_if_active, #decompressor, #decompressor_from_encoded, #encode_null_compressor, #is_compression_on?

Methods included from Common

#attach_mode, #cleanup_intOutputBuf, #cleanup_intOutputFile, #detach_mode, #disposeOutput, #intOutputBuf, #intOutputFile, #is_attach_mode?, #is_output_given?, #output, #output_obj, #sanitize_symbol, #write_to_output

Instance Attribute Details

#recipient_keyObject

Returns the value of attribute recipient_key.



10
11
12
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb', line 10

def recipient_key
  @recipient_key
end

#sender_keypairObject

Returns the value of attribute sender_keypair.



10
11
12
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb', line 10

def sender_keypair
  @sender_keypair
end

Instance Method Details

#att_encrypt_finalObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb', line 44

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

#att_encrypt_init(opts = { }, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb', line 12

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

#att_encrypt_update(val) ⇒ Object

Raises:

  • (ECCCipherError)


39
40
41
42
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb', line 39

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

#loggerObject



61
62
63
64
65
66
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_att_encrypt.rb', line 61

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