Class: OpenSSL::SignatureAlgorithm::ECDSA::VerifyKey

Inherits:
PKey::EC::Point
  • Object
show all
Defined in:
lib/openssl/signature_algorithm/ecdsa.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ VerifyKey

Returns a new instance of VerifyKey.



23
24
25
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 23

def initialize(*args)
  super(OpenSSL::PKey::EC::Point.new(*args))
end

Class Method Details

.deserialize(pem_string) ⇒ Object



27
28
29
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 27

def self.deserialize(pem_string)
  new(OpenSSL::PKey::EC.new(pem_string).public_key)
end

Instance Method Details

#ec_keyObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 35

def ec_key
  @ec_key ||=
    begin
      # RFC5480 SubjectPublicKeyInfo
      asn1 = OpenSSL::ASN1::Sequence(
        [
          OpenSSL::ASN1::Sequence(
            [
              OpenSSL::ASN1::ObjectId("id-ecPublicKey"),
              OpenSSL::ASN1::ObjectId(group.curve_name),
            ]
          ),
          OpenSSL::ASN1::BitString(to_octet_string(:uncompressed))
        ]
      )

      OpenSSL::PKey::EC.new(asn1.to_der)
    end
end

#serializeObject



31
32
33
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 31

def serialize
  ec_key.to_pem
end

#verify(*args) ⇒ Object



55
56
57
# File 'lib/openssl/signature_algorithm/ecdsa.rb', line 55

def verify(*args)
  ec_key.verify(*args)
end