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

imgtool: Fix getpriv error return with private key #1749

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -65,6 +65,9 @@ class ECDSAPrivateKey(PrivateBytesMixin):
def __init__(self, key):
self.key = key

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

def _build_minimal_ecdsa_privkey(self, der, format):
'''
Builds a new DER that only includes the EC private key, removing the
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
Loading