imgtool: add creation of ECIES-P256 encrypted images
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/scripts/imgtool/main.py b/scripts/imgtool/main.py
index 2b0d4fe..53c3c0f 100755
--- a/scripts/imgtool/main.py
+++ b/scripts/imgtool/main.py
@@ -226,11 +226,13 @@
img.load(infile)
key = load_key(key) if key else None
enckey = load_key(encrypt) if encrypt else None
- if enckey:
- if not isinstance(enckey, (keys.RSA, keys.RSAPublic)):
- raise Exception("Encryption only available with RSA key")
- if key and not isinstance(key, keys.RSA):
- raise Exception("Signing only available with private RSA key")
+ if enckey and key:
+ if ((isinstance(key, keys.ECDSA256P1) and
+ not isinstance(enckey, keys.ECDSA256P1Public))
+ or (isinstance(key, keys.RSA) and
+ not isinstance(enckey, keys.RSAPublic))):
+ # FIXME
+ raise Exception("Signing and encryption must use the same type of key")
img.create(key, enckey, dependencies)
img.save(outfile, hex_addr)