def test_invalid_signature(self): resp = OCSPResponse(resp_sig_sha1) cert = X509() cert.parseBinary(cert_sig_sha1) old_sig = resp.signature resp.signature = bytearray([0]) self.assertNotEqual(resp.signature, old_sig) with self.assertRaises(ValueError) as ctx: resp.verify_signature(cert.publicKey) self.assertTrue("Signature could not be verified for sha1" in str(ctx.exception))
def test_invalid_signature(self): resp = OCSPResponse(resp_sig_sha1) cert = X509() cert.parseBinary(cert_sig_sha1) old_sig = resp.signature resp.signature = bytearray([0]) self.assertNotEqual(resp.signature, old_sig) with self.assertRaises(ValueError) as ctx: resp.verify_signature(cert.publicKey) self.assertTrue( "Signature could not be verified for sha1" in str(ctx.exception))
def test_certs_signature(self): resp = OCSPResponse(resp_OK) self.assertGreater(len(resp.certs), 0) cert = resp.certs[0] # checking only first certificate self.assertIsInstance(cert, X509) self.assertTrue(resp.verify_signature(resp.certs[0].publicKey))
def test_verify_signature_sha256(self): resp = OCSPResponse(resp_sig_sha256) cert = X509() cert.parseBinary(cert_sig_sha256) self.assertTrue(resp.verify_signature(cert.publicKey))