def testD4VerifyGnuPGV3RSASig(self): """crypto.pkt2cryptokey: verify GnuPG V3 RSA one-pass signature""" rsasig_d = file('pgpfiles'+os.sep+'sig'+os.sep+'sig.RSA1.onepass.gpg').read() rsakey_d = file('pgpfiles'+os.sep+'key'+os.sep+'RSA1.pub.gpg').read() rsakeypkts, rsasigpkts = list_pkts(rsakey_d), list_pkts(rsasig_d) onepass, literal, sig = rsasigpkts[0].body, rsasigpkts[1].body, rsasigpkts[2].body key = rsakeypkts[0].body cryptokey = CRY.pkt2cryptokey(key) # grab the signature packet, see what the hashed value should be # see how it matches up with the hash fragments # the idea is to construct the hash value by hand and try to # match it up with "some" characters in gpg's do_encode_md(). # again, I *know* that this was signed using SHA1.. # "full hash prefix"? # SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E, # 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 # 01 PS 00 T # PS is at least 8 octets of '\xff' msg = sha.new(literal.data + sig.hashed_data).digest() prefix = '\x30\x21\x30\x09\x06\x05\x2b\x0E\x03\x02\x1A\x05\x00\x04\x14' PS = '' for i in range (90): PS += '\xff' construct = '\x00\x01' + PS + '\x00' + prefix + msg # remember to tuple-ize the signature value ret = cryptokey.verify(construct, (sig.RSA.value,)) self.assertEqual(1, ret)
def testD2VerifyGnuPGV3DSASig(self): """crypto.pkt2cryptokey: verify GnuPG V3 DSA one-pass signature""" sigdata = file('pgpfiles'+os.sep+'sig'+os.sep+'sig.DSAELG1.onepass.gpg').read() pktlist = list_pkts(sigdata) lit, sig = pktlist[1].body, pktlist[2].body key = self.keypkts[0].body cryptokey = CRY.pkt2cryptokey(key) # here, I *know* that this was signed using SHA1.. msg = sha.new(lit.data + sig.hashed_data).digest() ret = cryptokey.verify(msg, (sig.DSA_r.value, sig.DSA_s.value)) self.assertEqual(1, ret)
def testD2VerifyGnuPGV3DSASig(self): """crypto.pkt2cryptokey: verify GnuPG V3 DSA one-pass signature""" sigdata = file('pgpfiles' + os.sep + 'sig' + os.sep + 'sig.DSAELG1.onepass.gpg').read() pktlist = list_pkts(sigdata) lit, sig = pktlist[1].body, pktlist[2].body key = self.keypkts[0].body cryptokey = CRY.pkt2cryptokey(key) # here, I *know* that this was signed using SHA1.. msg = sha.new(lit.data + sig.hashed_data).digest() ret = cryptokey.verify(msg, (sig.DSA_r.value, sig.DSA_s.value)) self.assertEqual(1, ret)
def testD4VerifyGnuPGV3RSASig(self): """crypto.pkt2cryptokey: verify GnuPG V3 RSA one-pass signature""" rsasig_d = file('pgpfiles' + os.sep + 'sig' + os.sep + 'sig.RSA1.onepass.gpg').read() rsakey_d = file('pgpfiles' + os.sep + 'key' + os.sep + 'RSA1.pub.gpg').read() rsakeypkts, rsasigpkts = list_pkts(rsakey_d), list_pkts(rsasig_d) onepass, literal, sig = rsasigpkts[0].body, rsasigpkts[ 1].body, rsasigpkts[2].body key = rsakeypkts[0].body cryptokey = CRY.pkt2cryptokey(key) # grab the signature packet, see what the hashed value should be # see how it matches up with the hash fragments # the idea is to construct the hash value by hand and try to # match it up with "some" characters in gpg's do_encode_md(). # again, I *know* that this was signed using SHA1.. # "full hash prefix"? # SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E, # 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 # 01 PS 00 T # PS is at least 8 octets of '\xff' msg = sha.new(literal.data + sig.hashed_data).digest() prefix = '\x30\x21\x30\x09\x06\x05\x2b\x0E\x03\x02\x1A\x05\x00\x04\x14' PS = '' for i in range(90): PS += '\xff' construct = '\x00\x01' + PS + '\x00' + prefix + msg # remember to tuple-ize the signature value ret = cryptokey.verify(construct, (sig.RSA.value, )) self.assertEqual(1, ret)
def setUp(self): self.keydata = file('pgpfiles'+os.sep+'key'+os.sep+'DSAELG1.sec.nopass.gpg').read() self.keypkts = list_pkts(self.keydata)
import OpenPGP.message as MSG import OpenPGP.util.armory as ARM enc_d = file('encrypted_and_signed.cleartext.notepad.pgp7.0.3DHDSS1.pgp').read() asc_d = file('key.pgp7.0.3.DHDSS1.6.0ext.pub.asc').read() arm_list = ARM.list_armored(asc_d) print dir(arm_list[0]) for a in arm_list: print arm_list[0].title print arm_list[0].headerlines pkts = MSG.list_pkts(a.data) for p in pkts: print "got packet type: %s" % p.tag.type msgs = MSG.organize_msgs(pkts) print msgs
import OpenPGP.message as MSG d = file("encrypted_and_signed.cleartext.notepad.pgp8.0.2DHDSS1.pgp").read() print MSG.list_msgs(MSG.list_pkts(d))
import OpenPGP.message as MSG d = file('encrypted_and_signed.cleartext.notepad.pgp8.0.2DHDSS1.pgp').read() print MSG.list_msgs(MSG.list_pkts(d))
def setUp(self): self.keydata = file('pgpfiles' + os.sep + 'key' + os.sep + 'DSAELG1.sec.nopass.gpg').read() self.keypkts = list_pkts(self.keydata)