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
754B

  1. require 'erb'
  2. require 'parallel'
  3. module CryptCheck
  4. module Tls
  5. def self.analyze(host, port)
  6. ::CryptCheck.analyze host, port, TcpServer, Grade
  7. end
  8. def self.colorize(cipher)
  9. colors = case
  10. when /^SSL/ =~ cipher then { color: :white, background: :red }
  11. when :TLSv1_2 == cipher then { color: :green }
  12. end
  13. cipher.to_s.colorize colors
  14. end
  15. def self.key_to_s(key)
  16. size, color = case key.type
  17. when :ecc
  18. ["#{key.group.curve_name} #{key.size}", { color: :green }]
  19. when :dh
  20. [key.size, { color: :yellow }]
  21. when :dsa
  22. [key.size, { color: :white, background: :red }]
  23. end
  24. "#{key.type.to_s.upcase.colorize color} #{size.to_s.colorize key.status} bits"
  25. end
  26. end
  27. end