# File lib/rhc/vendor/sshkey.rb, line 76
        def valid_ssh_public_key?(ssh_public_key)
          ssh_type, encoded_key = ssh_public_key.split(" ")
          type = SSH_TYPES.invert[ssh_type]
          prefix = [0,0,0,7].pack("C*")
          decoded = Base64.decode64(encoded_key)

          # Base64 decoding is too permissive, so we should validate if encoding is correct
          return false unless Base64.encode64(decoded).gsub("\n", "") == encoded_key
          return false unless decoded.sub!(/^#{prefix}#{ssh_type}/, "")

          unpacked = decoded.unpack("C*")
          data = []
          index = 0
          until unpacked[index].nil?
            datum_size = from_byte_array unpacked[index..index+4-1], 4
            index = index + 4
            datum = from_byte_array unpacked[index..index+datum_size-1], datum_size
            data << datum
            index = index + datum_size
          end

          SSH_CONVERSION[type].size == data.size
        rescue
          false
        end