def test_from_string_pub_cert_failure(self):
     cert_bytes = self._load_public_cert_bytes()
     true_der = rsa.pem.load_pem(cert_bytes, 'CERTIFICATE')
     with mock.patch('rsa.pem.load_pem',
                     return_value=true_der + b'extra') as load_pem:
         with self.assertRaises(ValueError):
             RsaVerifier.from_string(cert_bytes, is_x509_cert=True)
         load_pem.assert_called_once_with(cert_bytes, 'CERTIFICATE')
Exemplo n.º 2
0
 def test_from_string_pub_cert_failure(self):
     cert_bytes = self._load_public_cert_bytes()
     true_der = rsa.pem.load_pem(cert_bytes, 'CERTIFICATE')
     with mock.patch('rsa.pem.load_pem',
                     return_value=true_der + b'extra') as load_pem:
         with self.assertRaises(ValueError):
             RsaVerifier.from_string(cert_bytes, is_x509_cert=True)
         load_pem.assert_called_once_with(cert_bytes, 'CERTIFICATE')
 def test_verify_failure(self):
     verifier = RsaVerifier.from_string(self._load_public_key_bytes(),
                                        is_x509_cert=False)
     bad_signature1 = b''
     self.assertFalse(verifier.verify(b'foo', bad_signature1))
     bad_signature2 = b'a'
     self.assertFalse(verifier.verify(b'foo', bad_signature2))
Exemplo n.º 4
0
 def test_verify_failure(self):
     verifier = RsaVerifier.from_string(self._load_public_key_bytes(),
                                        is_x509_cert=False)
     bad_signature1 = b''
     self.assertFalse(verifier.verify(b'foo', bad_signature1))
     bad_signature2 = b'a'
     self.assertFalse(verifier.verify(b'foo', bad_signature2))
    def test_verify_unicode_success(self):
        to_sign = u'foo'
        signer = RsaSigner.from_string(self._load_private_key_bytes())
        actual_signature = signer.sign(to_sign)

        verifier = RsaVerifier.from_string(self._load_public_key_bytes(),
                                           is_x509_cert=False)
        self.assertTrue(verifier.verify(to_sign, actual_signature))
Exemplo n.º 6
0
    def test_verify_unicode_success(self):
        to_sign = u'foo'
        signer = RsaSigner.from_string(self._load_private_key_bytes())
        actual_signature = signer.sign(to_sign)

        verifier = RsaVerifier.from_string(self._load_public_key_bytes(),
                                           is_x509_cert=False)
        self.assertTrue(verifier.verify(to_sign, actual_signature))
 def test_from_string_pub_cert_unicode(self):
     public_cert = _from_bytes(self._load_public_cert_bytes())
     verifier = RsaVerifier.from_string(public_cert, is_x509_cert=True)
     self.assertIsInstance(verifier, RsaVerifier)
     self.assertIsInstance(verifier._pubkey, rsa.key.PublicKey)
 def test_from_string_pub_key(self):
     public_key = self._load_public_key_bytes()
     verifier = RsaVerifier.from_string(public_key, is_x509_cert=False)
     self.assertIsInstance(verifier, RsaVerifier)
     self.assertIsInstance(verifier._pubkey, rsa.key.PublicKey)
Exemplo n.º 9
0
 def test_from_string_pub_cert_unicode(self):
     public_cert = _from_bytes(self._load_public_cert_bytes())
     verifier = RsaVerifier.from_string(public_cert, is_x509_cert=True)
     self.assertIsInstance(verifier, RsaVerifier)
     self.assertIsInstance(verifier._pubkey, rsa.key.PublicKey)
Exemplo n.º 10
0
 def test_from_string_pub_key(self):
     public_key = self._load_public_key_bytes()
     verifier = RsaVerifier.from_string(public_key, is_x509_cert=False)
     self.assertIsInstance(verifier, RsaVerifier)
     self.assertIsInstance(verifier._pubkey, rsa.key.PublicKey)