module PuTTY::Key::OpenSSL::EC
The {EC} module is included into OpenSSL::PKey::EC
when using the PuTTY::Key
refinement or calling {PuTTY::Key.global_install}. This adds a to_ppk
instance method to OpenSSL::PKey::EC
.
Public Instance Methods
to_ppk()
click to toggle source
Returns a new {PPK} instance that is equivalent to this key.
to_ppk
can be called on instances of OpenSSL::PKey::EC
.
@return [PPK] A new instance of {PPK} that is equivalent to this key.
@raise [InvalidStateError] If the key has not been initialized. @raise [UnsupportedCurveError] If the key uses a curve that is not supported by PuTTY
.
# File lib/putty/key/openssl.rb, line 143 def to_ppk curve = group && group.curve_name raise InvalidStateError, 'The key has not been fully initialized (a curve name must be assigned)' unless curve ssh_curve = SSH_CURVES[curve] raise UnsupportedCurveError, "The curve '#{curve}' is not supported" unless ssh_curve PPK.new.tap do |ppk| ppk.algorithm = "ecdsa-sha2-#{ssh_curve}" begin ppk.public_blob = Util.ssh_pack(ppk.algorithm, ssh_curve, public_key && public_key.to_bn) ppk.private_blob = Util.ssh_pack(private_key) rescue NilValueError raise InvalidStateError, 'The key has not been fully initialized (public_key and private_key must both be assigned)' end end end