Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for scripts/imgtool #1983

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

rustammendel
Copy link
Contributor

@rustammendel rustammendel commented Jun 21, 2024

Add various tests and improvements for imgtool commands

  • Add tests for sign command
  • Add tests for dumpinfo command
  • Add tests for verify command
  • Add more tests for key generation and derivation
  • Add pre-generated images and keys for testing
  • Move key unittests to tests/keys directory
  • Improve file input and error handling for some commands
  • Refactoring and linting

@d3zd3z d3zd3z requested review from utzig and davidvincze and removed request for utzig and davidvincze June 25, 2024 15:55
@rustammendel rustammendel marked this pull request as ready for review July 4, 2024 11:31
@davidvincze
Copy link
Collaborator

Please also update the cryptography dependency in scripts/setup.py:17

@@ -1,3 +1,6 @@
# Copyright 2024 Denis Mingulov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am agree to add the missing copyright notice on my behalf.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for confirming.

@rustammendel
Copy link
Contributor Author

Commit ded02c9 fixes issue 1846 and might be breaking for some users that use integer type custom TLVs.

rustammendel and others added 16 commits August 25, 2024 13:45
Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I52646f5f27d47e3639368c6adcaa9df62b1b7853
Add missing copyright notice to clarify authorship of the original
contribution. Having the notice present will make contributions to the
file from other parties easier. The date of the original contribution
is derived from the git history.

Change-Id: I9c97f064ee8c308333058113430176b87b81b397
Signed-off-by: David Vincze <david.vincze@arm.com>
Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Refactor test_keys.py
Move constants to separate file
Verify key type in all testcases
Add tests for generating keys with password
Add more testcases for getpriv command
Add more testcases for getpub command
Add more testcases for getpubhash command
Update list of expected to fail tests

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: If48a1c1496aced2e6f69f317f200aafc08d55538
Key type checking moved to separate function and added support for
ed25519, enckey is enforced to be a public key

Invalid pass-phrase was not reachable in methods as in that case an
exception raised instead of returning "None".
load_key function improved by adding handling for invalid pass-phrase
and FileNotFound exception.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I0caa0a6100fc95c8339403e991d6de0337c7a725
Add tests for various features of sign command

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I46005bbbfa3b707076f5f69e49b7e2028e13af16
Tests for verify command with various types of signed
image files

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I309aa42a77812cae41007c70b99f28e2597840cf
Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I380e2839ae14ceca706e5b03f5ecf2d4ed53af5c
Added tests for verification of hex files
Extract common assertions to a separate function

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: Ia20fcbec81c0fea22f7cfe4af7a8927a6dbbbc74
Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I37b54000955f30f87aff8f23a1ea71804bf967cd
Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I67e614811c31e786efebc05b9264611d6bb17edb
Move tests from imgtool/keys to test/keys
Move pre-generated files to test/assets folder
Fix paths for tests to run from root directory
Replace hardcoded paths with constants in tests

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I100e65609f31cefa1c17f20143bceb165862fa14
Fix verify command fails for big endian images.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: Ie563584c3f90e37002f9a01bb73ac1635b2b5e37
Add support for big-endian images.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: Ib664571bce71ceb4878525d0d4797963b3c64dbf
Add tests and test files to test endiannes support of dumpinfo
command.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: Ia8c312860834f8c9a23c79d24e716b8ab161fce9
Add sign and verify tests for testing endianness support.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I3ab85ba137164cebcb9f38f45c93d87b96afbe68
Encode custom TLV of integer type according to image's byteorder.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: If5028e57473a66cf9be61c770f45d3c1e32d9632
Use "HH" (16+16) format for struct instead of "BBH" (8+8+16) and
remove padding.
TLV types have modified to be 16-bit in image.h (d13318a).
This change was not fully reflected in image creation, dumpinfo
and verify commands.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I7780aeae171aea3428335f5448bde45760a76070
Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I51c928fe4c68924a679d85bcfbef339dd4178162
Enable previously ignored getpub tests for ed25519

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I84ebfb535e246bfe5dedd2acc6090a9b10e91103
Install imgtool dependencies before tf-m build in fih-test to fix
failing ci job due to ImportError, originating from missing new types
added in cryptography library version 40.0.0.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: Id05f251024cf126d90d0fea22d21167329530f87
Install imgtool dependencies before twister tests in zephyr-build to fix
failing ci job due to ImportError, originating from missing new types
added in cryptography library version 40.0.0.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I1e4ca88a4a0329a198290f6e1917c139c30abc4f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants