Skip to content

Commit 3c479e2

Browse files
committed
Test signatures with wrong length
1 parent 5283187 commit 3c479e2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_algorithms.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ def test_ec_verify_should_return_false_if_signature_invalid(self):
181181
result = algo.verify(message, pub_key, sig)
182182
assert not result
183183

184+
@pytest.mark.skipif(not has_crypto, reason='Not supported without cryptography library')
185+
def test_ec_verify_should_return_false_if_signature_wrong_length(self):
186+
algo = ECAlgorithm(ECAlgorithm.SHA256)
187+
188+
message = ensure_bytes('Hello World!')
189+
190+
sig = base64.b64decode(ensure_bytes('AC+m4Jf/xI3guAC6w0w3'))
191+
192+
with open(key_path('testkey_ec.pub'), 'r') as keyfile:
193+
pub_key = algo.prepare_key(keyfile.read())
194+
195+
result = algo.verify(message, pub_key, sig)
196+
assert not result
197+
184198
@pytest.mark.skipif(not has_crypto, reason='Not supported without cryptography library')
185199
def test_ec_verify_should_return_true_if_signature_valid(self):
186200
algo = ECAlgorithm(ECAlgorithm.SHA256)

0 commit comments

Comments
 (0)