Class: CcipherFactory::KeyPair::ECCKeyPair

Inherits:
Object
  • Object
show all
Includes:
AsymKey, TR::CondUtils
Defined in:
lib/ccipher_factory/asymkey/ecc_keypair.rb

Instance Attribute Summary collapse

Attributes included from AsymKey

#keypair

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AsymKey

#initialize

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mtd, *args, &block) ⇒ Object



41
42
43
44
# File 'lib/ccipher_factory/asymkey/ecc_keypair.rb', line 41

def method_missing(mtd, *args, &block)
  logger.debug "sending method #{mtd} to #{@keypair}"
  @keypair.send(mtd, *args, &block)
end

Instance Attribute Details

#curveObject



13
14
15
16
17
18
# File 'lib/ccipher_factory/asymkey/ecc_keypair.rb', line 13

def curve
  if is_empty?(@curve) and not_empty?(@key)
    @curve = @key.group.curve_name
  end
  @curve
end

Class Method Details

.from_signer_info(bin) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ccipher_factory/asymkey/ecc_keypair.rb', line 26

def self.from_signer_info(bin)

  bs = BinStruct.instance.struct(:ecc_signer_info)
  ts = bs.from_bin(bin)
  siType = ts.signer_info_type
  val = ts.signer_info_value
  case BTag.value_constant(siType)
  when :public_key
    Ccrypto::AlgoFactory.engine(Ccrypto::ECCPublicKey).to_key(val)
  else
    raise AsymKeyError, "Unknown signer info type #{BTag.value_constant(siType)}"
  end

end

Instance Method Details

#loggerObject



46
47
48
49
50
51
52
# File 'lib/ccipher_factory/asymkey/ecc_keypair.rb', line 46

def logger
  if @logger.nil?
    @logger = Tlogger.new
    @logger.tag = :cf_ecc_keypair
  end
  @logger
end

#to_signer_infoObject



20
21
22
23
24
# File 'lib/ccipher_factory/asymkey/ecc_keypair.rb', line 20

def to_signer_info
  bs = BinStruct.instance.struct(:ecc_signer_info)
  bs.signer_info_value = @keypair.public_key.to_bin
  bs.encoded
end