Class: MooTool::Models::ECCPublicKey

Inherits:
Object
  • Object
show all
Includes:
Helpers::IMG4
Defined in:
lib/mootool/models/ecc_public_key.rb

Constant Summary

Constants included from Helpers::IMG4

Helpers::IMG4::DECODE_TAGS, Helpers::IMG4::FIRMWARE_TAGS, Helpers::IMG4::HASH_LENGTHS, Helpers::IMG4::KEY_INSTANCE_TAGS, Helpers::IMG4::KVP_TAGS, Helpers::IMG4::OCTET_TAGS, Helpers::IMG4::SEQUENCE_TAGS, Helpers::IMG4::SIGNATURE_TAGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::IMG4

#construct, #construct_object, #decode_construct, parse_4cc

Constructor Details

#initialize(key) ⇒ ECCPublicKey

Returns a new instance of ECCPublicKey.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mootool/models/ecc_public_key.rb', line 10

def initialize(key)
  if key.is_a?(OpenSSL::PKey::EC::Point)
    @value = key
    @curve = @value.group
    @point = @value
  else
    @value = OpenSSL::ASN1.decode(key)

    @curve = OpenSSL::PKey::EC::Group.new @value.value[0].value[1].value
    @point = OpenSSL::PKey::EC::Point.new @curve, @value.value[1].value
  end
end

Instance Attribute Details

#curveObject (readonly)

Returns the value of attribute curve.



8
9
10
# File 'lib/mootool/models/ecc_public_key.rb', line 8

def curve
  @curve
end

#pointObject (readonly)

Returns the value of attribute point.



8
9
10
# File 'lib/mootool/models/ecc_public_key.rb', line 8

def point
  @point
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/mootool/models/ecc_public_key.rb', line 8

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/mootool/models/ecc_public_key.rb', line 23

def ==(other)
  case other
  when MooTool::Models::ECCPublicKey
    @curve == other.curve && @point == other.point
  when OpenSSL::PKey::EC
    @curve == other.group && @point = other.public_key
  end
end