Module: CcipherFactory::AsymKeySigner::ECCSigner

Includes:
Common, TR::CondUtils
Defined in:
lib/ccipher_factory/asymkey_cipher/ecc/ecc_signer.rb

Defined Under Namespace

Classes: ECCSignerError

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#signing_keyObject

Returns the value of attribute signing_key.



13
14
15
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_signer.rb', line 13

def signing_key
  @signing_key
end

Instance Method Details

#compression_offObject



19
20
21
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_signer.rb', line 19

def compression_off
  @compress = false
end

#compression_onObject



15
16
17
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_signer.rb', line 15

def compression_on
  @compress = true
end

#loggerObject



70
71
72
73
74
75
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_signer.rb', line 70

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

#sign_finalObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_signer.rb', line 54

def sign_final
  dig = @digest.digest_final

  eccConf = Ccrypto::ECCConfig.new
  eccConf.keypair = @signing_key.keypair
  eccEng = Ccrypto::AlgoFactory.engine(eccConf)
  sign = eccEng.sign(intOutputBuf.bytes)

  ts = BinStruct.instance.struct(:ecc_signature)
  ts.digest_info = dig
  ts.signer_info = @signing_key.to_signer_info
  ts.signature = sign
  ts.encoded

end

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

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_signer.rb', line 23

def sign_init(opts = {  }, &block)

  raise ECCSignerError, "Signer must be given" if is_empty?(@signing_key)

  @digest = Digest.instance
  @digest.output(intOutputBuf)
  @digest.digest_init

  if @compress
    logger.tdebug :asymkey_enc, "Compression on"
    @compressor = CcipherFactory::Compression::Compressor.new 
    @compressor.compress
    @compressor.compress_init
  else
    logger.tdebug :asymkey_enc, "Compression off"
  end


  if block
    instance_eval(&block)
    sign_final
  else
    self
  end

end

#sign_update(val) ⇒ Object



50
51
52
# File 'lib/ccipher_factory/asymkey_cipher/ecc/ecc_signer.rb', line 50

def sign_update(val)
  @digest.digest_update(val)
end