Class: OpenSSL::PKey::EC

Inherits:
Object
  • Object
show all
Defined in:
lib/openssl/pkey/ec.rb

Overview

Additional helpers for ECDSA keys.

Instance Method Summary collapse

Instance Method Details

#to_spki(format = :uncompressed) ⇒ OpenSSL::X509::SPKI

Generate an OpenSSL::X509::SPKI structure for this public key.

Parameters:

  • format (Symbol) (defaults to: :uncompressed)

    whether to return the SPKI containing the compressed or uncompressed form of the curve point which represents the public key. Note that from a functional perspective, the two forms are identical, but they will produce completely different key and SPKI fingerprints, which may be important.

Returns:



18
19
20
21
22
23
24
# File 'lib/openssl/pkey/ec.rb', line 18

def to_spki(format = :uncompressed)
  unless self.public_key?
    raise OpenSSL::PKey::ECError,
          "Cannot convert non-public-key to SPKI"
  end
  OpenSSL::X509::SPKI.new("id-ecPublicKey", OpenSSL::ASN1::ObjectId.new(self.public_key.group.curve_name), self.public_key.to_octet_string(format))
end