def testI01EncryptPublicElGamalDES3ZIP(self): """crypto.cipher: encrypt()/decrypt() ElGamal, DES3 w/ integrity, & ZIP""" key_d = read_test_file(['pgpfiles', 'key', 'DSAELG3.pub.gpg']) keypkt = list_pkts(key_d)[3] # ElGamal encrypting key d = "My secret message." # literal data packet litbody = create_LiteralDataBody(data=d, modified=0, format='b', filename='outfile') litpkt = create_Packet(PKT_LITERAL, litbody._d) # compressed data packet compbody = create_CompressedDataBody(COMP_ZIP, litpkt.rawstr()) comppkt = create_Packet(PKT_COMPRESSED, compbody._d) # session key key = gen_random(_keysize(SYM_DES3)) sespkt = encrypt_public_session(keypkt, key, SYM_DES3) # encrypted data encpkt = encrypt_integrity(SYM_DES3, key, comppkt.rawstr()) # decryption seckey_d = read_test_file( ['pgpfiles', 'key', 'DSAELG3.sec.nopass.gpg']) seckeypkt = list_pkts(seckey_d)[2] clrtxt = decrypt(encpkt, None, sespkt, seckeypkt) # got compressed comppkt_out = list_pkts(clrtxt)[0] # got literal litpkt_out = list_pkts(comppkt_out.body.data)[0] self.assertEqual(d, litpkt_out.body.data) self.assertEqual('outfile', litpkt_out.body.filename) self.assertEqual(0, litpkt_out.body.modified) self.assertEqual('b', litpkt_out.body.format)
def testI01EncryptPublicElGamalDES3ZIP(self): """crypto.cipher: encrypt()/decrypt() ElGamal, DES3 w/ integrity, & ZIP""" key_d = read_test_file(['pgpfiles','key','DSAELG3.pub.gpg']) keypkt = list_pkts(key_d)[3] # ElGamal encrypting key d = "My secret message." # literal data packet litbody = create_LiteralDataBody(data=d, modified=0, format='b', filename='outfile') litpkt = create_Packet(PKT_LITERAL, litbody._d) # compressed data packet compbody = create_CompressedDataBody(COMP_ZIP, litpkt.rawstr()) comppkt = create_Packet(PKT_COMPRESSED, compbody._d) # session key key = gen_random(_keysize(SYM_DES3)) sespkt = encrypt_public_session(keypkt, key, SYM_DES3) # encrypted data encpkt = encrypt_integrity(SYM_DES3, key, comppkt.rawstr()) # decryption seckey_d = read_test_file(['pgpfiles','key','DSAELG3.sec.nopass.gpg']) seckeypkt = list_pkts(seckey_d)[2] clrtxt = decrypt(encpkt, None, sespkt, seckeypkt) # got compressed comppkt_out = list_pkts(clrtxt)[0] # got literal litpkt_out = list_pkts(comppkt_out.body.data)[0] self.assertEqual(d, litpkt_out.body.data) self.assertEqual('outfile', litpkt_out.body.filename) self.assertEqual(0, litpkt_out.body.modified) self.assertEqual('b', litpkt_out.body.format)
def testB03CreateCompressed(self): """CompressedData: create_CompressedDataBody() ZLIB compression""" alg = COMP_ZLIB d = "testing 1, 2, 3" compbody = create_CompressedDataBody(alg, d) self.assertEqual(d, compbody.data)
def testB01CreateCompressed(self): """CompressedData: create_CompressedDataBody() no compression""" alg = COMP_UNCOMPRESSED d = "testing 1, 2, 3" compbody = create_CompressedDataBody(alg, d) self.assertEqual(d, compbody.data)