def testC05DecryptSymmetricCAST(self):
     "decrypt_str() symmetric CAST w/integrity"
     enc_d = read_test_file(['pgpfiles','enc','sym.cast.cleartext.txt.gpg'])
     clrtxt = decrypt_str(enc_d, passphrase='test')
     clrmsgs = list_as_signed(clrtxt)
     literal_pkt = list_pkts(clrmsgs[0].compressed.body.data)[0]
     self.assertEqual(self.lit_data, literal_pkt.body.data)
 def testC01DecryptDSA(self):
     "decrypt_str() DSA AES256 w/integrity"
     enc_d = read_test_file(['pgpfiles','enc','pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d)
     compmsg = list_as_signed(clrtxt)[0]
     literal_pkt = list_pkts(compmsg.compressed.body.data)[0]
     self.assertEqual(self.lit_data, literal_pkt.body.data)
 def testC02DecryptDSA_decompression(self):
     "decrypt_str() DSA AES256 w/integrity (decompressed)"
     enc_d = read_test_file(['pgpfiles','enc','pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d,
                                  decompress=True)
     litmsg = list_as_signed(clrtxt)[0] # no compressed msg to go through
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
示例#4
0
 def testC05DecryptSymmetricCAST(self):
     "decrypt_str() symmetric CAST w/integrity"
     enc_d = read_test_file(
         ['pgpfiles', 'enc', 'sym.cast.cleartext.txt.gpg'])
     clrtxt = decrypt_str(enc_d, passphrase='test')
     clrmsgs = list_as_signed(clrtxt)
     literal_pkt = list_pkts(clrmsgs[0].compressed.body.data)[0]
     self.assertEqual(self.lit_data, literal_pkt.body.data)
 def testF03EncryptPublicKeyID(self):
     "encrypt_str()/decrypt_str() ElGamal via key ID"
     pubkey_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     cphtxt = encrypt_str(self.lit_data, keys=pubkey_d, use_key=[(None,"CB7D6980A1F2BEF6")])
     clrtxt = decrypt_str(cphtxt, passphrase="test", keys=seckey_d, decompress=True)
     litmsg = list_as_signed(clrtxt)[0] # auto-decompressed above
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
 def testC04DecryptRSA(self):
     "decrypt_str() RSA w/integrity"
     lit_data = "My secret message."
     enc_d = read_test_file(['pgpfiles','enc','sap.2DSAELG1RSA.nocomp.gpg'])
     key_d = read_test_file(['pgpfiles','key','RSA1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d)
     clrmsgs = list_as_signed(clrtxt)
     literal_pkt = clrmsgs[0].literals[0]
     self.assertEqual(lit_data, literal_pkt.body.data)
 def testC03DecryptDSA_armor(self):
     "decrypt_str() DSA AES256 w/integrity (armored, decompressed)"
     enc_d = read_test_file(['pgpfiles','enc','pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d,
                                  decompress=True, armor=True)
     self.assertEqual(True, looks_armored(clrtxt)) # check armoring
     litmsg = list_as_signed(clrtxt)[0]
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
示例#8
0
 def testC01DecryptDSA(self):
     "decrypt_str() DSA AES256 w/integrity"
     enc_d = read_test_file(
         ['pgpfiles', 'enc', 'pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles', 'key', 'DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d)
     compmsg = list_as_signed(clrtxt)[0]
     literal_pkt = list_pkts(compmsg.compressed.body.data)[0]
     self.assertEqual(self.lit_data, literal_pkt.body.data)
示例#9
0
 def testC04DecryptRSA(self):
     "decrypt_str() RSA w/integrity"
     lit_data = "My secret message."
     enc_d = read_test_file(
         ['pgpfiles', 'enc', 'sap.2DSAELG1RSA.nocomp.gpg'])
     key_d = read_test_file(['pgpfiles', 'key', 'RSA1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d)
     clrmsgs = list_as_signed(clrtxt)
     literal_pkt = clrmsgs[0].literals[0]
     self.assertEqual(lit_data, literal_pkt.body.data)
示例#10
0
 def testC02DecryptDSA_decompression(self):
     "decrypt_str() DSA AES256 w/integrity (decompressed)"
     enc_d = read_test_file(
         ['pgpfiles', 'enc', 'pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles', 'key', 'DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d,
                          passphrase='test',
                          keys=key_d,
                          decompress=True)
     litmsg = list_as_signed(clrtxt)[0]  # no compressed msg to go through
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
示例#11
0
 def testC03DecryptDSA_armor(self):
     "decrypt_str() DSA AES256 w/integrity (armored, decompressed)"
     enc_d = read_test_file(
         ['pgpfiles', 'enc', 'pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles', 'key', 'DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d,
                          passphrase='test',
                          keys=key_d,
                          decompress=True,
                          armor=True)
     self.assertEqual(True, looks_armored(clrtxt))  # check armoring
     litmsg = list_as_signed(clrtxt)[0]
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
示例#12
0
 def testF03EncryptPublicKeyID(self):
     "encrypt_str()/decrypt_str() ElGamal via key ID"
     pubkey_d = read_test_file(['pgpfiles', 'key', 'DSAELG1.pub.asc'])
     seckey_d = read_test_file(['pgpfiles', 'key', 'DSAELG1.sec.asc'])
     cphtxt = encrypt_str(self.lit_data,
                          keys=pubkey_d,
                          use_key=[(None, "CB7D6980A1F2BEF6")])
     clrtxt = decrypt_str(cphtxt,
                          passphrase="test",
                          keys=seckey_d,
                          decompress=True)
     litmsg = list_as_signed(clrtxt)[0]  # auto-decompressed above
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
 def testF06EncryptMultiplePublicUserID(self):
     "encrypt_str()/decrypt_str() multiple public (no compression) via user ID"
     pubkey1_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     seckey1_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     #pubkey2_d = read_test_file(['pgpfiles','key','DSAELG3.pub.asc'])
     #seckey2_d = read_test_file(['pgpfiles','key','DSAELG3.sec.asc'])
     pubkey3_d = read_test_file(['pgpfiles','key','RSA1.pub.asc'])
     seckey3_d = read_test_file(['pgpfiles','key','RSA1.sec.asc'])
     pubkey_d = linesep.join([pubkey1_d, pubkey3_d])
     uids = [(None,"Tester"),
             #(None,"*****@*****.**"),
             (None,"testrsa")]
     cphtxt = encrypt_str(self.lit_data, keys=pubkey_d, use_userid=uids)
     # they all happen to have the same passphrase
     passphrase = "test"
     for seckey_d in [seckey1_d, seckey3_d]:
         clrtxt = decrypt_str(cphtxt, passphrase="test", keys=seckey_d,
                              decompress=True)
         litmsg = list_as_signed(clrtxt)[0]
         self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
示例#14
0
 def testF06EncryptMultiplePublicUserID(self):
     "encrypt_str()/decrypt_str() multiple public (no compression) via user ID"
     pubkey1_d = read_test_file(['pgpfiles', 'key', 'DSAELG1.pub.asc'])
     seckey1_d = read_test_file(['pgpfiles', 'key', 'DSAELG1.sec.asc'])
     #pubkey2_d = read_test_file(['pgpfiles','key','DSAELG3.pub.asc'])
     #seckey2_d = read_test_file(['pgpfiles','key','DSAELG3.sec.asc'])
     pubkey3_d = read_test_file(['pgpfiles', 'key', 'RSA1.pub.asc'])
     seckey3_d = read_test_file(['pgpfiles', 'key', 'RSA1.sec.asc'])
     pubkey_d = linesep.join([pubkey1_d, pubkey3_d])
     uids = [
         (None, "Tester"),
         #(None,"*****@*****.**"),
         (None, "testrsa")
     ]
     cphtxt = encrypt_str(self.lit_data, keys=pubkey_d, use_userid=uids)
     # they all happen to have the same passphrase
     passphrase = "test"
     for seckey_d in [seckey1_d, seckey3_d]:
         clrtxt = decrypt_str(cphtxt,
                              passphrase="test",
                              keys=seckey_d,
                              decompress=True)
         litmsg = list_as_signed(clrtxt)[0]
         self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
 def testF05EncryptSymmetric(self):
     "encrypt_str()/decrypt_str() symmetric default"
     cphtxt = encrypt_str(self.lit_data, passphrase="test")
     clrtxt = decrypt_str(cphtxt, passphrase="test", decompress=True)
     litmsg = list_as_signed(clrtxt)[0] # auto-decompressed above
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
示例#16
0
 def testF05EncryptSymmetric(self):
     "encrypt_str()/decrypt_str() symmetric default"
     cphtxt = encrypt_str(self.lit_data, passphrase="test")
     clrtxt = decrypt_str(cphtxt, passphrase="test", decompress=True)
     litmsg = list_as_signed(clrtxt)[0]  # auto-decompressed above
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)