@@ -37,6 +37,10 @@ body { | |||
table.center td { | |||
text-align: center; | |||
&.left { | |||
text-align: left; | |||
} | |||
} | |||
td.error { | |||
@@ -36,18 +36,20 @@ module CheckHelper | |||
def rank_color(rank) | |||
case rank | |||
when :'A+' then | |||
:great | |||
when :A then | |||
:best | |||
when :B then | |||
:good | |||
when :C, :D then | |||
:warning | |||
when :E, :F then | |||
:error | |||
else | |||
:critical | |||
when :'A+', :A | |||
:great | |||
when :'B+', :B | |||
:best | |||
when :'C+', :C | |||
:good | |||
when :D | |||
nil | |||
when :E | |||
:warning | |||
when :F | |||
:error | |||
else | |||
:critical | |||
end | |||
end | |||
@@ -55,32 +57,6 @@ module CheckHelper | |||
label rank, rank_color(rank) | |||
end | |||
def progress_color(percentage) | |||
case percentage | |||
when 0...20 then | |||
:error | |||
when 20...40 then | |||
:danger | |||
when 40...60 then | |||
:warning | |||
when 60...80 then | |||
:default | |||
when 80...90 then | |||
:success | |||
else | |||
:primary | |||
end | |||
end | |||
def score_progress(score) | |||
%Q(<div class="progress"> | |||
<div class="progress-bar progress-bar-striped progress-bar-#{progress_color score}" | |||
style="width: #{score}%"> | |||
#{score} / 100 | |||
</div> | |||
</div>).html_safe | |||
end | |||
def protocol_label(protocol) | |||
label protocol.to_sym, protocol.status | |||
end | |||
@@ -106,31 +82,31 @@ module CheckHelper | |||
def key_color(key) | |||
case key[:size] | |||
when nil then | |||
:default | |||
when 0...1024 then | |||
:error | |||
when 1024...2048 then | |||
:danger | |||
when 2048...4096 then | |||
:warning | |||
else | |||
:success | |||
when nil then | |||
:default | |||
when 0...1024 then | |||
:error | |||
when 1024...2048 then | |||
:danger | |||
when 2048...4096 then | |||
:warning | |||
else | |||
:success | |||
end | |||
end | |||
def cipher_color(key) | |||
case key | |||
when nil then | |||
:default | |||
when 0...128 then | |||
:error | |||
when 112...128 then | |||
:danger | |||
when 128...256 then | |||
:success | |||
else | |||
:primary | |||
when nil then | |||
:default | |||
when 0...128 then | |||
:error | |||
when 112...128 then | |||
:danger | |||
when 128...256 then | |||
:success | |||
else | |||
:primary | |||
end | |||
end | |||
@@ -147,14 +123,14 @@ module CheckHelper | |||
def cipher_kex_type_cell(kex) | |||
color = case kex | |||
when :ecdh then | |||
nil | |||
when :dh then | |||
:warning | |||
when :rsa then | |||
:error | |||
else | |||
:critical | |||
when :ecdh then | |||
nil | |||
when :dh then | |||
:warning | |||
when :rsa then | |||
:error | |||
else | |||
:critical | |||
end | |||
kex ||= 'None' | |||
cell kex.to_s.upcase, color | |||
@@ -167,10 +143,10 @@ module CheckHelper | |||
def cipher_auth_type_cell(auth) | |||
color = case auth | |||
when :ecdsa, :rsa then | |||
nil | |||
else | |||
:critical | |||
when :ecdsa, :rsa then | |||
nil | |||
else | |||
:critical | |||
end | |||
auth ||= 'None' | |||
cell auth.to_s.upcase, color | |||
@@ -183,10 +159,10 @@ module CheckHelper | |||
def cipher_enc_type_cell(enc) | |||
color = case enc | |||
when :chacha20 | |||
:success | |||
when nil, :rc4 | |||
:critical | |||
when :chacha20 | |||
:success | |||
when nil, :rc4 | |||
:critical | |||
end | |||
enc ||= 'NONE' | |||
cell enc.to_s.upcase, color | |||
@@ -194,44 +170,46 @@ module CheckHelper | |||
def cipher_enc_block_size_cell(enc) | |||
color = case | |||
when enc.nil? | |||
nil | |||
when enc <= 64 | |||
:critical | |||
when enc < 128 | |||
:error | |||
when enc == :stream | |||
nil | |||
when enc.nil? | |||
nil | |||
when enc <= 64 | |||
:critical | |||
when enc < 128 | |||
:error | |||
end | |||
cell enc, color | |||
end | |||
def cipher_enc_key_size_cell(enc) | |||
color = case | |||
when enc.nil? | |||
nil | |||
when enc < 128 | |||
:critical | |||
when enc.nil? | |||
nil | |||
when enc < 128 | |||
:critical | |||
end | |||
cell enc, color | |||
end | |||
def cipher_enc_mode_cell(enc) | |||
color = case enc | |||
when :gcm, :ccm, :aead | |||
:success | |||
when :gcm, :ccm, :aead | |||
:success | |||
end | |||
cell enc.to_s.upcase, color | |||
end | |||
def cipher_mac_type_cell(mac) | |||
color = case mac | |||
when :poly1305 then | |||
:success | |||
when :sha384, :sha256 then | |||
nil | |||
when :sha1 then | |||
:warning | |||
else | |||
:critical | |||
when :poly1305 then | |||
:success | |||
when :sha384, :sha256 then | |||
nil | |||
when :sha1 then | |||
:warning | |||
else | |||
:critical | |||
end | |||
cell mac.to_s.upcase, color | |||
end | |||
@@ -110,17 +110,13 @@ | |||
<thead> | |||
<tr> | |||
<th rowspan="2"><%= t 'Name' %></th> | |||
<th colspan="2"><%= t 'Key exchange' %></th> | |||
<th colspan="2"><%= t 'Authentication' %></th> | |||
<th rowspan="2"><%= t 'Key exchange' %></th> | |||
<th rowspan="2"><%= t 'Authentication' %></th> | |||
<th colspan="4"><%= t 'Encryption' %></th> | |||
<th colspan="2"><%= t 'MAC' %></th> | |||
<th rowspan="2"><%= t 'PFS' %></th> | |||
</tr> | |||
<tr> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Key size' %></th> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Key size' %></th> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Key size' %></th> | |||
<th><%= t 'Block size' %></th> | |||
@@ -150,11 +146,7 @@ | |||
<tr> | |||
<th><%= cipher_name_label cipher %></th> | |||
<%= cipher_kex_type_cell kex %> | |||
<th/> | |||
<%#= cipher_kex_size_cell kex&.last %> | |||
<%= cipher_auth_type_cell auth %> | |||
<th/> | |||
<%#= cipher_auth_size_cell auth&.last %> | |||
<%= cipher_enc_type_cell enc[0] %> | |||
<%= cipher_enc_key_size_cell enc[1] %> | |||
<%= cipher_enc_block_size_cell enc[2] %> | |||
@@ -12,8 +12,8 @@ | |||
</tr> | |||
<tr> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Block size' %></th> | |||
<th><%= t 'Key size' %></th> | |||
<th><%= t 'Block size' %></th> | |||
<th><%= t 'Mode' %></th> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Size' %></th> | |||
@@ -31,12 +31,12 @@ | |||
<th><%= cipher_name_label cipher %></th> | |||
<%= cipher_auth_type_cell auth %> | |||
<%= cipher_kex_type_cell kex %> | |||
<%= cipher_enc_type_cell enc&.first %> | |||
<%= cipher_enc_block_size_cell enc&.[] 1 %> | |||
<%= cipher_enc_key_size_cell enc&.[] 2 %> | |||
<%= cipher_enc_mode_cell enc&.last %> | |||
<%= cipher_mac_type_cell mac&.first %> | |||
<%= cipher_mac_size_cell mac&.last %> | |||
<%= cipher_enc_type_cell enc[0] %> | |||
<%= cipher_enc_key_size_cell enc[1] %> | |||
<%= cipher_enc_block_size_cell enc[2] %> | |||
<%= cipher_enc_mode_cell enc[3] %> | |||
<%= cipher_mac_type_cell mac[0] %> | |||
<%= cipher_mac_size_cell mac[1] %> | |||
<%= cipher_pfs_cell pfs %> | |||
</tr> | |||
<% end %> | |||
@@ -5,56 +5,55 @@ | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<table class="table table-bordered table-condensed table-striped col-sm-12"> | |||
<table class="table table-bordered table-condensed table-striped center col-sm-12"> | |||
<thead> | |||
<tr> | |||
<th rowspan="2"><%= t 'User agent' %></th> | |||
<th rowspan="2"><%= t 'Name' %></th> | |||
<th rowspan="2"><%= t 'Key exchange' %></th> | |||
<th rowspan="2"><%= t 'Authentication' %></th> | |||
<th colspan="4"><%= t 'Encryption' %></th> | |||
<th colspan="2"><%= t 'MAC' %></th> | |||
<th rowspan="2"><%= t 'PFS' %></th> | |||
</tr> | |||
<tr> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Key size' %></th> | |||
<th><%= t 'Block size' %></th> | |||
<th><%= t 'Mode' %></th> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Size' %></th> | |||
</tr> | |||
<tr> | |||
<th rowspan="2"><%= t 'User agent' %></th> | |||
<th rowspan="2"><%= t 'Name' %></th> | |||
<th rowspan="2"><%= t 'Key exchange' %></th> | |||
<th rowspan="2"><%= t 'Authentication' %></th> | |||
<th colspan="4"><%= t 'Encryption' %></th> | |||
<th colspan="2"><%= t 'MAC' %></th> | |||
<th rowspan="2"><%= t 'PFS' %></th> | |||
</tr> | |||
<tr> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Key size' %></th> | |||
<th><%= t 'Block size' %></th> | |||
<th><%= t 'Mode' %></th> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Size' %></th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<% | |||
iana_ciphers = Hash[@ciphers.collect { |c| [Rails.application.config.openssl_ciphers[c.name], c] }] | |||
Rails.application.config.user_agents_ciphers.each do |ua, support| | |||
cipher = (support['ciphers'].collect(&:first) & iana_ciphers.keys).first | |||
if cipher | |||
cipher = iana_ciphers[cipher] | |||
params = cipher.params | |||
kex = params[:kex] | |||
auth = params[:auth] | |||
enc = params[:enc] | |||
mac = params[:mac] | |||
pfs = params[:pfs] | |||
end | |||
iana_ciphers = Hash[@ciphers.collect { |c| [Rails.application.config.openssl_ciphers[c.name], c] }] | |||
Rails.application.config.user_agents_ciphers.each do |ua, support| | |||
cipher = (support['ciphers'].collect(&:first) & iana_ciphers.keys).first | |||
if cipher | |||
cipher = iana_ciphers[cipher] | |||
kex = cipher.kex | |||
auth = cipher.auth | |||
enc = cipher.encryption | |||
mac = cipher.hmac | |||
pfs = cipher.pfs? | |||
end | |||
%> | |||
<tr> | |||
<th><%= ua %></th> | |||
<% if cipher %> | |||
<th><%= cipher_name_label cipher %></th> | |||
<%= cipher_kex_type_cell kex&.first %> | |||
<%= cipher_auth_type_cell auth&.first %> | |||
<%= cipher_enc_type_cell enc&.first %> | |||
<%= cipher_enc_key_size_cell enc&.[] 1 %> | |||
<%= cipher_enc_block_size_cell enc&.[] 2 %> | |||
<%= cipher_enc_mode_cell enc&.last %> | |||
<%= cipher_mac_type_cell mac&.first %> | |||
<%= cipher_mac_size_cell mac&.last %> | |||
<%= cipher_pfs_cell pfs %> | |||
<th><%= cipher_name_label cipher %></th> | |||
<%= cipher_auth_type_cell auth %> | |||
<%= cipher_kex_type_cell kex %> | |||
<%= cipher_enc_type_cell enc[0] %> | |||
<%= cipher_enc_key_size_cell enc[1] %> | |||
<%= cipher_enc_block_size_cell enc[2] %> | |||
<%= cipher_enc_mode_cell enc[3] %> | |||
<%= cipher_mac_type_cell mac[0] %> | |||
<%= cipher_mac_size_cell mac[1] %> | |||
<%= cipher_pfs_cell pfs %> | |||
<% else %> | |||
<td colspan="10"><%= label t('Not supported'), :error %></td> | |||
<td colspan="10" class="left"><%= label t('Not supported'), :error, false %></td> | |||
<% end %> | |||
</tr> | |||
<% end %> | |||
@@ -65,46 +64,45 @@ | |||
<div class="row"> | |||
<table class="table table-bordered table-condensed table-striped center col-sm-12"> | |||
<thead> | |||
<tr> | |||
<th rowspan="2"><%= t 'Name' %></th> | |||
<th rowspan="2"><%= t 'Key exchange' %></th> | |||
<th rowspan="2"><%= t 'Authentication' %></th> | |||
<th colspan="4"><%= t 'Encryption' %></th> | |||
<th colspan="2"><%= t 'MAC' %></th> | |||
<th rowspan="2"><%= t 'PFS' %></th> | |||
</tr> | |||
<tr> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Key size' %></th> | |||
<th><%= t 'Block size' %></th> | |||
<th><%= t 'Mode' %></th> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Size' %></th> | |||
</tr> | |||
<tr> | |||
<th rowspan="2"><%= t 'Name' %></th> | |||
<th rowspan="2"><%= t 'Key exchange' %></th> | |||
<th rowspan="2"><%= t 'Authentication' %></th> | |||
<th colspan="4"><%= t 'Encryption' %></th> | |||
<th colspan="2"><%= t 'MAC' %></th> | |||
<th rowspan="2"><%= t 'PFS' %></th> | |||
</tr> | |||
<tr> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Key size' %></th> | |||
<th><%= t 'Block size' %></th> | |||
<th><%= t 'Mode' %></th> | |||
<th><%= t 'Type' %></th> | |||
<th><%= t 'Size' %></th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<% @ciphers.each do |cipher| | |||
params = cipher.params | |||
kex = params[:kex] | |||
auth = params[:auth] | |||
enc = params[:enc] | |||
mac = params[:mac] | |||
pfs = params[:pfs] | |||
%> | |||
<% @ciphers.each do |cipher| | |||
kex = cipher.kex | |||
auth = cipher.auth | |||
enc = cipher.encryption | |||
mac = cipher.hmac | |||
pfs = cipher.pfs? | |||
%> | |||
<tr> | |||
<th><%= cipher_name_label cipher %></th> | |||
<%= cipher_kex_type_cell kex&.first %> | |||
<%= cipher_auth_type_cell auth&.first %> | |||
<%= cipher_enc_type_cell enc&.first %> | |||
<%= cipher_enc_key_size_cell enc&.[] 1 %> | |||
<%= cipher_enc_block_size_cell enc&.[] 2 %> | |||
<%= cipher_enc_mode_cell enc&.last %> | |||
<%= cipher_mac_type_cell mac&.first %> | |||
<%= cipher_mac_size_cell mac&.last %> | |||
<%= cipher_auth_type_cell auth %> | |||
<%= cipher_kex_type_cell kex %> | |||
<%= cipher_enc_type_cell enc[0] %> | |||
<%= cipher_enc_key_size_cell enc[1] %> | |||
<%= cipher_enc_block_size_cell enc[2] %> | |||
<%= cipher_enc_mode_cell enc[3] %> | |||
<%= cipher_mac_type_cell mac[0] %> | |||
<%= cipher_mac_size_cell mac[1] %> | |||
<%= cipher_pfs_cell pfs %> | |||
</tr> | |||
<% end %> | |||
</tbody> | |||
<% end %> | |||
</tbody> | |||
</table> | |||
</div> | |||
</div> |