Class: EFIValidate::EALFParser

Inherits:
Object
  • Object
show all
Defined in:
lib/efivalidate/ealf_parser.rb

Defined Under Namespace

Classes: EALFParseError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ EALFParser

Returns a new instance of EALFParser.

Raises:



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/efivalidate/ealf_parser.rb', line 7

def initialize(data)
  @header = EFIValidate::EALFHeader.read(data, 97)

  raise EALFParseError, 'File header magic mismatch.' unless @header.ealf_magic == EFIValidate::EALFHeader::EALF_MAGIC
  raise EALFParseError, 'Only SHA256 EALF is supported.' unless @header.ealf_hash_function == EFIValidate::EALFHeader::EALF_HASH_SHA256

  @rows = []
  @header.ealf_rows.times do
    @rows << EFIValidate::EALFRow.read(data, @header.row_size).tap { |row| row.header = @header }
  end
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



5
6
7
# File 'lib/efivalidate/ealf_parser.rb', line 5

def header
  @header
end

#rowsObject (readonly)

Returns the value of attribute rows.



5
6
7
# File 'lib/efivalidate/ealf_parser.rb', line 5

def rows
  @rows
end

Class Method Details

.read(file) ⇒ Object



19
20
21
# File 'lib/efivalidate/ealf_parser.rb', line 19

def self.read(file)
  EFIValidate::EALFParser.new(File.open(file))
end