Class: OpenSSL::PKey::EC

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

Overview

Monkey patch OpenSSL::PKey::EC to provide convenience methods usable in this gem

Instance Method Summary collapse

Instance Method Details

#identifierObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sshkey.rb', line 13

def identifier
  # NOTE: Unable to find these constants within OpenSSL, so hardcode them here.
  # Analogous to net-ssh OpenSSL::PKey::EC::CurveNameAliasInv
  # https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/transport/openssl.rb#L147-L151
  case group.curve_name
  when "prime256v1" then "nistp256"  # https://stackoverflow.com/a/41953717
  when "secp256r1"  then "nistp256"  # JRuby
  when "secp384r1"  then "nistp384"
  when "secp521r1"  then "nistp521"
  else
    raise "Unknown curve name: #{public_key.group.curve_name}"
  end
end

#qObject



27
28
29
30
31
32
33
# File 'lib/sshkey.rb', line 27

def q
  # jruby-openssl does not currently support to_octet_string
  # https://github.com/jruby/jruby-openssl/issues/226
  jruby_not_implemented("to_octet_string is not implemented")

  public_key.to_octet_string(group.point_conversion_form)
end