Class: EC::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/elliptic.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r, s) ⇒ Signature

Returns a new instance of Signature.



25
26
27
# File 'lib/elliptic.rb', line 25

def initialize(r, s)
  @r, @s = r, s
end

Instance Attribute Details

#rObject (readonly)

Returns the value of attribute r.



24
25
26
# File 'lib/elliptic.rb', line 24

def r
  @r
end

#sObject (readonly)

Returns the value of attribute s.



24
25
26
# File 'lib/elliptic.rb', line 24

def s
  @s
end

Class Method Details

.decode_der(der) ⇒ Object



17
18
19
20
21
22
# File 'lib/elliptic.rb', line 17

def self.decode_der( der )
  asn1 = OpenSSL::ASN1.decode(der )
  r = asn1.value[0].value.to_i
  s = asn1.value[1].value.to_i
  new(r, s)
end

Instance Method Details

#to_derObject



29
30
31
32
33
34
35
# File 'lib/elliptic.rb', line 29

def to_der
  asn1 = OpenSSL::ASN1::Sequence.new [
      OpenSSL::ASN1::Integer.new( @r ),
      OpenSSL::ASN1::Integer.new( @s ),
    ]
  asn1.to_der
end