Skip to content

Commit 9c7a4df

Browse files
committed
bytes input for SigningKey.sign_digest()
1 parent 9f4c6d1 commit 9c7a4df

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/ecdsa/keys.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,7 @@ def sign_digest(self, digest, entropy=None, sigencode=sigencode_string,
11231123
:return: encoded signature for the `digest` hash
11241124
:rtype: bytes or sigencode function dependant type
11251125
"""
1126+
digest = normalise_bytes(digest)
11261127
if len(digest) > self.curve.baselen:
11271128
raise BadDigestError("this curve (%s) is too short "
11281129
"for your digest (%d)" % (self.curve.name,

src/ecdsa/test_keys.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,10 @@ def test_SigningKey_sign(convert):
301301
sig = sk.sign(convert(data))
302302

303303
vk.verify(sig, data)
304+
305+
306+
@pytest.mark.parametrize("convert", converters)
307+
def test_SigningKey_sign_digest(convert):
308+
sig = sk.sign_digest(convert(data_hash))
309+
310+
vk.verify(sig, data)

0 commit comments

Comments
 (0)