Skip to content

Commit 92fcf93

Browse files
kendallgotonvlsianpu
authored andcommitted
scripts: Fix extracted ECDSA signature padding
Ensure that ECDSA key components that are too short are properly left-padded with 0s. Signed-off-by: Kendall Goto <[email protected]>
1 parent c931960 commit 92fcf93

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/bootloader/asn1parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_ecdsa_signature(der, clength):
2929
# Disable pylint error as 'input' keyword has specific handling in 'check_output'
3030
# pylint: disable=unexpected-keyword-arg
3131
stdout = check_output(['openssl', 'asn1parse', '-inform', 'der'], input=der)
32-
sig = b''.join([bytes.fromhex(re.search(r'(?<=\:)([0-9A-F]+)', num)[0]).ljust(clength, b'\0') \
32+
sig = b''.join([bytes.fromhex(re.search(r'(?<=\:)([0-9A-F]+)', num)[0]).rjust(clength, b'\0') \
3333
for num in re.findall(r'INTEGER *\:[0-9A-F]+', stdout.decode())])
3434

3535
assert len(sig) == 2*clength

0 commit comments

Comments
 (0)