summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMiklos Fazekas <mfazekas@szemafor.com>2019-02-10 16:02:38 +0100
committerMiklos Fazekas <mfazekas@szemafor.com>2019-02-10 16:56:28 +0100
commit73fa93c02beac58de2bd1b4371cb8cfd992b36b9 (patch)
treeb85d9e4288238da91496b9d9ad7d7a737324dd34 /test
parent95ec1341fa201fd8756cb8fe2d04b55e00213221 (diff)
downloadnet-ssh-73fa93c02beac58de2bd1b4371cb8cfd992b36b9.tar.gz
Encrypted openssh keys were not asked for passphrase
Diffstat (limited to 'test')
-rw-r--r--test/authentication/test_ed25519.rb29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/authentication/test_ed25519.rb b/test/authentication/test_ed25519.rb
index 10d3133..e8ccddc 100644
--- a/test/authentication/test_ed25519.rb
+++ b/test/authentication/test_ed25519.rb
@@ -1,7 +1,8 @@
unless ENV['NET_SSH_NO_ED25519']
- require 'common'
+ require_relative '../common'
require 'net/ssh/authentication/ed25519_loader'
+ require 'net/ssh/key_factory'
require 'base64'
module Authentication
@@ -49,6 +50,32 @@ unless ENV['NET_SSH_NO_ED25519']
self.assert_equal(pub_key.fingerprint('sha256'), key_fingerprint_sha256_pwd)
end
+ def test_pwd_key_should_ask
+ pub = Net::SSH::Buffer.new(Base64.decode64(public_key_pwd.split(' ')[1]))
+ _type = pub.read_string
+ pub_data = pub.read_string
+ priv = private_key_pwd
+
+ prompt = OpenStruct.new
+ def prompt.start(opts)
+ prompter = OpenStruct.new
+ def prompter.ask(*opts)
+ return "pwd"
+ end
+ prompter
+ end
+
+ pub_key = Net::SSH::Authentication::ED25519::PubKey.new(pub_data)
+ priv_key = Net::SSH::KeyFactory.load_data_private_key(priv, nil, true, "", prompt)
+
+ shared_secret = "Hello"
+ signed = priv_key.ssh_do_sign(shared_secret)
+ self.assert_equal(true,pub_key.ssh_do_verify(signed,shared_secret))
+ self.assert_equal(priv_key.public_key.fingerprint, pub_key.fingerprint)
+ self.assert_equal(pub_key.fingerprint, key_fingerprint_md5_pwd)
+ self.assert_equal(pub_key.fingerprint('sha256'), key_fingerprint_sha256_pwd)
+ end
+
def private_key_pwd
@pwd_key = <<-EOF
-----BEGIN OPENSSH PRIVATE KEY-----