Ejemplo n.º 1
0
def test1():
    pkr = PGP.load_pubring('pubring.pgp')
    daft = pkr['daft']
    daft_pkt = daft._pubkey_pkt.pack()
    s1 = EVP.MessageDigest('sha1')
    s1.update(daft_pkt)
    print `s1.final()`

    buf = StringIO(daft_pkt)
    ps = PGP.packet_stream(buf)
    dift_pkt = ps.read()
    s2 = EVP.MessageDigest('sha1')
    s2.update(dift_pkt.pack())
    print `s2.final()`
Ejemplo n.º 2
0
    def test_simple(self):
        pkr = PGP.load_pubring('tests/pubring.pgp')
        daft = pkr['daft']
        daft_pkt = daft._pubkey_pkt.pack()
        s1 = EVP.MessageDigest('sha1')
        s1.update(daft_pkt)
        s1f = ` s1.final() `

        buf = StringIO(daft_pkt)
        ps = PGP.packet_stream(buf)
        dift_pkt = ps.read()
        s2 = EVP.MessageDigest('sha1')
        s2.update(dift_pkt.pack())
        s2f = ` s2.final() `

        self.assertEqual(s1f, s2f)
Ejemplo n.º 3
0
    def test_simple(self):
        pkr = PGP.load_pubring('tests/pubring.pgp')
        daft = pkr['daft']
        daft_pkt = daft._pubkey_pkt.pack()
        s1 = EVP.MessageDigest('sha1')
        s1.update(daft_pkt)
        s1f = `s1.final()`
    
        buf = StringIO(daft_pkt)
        ps = PGP.packet_stream(buf)
        dift_pkt = ps.read()
        s2 = EVP.MessageDigest('sha1')
        s2.update(dift_pkt.pack())
        s2f = `s2.final()`

        self.assertEqual(s1f, s2f)
Ejemplo n.º 4
0
DESC = {
    PGP.public_key_packet: desc_public_key,
    PGP.trust_packet: desc_trust,
    PGP.userid_packet: desc_userid,
    PGP.signature_packet: desc_signature,
    PGP.private_key_packet: desc_private_key,
    PGP.cke_packet: desc_cke,
    PGP.pke_packet: desc_pke,
    PGP.literal_packet: desc_literal,
}

if __name__ == '__main__':
    import sys
    count = 0
    for arg in sys.argv[1:]:
	    f = open(arg, 'rb')
	    ps = PGP.packet_stream(f)
	    while 1:
	        pkt = ps.read()
	        if pkt is None:
	            break
	        elif pkt:
	            print '-'*70
	            DESC[pkt.__class__](pkt)
	    count = count + ps.count()
	    ps.close()
    print '-'*70
    print 'Total octets processed =', count