Browse Source

Display curve for ECC key

new-scoring
aeris 2 years ago
parent
commit
299725996b
1 changed files with 12 additions and 7 deletions
  1. 12
    7
      lib/cryptcheck/tls.rb

+ 12
- 7
lib/cryptcheck/tls.rb View File

@@ -9,19 +9,24 @@ module CryptCheck

def self.colorize(cipher)
colors = case
when /^SSL/ =~ cipher then :critical
when :TLSv1_2 == cipher then :good
when /^SSL/ =~ cipher
:critical
when :TLSv1_2 == cipher
:good
end
cipher.to_s.colorize colors
end

def self.key_to_s(key)
type_color = case key.type
when :ecc then :good
when :dh then :warning
when :dsa then :critical
size, color = case key.type
when :ecc
["#{key.group.curve_name} #{key.size}", :good]
when :dh
[key.size, :warning]
when :dsa
[key.size, :critical]
end
"#{key.type.to_s.upcase.colorize type_color} #{key.size.to_s.colorize key.status} bits"
"#{key.type.to_s.upcase.colorize color} #{size.to_s.colorize key.status} bits"
end
end
end

Loading…
Cancel
Save