You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
671B

  1. require 'erb'
  2. require 'parallel'
  3. module CryptCheck
  4. module Tls
  5. def self.analyze(hostname, port)
  6. host = Host.new hostname, port
  7. self.aggregate host
  8. end
  9. def self.aggregate(hosts)
  10. hosts = [hosts] unless hosts.respond_to? :collect
  11. hosts.inject([]) { |l, h| l + h.to_h }
  12. end
  13. def self.key_to_s(key)
  14. size, color = case key.type
  15. when :ecc
  16. ["#{key.group.curve_name} #{key.size}", :good]
  17. when :rsa
  18. [key.size, nil]
  19. when :dsa
  20. [key.size, :critical]
  21. when :dh
  22. [key.size, :warning]
  23. end
  24. "#{key.type.to_s.upcase.colorize color} #{size.to_s.colorize key.status} bits"
  25. end
  26. end
  27. end