summaryrefslogtreecommitdiff
path: root/test/py/tests/test_fit_ecdsa.py
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-04-07 16:40:02 -0600
committerTom Rini <trini@konsulko.com>2025-04-08 11:43:23 -0600
commitff61d6bfd1c9534d3fc2397846a5899639f2e55d (patch)
treedcfe4bc52848a5637c975a3352b57885e5b8a06d /test/py/tests/test_fit_ecdsa.py
parent34820924edbc4ec7803eb89d9852f4b870fa760a (diff)
parentf892a7f397a66d8d09f418d1e0e06dfb48bac27d (diff)
Merge branch 'next'
Note that this undoes the changes of commit cf6d4535cc4c ("x86: emulation: Disable bloblist for now") as that was intended only for the release due to time.
Diffstat (limited to 'test/py/tests/test_fit_ecdsa.py')
-rw-r--r--test/py/tests/test_fit_ecdsa.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/test/py/tests/test_fit_ecdsa.py b/test/py/tests/test_fit_ecdsa.py
index cc6c0c4dc42..3e816d68eb6 100644
--- a/test/py/tests/test_fit_ecdsa.py
+++ b/test/py/tests/test_fit_ecdsa.py
@@ -12,27 +12,29 @@ This test doesn't run the sandbox. It only checks the host tool 'mkimage'
import os
import pytest
-import u_boot_utils as util
+import utils
from Cryptodome.Hash import SHA256
from Cryptodome.PublicKey import ECC
from Cryptodome.Signature import DSS
class SignableFitImage(object):
""" Helper to manipulate a FIT image on disk """
- def __init__(self, cons, file_name):
+ def __init__(self, ubman, file_name):
self.fit = file_name
- self.cons = cons
+ self.ubman = ubman
self.signable_nodes = set()
def __fdt_list(self, path):
- return util.run_and_log(self.cons, f'fdtget -l {self.fit} {path}')
+ return utils.run_and_log(self.ubman, f'fdtget -l {self.fit} {path}')
def __fdt_set(self, node, **prop_value):
for prop, value in prop_value.items():
- util.run_and_log(self.cons, f'fdtput -ts {self.fit} {node} {prop} {value}')
+ utils.run_and_log(self.ubman,
+ f'fdtput -ts {self.fit} {node} {prop} {value}')
def __fdt_get_binary(self, node, prop):
- numbers = util.run_and_log(self.cons, f'fdtget -tbi {self.fit} {node} {prop}')
+ numbers = utils.run_and_log(self.ubman,
+ f'fdtget -tbi {self.fit} {node} {prop}')
bignum = bytearray()
for little_num in numbers.split():
@@ -53,7 +55,7 @@ class SignableFitImage(object):
self.__fdt_set(f'{image}/signature', algo='sha256,ecdsa256')
def sign(self, mkimage, key_file):
- util.run_and_log(self.cons, [mkimage, '-F', self.fit, f'-G{key_file}'])
+ utils.run_and_log(self.ubman, [mkimage, '-F', self.fit, f'-G{key_file}'])
def check_signatures(self, key):
for image in self.signable_nodes:
@@ -69,23 +71,22 @@ class SignableFitImage(object):
@pytest.mark.requiredtool('dtc')
@pytest.mark.requiredtool('fdtget')
@pytest.mark.requiredtool('fdtput')
-def test_fit_ecdsa(u_boot_console):
+def test_fit_ecdsa(ubman):
""" Test that signatures generated by mkimage are legible. """
def generate_ecdsa_key():
return ECC.generate(curve='prime256v1')
def assemble_fit_image(dest_fit, its, destdir):
dtc_args = f'-I dts -O dtb -i {destdir}'
- util.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', its, dest_fit])
+ utils.run_and_log(ubman, [mkimage, '-D', dtc_args, '-f', its, dest_fit])
def dtc(dts):
dtb = dts.replace('.dts', '.dtb')
- util.run_and_log(cons, f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}')
+ utils.run_and_log(ubman, f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}')
- cons = u_boot_console
- mkimage = cons.config.build_dir + '/tools/mkimage'
- datadir = cons.config.source_dir + '/test/py/tests/vboot/'
- tempdir = os.path.join(cons.config.result_dir, 'ecdsa')
+ mkimage = ubman.config.build_dir + '/tools/mkimage'
+ datadir = ubman.config.source_dir + '/test/py/tests/vboot/'
+ tempdir = os.path.join(ubman.config.result_dir, 'ecdsa')
os.makedirs(tempdir, exist_ok=True)
key_file = f'{tempdir}/ecdsa-test-key.pem'
fit_file = f'{tempdir}/test.fit'
@@ -103,7 +104,7 @@ def test_fit_ecdsa(u_boot_console):
assemble_fit_image(fit_file, f'{datadir}/sign-images-sha256.its', tempdir)
- fit = SignableFitImage(cons, fit_file)
+ fit = SignableFitImage(ubman, fit_file)
nodes = fit.find_signable_image_nodes()
if len(nodes) == 0:
raise ValueError('FIT image has no "/image" nodes with "signature"')