Class: Net::SSH::Authentication::ED25519::PrivKey
- Inherits:
-
Object
- Object
- Net::SSH::Authentication::ED25519::PrivKey
- Defined in:
- lib/net/ssh/authentication/ed25519.rb
Constant Summary collapse
- CipherFactory =
Net::SSH::Transport::CipherFactory
Instance Attribute Summary collapse
-
#sign_key ⇒ Object
readonly
Returns the value of attribute sign_key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(buffer) ⇒ PrivKey
constructor
A new instance of PrivKey.
- #private_key_bytes ⇒ Object
- #private_key_bytes_for_agent ⇒ Object
- #public_key ⇒ Object
- #public_key_bytes ⇒ Object
- #ssh_do_sign(data, sig_alg = nil) ⇒ Object
- #ssh_signature_type ⇒ Object
- #ssh_type ⇒ Object
- #to_blob ⇒ Object
Constructor Details
#initialize(buffer) ⇒ PrivKey
Returns a new instance of PrivKey.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 225 def initialize(buffer) pk = buffer.read_string sk = buffer.read_string _comment = buffer.read_string ED25519.validate_key_bytes!(pk, "public key", KEY_BYTES) ED25519.validate_key_bytes!(sk, "private key field", PRIVATE_KEY_BYTES) private_key_bytes = sk[0, KEY_BYTES] raise ArgumentError, "Ed25519 private key does not include matching public key" unless sk[KEY_BYTES, KEY_BYTES] == pk @sign_key = ED25519.new_private_key(private_key_bytes) raise ArgumentError, "Ed25519 public key does not match private key" unless @sign_key.raw_public_key == pk @public_key_bytes = pk.dup.force_encoding('BINARY') @private_key_bytes = private_key_bytes.dup.force_encoding('BINARY') end |
Instance Attribute Details
#sign_key ⇒ Object (readonly)
Returns the value of attribute sign_key.
223 224 225 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 223 def sign_key @sign_key end |
Class Method Details
.read(data, password) ⇒ Object
275 276 277 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 275 def self.read(data, password) OpenSSHPrivateKeyLoader.read(data, password) end |
Instance Method Details
#private_key_bytes ⇒ Object
267 268 269 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 267 def private_key_bytes @private_key_bytes.dup end |
#private_key_bytes_for_agent ⇒ Object
271 272 273 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 271 def private_key_bytes_for_agent private_key_bytes + public_key_bytes end |
#public_key ⇒ Object
255 256 257 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 255 def public_key PubKey.new(public_key_bytes) end |
#public_key_bytes ⇒ Object
263 264 265 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 263 def public_key_bytes @public_key_bytes.dup end |
#ssh_do_sign(data, sig_alg = nil) ⇒ Object
259 260 261 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 259 def ssh_do_sign(data, sig_alg = nil) ED25519.sign(@sign_key, data) end |
#ssh_signature_type ⇒ Object
251 252 253 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 251 def ssh_signature_type ssh_type end |
#ssh_type ⇒ Object
247 248 249 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 247 def ssh_type "ssh-ed25519" end |
#to_blob ⇒ Object
243 244 245 |
# File 'lib/net/ssh/authentication/ed25519.rb', line 243 def to_blob public_key.to_blob end |