Skip to content

Commit

Permalink
[python] Pass bytes to cryptography.io's RSAPrivateKey.sign()
Browse files Browse the repository at this point in the history
Until RIIR, cryptography.io accepted bytearray for arguments in various
methods like `RSAPrivateKey.sign()`. Technically at least `.sign()` is
documented to accept bytes only (even if bytearray is "bytes-like").
Fix by always converting to bytes in `Sigstruct.to_bytes()` (which BTW
should return bytes, as the name suggests).

Corresponding upstream commit in `pyca/cryptography` repository:
0000b402dd5edffa6a86ca560464e83a66fd91f5

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
  • Loading branch information
woju authored and dimakuv committed Jan 26, 2024
1 parent 36676a7 commit 9f1b079
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/graminelibos/sigstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def to_bytes(self, verify=True, verify_sig_fields=False):
struct.pack_into(fmt, buffer, offset, int(f'{self[key]}', 16))
continue
struct.pack_into(fmt, buffer, offset, self[key])
return buffer
return bytes(buffer)


@classmethod
Expand Down

0 comments on commit 9f1b079

Please sign in to comment.