Method: OpenSSL::PKey::EC#identifier

Defined in:
lib/sshkey.rb

#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