summaryrefslogtreecommitdiff
path: root/qa/qa/runtime/rsa_key.rb
blob: d456062bce76ca6ea595bbddb5349499be9824aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'net/ssh'
require 'forwardable'

module QA
  module Runtime
    class RSAKey
      extend Forwardable

      attr_reader :key
      def_delegators :@key, :fingerprint

      def initialize(bits = 4096)
        @key = OpenSSL::PKey::RSA.new(bits)
      end

      def public_key
        @public_key ||= "#{key.ssh_type} #{[key.to_blob].pack('m0')}"
      end
    end
  end
end