def testForge(self): e = 17 n = 3233 d = 2753 m1 = 11 m2 = 19 bm1 = crypto.rsaBlind(m1, 11, e, n) bs1 = pow(bm1, d, n) s1 = crypto.rsaUnblind(11, n, bs1) self.assertTrue(crypto.rsaVerify(s1, m1, e, n)) bm2 = crypto.rsaBlind(m2, 13, e, n) bs2 = pow(bm2, d, n) s2 = crypto.rsaUnblind(13, n, bs2) self.assertTrue(crypto.rsaVerify(s2, m2, e, n)) self.assertTrue(crypto.rsaVerify((s1 * s2) % n, (m1 * m2) % n, e, n)) self.assertTrue(crypto.rsaVerify(crypto.modInverse(s1, n), crypto.modInverse(m1, n), e, n))
def testModInverse(self): self.assertEqual(crypto.modInverse(5, 14), 3) self.assertRaises(Exception, crypto.modInverse, (2, 10))