imgtool: Fix getpub fails for ed25519 key

Fix getpub command fails to emit public pair of ed25519 key with
encoding.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I3d255f576b2d8a8d0cbc8e31ff378717acb060c7
This commit is contained in:
Rustam Ismayilov 2024-07-11 11:50:13 +02:00 committed by Dávid Vincze
parent 078874fbf0
commit ef598b13b5
1 changed files with 5 additions and 1 deletions

View File

@ -4,7 +4,6 @@ ED25519 key management
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ed25519 from cryptography.hazmat.primitives.asymmetric import ed25519
@ -34,6 +33,11 @@ class Ed25519Public(KeyClass):
encoding=serialization.Encoding.DER, encoding=serialization.Encoding.DER,
format=serialization.PublicFormat.SubjectPublicKeyInfo) format=serialization.PublicFormat.SubjectPublicKeyInfo)
def get_public_pem(self):
return self._get_public().public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo)
def get_private_bytes(self, minimal, format): def get_private_bytes(self, minimal, format):
self._unsupported('get_private_bytes') self._unsupported('get_private_bytes')