diff options
| author | Adrian Freihofer <adrian.freihofer@siemens.com> | 2025-06-03 10:23:19 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-06-05 11:02:21 +0100 |
| commit | 1e29226879f739543531adb211f12ce1c6586002 (patch) | |
| tree | b73223e1e0f6a3e4e90e5af0958c593a58cfb262 | |
| parent | d5c04a81ac0b3f983b78415d52af4a0bc3111f1b (diff) | |
| download | poky-1e29226879f739543531adb211f12ce1c6586002.tar.gz | |
oe-selftest: fitimage: cleanup FIT_GENERATE_KEYS
It is closer to practice to use static and predictable keys to sign the
FIT images. In addition, the new kernel-signing-keys-native is only
reliable if the temporary directory is not deleted. However, depending
on how this test suite is started, this can happen.
There will therefore only be one test that uses the recipe to generate
the keys, which ensures that the recipe works in principle.
It is also ensured that no keys are present before the test and that the
recipe runs safely and is not skipped by Bitbake.
(From OE-Core rev: 97e58d7c2bc1943f0696fc72984788f459f7f7c4)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/fitimage.py | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index 8a3eb7f8c1..fcba28b7b7 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py | |||
| @@ -760,8 +760,7 @@ PREFERRED_PROVIDER_virtual/dtb = "bbb-dtbs-as-ext" | |||
| 760 | and the configuration nodes are signed correctly. | 760 | and the configuration nodes are signed correctly. |
| 761 | Expected: 1) its and FIT image are built successfully | 761 | Expected: 1) its and FIT image are built successfully |
| 762 | 2) Scanning the its file indicates signing is enabled | 762 | 2) Scanning the its file indicates signing is enabled |
| 763 | as requested by UBOOT_SIGN_ENABLE (using 1 key | 763 | as requested by UBOOT_SIGN_ENABLE |
| 764 | generated by the test not via FIT_GENERATE_KEYS) | ||
| 765 | 3) Dumping the FIT image indicates signature values | 764 | 3) Dumping the FIT image indicates signature values |
| 766 | are present (only for the configuration nodes as | 765 | are present (only for the configuration nodes as |
| 767 | FIT_SIGN_INDIVIDUAL is disabled) | 766 | FIT_SIGN_INDIVIDUAL is disabled) |
| @@ -792,10 +791,7 @@ FIT_CONF_DEFAULT_DTB = "am335x-bonegreen.dtb" | |||
| 792 | 'UBOOT_SIGN_KEYDIR', | 791 | 'UBOOT_SIGN_KEYDIR', |
| 793 | ]) | 792 | ]) |
| 794 | 793 | ||
| 795 | # Do not use the random keys generated by FIT_GENERATE_KEYS. | ||
| 796 | # Using a static key is probably a more realistic scenario. | ||
| 797 | self._gen_signing_key(bb_vars) | 794 | self._gen_signing_key(bb_vars) |
| 798 | |||
| 799 | self._test_fitimage(bb_vars) | 795 | self._test_fitimage(bb_vars) |
| 800 | 796 | ||
| 801 | def test_sign_fit_image_individual(self): | 797 | def test_sign_fit_image_individual(self): |
| @@ -804,11 +800,11 @@ FIT_CONF_DEFAULT_DTB = "am335x-bonegreen.dtb" | |||
| 804 | and all nodes are signed correctly. | 800 | and all nodes are signed correctly. |
| 805 | Expected: 1) its and FIT image are built successfully | 801 | Expected: 1) its and FIT image are built successfully |
| 806 | 2) Scanning the its file indicates signing is enabled | 802 | 2) Scanning the its file indicates signing is enabled |
| 807 | as requested by UBOOT_SIGN_ENABLE (using 2 keys | 803 | as requested by UBOOT_SIGN_ENABLE |
| 808 | generated via FIT_GENERATE_KEYS) | ||
| 809 | 3) Dumping the FIT image indicates signature values | 804 | 3) Dumping the FIT image indicates signature values |
| 810 | are present (including for images as enabled via | 805 | are present (including for images as enabled via |
| 811 | FIT_SIGN_INDIVIDUAL) | 806 | FIT_SIGN_INDIVIDUAL) |
| 807 | This also implies that FIT_GENERATE_KEYS = "1" works. | ||
| 812 | 4) Verify the FIT image contains the comments passed via | 808 | 4) Verify the FIT image contains the comments passed via |
| 813 | UBOOT_MKIMAGE_SIGN_ARGS once per image and per | 809 | UBOOT_MKIMAGE_SIGN_ARGS once per image and per |
| 814 | configuration node. | 810 | configuration node. |
| @@ -837,6 +833,10 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c 'a smart comment'" | |||
| 837 | config = self._config_add_uboot_env(config) | 833 | config = self._config_add_uboot_env(config) |
| 838 | self.write_config(config) | 834 | self.write_config(config) |
| 839 | bb_vars = self._fit_get_bb_vars() | 835 | bb_vars = self._fit_get_bb_vars() |
| 836 | |||
| 837 | # Ensure new keys are generated and FIT_GENERATE_KEYS = "1" is tested | ||
| 838 | bitbake("kernel-signing-keys-native -c cleansstate") | ||
| 839 | |||
| 840 | self._test_fitimage(bb_vars) | 840 | self._test_fitimage(bb_vars) |
| 841 | 841 | ||
| 842 | def test_fit_image_sign_initramfs(self): | 842 | def test_fit_image_sign_initramfs(self): |
| @@ -875,7 +875,6 @@ UBOOT_ARCH = "arm" | |||
| 875 | UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000" | 875 | UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000" |
| 876 | UBOOT_MKIMAGE_KERNEL_TYPE = "kernel" | 876 | UBOOT_MKIMAGE_KERNEL_TYPE = "kernel" |
| 877 | UBOOT_EXTLINUX = "0" | 877 | UBOOT_EXTLINUX = "0" |
| 878 | FIT_GENERATE_KEYS = "1" | ||
| 879 | KERNEL_IMAGETYPE_REPLACEMENT = "zImage" | 878 | KERNEL_IMAGETYPE_REPLACEMENT = "zImage" |
| 880 | FIT_KERNEL_COMP_ALG = "none" | 879 | FIT_KERNEL_COMP_ALG = "none" |
| 881 | FIT_HASH_ALG = "sha256" | 880 | FIT_HASH_ALG = "sha256" |
| @@ -892,10 +891,7 @@ FIT_HASH_ALG = "sha256" | |||
| 892 | 'UBOOT_SIGN_KEYDIR', | 891 | 'UBOOT_SIGN_KEYDIR', |
| 893 | ]) | 892 | ]) |
| 894 | 893 | ||
| 895 | # Do not use the random keys generated by FIT_GENERATE_KEYS. | ||
| 896 | # Using a static key is probably a more realistic scenario. | ||
| 897 | self._gen_signing_key(bb_vars) | 894 | self._gen_signing_key(bb_vars) |
| 898 | |||
| 899 | self._test_fitimage(bb_vars) | 895 | self._test_fitimage(bb_vars) |
| 900 | 896 | ||
| 901 | def test_fit_image_sign_initramfs_bundle(self): | 897 | def test_fit_image_sign_initramfs_bundle(self): |
| @@ -933,7 +929,6 @@ UBOOT_ARCH = "arm" | |||
| 933 | UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000" | 929 | UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000" |
| 934 | UBOOT_MKIMAGE_KERNEL_TYPE = "kernel" | 930 | UBOOT_MKIMAGE_KERNEL_TYPE = "kernel" |
| 935 | UBOOT_EXTLINUX = "0" | 931 | UBOOT_EXTLINUX = "0" |
| 936 | FIT_GENERATE_KEYS = "1" | ||
| 937 | KERNEL_IMAGETYPE_REPLACEMENT = "zImage" | 932 | KERNEL_IMAGETYPE_REPLACEMENT = "zImage" |
| 938 | FIT_KERNEL_COMP_ALG = "none" | 933 | FIT_KERNEL_COMP_ALG = "none" |
| 939 | FIT_HASH_ALG = "sha256" | 934 | FIT_HASH_ALG = "sha256" |
| @@ -941,6 +936,7 @@ FIT_HASH_ALG = "sha256" | |||
| 941 | config = self._config_add_uboot_env(config) | 936 | config = self._config_add_uboot_env(config) |
| 942 | self.write_config(config) | 937 | self.write_config(config) |
| 943 | bb_vars = self._fit_get_bb_vars() | 938 | bb_vars = self._fit_get_bb_vars() |
| 939 | self._gen_signing_key(bb_vars) | ||
| 944 | self._test_fitimage(bb_vars) | 940 | self._test_fitimage(bb_vars) |
| 945 | 941 | ||
| 946 | 942 | ||
| @@ -1345,9 +1341,7 @@ UBOOT_SIGN_KEYNAME = "cfg-oe-selftest" | |||
| 1345 | self.write_config(config) | 1341 | self.write_config(config) |
| 1346 | bb_vars = self._fit_get_bb_vars() | 1342 | bb_vars = self._fit_get_bb_vars() |
| 1347 | 1343 | ||
| 1348 | # Using a static key. FIT_GENERATE_KEYS = "1" does not work without kernel-fitimage.bbclass | ||
| 1349 | self._gen_signing_key(bb_vars) | 1344 | self._gen_signing_key(bb_vars) |
| 1350 | |||
| 1351 | self._test_fitimage(bb_vars) | 1345 | self._test_fitimage(bb_vars) |
| 1352 | self._check_kernel_dtb(bb_vars) | 1346 | self._check_kernel_dtb(bb_vars) |
| 1353 | 1347 | ||
| @@ -1508,8 +1502,6 @@ FIT_SIGN_INDIVIDUAL = "1" | |||
| 1508 | """ | 1502 | """ |
| 1509 | self.write_config(config) | 1503 | self.write_config(config) |
| 1510 | bb_vars = self._fit_get_bb_vars() | 1504 | bb_vars = self._fit_get_bb_vars() |
| 1511 | |||
| 1512 | # Using a static key. FIT_GENERATE_KEYS = "1" does not work without kernel-fitimage.bbclass | ||
| 1513 | self._gen_signing_key(bb_vars) | 1505 | self._gen_signing_key(bb_vars) |
| 1514 | 1506 | ||
| 1515 | bitbake("virtual/bootloader") | 1507 | bitbake("virtual/bootloader") |
