From fda937ab02296f6fd8e7195e2846d631f3d70559 Mon Sep 17 00:00:00 2001 From: Chris Bittner Date: Fri, 29 Mar 2019 10:11:31 +0100 Subject: [PATCH] imgtool: Discard public RSA if set for signing If imgtool is used for signing with encryption it will disallow using public RSA key for signing. Signed-off-by: Chris Bittner --- scripts/imgtool/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/imgtool/main.py b/scripts/imgtool/main.py index a03a1642..96f43868 100755 --- a/scripts/imgtool/main.py +++ b/scripts/imgtool/main.py @@ -156,9 +156,9 @@ def sign(key, align, version, header_size, pad_header, slot_size, pad, enckey = load_key(encrypt) if encrypt else None if enckey: if not isinstance(enckey, (keys.RSA2048, keys.RSA2048Public)): - raise Exception("Encryption only available with RSA") - if key and not isinstance(key, (keys.RSA2048, keys.RSA2048Public)): - raise Exception("Encryption with sign only available with RSA") + raise Exception("Encryption only available with RSA key") + if key and not isinstance(key, keys.RSA2048): + raise Exception("Signing only available with private RSA key") img.create(key, enckey) img.save(outfile)