Skip to content

Commit

Permalink
imgtool: Fix getpriv error return with private key
Browse files Browse the repository at this point in the history
This commit fixes a bug with the getpriv command using
ECDSA keys.

Signed-off-by: Roland Mikhel <[email protected]>
Change-Id: I66c1365a855e97199921ac136a18e26988bce508
  • Loading branch information
Roland Mikhel committed Jul 20, 2023
1 parent 23fdb0d commit fc6900e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/imgtool/keys/ecdsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _unsupported(self, name):
raise ECDSAUsageError("Operation {} requires private key".format(name))

def _get_public(self):
return self.key.public_key()
return self.key

def get_public_bytes(self):
# The key is embedded into MBUboot in "SubjectPublicKeyInfo" format
Expand Down Expand Up @@ -137,6 +137,9 @@ def export_private(self, path, passwd=None):
with open(path, 'wb') as f:
f.write(pem)

def _get_public(self):
return self.key.public_key()


class ECDSA256P1Public(ECDSAPublicKey):
"""
Expand Down Expand Up @@ -179,7 +182,7 @@ def verify(self, signature, payload):
signature_algorithm=ec.ECDSA(SHA256()))


class ECDSA256P1(ECDSA256P1Public, ECDSAPrivateKey):
class ECDSA256P1(ECDSAPrivateKey, ECDSA256P1Public):
"""
Wrapper around an ECDSA (p256) private key.
"""
Expand Down Expand Up @@ -252,7 +255,7 @@ def verify(self, signature, payload):
signature_algorithm=ec.ECDSA(SHA384()))


class ECDSA384P1(ECDSA384P1Public, ECDSAPrivateKey):
class ECDSA384P1(ECDSAPrivateKey, ECDSA384P1Public):
"""
Wrapper around an ECDSA (p384) private key.
"""
Expand Down

0 comments on commit fc6900e

Please sign in to comment.