imgtool: Fix verify command for edcsa-p384 signed images
Fixed hash algorithm defaults to SHA256 in case no key provided.
Verification improved by adding check for key - tlv mismatch,
VerifyResult.KEY_MISMATCH added to indicate this case.
Multiple styling fixes and import optimisation, exception handling.
Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I61a588de5b39678707c0179f4edaa411ceb67c8e
diff --git a/scripts/imgtool/main.py b/scripts/imgtool/main.py
index e24c9a0..f70a8bf 100755
--- a/scripts/imgtool/main.py
+++ b/scripts/imgtool/main.py
@@ -228,6 +228,8 @@
print("Image has an invalid hash")
elif ret == image.VerifyResult.INVALID_SIGNATURE:
print("No signature found for the given key")
+ elif ret == image.VerifyResult.KEY_MISMATCH:
+ print("Key type does not match TLV record")
else:
print("Unknown return code: {}".format(ret))
sys.exit(1)