From 246058ffbb8f1c2ba09e6da96fe400915cb9a916 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 12 Apr 2021 17:28:52 -0700 Subject: [PATCH] Add `#signature_algorithm` and update `#ssh_do_sign` and `#to_blob` Modifies `OpenSSL::PKey::RSA` to provide a `#signature_algorithm` method which provides the signature algorithm value expected by OpenSSH. The `#ssh_do_sign` method is updated to use the set algorithm (SHA256) and `#to_blob` is updated to include the signature algorithm instead of the key type. --- lib/vagrant/patches/net-ssh.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/vagrant/patches/net-ssh.rb b/lib/vagrant/patches/net-ssh.rb index 35b0292a0..bdd717048 100644 --- a/lib/vagrant/patches/net-ssh.rb +++ b/lib/vagrant/patches/net-ssh.rb @@ -99,6 +99,18 @@ if Net::SSH::Version::STRING == "6.1.0" verify(digester, sig, data) end + + def signature_algorithm + "rsa-sha2-256" + end + + def ssh_do_sign(data) + sign(OpenSSL::Digest::SHA256.new, data) + end + + def to_blob + @blob ||= Net::SSH::Buffer.from(:string, signature_algorithm, :bignum, e, :bignum, n).to_s + end end OpenSSL::PKey::DSA.class_eval do