def testC02RSAPGPSignature(self): "crypto.signature: verify_RSA() One-Pass v3 by hand" rsakey = list_pkts(rsapubkey_d)[0].body onepass, lit, sig = [x.body for x in list_pkts(rsasig_d)] # again, we know that this was signed using SHA1 (ignoring onepass).. msg = sha.new(lit.data + sig.hashed_data).digest() # ..and know that this is the "full hash prefix" we need: prefix = '\x30\x21\x30\x09\x06\x05\x2b\x0E\x03\x02\x1A\x05\x00\x04\x14' # by hand count (and assumption that range = length of RSA modulus): PS = '' for i in range (90): PS += '\xff' context = '\x00\x01' + PS + '\x00' + prefix + msg keytup = (rsakey.RSA_n.value, rsakey.RSA_e.value) self.assertEqual(1, verify_RSA(context, sig.RSA.value, keytup))
def testC02RSAPGPSignature(self): "crypto.signature: verify_RSA() One-Pass v3 by hand" rsakey = list_pkts(rsapubkey_d)[0].body onepass, lit, sig = [x.body for x in list_pkts(rsasig_d)] # again, we know that this was signed using SHA1 (ignoring onepass).. msg = sha.new(lit.data + sig.hashed_data).digest() # ..and know that this is the "full hash prefix" we need: prefix = '\x30\x21\x30\x09\x06\x05\x2b\x0E\x03\x02\x1A\x05\x00\x04\x14' # by hand count (and assumption that range = length of RSA modulus): PS = '' for i in range(90): PS += '\xff' context = '\x00\x01' + PS + '\x00' + prefix + msg keytup = (rsakey.RSA_n.value, rsakey.RSA_e.value) self.assertEqual(1, verify_RSA(context, sig.RSA.value, keytup))
def testB02RSAsignature(self): "crypto.signature: sign_RSA()/verify_RSA() sanity" sig = sign_RSA(txt, (rsakey.n, rsakey.d)) ret = verify_RSA(txt, sig, (rsakey.n, rsakey.e)) self.assertEqual(ret, 1)