Skip to content
This repository was archived by the owner on Jan 17, 2023. It is now read-only.

Commit 74d1e64

Browse files
committed
Consolidate on returning str in get_vk and get_sk
1 parent 5b5e535 commit 74d1e64

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

nordicsemi/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def display(key_file, key, format, out_file):
454454
if key == "pk":
455455
kstr = signer.get_vk(format, dbg)
456456
elif key == "sk":
457-
kstr = b"\nWARNING: Security risk! Do not share the private key.\n\n"
457+
kstr = "\nWARNING: Security risk! Do not share the private key.\n\n"
458458
kstr = kstr + signer.get_sk(format, dbg)
459459

460460
if not out_file:

nordicsemi/dfu/signing.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def verify(self, init_packet, signature):
121121

122122
return True
123123

124-
def get_vk(self, output_type, dbg):
124+
def get_vk(self, output_type, dbg) -> str:
125125
"""
126126
Get public key (as hex, code or pem)
127127
"""
@@ -135,11 +135,12 @@ def get_vk(self, output_type, dbg):
135135
elif output_type == 'code':
136136
return self.get_vk_code(dbg)
137137
elif output_type == 'pem':
138-
return self.get_vk_pem()
138+
# Return pem as str to conform in type with the other cases.
139+
return self.get_vk_pem().decode()
139140
else:
140141
raise InvalidArgumentException("Invalid argument. Can't get key")
141142

142-
def get_sk(self, output_type, dbg):
143+
def get_sk(self, output_type, dbg) -> str:
143144
"""
144145
Get private key (as hex, code or pem)
145146
"""
@@ -153,7 +154,8 @@ def get_sk(self, output_type, dbg):
153154
elif output_type == 'code':
154155
raise InvalidArgumentException("Private key cannot be shown as code")
155156
elif output_type == 'pem':
156-
return self.sk.to_pem()
157+
# Return pem as str to conform in type with the other cases.
158+
return self.sk.to_pem().decode()
157159
else:
158160
raise InvalidArgumentException("Invalid argument. Can't get key")
159161

0 commit comments

Comments
 (0)