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.

tls.rb 877B

1234567891011121314151617181920212223242526272829303132
  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 = key.rsa_equivalent_size
  17. type_color = case key.type
  18. when :ecc then { color: :green }
  19. when :dsa then { color: :yellow }
  20. end
  21. size_color = case size
  22. when 0...1024 then { color: :white, background: :red }
  23. when 1024...2048 then { color: :yellow }
  24. when 4096...::Float::INFINITY then { color: :green }
  25. end
  26. "#{key.type.to_s.upcase.colorize type_color} #{key.size.to_s.colorize size_color} bits"
  27. end
  28. end
  29. end