Class: SSHData::PublicKey::SKECDSA

Inherits:
ECDSA
  • Object
show all
Defined in:
lib/ssh_data/public_key/skecdsa.rb

Constant Summary collapse

OPENSSL_CURVE_NAME_FOR_CURVE =
{
  NISTP256 => "prime256v1",
}

Constants inherited from ECDSA

ECDSA::CURVE_FOR_OPENSSL_CURVE_NAME, ECDSA::DIGEST_FOR_CURVE, ECDSA::NISTP256, ECDSA::NISTP384, ECDSA::NISTP521

Instance Attribute Summary collapse

Attributes inherited from ECDSA

#curve, #openssl, #public_key_bytes

Attributes inherited from Base

#algo

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ECDSA

#digest, openssl_signature, ssh_signature

Methods inherited from Base

#fingerprint, #openssh, #sign

Constructor Details

#initialize(algo:, curve:, public_key:, application:) ⇒ SKECDSA

Returns a new instance of SKECDSA.



20
21
22
23
# File 'lib/ssh_data/public_key/skecdsa.rb', line 20

def initialize(algo:, curve:, public_key:, application:)
  @application = application
  super(algo: algo, curve: curve, public_key: public_key)
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



4
5
6
# File 'lib/ssh_data/public_key/skecdsa.rb', line 4

def application
  @application
end

Class Method Details

.check_algorithm!(algo, curve) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/ssh_data/public_key/skecdsa.rb', line 10

def self.check_algorithm!(algo, curve)
  unless algo == ALGO_SKECDSA256
    raise DecodeError, "bad algorithm: #{algo.inspect}"
  end

  unless algo == "sk-ecdsa-sha2-#{curve}@openssh.com"
    raise DecodeError, "bad curve: #{curve.inspect}"
  end
end

Instance Method Details

#==(other) ⇒ Object



41
42
43
# File 'lib/ssh_data/public_key/skecdsa.rb', line 41

def ==(other)
  super && other.application == application
end

#rfc4253Object

RFC4253 binary encoding of the public key.

Returns a binary String.



28
29
30
31
32
33
34
35
# File 'lib/ssh_data/public_key/skecdsa.rb', line 28

def rfc4253
  Encoding.encode_fields(
    [:string, algo],
    [:string, curve],
    [:string, public_key_bytes],
    [:string, application],
  )
end

#verify(signed_data, signature) ⇒ Object

Raises:



37
38
39
# File 'lib/ssh_data/public_key/skecdsa.rb', line 37

def verify(signed_data, signature)
  raise UnsupportedError, "SK-ECDSA verification is not supported."
end