bmpfv_size = gbb_size - 0x2180
if bmpfv_size < 0:
self.Raise('GBB is too small (minimum 0x2180 bytes)')
- sizes = [0x100, 0x1000, bmpfv_size, 0x1000]
- sizes = ['%#x' % size for size in sizes]
keydir = tools.GetInputFilename(self.keydir)
- gbb_set_command = [
- 'gbb_utility', '-s',
- '--hwid=%s' % self.hardware_id,
- '--rootkey=%s/root_key.vbpubk' % keydir,
- '--recoverykey=%s/recovery_key.vbpubk' % keydir,
- '--flags=%d' % self.gbb_flags,
- '--bmpfv=%s' % tools.GetInputFilename(self.bmpblk),
- fname]
-
- tools.Run('futility', 'gbb_utility', '-c', ','.join(sizes), fname)
- tools.Run('futility', *gbb_set_command)
-
- self.SetContents(tools.ReadFile(fname))
+
+ stdout = self.futility.gbb_create(
+ fname, [0x100, 0x1000, bmpfv_size, 0x1000])
+ if stdout is not None:
+ stdout = self.futility.gbb_set(
+ fname,
+ hwid=self.hardware_id,
+ rootkey='%s/root_key.vbpubk' % keydir,
+ recoverykey='%s/recovery_key.vbpubk' % keydir,
+ flags=self.gbb_flags,
+ bmpfv=tools.GetInputFilename(self.bmpblk))
+
+ if stdout is not None:
+ self.SetContents(tools.ReadFile(fname))
+ else:
+ # Bintool is missing; just use the required amount of zero data
+ self.record_missing_bintool(self.futility)
+ self.SetContents(tools.GetBytes(0, gbb_size))
+
return True
+
+ def AddBintools(self, tools):
+ self.futility = self.AddBintool(tools, 'futility')
"""
def __init__(self, section, etype, node):
super().__init__(section, etype, node)
+ self.futility = None
(self.keydir, self.keyblock, self.signprivate, self.version,
self.kernelkey, self.preamble_flags) = self.GetEntryArgsOrProps([
EntryArg('keydir', str),
input_fname = tools.GetOutputFilename('input.%s' % uniq)
tools.WriteFile(input_fname, input_data)
prefix = self.keydir + '/'
- args = [
- 'vbutil_firmware',
- '--vblock', output_fname,
- '--keyblock', prefix + self.keyblock,
- '--signprivate', prefix + self.signprivate,
- '--version', '%d' % self.version,
- '--fv', input_fname,
- '--kernelkey', prefix + self.kernelkey,
- '--flags', '%d' % self.preamble_flags,
- ]
- #out.Notice("Sign '%s' into %s" % (', '.join(self.value), self.label))
- stdout = tools.Run('futility', *args)
- return tools.ReadFile(output_fname)
+ stdout = self.futility.sign_firmware(
+ vblock=output_fname,
+ keyblock=prefix + self.keyblock,
+ signprivate=prefix + self.signprivate,
+ version=f'{self.version,}',
+ firmware=input_fname,
+ kernelkey=prefix + self.kernelkey,
+ flags=f'{self.preamble_flags}')
+ if stdout is not None:
+ data = tools.ReadFile(output_fname)
+ else:
+ # Bintool is missing; just use 4KB of zero data
+ self.record_missing_bintool(self.futility)
+ data = tools.GetBytes(0, 4096)
+ return data
def ObtainContents(self):
data = self.GetVblock(False)
# The blob may have changed due to WriteSymbols()
data = self.GetVblock(True)
return self.ProcessContentsUpdate(data)
+
+ def AddBintools(self, tools):
+ self.futility = self.AddBintool(tools, 'futility')