diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-12-25 08:05:49 -0800 | 
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-12-25 08:05:49 -0800 | 
| commit | abc4666addc0b985c95815bf18eb2868f504fc19 (patch) | |
| tree | b2ace479c238991f148b879e75494c1b79408f83 /tests/hazmat/primitives/test_serialization.py | |
| parent | f05763c7308574b246d4c5b559ea0fe71c873599 (diff) | |
| download | cryptography-abc4666addc0b985c95815bf18eb2868f504fc19.tar.gz cryptography-abc4666addc0b985c95815bf18eb2868f504fc19.tar.bz2 cryptography-abc4666addc0b985c95815bf18eb2868f504fc19.zip | |
Write some tests for failure cases
Diffstat (limited to 'tests/hazmat/primitives/test_serialization.py')
| -rw-r--r-- | tests/hazmat/primitives/test_serialization.py | 29 | 
1 files changed, 29 insertions, 0 deletions
| diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py index acdbbd73..2434ee45 100644 --- a/tests/hazmat/primitives/test_serialization.py +++ b/tests/hazmat/primitives/test_serialization.py @@ -811,3 +811,32 @@ class TestECDSASSHSerialization(object):          assert key.public_numbers() == ec.EllipticCurvePublicNumbers(              expected_x, expected_y, ec.SECP256R1()          ) + +    def test_load_ssh_public_key_ecdsa_nist_p256_trailing_data(self, backend): +        ssh_key = ( +            b"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAy" +            b"NTYAAABBBGG2MfkHXp0UkxUyllDzWNBAImsvt5t7pFtTXegZK2WbGxml8zMrgWi5" +            b"teIg1TO03/FD9hbpBFgBeix3NrCFPltB= root@cloud-server-01" +        ) +        with pytest.raises(ValueError): +            load_ssh_public_key(ssh_key, backend) + +    def test_load_ssh_public_key_ecdsa_nist_p256_missing_data(self, backend): +        ssh_key = ( +            b"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAy" +            b"NTYAAABBBGG2MfkHXp0UkxUyllDzWNBAImsvt5t7pFtTXegZK2WbGxml8zMrgWi5" +            b"teIg1TO03/FD9hbpBFgBeix3NrCF= root@cloud-server-01" +        ) +        with pytest.raises(ValueError): +            load_ssh_public_key(ssh_key, backend) + +    def test_load_ssh_public_key_ecdsa_nist_p256_compressed(self, backend): +        # If we ever implement compressed points, note that this is not a valid +        # one, it just has the compressed marker in the right place. +        ssh_key = ( +            b"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAy" +            b"NTYAAABBAWG2MfkHXp0UkxUyllDzWNBAImsvt5t7pFtTXegZK2WbGxml8zMrgWi5" +            b"teIg1TO03/FD9hbpBFgBeix3NrCFPls= root@cloud-server-01" +        ) +        with pytest.raises(NotImplementedError): +            load_ssh_public_key(ssh_key, backend) | 
