Skip to content

Commit

Permalink
Improvements from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Jan 21, 2025
1 parent b648c74 commit bb1850d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib/y2partitioner/widgets/pervasive_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ module Y2Partitioner
module Widgets
# Widget to display the full verification pattern for the selected master key, in case the
# pattern is too long to be displayed at the corresponding selector
#
# Verification patterns for CCA keys are 18 characters long ("0x" + 16 hexadecimal digits) so
# they fit at the selector. But with EP11 keys, the pattern is 66 characters long ("0x" +
# 64 digits), so an extra label with two lines is displayed.
class PervasiveKey < CWM::ReplacePoint
# Internal widget showing the full verification pattern split into several lines
class Label < CWM::CustomWidget
Expand All @@ -36,11 +40,16 @@ def initialize(widget_id, key)

# @macro seeCustomWidget
def contents
# This shows the EP11 pattern in a readable way in both text and graphical modes
lines = [@key[0..33], " #{@key[34..-1]}"]
Left(Label(lines.join("\n")))
end
end

# Size of a pattern for CCA APQNs. This is the maximum size that fits into a selector.
CCA_PATTERN_SIZE = 18
private_constant :CCA_PATTERN_SIZE

# Constructor
#
# @param initial_key [String]
Expand All @@ -62,7 +71,7 @@ def refresh(key)
# Empty widget or multi-line label
def widget_for(key)
widget_id = "FullKey#{key}"
if key.size > 20
if key.size > CCA_PATTERN_SIZE
Label.new(widget_id, key)
else
CWM::Empty.new(widget_id)
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2storage/encryption_processes/pervasive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def pre_commit(device)

master_key_file = @secure_key.filename
sector_size = sector_size_for(device.blk_device)
# Convert from bytes to bits
key_size = @secure_key.secure_key_size * 8

# NOTE: The options cipher and key-size could also be influenced by setting
Expand Down

0 comments on commit bb1850d

Please sign in to comment.