Exemple #1
0
    def test_good_signatures(self):
        for key_name, key_pkcs1 in key_pkcs1s.items():
            key = load_key(key_pkcs1)

            for data_name, digest in digests.items():
                signature_name = data_name + key_name
                signature = signatures[signature_name]

                assert key.verify(digest, signature)
Exemple #2
0
    def test_bad_signatures(self):
        for key_name, key_pkcs1 in key_pkcs1s.items():
            key = load_key(key_pkcs1)

            for data_name, digest in digests.items():
                good_signature_name = data_name + key_name

                for signature_name, signature in signatures.items():
                    if signature_name == good_signature_name:
                        continue
                    else:
                        assert not key.verify(digest, signature)
Exemple #3
0
 def test_rejects_bad_length_digest(self):
     key = load_key(key_pkcs1s["a"])
     signature = signatures["1a"]
     assert_raises(ValueError, key.verify, b"short digest", signature)
Exemple #4
0
 def test_rejects_garbage_signature(self):
     key = load_key(key_pkcs1s["a"])
     digest = digests['1']
     assert_raises(TypeError, key.verify, digest, 123)
     if sys.version_info[0] >= 3:
         assert_raises(TypeError, key.verify, digest, "asdf")
Exemple #5
0
 def test_rejects_garbage_digest(self):
     key = load_key(key_pkcs1s["a"])
     signature = signatures["1a"]
     assert_raises(TypeError, key.verify, 123, signature)
     if sys.version_info[0] >= 3:
         assert_raises(TypeError, key.verify, "short digest", signature)